diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2015-03-10 09:56:03 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-03-20 11:21:23 +0000 |
commit | 96b98451c4cb5afa48fe951c3cac8e7bf1618142 (patch) | |
tree | 1e71a34cef1b4f1fc623a220243cb14e1e34b1f3 /scripts | |
parent | 627e524238893b537454fd48dade0dde8c64362d (diff) | |
download | poky-96b98451c4cb5afa48fe951c3cac8e7bf1618142.tar.gz |
combo-layer: exclude files
Some combined repos intentionally do not include certain files.
For example, Poky does not include bitbake's setup files and
OE-core's sample files under meta/conf.
When these files get modified in the upstream repository, applying the
patches fails and requires manual intervention. That is merely a
nuisance for someone familiar with the problem, but a real show
stopper when having the import run automatically or by someone less
experienced.
Therefore this change introduces "file_exclude", a new per-repo list
of file patterns which removes all matching files when initializing or
updating a combined repository. Because fnmatch is used under the hood
to match full path strings, removing entire directories must be done
with a pattern ending in a '/*' (in contrast to file_filter).
For Poky, the additional configuration looks like this:
[bitbake]
...
file_exclude = classes/base.bbclass
conf/bitbake.conf
.gitignore
MANIFEST.in
setup.py
TODO
[openembedded-core]
...
file_exclude = meta/conf/bblayers.conf.sample
meta/conf/local.conf.sample
meta/conf/local.conf.sample.extended
meta/conf/site.conf.sample
(From OE-Core rev: a51b37f4db6b144386d1bd5789ec91acc78a0bd8)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/combo-layer | 42 | ||||
-rw-r--r-- | scripts/combo-layer.conf.example | 14 |
2 files changed, 55 insertions, 1 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 3ee9eb203d..8db5d7e376 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -20,6 +20,7 @@ | |||
20 | # with this program; if not, write to the Free Software Foundation, Inc., | 20 | # with this program; if not, write to the Free Software Foundation, Inc., |
21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22 | 22 | ||
23 | import fnmatch | ||
23 | import os, sys | 24 | import os, sys |
24 | import optparse | 25 | import optparse |
25 | import logging | 26 | import logging |
@@ -211,7 +212,18 @@ def action_init(conf, args): | |||
211 | else: | 212 | else: |
212 | extract_dir = os.getcwd() | 213 | extract_dir = os.getcwd() |
213 | file_filter = repo.get('file_filter', "") | 214 | file_filter = repo.get('file_filter', "") |
214 | runcmd("git archive %s | tar -x -C %s %s" % (initialrev, extract_dir, file_filter), ldir) | 215 | files = runcmd("git archive %s | tar -x -v -C %s %s" % (initialrev, extract_dir, file_filter), ldir) |
216 | exclude_patterns = repo.get('file_exclude', '').split() | ||
217 | if exclude_patterns: | ||
218 | # Implement file removal by letting tar create the | ||
219 | # file and then deleting it in the file system | ||
220 | # again. Uses the list of files created by tar (easier | ||
221 | # than walking the tree). | ||
222 | for file in files.split('\n'): | ||
223 | for pattern in exclude_patterns: | ||
224 | if fnmatch.fnmatch(file, pattern): | ||
225 | os.unlink(os.path.join(extract_dir, file)) | ||
226 | break | ||
215 | if not lastrev: | 227 | if not lastrev: |
216 | lastrev = runcmd("git rev-parse %s" % initialrev, ldir).strip() | 228 | lastrev = runcmd("git rev-parse %s" % initialrev, ldir).strip() |
217 | conf.update(name, "last_revision", lastrev, initmode=True) | 229 | conf.update(name, "last_revision", lastrev, initmode=True) |
@@ -426,6 +438,34 @@ def action_update(conf, args): | |||
426 | runcmd("%s %s %s %s" % (repo['hook'], patch, revlist[count], name)) | 438 | runcmd("%s %s %s %s" % (repo['hook'], patch, revlist[count], name)) |
427 | count=count-1 | 439 | count=count-1 |
428 | 440 | ||
441 | # Step 3a: Filter out unwanted files and patches. | ||
442 | exclude = repo.get('file_exclude', '') | ||
443 | if exclude: | ||
444 | filter = ['filterdiff', '-p1'] | ||
445 | for path in exclude.split(): | ||
446 | filter.append('-x') | ||
447 | filter.append('%s/%s' % (dest_dir, path) if dest_dir else path) | ||
448 | for patch in patchlist[:]: | ||
449 | filtered = patch + '.tmp' | ||
450 | with open(filtered, 'w') as f: | ||
451 | runcmd(filter + [patch], out=f) | ||
452 | # Now check for empty patches. | ||
453 | if runcmd(['filterdiff', '--list', filtered]): | ||
454 | # Possibly modified. | ||
455 | os.unlink(patch) | ||
456 | os.rename(filtered, patch) | ||
457 | else: | ||
458 | # Empty, ignore it. Must also remove from revlist. | ||
459 | with open(patch, 'r') as f: | ||
460 | fromline = f.readline() | ||
461 | m = re.match(r'''^From ([0-9a-fA-F]+) .*\n''', fromline) | ||
462 | rev = m.group(1) | ||
463 | logger.debug('skipping empty patch %s = %s' % (patch, rev)) | ||
464 | os.unlink(patch) | ||
465 | os.unlink(filtered) | ||
466 | patchlist.remove(patch) | ||
467 | revlist.remove(rev) | ||
468 | |||
429 | # Step 4: write patch list and revision list to file, for user to edit later | 469 | # Step 4: write patch list and revision list to file, for user to edit later |
430 | patchlist_file = os.path.join(os.getcwd(), patch_dir, "patchlist-%s" % name) | 470 | patchlist_file = os.path.join(os.getcwd(), patch_dir, "patchlist-%s" % name) |
431 | repo['patchlist'] = patchlist_file | 471 | repo['patchlist'] = patchlist_file |
diff --git a/scripts/combo-layer.conf.example b/scripts/combo-layer.conf.example index 427c1b399f..38bc53c59f 100644 --- a/scripts/combo-layer.conf.example +++ b/scripts/combo-layer.conf.example | |||
@@ -42,6 +42,20 @@ last_revision = | |||
42 | # file_filter = src/*.c : only include the src *.c file | 42 | # file_filter = src/*.c : only include the src *.c file |
43 | # file_filter = src/main.c src/Makefile.am : only include these two files | 43 | # file_filter = src/main.c src/Makefile.am : only include these two files |
44 | 44 | ||
45 | # file_exclude: filter out these file(s) | ||
46 | # file_exclude = [path] [path] ... | ||
47 | # | ||
48 | # Each entry must match a file name. In contrast do file_filter, matching | ||
49 | # a directory has no effect. To achieve that, use append a * wildcard | ||
50 | # at the end. | ||
51 | # | ||
52 | # Wildcards are applied to the complete path and also match slashes. | ||
53 | # | ||
54 | # example: | ||
55 | # file_exclude = src/foobar/* : exclude everything under src/foobar | ||
56 | # file_exclude = src/main.c : filter out main.c after including it with file_filter = src/*.c | ||
57 | # file_exclude = *~ : exclude backup files | ||
58 | |||
45 | # hook: if provided, the tool will call the hook to process the generated | 59 | # hook: if provided, the tool will call the hook to process the generated |
46 | # patch from upstream, and then apply the modified patch to the combo | 60 | # patch from upstream, and then apply the modified patch to the combo |
47 | # repo. | 61 | # repo. |