[oe-commits] Patrick Ohly : combo-layer: clean up dest_dir checking
git at git.openembedded.org
git at git.openembedded.org
Sat Mar 28 09:00:36 UTC 2015
Module: openembedded-core.git
Branch: master-next
Commit: a1c0bf21e03e990841af21d383de8c96457931a5
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=a1c0bf21e03e990841af21d383de8c96457931a5
Author: Patrick Ohly <patrick.ohly at intel.com>
Date: Fri Mar 27 14:53:10 2015 +0100
combo-layer: clean up dest_dir checking
Empty dest_dir is basically undocumented behavior. The sample conf
only mentions using just a dot for the current directory. In practice,
the empty string does not work because of code like this:
def action_splitpatch(conf, args):
...
if dest_dir != ".":
filerange_root = '%s -x "%s/*"' % (filerange_root, dest_dir)
However, the empty string was not explicitly checked for, leading to
strange errors when trying to apply patches:
[12:50:23] Applying: foobar: xyz
fatal: unable to stat newly created file '/foobar': No such file or directory
This patch turns the empty string into an alias for the dot. This seems
more user-friendly than throwing an error. This alias is intentionally
not document in the sample conf, because the dot is clearer and works also
with older copies of combo-layer.
Instead of checking for both all the time and normalizing the path when
needed (as done in some places), rewrite the value in sanity_check()
and then only check for '.'.
Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
scripts/combo-layer | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 83cfc8e..8f01974 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -144,6 +144,10 @@ class Configuration(object):
if option not in self.repos[name]:
msg = "%s\nOption %s is not defined for component %s" %(msg, option, name)
missing_options.append(option)
+ # Sanitize dest_dir so that we do not have to deal with edge cases
+ # (empty string, double slashes) in the rest of the code.
+ dest_dir = os.path.normpath(self.repos[name]["dest_dir"])
+ self.repos[name]["dest_dir"] = "." if not dest_dir else dest_dir
if msg != "":
logger.error("configuration file %s has the following error: %s" % (self.conffile,msg))
if self.localconffile and 'last_revision' in missing_options:
@@ -231,7 +235,7 @@ def action_init(conf, args):
pass
initialrev = rev
dest_dir = repo['dest_dir']
- if dest_dir and dest_dir != ".":
+ if dest_dir != ".":
extract_dir = os.path.join(os.getcwd(), dest_dir)
if not os.path.exists(extract_dir):
os.makedirs(extract_dir)
@@ -325,7 +329,7 @@ EOF
runcmd('git replace --edit %s' % rev)
# Optional: rewrite history to change commit messages or to move files.
- if 'hook' in repo or dest_dir and dest_dir != ".":
+ if 'hook' in repo or dest_dir != ".":
filter_branch = ['git', 'filter-branch', '--force']
with tempfile.NamedTemporaryFile() as hookwrapper:
if 'hook' in repo:
@@ -353,7 +357,7 @@ tail -c +18 $tmpname | head -c -4
''' % (hook, name))
hookwrapper.flush()
filter_branch.extend(['--msg-filter', 'bash %s' % hookwrapper.name])
- if dest_dir and dest_dir != ".":
+ if dest_dir != ".":
parent = os.path.dirname(dest_dir)
if not parent:
parent = '.'
@@ -371,7 +375,7 @@ tail -c +18 $tmpname | head -c -4
if not os.path.exists(extract_dir):
os.makedirs(extract_dir)
copy_selected_files('HEAD', extract_dir, file_filter, exclude_patterns, '.',
- subdir=dest_dir if dest_dir and dest_dir != '.' else '')
+ subdir=dest_dir if dest_dir != '.' else '')
runcmd('git add --all --force .')
if runcmd('git status --porcelain'):
# Something to commit.
More information about the Openembedded-commits
mailing list