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>
This commit is contained in:
parent
627e524238
commit
96b98451c4
|
@ -20,6 +20,7 @@
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
import fnmatch
|
||||||
import os, sys
|
import os, sys
|
||||||
import optparse
|
import optparse
|
||||||
import logging
|
import logging
|
||||||
|
@ -211,7 +212,18 @@ def action_init(conf, args):
|
||||||
else:
|
else:
|
||||||
extract_dir = os.getcwd()
|
extract_dir = os.getcwd()
|
||||||
file_filter = repo.get('file_filter', "")
|
file_filter = repo.get('file_filter', "")
|
||||||
runcmd("git archive %s | tar -x -C %s %s" % (initialrev, extract_dir, file_filter), ldir)
|
files = runcmd("git archive %s | tar -x -v -C %s %s" % (initialrev, extract_dir, file_filter), ldir)
|
||||||
|
exclude_patterns = repo.get('file_exclude', '').split()
|
||||||
|
if exclude_patterns:
|
||||||
|
# Implement file removal by letting tar create the
|
||||||
|
# file and then deleting it in the file system
|
||||||
|
# again. Uses the list of files created by tar (easier
|
||||||
|
# than walking the tree).
|
||||||
|
for file in files.split('\n'):
|
||||||
|
for pattern in exclude_patterns:
|
||||||
|
if fnmatch.fnmatch(file, pattern):
|
||||||
|
os.unlink(os.path.join(extract_dir, file))
|
||||||
|
break
|
||||||
if not lastrev:
|
if not lastrev:
|
||||||
lastrev = runcmd("git rev-parse %s" % initialrev, ldir).strip()
|
lastrev = runcmd("git rev-parse %s" % initialrev, ldir).strip()
|
||||||
conf.update(name, "last_revision", lastrev, initmode=True)
|
conf.update(name, "last_revision", lastrev, initmode=True)
|
||||||
|
@ -426,6 +438,34 @@ def action_update(conf, args):
|
||||||
runcmd("%s %s %s %s" % (repo['hook'], patch, revlist[count], name))
|
runcmd("%s %s %s %s" % (repo['hook'], patch, revlist[count], name))
|
||||||
count=count-1
|
count=count-1
|
||||||
|
|
||||||
|
# Step 3a: Filter out unwanted files and patches.
|
||||||
|
exclude = repo.get('file_exclude', '')
|
||||||
|
if exclude:
|
||||||
|
filter = ['filterdiff', '-p1']
|
||||||
|
for path in exclude.split():
|
||||||
|
filter.append('-x')
|
||||||
|
filter.append('%s/%s' % (dest_dir, path) if dest_dir else path)
|
||||||
|
for patch in patchlist[:]:
|
||||||
|
filtered = patch + '.tmp'
|
||||||
|
with open(filtered, 'w') as f:
|
||||||
|
runcmd(filter + [patch], out=f)
|
||||||
|
# Now check for empty patches.
|
||||||
|
if runcmd(['filterdiff', '--list', filtered]):
|
||||||
|
# Possibly modified.
|
||||||
|
os.unlink(patch)
|
||||||
|
os.rename(filtered, patch)
|
||||||
|
else:
|
||||||
|
# Empty, ignore it. Must also remove from revlist.
|
||||||
|
with open(patch, 'r') as f:
|
||||||
|
fromline = f.readline()
|
||||||
|
m = re.match(r'''^From ([0-9a-fA-F]+) .*\n''', fromline)
|
||||||
|
rev = m.group(1)
|
||||||
|
logger.debug('skipping empty patch %s = %s' % (patch, rev))
|
||||||
|
os.unlink(patch)
|
||||||
|
os.unlink(filtered)
|
||||||
|
patchlist.remove(patch)
|
||||||
|
revlist.remove(rev)
|
||||||
|
|
||||||
# Step 4: write patch list and revision list to file, for user to edit later
|
# Step 4: write patch list and revision list to file, for user to edit later
|
||||||
patchlist_file = os.path.join(os.getcwd(), patch_dir, "patchlist-%s" % name)
|
patchlist_file = os.path.join(os.getcwd(), patch_dir, "patchlist-%s" % name)
|
||||||
repo['patchlist'] = patchlist_file
|
repo['patchlist'] = patchlist_file
|
||||||
|
|
|
@ -42,6 +42,20 @@ last_revision =
|
||||||
# file_filter = src/*.c : only include the src *.c file
|
# file_filter = src/*.c : only include the src *.c file
|
||||||
# file_filter = src/main.c src/Makefile.am : only include these two files
|
# file_filter = src/main.c src/Makefile.am : only include these two files
|
||||||
|
|
||||||
|
# file_exclude: filter out these file(s)
|
||||||
|
# file_exclude = [path] [path] ...
|
||||||
|
#
|
||||||
|
# Each entry must match a file name. In contrast do file_filter, matching
|
||||||
|
# a directory has no effect. To achieve that, use append a * wildcard
|
||||||
|
# at the end.
|
||||||
|
#
|
||||||
|
# Wildcards are applied to the complete path and also match slashes.
|
||||||
|
#
|
||||||
|
# example:
|
||||||
|
# file_exclude = src/foobar/* : exclude everything under src/foobar
|
||||||
|
# file_exclude = src/main.c : filter out main.c after including it with file_filter = src/*.c
|
||||||
|
# file_exclude = *~ : exclude backup files
|
||||||
|
|
||||||
# hook: if provided, the tool will call the hook to process the generated
|
# hook: if provided, the tool will call the hook to process the generated
|
||||||
# patch from upstream, and then apply the modified patch to the combo
|
# patch from upstream, and then apply the modified patch to the combo
|
||||||
# repo.
|
# repo.
|
||||||
|
|
Loading…
Reference in New Issue