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 v3] Support USE_EXPAND prefixes in package.use and relevant files
Date: Sat, 24 Jan 2015 09:39:45
Message-Id: 1422092377-8701-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 X-Gentoo-Bug: 471776
10 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=471776
11 ---
12 man/portage.5 | 6 ++++++
13 pym/portage/package/ebuild/_config/UseManager.py | 24 +++++++++++++++++++++---
14 2 files changed, 27 insertions(+), 3 deletions(-)
15
16 diff --git a/man/portage.5 b/man/portage.5
17 index 189561c..5ac3100 100644
18 --- a/man/portage.5
19 +++ b/man/portage.5
20 @@ -792,6 +792,10 @@ documentation for QT. Easy as pie my friend!
21 .nf
22 \- comments begin with # (no inline comments)
23 \- one DEPEND atom per line with space-delimited USE flags
24 +\- USE flags can be prefixed with USE_EXPAND name followed by a colon (:)
25 +and a space. In this case, all the names following it are treated
26 +as values for the USE_EXPAND. Note that if you need to remove earlier
27 +assignments or defaults, you need to explicitly specify '\-*'.
28 .fi
29
30 .I Example:
31 @@ -800,6 +804,8 @@ documentation for QT. Easy as pie my friend!
32 =x11\-libs/gtk+\-2* doc
33 # disable mysql support for QT
34 x11\-libs/qt \-mysql
35 +# set preferred video card for all packages
36 +*/* VIDEO_CARDS: \-* radeon
37 .fi
38 .TP
39 .BR repos.conf
40 diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py
41 index 3a4ec22..60d5f92 100644
42 --- a/pym/portage/package/ebuild/_config/UseManager.py
43 +++ b/pym/portage/package/ebuild/_config/UseManager.py
44 @@ -202,11 +202,18 @@ class UseManager(object):
45 useflag_re = _get_useflag_re(eapi)
46 for k, v in file_dict.items():
47 useflags = []
48 + use_expand_prefix = ''
49 for prefixed_useflag in v:
50 + if extended_syntax and prefixed_useflag[-1] == ":":
51 + use_expand_prefix = prefixed_useflag[:-1].lower() + "_"
52 + continue
53 +
54 if prefixed_useflag[:1] == "-":
55 - useflag = prefixed_useflag[1:]
56 + useflag = use_expand_prefix + prefixed_useflag[1:]
57 + prefixed_useflag = "-" + useflag
58 else:
59 - useflag = prefixed_useflag
60 + useflag = use_expand_prefix + prefixed_useflag
61 + prefixed_useflag = useflag
62 if useflag_re.match(useflag) is None:
63 writemsg(_("--- Invalid USE flag for '%s' in '%s': '%s'\n") %
64 (k, file_name, prefixed_useflag), noiselevel=-1)
65 @@ -227,7 +234,18 @@ class UseManager(object):
66 pusedict = grabdict_package(
67 os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
68 for k, v in pusedict.items():
69 - ret.setdefault(k.cp, {})[k] = tuple(v)
70 + l = []
71 + use_expand_prefix = ''
72 + for flag in v:
73 + if flag[-1] == ":":
74 + use_expand_prefix = flag[:-1].lower() + "_"
75 + continue
76 + if flag[0] == "-":
77 + nv = "-" + use_expand_prefix + flag[1:]
78 + else:
79 + nv = use_expand_prefix + flag
80 + l.append(nv)
81 + ret.setdefault(k.cp, {})[k] = tuple(l)
82
83 return ret
84
85 --
86 2.2.2

Replies