diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2015-03-27 14:53:10 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-31 22:23:16 +0100 |
commit | 5508950045aa7b3119275c00e6504804242eed6b (patch) | |
tree | 992de41eb638ca7a37841500be07e1d64db88e95 /scripts/combo-layer | |
parent | 47dedbcb52702539b124ecf43cf53e4c3b7b3b33 (diff) | |
download | poky-5508950045aa7b3119275c00e6504804242eed6b.tar.gz |
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 '.'.
(From OE-Core rev: f8cdbe749755dc769150d3a6c2c54318c80e1562)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-x | scripts/combo-layer | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 83cfc8e16a..8f019744fc 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -144,6 +144,10 @@ class Configuration(object): | |||
144 | if option not in self.repos[name]: | 144 | if option not in self.repos[name]: |
145 | msg = "%s\nOption %s is not defined for component %s" %(msg, option, name) | 145 | msg = "%s\nOption %s is not defined for component %s" %(msg, option, name) |
146 | missing_options.append(option) | 146 | missing_options.append(option) |
147 | # Sanitize dest_dir so that we do not have to deal with edge cases | ||
148 | # (empty string, double slashes) in the rest of the code. | ||
149 | dest_dir = os.path.normpath(self.repos[name]["dest_dir"]) | ||
150 | self.repos[name]["dest_dir"] = "." if not dest_dir else dest_dir | ||
147 | if msg != "": | 151 | if msg != "": |
148 | logger.error("configuration file %s has the following error: %s" % (self.conffile,msg)) | 152 | logger.error("configuration file %s has the following error: %s" % (self.conffile,msg)) |
149 | if self.localconffile and 'last_revision' in missing_options: | 153 | if self.localconffile and 'last_revision' in missing_options: |
@@ -231,7 +235,7 @@ def action_init(conf, args): | |||
231 | pass | 235 | pass |
232 | initialrev = rev | 236 | initialrev = rev |
233 | dest_dir = repo['dest_dir'] | 237 | dest_dir = repo['dest_dir'] |
234 | if dest_dir and dest_dir != ".": | 238 | if dest_dir != ".": |
235 | extract_dir = os.path.join(os.getcwd(), dest_dir) | 239 | extract_dir = os.path.join(os.getcwd(), dest_dir) |
236 | if not os.path.exists(extract_dir): | 240 | if not os.path.exists(extract_dir): |
237 | os.makedirs(extract_dir) | 241 | os.makedirs(extract_dir) |
@@ -325,7 +329,7 @@ EOF | |||
325 | runcmd('git replace --edit %s' % rev) | 329 | runcmd('git replace --edit %s' % rev) |
326 | 330 | ||
327 | # Optional: rewrite history to change commit messages or to move files. | 331 | # Optional: rewrite history to change commit messages or to move files. |
328 | if 'hook' in repo or dest_dir and dest_dir != ".": | 332 | if 'hook' in repo or dest_dir != ".": |
329 | filter_branch = ['git', 'filter-branch', '--force'] | 333 | filter_branch = ['git', 'filter-branch', '--force'] |
330 | with tempfile.NamedTemporaryFile() as hookwrapper: | 334 | with tempfile.NamedTemporaryFile() as hookwrapper: |
331 | if 'hook' in repo: | 335 | if 'hook' in repo: |
@@ -353,7 +357,7 @@ tail -c +18 $tmpname | head -c -4 | |||
353 | ''' % (hook, name)) | 357 | ''' % (hook, name)) |
354 | hookwrapper.flush() | 358 | hookwrapper.flush() |
355 | filter_branch.extend(['--msg-filter', 'bash %s' % hookwrapper.name]) | 359 | filter_branch.extend(['--msg-filter', 'bash %s' % hookwrapper.name]) |
356 | if dest_dir and dest_dir != ".": | 360 | if dest_dir != ".": |
357 | parent = os.path.dirname(dest_dir) | 361 | parent = os.path.dirname(dest_dir) |
358 | if not parent: | 362 | if not parent: |
359 | parent = '.' | 363 | parent = '.' |
@@ -371,7 +375,7 @@ tail -c +18 $tmpname | head -c -4 | |||
371 | if not os.path.exists(extract_dir): | 375 | if not os.path.exists(extract_dir): |
372 | os.makedirs(extract_dir) | 376 | os.makedirs(extract_dir) |
373 | copy_selected_files('HEAD', extract_dir, file_filter, exclude_patterns, '.', | 377 | copy_selected_files('HEAD', extract_dir, file_filter, exclude_patterns, '.', |
374 | subdir=dest_dir if dest_dir and dest_dir != '.' else '') | 378 | subdir=dest_dir if dest_dir != '.' else '') |
375 | runcmd('git add --all --force .') | 379 | runcmd('git add --all --force .') |
376 | if runcmd('git status --porcelain'): | 380 | if runcmd('git status --porcelain'): |
377 | # Something to commit. | 381 | # Something to commit. |