diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2015-03-27 14:53:11 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-31 22:23:16 +0100 |
commit | 3775c6e7147dec71fde7121870bf919525138c28 (patch) | |
tree | 90add1ad9d9ed023697acfbc04c3f9afa2c4f18d /scripts/combo-layer | |
parent | 5508950045aa7b3119275c00e6504804242eed6b (diff) | |
download | poky-3775c6e7147dec71fde7121870bf919525138c28.tar.gz |
combo-layer: fix file_exclude for dest_dir = .
"filterdiff -x ./some/file" does not remove changes for some/file.
We must be more careful about constructing the path name and
only add the prefix when it really means a directory.
While at it, also better normalize the path in copy_selected_files()
early on, to handle double slashes. Useful should the function ever
gets used for something other that dest_dir (which gets normalized in
sanity_check()).
(From OE-Core rev: 8ea63c6c920c39e5a4ba176223fe472f92e2632a)
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 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 8f019744fc..fa60579272 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -249,13 +249,16 @@ def action_init(conf, args): | |||
249 | # files already moved, we need to prepend the | 249 | # files already moved, we need to prepend the |
250 | # subdirectory to all filters, otherwise they would | 250 | # subdirectory to all filters, otherwise they would |
251 | # not match. | 251 | # not match. |
252 | if subdir: | 252 | if subdir == '.': |
253 | subdir = '' | ||
254 | elif subdir: | ||
255 | subdir = os.path.normpath(subdir) | ||
253 | file_filter = ' '.join([subdir + '/' + x for x in file_filter.split()]) | 256 | file_filter = ' '.join([subdir + '/' + x for x in file_filter.split()]) |
254 | exclude_patterns = [subdir + '/' + x for x in exclude_patterns] | 257 | exclude_patterns = [subdir + '/' + x for x in exclude_patterns] |
255 | # To handle both cases, we cd into the target | 258 | # To handle both cases, we cd into the target |
256 | # directory and optionally tell tar to strip the path | 259 | # directory and optionally tell tar to strip the path |
257 | # prefix when the files were already moved. | 260 | # prefix when the files were already moved. |
258 | subdir_components = len(os.path.normpath(subdir).split(os.path.sep)) if subdir else 0 | 261 | subdir_components = len(subdir.split(os.path.sep)) if subdir else 0 |
259 | strip=('--strip-components=%d' % subdir_components) if subdir else '' | 262 | strip=('--strip-components=%d' % subdir_components) if subdir else '' |
260 | # TODO: file_filter wild cards do not work (and haven't worked before either), because | 263 | # TODO: file_filter wild cards do not work (and haven't worked before either), because |
261 | # a) GNU tar requires a --wildcards parameter before turning on wild card matching. | 264 | # a) GNU tar requires a --wildcards parameter before turning on wild card matching. |
@@ -375,7 +378,7 @@ tail -c +18 $tmpname | head -c -4 | |||
375 | if not os.path.exists(extract_dir): | 378 | if not os.path.exists(extract_dir): |
376 | os.makedirs(extract_dir) | 379 | os.makedirs(extract_dir) |
377 | copy_selected_files('HEAD', extract_dir, file_filter, exclude_patterns, '.', | 380 | copy_selected_files('HEAD', extract_dir, file_filter, exclude_patterns, '.', |
378 | subdir=dest_dir if dest_dir != '.' else '') | 381 | subdir=dest_dir) |
379 | runcmd('git add --all --force .') | 382 | runcmd('git add --all --force .') |
380 | if runcmd('git status --porcelain'): | 383 | if runcmd('git status --porcelain'): |
381 | # Something to commit. | 384 | # Something to commit. |
@@ -648,7 +651,7 @@ def action_update(conf, args): | |||
648 | filter = ['filterdiff', '-p1'] | 651 | filter = ['filterdiff', '-p1'] |
649 | for path in exclude.split(): | 652 | for path in exclude.split(): |
650 | filter.append('-x') | 653 | filter.append('-x') |
651 | filter.append('%s/%s' % (dest_dir, path) if dest_dir else path) | 654 | filter.append('%s/%s' % (dest_dir, path) if dest_dir != '.' else path) |
652 | for patch in patchlist[:]: | 655 | for patch in patchlist[:]: |
653 | filtered = patch + '.tmp' | 656 | filtered = patch + '.tmp' |
654 | with open(filtered, 'w') as f: | 657 | with open(filtered, 'w') as f: |