Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] Support USE_EXPAND prefixes in package.use and relevant files
Date: Tue, 20 Jan 2015 11:19:00
Message-Id: 1421752723-2045-1-git-send-email-mgorny@gentoo.org
1 Support prefixing groups of USE_EXPAND flags with 'USE_EXPAND:' in user
2 configuration package.use and similar files. This provides a convenient
3 way of declaring specifying multiple USE_EXPAND flags and matches the
4 syntax supported by Paludis. Example:
5
6 dev-util/netbeans NETBEANS_MODULES: php webcommon extide
7 media-libs/mesa osmesa VIDEO_CARDS: intel nouveau
8 ---
9 pym/portage/package/ebuild/_config/UseManager.py | 20 +++++++++++++++++++-
10 1 file changed, 19 insertions(+), 1 deletion(-)
11
12 diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py
13 index 3a4ec22..59f474e 100644
14 --- a/pym/portage/package/ebuild/_config/UseManager.py
15 +++ b/pym/portage/package/ebuild/_config/UseManager.py
16 @@ -202,10 +202,17 @@ class UseManager(object):
17 useflag_re = _get_useflag_re(eapi)
18 for k, v in file_dict.items():
19 useflags = []
20 + use_expand_prefix = ''
21 for prefixed_useflag in v:
22 + if extended_syntax and prefixed_useflag[-1] == ":":
23 + use_expand_prefix = prefixed_useflag[:-1].lower() + "_"
24 + continue
25 +
26 if prefixed_useflag[:1] == "-":
27 useflag = prefixed_useflag[1:]
28 + prefixed_useflag = "-" + use_expand_prefix + useflag
29 else:
30 + prefixed_useflag = use_expand_prefix + prefixed_useflag
31 useflag = prefixed_useflag
32 if useflag_re.match(useflag) is None:
33 writemsg(_("--- Invalid USE flag for '%s' in '%s': '%s'\n") %
34 @@ -227,7 +234,18 @@ class UseManager(object):
35 pusedict = grabdict_package(
36 os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
37 for k, v in pusedict.items():
38 - ret.setdefault(k.cp, {})[k] = tuple(v)
39 + l = []
40 + use_expand_prefix = ''
41 + for flag in v:
42 + if flag[-1] == ":":
43 + use_expand_prefix = flag[:-1].lower() + "_"
44 + continue
45 + if flag[0] == "-":
46 + nv = "-" + use_expand_prefix + flag[1:]
47 + else:
48 + nv = use_expand_prefix + flag
49 + l.append(nv)
50 + ret.setdefault(k.cp, {})[k] = tuple(l)
51
52 return ret
53
54 --
55 2.2.1

Replies