From: Zac Medico Date: Sun, 22 Oct 2006 07:26:48 +0000 (-0000) Subject: Add support for masking of packages via ACCEPT_LICENSE and /etc/portage/package.licen... X-Git-Tag: v2.1.2~572 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6d7fefc073c6182ff3734ee8ec0a2e528e1cc6ef;p=portage.git Add support for masking of packages via ACCEPT_LICENSE and /etc/portage/package.license. Thanks to Jason Stubbs for the initial patch from bug #17367. svn path=/main/trunk/; revision=4792 --- diff --git a/bin/repoman b/bin/repoman index 7b0a0fe67..ba4e62415 100755 --- a/bin/repoman +++ b/bin/repoman @@ -474,6 +474,7 @@ if quiet < 2: print "PORTDIR_OVERLAY = \""+os.environ["PORTDIR_OVERLAY"]+"\"" # Now that PORTDIR_OVERLAY is properly overridden, create the portdb. +os.environ["ACCEPT_LICENSE"] = "*" repoman_settings = portage.config(local_config=False, config_incrementals=portage_const.INCREMENTALS) trees = portage.create_trees() diff --git a/pym/portage.py b/pym/portage.py index ff295e418..1b936e2c6 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -916,6 +916,9 @@ class config: self.dirVirtuals = copy.deepcopy(clone.dirVirtuals) self.treeVirtuals = copy.deepcopy(clone.treeVirtuals) self.features = copy.deepcopy(clone.features) + + self._accept_license = copy.deepcopy(clone._accept_license) + self._plicensedict = copy.deepcopy(clone._plicensedict) else: # backupenv is for calculated incremental variables. @@ -1181,6 +1184,7 @@ class config: self.pusedict = {} self.pkeywordsdict = {} + self._plicensedict = {} self.punmaskdict = {} abs_user_config = os.path.join(config_root, USER_CONFIG_PATH.lstrip(os.path.sep)) @@ -1233,6 +1237,14 @@ class config: if not self.pkeywordsdict.has_key(cp): self.pkeywordsdict[cp] = {} self.pkeywordsdict[cp][key] = pkgdict[key] + + #package.license + licdict = grabdict_package( + os.path.join(abs_user_config, "package.license"), + recursive=1) + for k, v in licdict.iteritems(): + self._plicensedict.setdefault( + dep_getkey(k), {})[k] = v #package.unmask pkgunmasklines = grabfile_package( @@ -1326,6 +1338,8 @@ class config: self.regenerate() self.features = portage_util.unique_array(self["FEATURES"].split()) + + self._accept_license = set(self.get("ACCEPT_LICENSE", "*").split()) if "gpg" in self.features: if not os.path.exists(self["PORTAGE_GPG_DIR"]) or \ @@ -1569,6 +1583,16 @@ class config: if has_changed: self.reset(keeping_pkg=1,use_cache=use_cache) + def acceptable_licenses(self, cpv): + cpdict = self._plicensedict.get(dep_getkey(cpv), None) + if not cpdict: + return self._accept_license.copy() + plicenses = self._accept_license.copy() + matches = match_to_list(cpv, cpdict.keys()) + for atom in matches: + plicenses.update(cpdict[atom]) + return plicenses + def setinst(self,mycpv,mydbapi): self.modifying() if len(self.virtuals) == 0: @@ -3449,9 +3473,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None, return_all_deps=False): """Takes an unreduced and reduced deplist and removes satisfied dependencies. Returned deplist contains steps that must be taken to satisfy dependencies.""" - if trees is None: - global db - trees = db + writemsg("ZapDeps -- %s\n" % (use_binaries), 2) if not reduced or unreduced == ["||"] or \ (not return_all_deps and dep_eval(reduced)): @@ -3472,6 +3494,17 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None, deps = unreduced[1:] satisfieds = reduced[1:] + if trees is None: + # We don't have trees to check availability against, so we + # just default to the first choice. + if isinstance(deps[0], list): + atoms = dep_zapdeps(deps[0], satisfieds[0], myroot, + use_binaries=use_binaries, trees=trees, + return_all_deps=return_all_deps) + else: + atoms = [deps[0]] + return atoms + # Our preference order is for an the first item that: # a) contains all unmasked packages with the same key as installed packages # b) contains all unmasked packages @@ -3576,7 +3609,8 @@ def dep_expand(mydep, mydb=None, use_cache=1, settings=None): mydep, mydb=mydb, use_cache=use_cache, settings=settings) + postfix def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, - use_cache=1, use_binaries=0, myroot="/", trees=None, return_all_deps=False): + use_cache=1, use_binaries=0, myroot="/", trees=None, str_matches=None, + return_all_deps=False): """Takes a depend string and parses the condition.""" #check_config_instance(mysettings) @@ -3633,7 +3667,8 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, #dependencies were reduced to nothing return [1,[]] mysplit2=mysplit[:] - mysplit2=dep_wordreduce(mysplit2,mysettings,mydbapi,mode,use_cache=use_cache) + mysplit2 = dep_wordreduce(mysplit2, mysettings, mydbapi, mode, + str_matches=str_matches, use_cache=use_cache) if mysplit2 is None: return [0,"Invalid token"] @@ -3654,19 +3689,24 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, writemsg("mydict: %s\n" % (mydict), 1) return [1,mydict.keys()] -def dep_wordreduce(mydeplist,mysettings,mydbapi,mode,use_cache=1): +def dep_wordreduce(mydeplist, mysettings, mydbapi, mode, str_matches=None, + use_cache=1): "Reduces the deplist to ones and zeros" mypos=0 deplist=mydeplist[:] while mypos