mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 15:41:04 +02:00
Add a flag to pick up timestamp of commits and print information if found and add noclobber option for easier testing.
TEST=Ran cbuildbot with file. Review URL: http://codereview.chromium.org/3174021
This commit is contained in:
parent
d26c87d176
commit
81dae09de0
@ -17,11 +17,12 @@ _DEFAULT_RETRIES=3
|
|||||||
|
|
||||||
# Utility functions
|
# Utility functions
|
||||||
|
|
||||||
def RunCommand(cmd, error_ok=False, error_message=None, exit_code=False,
|
def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
||||||
redirect_stdout=False, redirect_stderr=False, cwd=None,
|
exit_code=False, redirect_stdout=False, redirect_stderr=False,
|
||||||
input=None):
|
cwd=None, input=None):
|
||||||
# Print out the command before running.
|
# Print out the command before running.
|
||||||
print >>sys.stderr, "CBUILDBOT -- RunCommand:", ' '.join(cmd)
|
if print_cmd:
|
||||||
|
print >> sys.stderr, "CBUILDBOT -- RunCommand:", ' '.join(cmd)
|
||||||
if redirect_stdout:
|
if redirect_stdout:
|
||||||
stdout = subprocess.PIPE
|
stdout = subprocess.PIPE
|
||||||
else:
|
else:
|
||||||
@ -47,7 +48,7 @@ def RunCommand(cmd, error_ok=False, error_message=None, exit_code=False,
|
|||||||
def MakeDir(path, parents=False):
|
def MakeDir(path, parents=False):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except OSError,e:
|
except OSError, e:
|
||||||
if e.errno == errno.EEXIST and parents:
|
if e.errno == errno.EEXIST and parents:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -98,12 +99,26 @@ def _Build(buildroot):
|
|||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./build_packages'], cwd=cwd)
|
RunCommand(['./build_packages'], cwd=cwd)
|
||||||
|
|
||||||
def _UprevPackages(buildroot):
|
def _UprevAllPackages(buildroot):
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./enter_chroot.sh', '--', './cros_mark_all_as_stable',
|
RunCommand(['./enter_chroot.sh', '--', './cros_mark_all_as_stable',
|
||||||
'--tracking_branch="cros/master"'],
|
'--tracking_branch="cros/master"'],
|
||||||
cwd=cwd)
|
cwd=cwd)
|
||||||
|
|
||||||
|
def _UprevPackages(buildroot, revisionfile):
|
||||||
|
revisions = None
|
||||||
|
if (revision_file):
|
||||||
|
rev_file = revisionfile.open(revisionfile)
|
||||||
|
revisions = rev_file.read()
|
||||||
|
rev_file.close()
|
||||||
|
|
||||||
|
# Note: Revisions == "None" indicates a Force Build.
|
||||||
|
if revisions and revisions != 'None':
|
||||||
|
print 'CBUILDBOT - Revision list found %s' % revisions
|
||||||
|
print 'Revision list not yet propagating to build, marking all instead'
|
||||||
|
|
||||||
|
_UprevAllPackages(buildroot)
|
||||||
|
|
||||||
def _UprevCleanup(buildroot):
|
def _UprevCleanup(buildroot):
|
||||||
cwd = os.path.join(buildroot, 'src', 'scripts')
|
cwd = os.path.join(buildroot, 'src', 'scripts')
|
||||||
RunCommand(['./cros_mark_as_stable', '--srcroot=..',
|
RunCommand(['./cros_mark_as_stable', '--srcroot=..',
|
||||||
@ -135,13 +150,21 @@ def main():
|
|||||||
help='root directory where build occurs', default=".")
|
help='root directory where build occurs', default=".")
|
||||||
parser.add_option('-n', '--buildnumber',
|
parser.add_option('-n', '--buildnumber',
|
||||||
help='build number', type='int', default=0)
|
help='build number', type='int', default=0)
|
||||||
|
parser.add_option('-f', '--revisionfile',
|
||||||
|
help='file where new revisions are stored')
|
||||||
|
parser.add_option('--noclobber', action='store_false', dest='clobber',
|
||||||
|
default=True,
|
||||||
|
help='Disables clobbering the buildroot on failure')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
buildroot = options.buildroot
|
buildroot = options.buildroot
|
||||||
|
revisionfile = options.revisionfile
|
||||||
|
clobber = options.clobber
|
||||||
|
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
buildconfig = _GetConfig(args[0])
|
buildconfig = _GetConfig(args[0])
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, "Missing configuration description"
|
print >> sys.stderr, "Missing configuration description"
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
@ -156,14 +179,15 @@ def main():
|
|||||||
if not os.path.isdir(boardpath):
|
if not os.path.isdir(boardpath):
|
||||||
_SetupBoard(buildroot, board=buildconfig['board'])
|
_SetupBoard(buildroot, board=buildconfig['board'])
|
||||||
if buildconfig['uprev']:
|
if buildconfig['uprev']:
|
||||||
_UprevPackages(buildroot)
|
_UprevPackages(buildroot, revisionfile)
|
||||||
_Build(buildroot)
|
_Build(buildroot)
|
||||||
if buildconfig['uprev']:
|
if buildconfig['uprev']:
|
||||||
_UprevPush(buildroot)
|
_UprevPush(buildroot)
|
||||||
_UprevCleanup(buildroot)
|
_UprevCleanup(buildroot)
|
||||||
except:
|
except:
|
||||||
# something went wrong, cleanup (being paranoid) for next build
|
# something went wrong, cleanup (being paranoid) for next build
|
||||||
RunCommand(['sudo', 'rm', '-rf', buildroot])
|
if clobber:
|
||||||
|
RunCommand(['sudo', 'rm', '-rf', buildroot], print_cmd=False)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user