summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-08 11:39:08 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-09 14:27:50 +0100
commit7cde0ebd59f12da363e780126ca4284e0930721d (patch)
treea77b1a6335a72c4e5a2913ab8d9a0336c13e861b /scripts/lib/devtool/standard.py
parentee0c11d9889cc5abbffbec512d7232416a6e6319 (diff)
downloadpoky-7cde0ebd59f12da363e780126ca4284e0930721d.tar.gz
devtool: improve modified file preservation to handle directory structures
Allow the _add_md5() function to be called with a directory in order to recursively add the files under it. Additionally, we need to skip preserving empty directories (since directories aren't listed in the md5 file). (From OE-Core rev: 9383af78adc854a6f6de8b1520edf3cea0c477a6) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-rw-r--r--scripts/lib/devtool/standard.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ee00c6d7b0..a5a20e3ae8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -362,14 +362,23 @@ def _extract_source(srctree, keep_temp, devbranch, d):
362 return initial_rev 362 return initial_rev
363 363
364def _add_md5(config, recipename, filename): 364def _add_md5(config, recipename, filename):
365 """Record checksum of a recipe to the md5-file of the workspace""" 365 """Record checksum of a file (or recursively for a directory) to the md5-file of the workspace"""
366 import bb.utils 366 import bb.utils
367 md5 = bb.utils.md5_file(filename) 367
368 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a') as f: 368 def addfile(fn):
369 f.write('%s|%s|%s\n' % (recipename, os.path.relpath(filename, config.workspace_path), md5)) 369 md5 = bb.utils.md5_file(fn)
370 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a') as f:
371 f.write('%s|%s|%s\n' % (recipename, os.path.relpath(fn, config.workspace_path), md5))
372
373 if os.path.isdir(filename):
374 for root, _, files in os.walk(os.path.dirname(filename)):
375 for f in files:
376 addfile(os.path.join(root, f))
377 else:
378 addfile(filename)
370 379
371def _check_preserve(config, recipename): 380def _check_preserve(config, recipename):
372 """Check if a recipe was manually changed and needs to be saved in 'attic' 381 """Check if a file was manually changed and needs to be saved in 'attic'
373 directory""" 382 directory"""
374 import bb.utils 383 import bb.utils
375 origfile = os.path.join(config.workspace_path, '.devtool_md5') 384 origfile = os.path.join(config.workspace_path, '.devtool_md5')
@@ -830,10 +839,13 @@ def reset(args, config, basepath, workspace):
830 preservepath = os.path.join(config.workspace_path, 'attic', pn) 839 preservepath = os.path.join(config.workspace_path, 'attic', pn)
831 def preservedir(origdir): 840 def preservedir(origdir):
832 if os.path.exists(origdir): 841 if os.path.exists(origdir):
833 for fn in os.listdir(origdir): 842 for root, dirs, files in os.walk(origdir):
834 logger.warn('Preserving %s in %s' % (fn, preservepath)) 843 for fn in files:
835 bb.utils.mkdirhier(preservepath) 844 logger.warn('Preserving %s in %s' % (fn, preservepath))
836 shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn)) 845 bb.utils.mkdirhier(preservepath)
846 shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn))
847 for dn in dirs:
848 os.rmdir(os.path.join(root, dn))
837 os.rmdir(origdir) 849 os.rmdir(origdir)
838 850
839 preservedir(os.path.join(config.workspace_path, 'recipes', pn)) 851 preservedir(os.path.join(config.workspace_path, 'recipes', pn))