mirror of
https://git.yoctoproject.org/poky
synced 2026-09-13 09:49:32 +02:00
combo-layer: improve patch list handling and output
* Ignore blank lines in patch list * Don't fail in interactive mode if patch list is deleted * Show patch counter * Show relative path for patches * Print headings before applying patch list for each component Also change to using a "with" block to read the patch list so it gets closed properly when we're finished. Fixes [YOCTO #2455]. (From OE-Core rev: 65461d7c35fdadb5b008052798731dce19ed187f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
2dc0b337bc
commit
8140c5b7ee
@@ -263,7 +263,7 @@ def action_update(conf, args):
|
|||||||
repo_patch_dir = os.path.join(os.getcwd(), patch_dir, name)
|
repo_patch_dir = os.path.join(os.getcwd(), patch_dir, name)
|
||||||
|
|
||||||
# Step 2: generate the patch list and store to patch dir
|
# Step 2: generate the patch list and store to patch dir
|
||||||
logger.info("generating patches for %s" % name)
|
logger.info("Generating patches from %s..." % name)
|
||||||
if dest_dir != ".":
|
if dest_dir != ".":
|
||||||
prefix = "--src-prefix=a/%s/ --dst-prefix=b/%s/" % (dest_dir, dest_dir)
|
prefix = "--src-prefix=a/%s/ --dst-prefix=b/%s/" % (dest_dir, dest_dir)
|
||||||
else:
|
else:
|
||||||
@@ -337,27 +337,50 @@ def apply_patchlist(conf, repos):
|
|||||||
repo = conf.repos[name]
|
repo = conf.repos[name]
|
||||||
lastrev = repo["last_revision"]
|
lastrev = repo["last_revision"]
|
||||||
prevrev = lastrev
|
prevrev = lastrev
|
||||||
for line in open(repo['patchlist']):
|
|
||||||
patchfile = line.split()[0]
|
# Get non-blank lines from patch list file
|
||||||
lastrev = line.split()[1]
|
patchlist = []
|
||||||
if os.path.getsize(patchfile) == 0:
|
if os.path.exists(repo['patchlist']) or not conf.interactive:
|
||||||
logger.info("(skipping %s - no changes)", lastrev)
|
# Note: we want this to fail here if the file doesn't exist and we're not in
|
||||||
else:
|
# interactive mode since the file should exist in this case
|
||||||
cmd = "git am --keep-cr -s -p1 %s" % patchfile
|
with open(repo['patchlist']) as f:
|
||||||
logger.info("Apply %s" % patchfile )
|
for line in f:
|
||||||
try:
|
line = line.rstrip()
|
||||||
runcmd(cmd)
|
if line:
|
||||||
except subprocess.CalledProcessError:
|
patchlist.append(line)
|
||||||
logger.info('running "git am --abort" to cleanup repo')
|
|
||||||
runcmd("git am --abort")
|
if patchlist:
|
||||||
logger.error('"%s" failed' % cmd)
|
logger.info("Applying patches from %s..." % name)
|
||||||
logger.info("please manually apply patch %s" % patchfile)
|
linecount = len(patchlist)
|
||||||
logger.info("Note: if you exit and continue applying without manually applying the patch, it will be skipped")
|
i = 1
|
||||||
if not drop_to_shell():
|
for line in patchlist:
|
||||||
if prevrev != repo['last_revision']:
|
patchfile = line.split()[0]
|
||||||
conf.update(name, "last_revision", prevrev)
|
lastrev = line.split()[1]
|
||||||
sys.exit(0)
|
patchdisp = os.path.relpath(patchfile)
|
||||||
prevrev = lastrev
|
if os.path.getsize(patchfile) == 0:
|
||||||
|
logger.info("(skipping %d/%d %s - no changes)" % (i, linecount, patchdisp))
|
||||||
|
else:
|
||||||
|
cmd = "git am --keep-cr -s -p1 %s" % patchfile
|
||||||
|
logger.info("Applying %d/%d: %s" % (i, linecount, patchdisp))
|
||||||
|
try:
|
||||||
|
runcmd(cmd)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
logger.info('Running "git am --abort" to cleanup repo')
|
||||||
|
runcmd("git am --abort")
|
||||||
|
logger.error('"%s" failed' % cmd)
|
||||||
|
logger.info("Please manually apply patch %s" % patchdisp)
|
||||||
|
logger.info("Note: if you exit and continue applying without manually applying the patch, it will be skipped")
|
||||||
|
if not drop_to_shell():
|
||||||
|
if prevrev != repo['last_revision']:
|
||||||
|
conf.update(name, "last_revision", prevrev)
|
||||||
|
sys.exit(0)
|
||||||
|
prevrev = lastrev
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
logger.info("No patches to apply from %s" % name)
|
||||||
|
ldir = conf.repos[name]['local_repo_dir']
|
||||||
|
lastrev = runcmd("git rev-parse HEAD", ldir).strip()
|
||||||
|
|
||||||
if lastrev != repo['last_revision']:
|
if lastrev != repo['last_revision']:
|
||||||
conf.update(name, "last_revision", lastrev)
|
conf.update(name, "last_revision", lastrev)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user