Gentoo Archives: gentoo-portage-dev

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

Replies