summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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))