mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-11 12:21:44 +01:00
Add repo sync all helper for non-pfq buildbots.
TEST=Ran script and re-ran cbuildbot to completion of sync. Change-Id: I31fddca6f720fecb461a96c1ffa54d4923b3c1c4 Review URL: http://codereview.chromium.org/3166019
This commit is contained in:
parent
9a27b4099f
commit
1ee50d3ce2
@ -13,6 +13,8 @@ import sys
|
|||||||
|
|
||||||
from cbuildbot_config import config
|
from cbuildbot_config import config
|
||||||
|
|
||||||
|
_DEFAULT_RETRIES=3
|
||||||
|
|
||||||
# Utility functions
|
# Utility functions
|
||||||
|
|
||||||
def RunCommand(cmd, error_ok=False, error_message=None, exit_code=False,
|
def RunCommand(cmd, error_ok=False, error_message=None, exit_code=False,
|
||||||
@ -51,19 +53,34 @@ def MakeDir(path, parents=False):
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def RepoSync(buildroot, retries=_DEFAULT_RETRIES):
|
||||||
|
while retries > 0:
|
||||||
|
try:
|
||||||
|
RunCommand(['repo', 'sync'], cwd=buildroot)
|
||||||
|
retries = 0
|
||||||
|
except:
|
||||||
|
retries -= 1
|
||||||
|
if retries > 0:
|
||||||
|
print >>sys.stderr, 'CBUILDBOT -- Repo Sync Failed, retrying'
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, 'CBUILDBOT -- Retries exhausted'
|
||||||
|
raise
|
||||||
|
|
||||||
# Main functions
|
# Main functions
|
||||||
|
|
||||||
def _FullCheckout(buildroot):
|
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
||||||
|
RunCommand(['sudo', 'rm', '-rf', buildroot])
|
||||||
MakeDir(buildroot, parents=True)
|
MakeDir(buildroot, parents=True)
|
||||||
RunCommand(['repo', 'init', '-u', 'http://src.chromium.org/git/manifest'],
|
RunCommand(['repo', 'init', '-u', 'http://src.chromium.org/git/manifest'],
|
||||||
cwd=buildroot, input='\n\ny\n')
|
cwd=buildroot, input='\n\ny\n')
|
||||||
RunCommand(['repo', 'sync'], cwd=buildroot)
|
RepoSync(buildroot, retries)
|
||||||
RunCommand(['repo', 'forall', '-c', 'git', 'config',
|
if rw_checkout:
|
||||||
'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof',
|
RunCommand(['repo', 'forall', '-c', 'git', 'config',
|
||||||
'http://src.chromium.org/git'], cwd=buildroot)
|
'url.ssh://git@gitrw.chromium.org:9222.pushinsteadof',
|
||||||
|
'http://src.chromium.org/git'], cwd=buildroot)
|
||||||
|
|
||||||
def _IncrementalCheckout(buildroot):
|
def _IncrementalCheckout(buildroot, retries=_DEFAULT_RETRIES):
|
||||||
RunCommand(['repo', 'sync'], cwd=buildroot)
|
RepoSync(buildroot, retries)
|
||||||
# Always re-run in case of new git repos or repo sync
|
# Always re-run in case of new git repos or repo sync
|
||||||
# failed in a previous run because of a forced Stop Build.
|
# failed in a previous run because of a forced Stop Build.
|
||||||
RunCommand(['repo', 'forall', '-c', 'git', 'config',
|
RunCommand(['repo', 'forall', '-c', 'git', 'config',
|
||||||
|
|||||||
1
bin/cros_repo_sync_all
Symbolic link
1
bin/cros_repo_sync_all
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
cros_repo_sync_all.py
|
||||||
35
bin/cros_repo_sync_all.py
Executable file
35
bin/cros_repo_sync_all.py
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
"""Stop gap sync function until cbuildbot is integrated into all builders"""
|
||||||
|
|
||||||
|
import cbuildbot
|
||||||
|
import optparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
"""Number of retries to retry repo sync before giving up"""
|
||||||
|
_NUMBER_OF_RETRIES=3
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
parser.add_option('-r', '--buildroot',
|
||||||
|
help='root directory where sync occurs')
|
||||||
|
parser.add_option('-c', '--clobber', action='store_true', default=False,
|
||||||
|
help='clobber build directory and do a full checkout')
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
if options.buildroot:
|
||||||
|
if options.clobber:
|
||||||
|
cbuildbot._FullCheckout(options.buildroot, rw_checkout=False,
|
||||||
|
retries=_NUMBER_OF_RETRIES)
|
||||||
|
else:
|
||||||
|
cbuildbot._IncrementalCheckout(options.buildroot,
|
||||||
|
retries=_NUMBER_OF_RETRIES)
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, 'ERROR: Must set buildroot'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user