Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: "Michał Górny" <mgorny@g.o>, gentoo-portage-dev@l.g.o, Zac Medico <zmedico@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK
Date: Sun, 12 Jun 2016 09:43:40
Message-Id: 575D2EC7.6060805@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 3/3] portage.dbapi.vartree: Support exclusions in INSTALL_MASK by "Michał Górny"
1 On 06/12/2016 02:31 AM, Michał Górny wrote:
2 > Dnia 12 czerwca 2016 11:20:36 CEST, Zac Medico <zmedico@g.o> napisał(a):
3 >> On 05/21/2016 11:56 PM, Michał Górny wrote:
4 >>> Allow INSTALL_MASK patterns to start with '-' to indicate that
5 >>> a specific match is to be excluded from being masked. In this case,
6 >>> the last matching pattern determines whether the file is actually
7 >>> filtered out or kept.
8 >>> ---
9 >>> pym/portage/dbapi/vartree.py | 10 ++++++----
10 >>> 1 file changed, 6 insertions(+), 4 deletions(-)
11 >>>
12 >>> diff --git a/pym/portage/dbapi/vartree.py
13 >> b/pym/portage/dbapi/vartree.py
14 >>> index 8e5ac43..d02d850 100644
15 >>> --- a/pym/portage/dbapi/vartree.py
16 >>> +++ b/pym/portage/dbapi/vartree.py
17 >>> @@ -3690,19 +3690,21 @@ class dblink(object):
18 >>> def _is_install_masked(self, relative_path):
19 >>> ret = False
20 >>> for pattern in self.settings.install_mask:
21 >>> + # if pattern starts with -, possibly exclude this path
22 >>> + pat_res = not pattern.startswith('-')
23 >>> + if not pat_res:
24 >>> + pattern = pattern[1:]
25 >>> # absolute path pattern
26 >>> if pattern.startswith('/'):
27 >>> # match either exact path or one of parent dirs
28 >>> # the latter is done via matching pattern/*
29 >>> if (fnmatch.fnmatch(relative_path, pattern[1:])
30 >>> or fnmatch.fnmatch(relative_path, pattern[1:] + '/*')):
31 >>> - ret = True
32 >>> - break
33 >>> + ret = pat_res
34 >>> # filename
35 >>> else:
36 >>> if fnmatch.fnmatch(os.path.basename(relative_path), pattern):
37 >>> - ret = True
38 >>> - break
39 >>> + ret = pat_res
40 >>> return ret
41 >>>
42 >>> def treewalk(self, srcroot, destroot, inforoot, myebuild,
43 >> cleanup=0,
44 >>>
45 >>
46 >> In order to implement this with pre-compiled patterns, we can use a
47 >> separate regular expression to represent all of the exclusions.
48 >
49 > That won't work since exclusive and inclusive patterns can be stacked, and for this to work they are applied in order.
50 >
51 > E.g. /usr/foo -/usr/foo/bar /usr/foo/bar/baz
52 >
53 > Should remove all foo subdirectories except for bar, and also baz inside bar.
54
55 Hmm, I suppose there could be an optimized implementation to handle
56 INSTALL_MASK settings where there are no such ordering constraints.
57 --
58 Thanks,
59 Zac

Replies