From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SW78x-0008Iu-SH for garchives@archives.gentoo.org; Sun, 20 May 2012 14:30:00 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 36C67E04C2; Sun, 20 May 2012 14:29:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E473EE04C2 for ; Sun, 20 May 2012 14:29:51 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 062FD1B4011 for ; Sun, 20 May 2012 14:29:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id F3306E542A for ; Sun, 20 May 2012 14:29:48 +0000 (UTC) From: "Magnus Granberg" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Magnus Granberg" Message-ID: <1337524040.e09e651579629aa5e2e15367fb47af9d7c9f9d8f.zorry@gentoo> Subject: [gentoo-commits] dev/zorry:master commit in: gobs/pym/ X-VCS-Repository: dev/zorry X-VCS-Files: gobs/pym/build_queru.py gobs/pym/depgraph.py X-VCS-Directories: gobs/pym/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: e09e651579629aa5e2e15367fb47af9d7c9f9d8f X-VCS-Branch: master Date: Sun, 20 May 2012 14:29:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 4222fc25-a474-4419-89d3-11f55d54964a X-Archives-Hash: 8b809b07b0bd6d34f4d7b72bf4dbc22c commit: e09e651579629aa5e2e15367fb47af9d7c9f9d8f Author: Magnus Granberg gentoo org> AuthorDate: Sun May 20 14:27:20 2012 +0000 Commit: Magnus Granberg gentoo org> CommitDate: Sun May 20 14:27:20 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Ddev/zorry.git;a=3D= commit;h=3De09e6515 add check_required_use2() --- gobs/pym/build_queru.py | 2 - gobs/pym/depgraph.py | 191 +++++++++++++++++++++++++++++++++++++++++= +++++- 2 files changed, 187 insertions(+), 6 deletions(-) diff --git a/gobs/pym/build_queru.py b/gobs/pym/build_queru.py index 004afbb..8b33440 100644 --- a/gobs/pym/build_queru.py +++ b/gobs/pym/build_queru.py @@ -153,8 +153,6 @@ class queruaction(object): build_dict['check_fail'] =3D True use_changes =3D None if not success: - for pargs, kwargs in mydepgraph._dynamic_config._unsatisfied_deps_for= _display: - mydepgraph._show_unsatisfied_dep(mydepgraph, *pargs, **kwargs) mydepgraph.display_problems() settings, trees, mtimedb =3D load_emerge_config() myparams =3D create_depgraph_params(myopts, myaction) diff --git a/gobs/pym/depgraph.py b/gobs/pym/depgraph.py index 75d4db2..332fb9f 100644 --- a/gobs/pym/depgraph.py +++ b/gobs/pym/depgraph.py @@ -20,7 +20,8 @@ from portage import _unicode_decode, _unicode_encode, _= encodings from portage.const import PORTAGE_PACKAGE_ATOM, USER_CONFIG_PATH from portage.dbapi import dbapi from portage.dep import Atom, best_match_to_list, extract_affecting_use,= \ - check_required_use, human_readable_required_use, _repo_separator + check_required_use, human_readable_required_use, _repo_separator, \ + _RequiredUseBranch, _RequiredUseLeaf from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use from portage.exception import InvalidAtom, InvalidDependString, PortageE= xception from portage.output import colorize, create_color_func, \ @@ -1099,7 +1100,7 @@ class depgraph(object): # package selection, since we want to prompt the user # for USE adjustment rather than have REQUIRED_USE # affect package selection and || dep choices. - if not pkg.built and pkg.metadata.get("REQUIRED_USE") and \ + """if not pkg.built and pkg.metadata.get("REQUIRED_USE") and \ eapi_has_required_use(pkg.metadata["EAPI"]): required_use_is_sat =3D check_required_use( pkg.metadata["REQUIRED_USE"], @@ -1120,7 +1121,7 @@ class depgraph(object): self._dynamic_config._unsatisfied_deps_for_display.append( ((pkg.root, atom), {"myparent":dep.parent})) self._dynamic_config._skip_restart =3D True - return 0 + return 0""" =20 if not pkg.onlydeps: =20 @@ -3775,6 +3776,179 @@ class depgraph(object): self._dynamic_config._need_restart =3D True return new_use =20 + def check_required_use2(required_use, use, iuse_match): + """ + Checks if the use flags listed in 'use' satisfy all + constraints specified in 'constraints'. + + @param required_use: REQUIRED_USE string + @type required_use: String + @param use: Enabled use flags + @param use: List + @param iuse_match: Callable that takes a single flag argument and retu= rns + True if the flag is matched, false otherwise, + @param iuse_match: Callable + @rtype: Bool + @return: Indicates if REQUIRED_USE constraints are satisfied + """ + + def is_active(token): + if token.startswith("!"): + flag =3D token[1:] + is_negated =3D True + else: + flag =3D token + is_negated =3D False + + if not flag or not iuse_match(flag): + msg =3D _("USE flag '%s' is not in IUSE") \ + % (flag,) + e =3D InvalidData(msg, category=3D'IUSE.missing') + raise InvalidDependString(msg, errors=3D(e,)) + + return (flag in use and not is_negated) or \ + (flag not in use and is_negated) +=09 + def is_satisfied(operator, argument): + if not argument: + #|| ( ) -> True + return True + + if operator =3D=3D "||": + return (True in argument) + elif operator =3D=3D "^^": + return (argument.count(True) =3D=3D 1) + elif operator[-1] =3D=3D "?": + return (False not in argument) + + mysplit =3D required_use.split() + level =3D 0 + stack =3D [[]] + tree =3D _RequiredUseBranch() + node =3D tree + need_bracket =3D False + + for token in mysplit: + if token =3D=3D "(": + if not need_bracket: + child =3D _RequiredUseBranch(parent=3Dnode) + node._children.append(child) + node =3D child + + need_bracket =3D False + stack.append([]) + level +=3D 1 + elif token =3D=3D ")": + if need_bracket: + raise InvalidDependString( + _("malformed syntax: '%s'") % required_use) + if level > 0: + level -=3D 1 + l =3D stack.pop() + op =3D None + if stack[level]: + if stack[level][-1] in ("||", "^^"): + op =3D stack[level].pop() + satisfied =3D is_satisfied(op, l) + stack[level].append(satisfied) + node._satisfied =3D satisfied + + elif not isinstance(stack[level][-1], bool) and \ + stack[level][-1][-1] =3D=3D "?": + op =3D stack[level].pop() + if is_active(op[:-1]): + satisfied =3D is_satisfied(op, l) + stack[level].append(satisfied) + node._satisfied =3D satisfied + else: + node._satisfied =3D True + last_node =3D node._parent._children.pop() + if last_node is not node: + raise AssertionError( + "node is not last child of parent") + node =3D node._parent + continue + + if op is None: + satisfied =3D False not in l + node._satisfied =3D satisfied + if l: + stack[level].append(satisfied) + + if len(node._children) <=3D 1 or \ + node._parent._operator not in ("||", "^^"): + last_node =3D node._parent._children.pop() + if last_node is not node: + raise AssertionError( + "node is not last child of parent") + for child in node._children: + node._parent._children.append(child) + if isinstance(child, _RequiredUseBranch): + child._parent =3D node._parent + + elif not node._children: + last_node =3D node._parent._children.pop() + if last_node is not node: + raise AssertionError( + "node is not last child of parent") + + elif len(node._children) =3D=3D 1 and op in ("||", "^^"): + last_node =3D node._parent._children.pop() + if last_node is not node: + raise AssertionError( + "node is not last child of parent") + node._parent._children.append(node._children[0]) + if isinstance(node._children[0], _RequiredUseBranch): + node._children[0]._parent =3D node._parent + node =3D node._children[0] + if node._operator is None and \ + node._parent._operator not in ("||", "^^"): + last_node =3D node._parent._children.pop() + if last_node is not node: + raise AssertionError( + "node is not last child of parent") + for child in node._children: + node._parent._children.append(child) + if isinstance(child, _RequiredUseBranch): + child._parent =3D node._parent + + node =3D node._parent + else: + raise InvalidDependString( + _("malformed syntax: '%s'") % required_use) + elif token in ("||", "^^"): + if need_bracket: + raise InvalidDependString( + _("malformed syntax: '%s'") % required_use) + need_bracket =3D True + stack[level].append(token) + child =3D _RequiredUseBranch(operator=3Dtoken, parent=3Dnode) + node._children.append(child) + node =3D child + else: + if need_bracket or "(" in token or ")" in token or \ + "|" in token or "^" in token: + raise InvalidDependString( + _("malformed syntax: '%s'") % required_use) + + if token[-1] =3D=3D "?": + need_bracket =3D True + stack[level].append(token) + child =3D _RequiredUseBranch(operator=3Dtoken, parent=3Dnode) + node._children.append(child) + node =3D child + else: + satisfied =3D is_active(token) + stack[level].append(satisfied) + node._children.append(_RequiredUseLeaf(token, satisfied)) + + if level !=3D 0 or need_bracket: + raise InvalidDependString( + _("malformed syntax: '%s'") % required_use) + + tree._satisfied =3D False not in stack[0] + return tree + def _wrapped_select_pkg_highest_available_imp(self, root, atom, onlydep= s=3DFalse, autounmask_level=3DNone): root_config =3D self._frozen_config.roots[root] pkgsettings =3D self._frozen_config.pkgsettings[root] @@ -3975,8 +4149,17 @@ class depgraph(object): # since IUSE cannot be adjusted by the user. continue =20 + if pkg.metadata.get("REQUIRED_USE") and eapi_has_required_use(pkg.m= etadata["EAPI"]): + required_use_is_sat =3D check_required_use(pkg.metadata["REQUIRED_= USE"], + self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag) + if not required_use_is_sat: + if autounmask_level and autounmask_level.allow_use_changes and no= t pkg.built: + # pers the required_use to get the needed use flags + required_use =3D foo() + else: + =09 + =09 if atom.use: - matched_pkgs_ignore_use.append(pkg) if autounmask_level and autounmask_level.allow_use_changes and not= pkg.built: target_use =3D {}