add 5 minute timeout on binary patch construction
When making bsdiff/imgdiff patches, give up after 5 minutes. (On certain large files it can take hours to build a patch, if it ever even completes.) Change-Id: I123c06f8194f85f6f4e640f7eb31c7746f76ba4d
This commit is contained in:
@@ -900,10 +900,26 @@ class Difference(object):
|
|||||||
cmd.append(ttemp.name)
|
cmd.append(ttemp.name)
|
||||||
cmd.append(ptemp.name)
|
cmd.append(ptemp.name)
|
||||||
p = Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
_, err = p.communicate()
|
err = []
|
||||||
|
def run():
|
||||||
|
_, e = p.communicate()
|
||||||
|
if e: err.append(e)
|
||||||
|
th = threading.Thread(target=run)
|
||||||
|
th.start()
|
||||||
|
th.join(timeout=300) # 5 mins
|
||||||
|
if th.is_alive():
|
||||||
|
print "WARNING: diff command timed out"
|
||||||
|
p.terminate()
|
||||||
|
th.join(5)
|
||||||
|
if th.is_alive():
|
||||||
|
p.kill()
|
||||||
|
th.join()
|
||||||
|
|
||||||
if err or p.returncode != 0:
|
if err or p.returncode != 0:
|
||||||
print "WARNING: failure running %s:\n%s\n" % (diff_program, err)
|
print "WARNING: failure running %s:\n%s\n" % (
|
||||||
return None
|
diff_program, "".join(err))
|
||||||
|
self.patch = None
|
||||||
|
return None, None, None
|
||||||
diff = ptemp.read()
|
diff = ptemp.read()
|
||||||
finally:
|
finally:
|
||||||
ptemp.close()
|
ptemp.close()
|
||||||
|
@@ -853,15 +853,20 @@ else if get_stage("%(bcb_dev)s", "stage") != "3/3" then
|
|||||||
GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
|
GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
|
||||||
|
|
||||||
if updating_boot:
|
if updating_boot:
|
||||||
|
boot_type, boot_device = common.GetTypeAndDevice("/boot", OPTIONS.info_dict)
|
||||||
d = common.Difference(target_boot, source_boot)
|
d = common.Difference(target_boot, source_boot)
|
||||||
_, _, d = d.ComputePatch()
|
_, _, d = d.ComputePatch()
|
||||||
|
if d is None:
|
||||||
|
include_full_boot = True
|
||||||
|
common.ZipWriteStr(output_zip, "boot.img", target_boot.data)
|
||||||
|
else:
|
||||||
|
include_full_boot = False
|
||||||
|
|
||||||
print "boot target: %d source: %d diff: %d" % (
|
print "boot target: %d source: %d diff: %d" % (
|
||||||
target_boot.size, source_boot.size, len(d))
|
target_boot.size, source_boot.size, len(d))
|
||||||
|
|
||||||
common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
|
common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
|
||||||
|
|
||||||
boot_type, boot_device = common.GetTypeAndDevice("/boot", OPTIONS.info_dict)
|
|
||||||
|
|
||||||
script.PatchCheck("%s:%s:%d:%s:%d:%s" %
|
script.PatchCheck("%s:%s:%d:%s:%d:%s" %
|
||||||
(boot_type, boot_device,
|
(boot_type, boot_device,
|
||||||
source_boot.size, source_boot.sha1,
|
source_boot.size, source_boot.sha1,
|
||||||
@@ -906,9 +911,15 @@ else
|
|||||||
|
|
||||||
if not OPTIONS.two_step:
|
if not OPTIONS.two_step:
|
||||||
if updating_boot:
|
if updating_boot:
|
||||||
|
if include_full_boot:
|
||||||
|
print "boot image changed; including full."
|
||||||
|
script.Print("Installing boot image...")
|
||||||
|
script.WriteRawImage("/boot", "boot.img")
|
||||||
|
else:
|
||||||
# Produce the boot image by applying a patch to the current
|
# Produce the boot image by applying a patch to the current
|
||||||
# contents of the boot partition, and write it back to the
|
# contents of the boot partition, and write it back to the
|
||||||
# partition.
|
# partition.
|
||||||
|
print "boot image changed; including patch."
|
||||||
script.Print("Patching boot image...")
|
script.Print("Patching boot image...")
|
||||||
script.ShowProgress(0.1, 10)
|
script.ShowProgress(0.1, 10)
|
||||||
script.ApplyPatch("%s:%s:%d:%s:%d:%s"
|
script.ApplyPatch("%s:%s:%d:%s:%d:%s"
|
||||||
@@ -918,7 +929,6 @@ else
|
|||||||
"-",
|
"-",
|
||||||
target_boot.size, target_boot.sha1,
|
target_boot.size, target_boot.sha1,
|
||||||
source_boot.sha1, "patch/boot.img.p")
|
source_boot.sha1, "patch/boot.img.p")
|
||||||
print "boot image changed; including."
|
|
||||||
else:
|
else:
|
||||||
print "boot image unchanged; skipping."
|
print "boot image unchanged; skipping."
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user