mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 13:36:58 +02:00
Fix cleanup so we don't have to clobber as much when failures occur
Change-Id: I120c49a38d2a17a2216296a68378fee7345f616a TBR=petkov Review URL: http://codereview.chromium.org/3255004
This commit is contained in:
parent
ae26a5cbbf
commit
e13960240b
@ -216,6 +216,7 @@ def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
|
|||||||
def _IncrementalCheckout(buildroot, rw_checkout=True,
|
def _IncrementalCheckout(buildroot, rw_checkout=True,
|
||||||
retries=_DEFAULT_RETRIES):
|
retries=_DEFAULT_RETRIES):
|
||||||
"""Performs a checkout without clobbering previous checkout."""
|
"""Performs a checkout without clobbering previous checkout."""
|
||||||
|
_UprevCleanup(buildroot, error_ok=True)
|
||||||
RepoSync(buildroot, rw_checkout, retries)
|
RepoSync(buildroot, rw_checkout, retries)
|
||||||
|
|
||||||
|
|
||||||
@ -281,12 +282,12 @@ def _UprevPackages(buildroot, revisionfile, board):
|
|||||||
_UprevAllPackages(buildroot)
|
_UprevAllPackages(buildroot)
|
||||||
|
|
||||||
|
|
||||||
def _UprevCleanup(buildroot):
|
def _UprevCleanup(buildroot, error_ok=False):
|
||||||
"""Clean up after a previous uprev attempt."""
|
"""Clean up after a previous uprev attempt."""
|
||||||
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=..',
|
||||||
'--tracking_branch="cros/master"', 'clean'],
|
'--tracking_branch="cros/master"', 'clean'],
|
||||||
cwd=cwd)
|
cwd=cwd, error_ok=error_ok)
|
||||||
|
|
||||||
|
|
||||||
def _UprevPush(buildroot):
|
def _UprevPush(buildroot):
|
||||||
|
@ -34,6 +34,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
|||||||
stdout = None
|
stdout = None
|
||||||
stderr = None
|
stderr = None
|
||||||
stdin = None
|
stdin = None
|
||||||
|
output = ''
|
||||||
|
|
||||||
# Modify defaults based on parameters.
|
# Modify defaults based on parameters.
|
||||||
if redirect_stdout: stdout = subprocess.PIPE
|
if redirect_stdout: stdout = subprocess.PIPE
|
||||||
@ -45,6 +46,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
|||||||
if print_cmd:
|
if print_cmd:
|
||||||
Info('RunCommand: %s' % ' '.join(cmd))
|
Info('RunCommand: %s' % ' '.join(cmd))
|
||||||
|
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
|
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
|
||||||
stdout=stdout, stderr=stderr)
|
stdout=stdout, stderr=stderr)
|
||||||
(output, error) = proc.communicate(input)
|
(output, error) = proc.communicate(input)
|
||||||
@ -54,6 +56,11 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
|
|||||||
if not error_ok and proc.returncode:
|
if not error_ok and proc.returncode:
|
||||||
raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) +
|
raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) +
|
||||||
(error_message or error or output or ''))
|
(error_message or error or output or ''))
|
||||||
|
except Exception,e:
|
||||||
|
if not error_ok:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
Warning(str(e))
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user