From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 00E37138A1A for ; Sat, 24 Jan 2015 09:32:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8A859E0999; Sat, 24 Jan 2015 09:32:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3077CE099B for ; Sat, 24 Jan 2015 09:32:04 +0000 (UTC) Received: from pomiot.lan (87-205-67-137.adsl.inetia.pl [87.205.67.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id B63033406C2; Sat, 24 Jan 2015 09:32:02 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH v2] Support USE_EXPAND prefixes in package.use and relevant files Date: Sat, 24 Jan 2015 10:31:57 +0100 Message-Id: <1422091917-5384-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.2.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: f52d09de-36e2-47f8-96e0-958ac6212961 X-Archives-Hash: bb95e806f247b68bf7b1c9ac37e5061c Support prefixing groups of USE_EXPAND flags with 'USE_EXPAND:' in user configuration package.use and similar files. This provides a convenient way of declaring specifying multiple USE_EXPAND flags and matches the syntax supported by Paludis. Example: dev-util/netbeans NETBEANS_MODULES: php webcommon extide media-libs/mesa osmesa VIDEO_CARDS: intel nouveau X-Gentoo-Bug: 471776 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=471776 --- man/portage.5 | 6 ++++++ pym/portage/package/ebuild/_config/UseManager.py | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/man/portage.5 b/man/portage.5 index 189561c..5ac3100 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -792,6 +792,10 @@ documentation for QT. Easy as pie my friend! .nf \- comments begin with # (no inline comments) \- one DEPEND atom per line with space-delimited USE flags +\- USE flags can be prefixed with USE_EXPAND name followed by a colon (:) +and a space. In this case, all the names following it are treated +as values for the USE_EXPAND. Note that if you need to remove earlier +assignments or defaults, you need to explicitly specify '\-*'. .fi .I Example: @@ -800,6 +804,8 @@ documentation for QT. Easy as pie my friend! =x11\-libs/gtk+\-2* doc # disable mysql support for QT x11\-libs/qt \-mysql +# set preferred video card for all packages +*/* VIDEO_CARDS: \-* radeon .fi .TP .BR repos.conf diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py index 3a4ec22..7e235ef 100644 --- a/pym/portage/package/ebuild/_config/UseManager.py +++ b/pym/portage/package/ebuild/_config/UseManager.py @@ -145,7 +145,7 @@ class UseManager(object): useflag = prefixed_useflag[1:] else: useflag = prefixed_useflag - if useflag_re.match(useflag) is None: + if useflag_re.match(prefixed_useflag) is None: writemsg(_("--- Invalid USE flag in '%s': '%s'\n") % (file_name, prefixed_useflag), noiselevel=-1) else: @@ -202,12 +202,19 @@ class UseManager(object): useflag_re = _get_useflag_re(eapi) for k, v in file_dict.items(): useflags = [] + use_expand_prefix = '' for prefixed_useflag in v: + if extended_syntax and prefixed_useflag[-1] == ":": + use_expand_prefix = prefixed_useflag[:-1].lower() + "_" + continue + if prefixed_useflag[:1] == "-": useflag = prefixed_useflag[1:] + prefixed_useflag = "-" + use_expand_prefix + useflag else: + prefixed_useflag = use_expand_prefix + prefixed_useflag useflag = prefixed_useflag - if useflag_re.match(useflag) is None: + if useflag_re.match(prefixed_useflag) is None: writemsg(_("--- Invalid USE flag for '%s' in '%s': '%s'\n") % (k, file_name, prefixed_useflag), noiselevel=-1) else: @@ -227,7 +234,18 @@ class UseManager(object): pusedict = grabdict_package( os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False) for k, v in pusedict.items(): - ret.setdefault(k.cp, {})[k] = tuple(v) + l = [] + use_expand_prefix = '' + for flag in v: + if flag[-1] == ":": + use_expand_prefix = flag[:-1].lower() + "_" + continue + if flag[0] == "-": + nv = "-" + use_expand_prefix + flag[1:] + else: + nv = use_expand_prefix + flag + l.append(nv) + ret.setdefault(k.cp, {})[k] = tuple(l) return ret -- 2.2.2