From f3c2ef9dd6ecf5d2e9f801ffcb414730e2028556 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Tue, 24 Oct 2006 20:00:06 +0000 Subject: [PATCH] Merged from trunk 4796:4810 Add some ACCEPT_LICENSE docs. Put the package.keywords docs in alphabetical order with the others. Add some package.license docs. Add news about ACCEPT_LICENSE and package.license. Make config.load_infodir also load the data into the env layer in order to ensure that it has preference over what may have been there. Don't limit the size of USE in config.load_infodir. Add package.license to the list of files. Don't put -* in the env layer, since that layer isn't part of the incremental stacking in regenerate. In getmaskingstatus(), add missing check for * in acceptable_licenses. Don't display the "Please update portage" message in --quiet mode. Thanks to solar. Remove paths from _eclasses_ serialization in the cache. This makes the mtimes of the eclasses the only thing that distinguishes them, but the probablility of collision is negligible. This same _eclasses_ format will be used to serialize eclass mtimes in cache that is distributed via the rsync mirrors. The deserialization code can handle mixtures of both the old and new formats. Enable recognition of _mtime_ that doesn't rely on cache mtime mangling. Add ACCEPT_LICENSE back to incrementals so that profiles can affect it. Disable ACCEPT_LICENSE support until the details of license groups are decided and implemented. svn path=/main/branches/prefix/; revision=4812 --- NEWS | 2 ++ bin/emerge | 2 +- man/make.conf.5 | 6 ++++ man/portage.5 | 74 +++++++++++++++++++++++++++--------------- pym/cache/flat_hash.py | 5 ++- pym/cache/template.py | 19 ++++++++--- pym/eclass_cache.py | 12 ++++--- pym/portage.py | 28 +++++++++++----- pym/portage_const.py | 3 +- 9 files changed, 104 insertions(+), 47 deletions(-) diff --git a/NEWS b/NEWS index fa295cd7e..a5ecef4ae 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ News (mainly features/major bug fixes) portage-2.1.2 ------------ +* ACCEPT_LICENSE and package.license allow packages with unaccepted licenses to + be masked. * Ebuilds support default USE flags via +flag in IUSE. * New-style virtuals are now usable for packages that depend on themselves for bootstrap. diff --git a/bin/emerge b/bin/emerge index aed9c1be6..e0a05f32b 100755 --- a/bin/emerge +++ b/bin/emerge @@ -2098,7 +2098,7 @@ class depgraph: else: myversion = "%s-%s" % (mysplit[1], mysplit[2]) - if myversion != portage.VERSION : + if myversion != portage.VERSION and "--quiet" not in self.myopts: if "--emptytree" in self.myopts: p.append(colorize("WARN", "***")+" Please update portage to the above version before proceeding.") p.append(" Failure to do so may result in failed or improper merges.") diff --git a/man/make.conf.5 b/man/make.conf.5 index eb04a8533..dc382fd64 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -29,6 +29,12 @@ set this to '~ppc'. This is an incremental variable. Only define a .br Defaults to the value of $ARCH. .TP +\fBACCEPT_LICENSE\fR = \fI[space delimited list of licenses]\fR +Specify acceptable licenses for installed packages. Any packages with +unaccepted licenses will be masked. The default value is "*", which means to +accept all licenses. Licenses can be accepted for individual packages via the +package.license file. See \fBportage\fR(5) for more information. +.TP \fBBUILD_PREFIX\fR = \fI[path]\fR Defines the location of the package working directory. .br diff --git a/man/portage.5 b/man/portage.5 index 156bbdd0b..74ae5335d 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -42,9 +42,10 @@ virtuals .nf bashrc modules +package.keywords +package.license package.mask package.unmask -package.keywords package.use mirrors categories @@ -374,34 +375,9 @@ portage will not be able to detect that cache regeneration is necessary. If the user would like to modify eclasses, it is safe to use metadata_overlay together with PORTDIR_OVERLAY in \fBmake.conf\fR. .TP -.BR package.mask -A list of package atoms to mask. Useful if specific versions of packages do -not work well for you. For example, you swear by the Nvidia drivers, but only -versions earlier than 1.0.4496. No problem! - -.I Format: -.nf -\- comments begin with # -\- one DEPEND atom per line -.fi - -.I Example: -.nf -# mask out versions 1.0.4496 of the nvidia -# drivers and later ->=media\-video/nvidia\-kernel\-1.0.4496 ->=media\-video/nvidia\-glx\-1.0.4496 -.fi -.TP -.BR package.unmask -Just like package.mask above, except here you list packages you want to -unmask. Useful for overriding the global package.mask file (see -below). Note that this does not override packages that are masked via -KEYWORDS. -.TP .BR package.keywords Per\-package KEYWORDS. Useful for mixing unstable packages in with a normally -stable machine or vice versa. This will allow you to augment ACCEPT_KEYWORDS +stable system or vice versa. This will allow ACCEPT_KEYWORDS to be augmented for a single package. .nf @@ -435,6 +411,50 @@ package.keywords like this: games-fps/quake3-demo -* .TP +.BR package.license +Per\-package acceptance of licenses. This is useful if a license needs to be +accepted for a single package but should not be accepted for any package. See +\fIACCEPT_LICENSE\fR in \fBmake.conf\fR(5) for global license acceptance. + +.I Format: +.nf +\- comments begin with # +\- one DEPEND atom per line followed by additional licenses +.fi + +.I Example: +.nf +# accept the zlib license just for the zlib package +sys-libs/zlib ZLIB +# accept any license for mplayer +media\-video/mplayer * +.fi +.TP +.BR package.mask +A list of package atoms to mask. Useful if specific versions of packages do +not work well for you. For example, you swear by the Nvidia drivers, but only +versions earlier than 1.0.4496. No problem! + +.I Format: +.nf +\- comments begin with # +\- one DEPEND atom per line +.fi + +.I Example: +.nf +# mask out versions 1.0.4496 of the nvidia +# drivers and later +>=media\-video/nvidia\-kernel\-1.0.4496 +>=media\-video/nvidia\-glx\-1.0.4496 +.fi +.TP +.BR package.unmask +Just like package.mask above, except here you list packages you want to +unmask. Useful for overriding the global package.mask file (see +below). Note that this does not override packages that are masked via +KEYWORDS. +.TP .BR package.use Per\-package USE flags. Useful for tracking local USE flags or for enabling USE flags for certain packages only. Perhaps you develop GTK diff --git a/pym/cache/flat_hash.py b/pym/cache/flat_hash.py index 408d33273..26861e494 100644 --- a/pym/cache/flat_hash.py +++ b/pym/cache/flat_hash.py @@ -26,7 +26,10 @@ class database(fs_template.FsBased): myf = open(fp, "r") try: d = self._parse_data(myf, cpv) - d["_mtime_"] = long(os.fstat(myf.fileno()).st_mtime) + if "_mtime_" not in d: + """Backward compatibility with old cache that uses mtime + mangling.""" + d["_mtime_"] = long(os.fstat(myf.fileno()).st_mtime) return d finally: myf.close() diff --git a/pym/cache/template.py b/pym/cache/template.py index c33e92b59..0e2a5f368 100644 --- a/pym/cache/template.py +++ b/pym/cache/template.py @@ -151,7 +151,8 @@ class database(object): def serialize_eclasses(eclass_dict): """takes a dict, returns a string representing said dict""" - return "\t".join(["%s\t%s\t%s" % (k, v[0], str(v[1])) for k,v in eclass_dict.items()]) + return "\t".join(["%s\t%s" % (k, str(v)) \ + for k, v in eclass_dict.iteritems()]) def reconstruct_eclasses(cpv, eclass_string): """returns a dict when handed a string generated by serialize_eclasses""" @@ -159,10 +160,20 @@ def reconstruct_eclasses(cpv, eclass_string): if eclasses == [""]: # occasionally this occurs in the fs backends. they suck. return {} - if len(eclasses) % 3 != 0: + + if len(eclasses) % 2 != 0 and len(eclasses) % 3 != 0: raise cache_errors.CacheCorruption(cpv, "_eclasses_ was of invalid len %i" % len(eclasses)) d={} - for x in range(0, len(eclasses), 3): - d[eclasses[x]] = (eclasses[x + 1], long(eclasses[x + 2])) + has_paths = False + try: + long(eclasses[1]) + except ValueError: + has_paths = True + if has_paths: + for x in range(0, len(eclasses), 3): + d[eclasses[x]] = long(eclasses[x + 2]) + else: + for x in range(0, len(eclasses), 2): + d[eclasses[x]] = long(eclasses[x + 1]) del eclasses return d diff --git a/pym/eclass_cache.py b/pym/eclass_cache.py index 8d2a2bb81..904e63261 100644 --- a/pym/eclass_cache.py +++ b/pym/eclass_cache.py @@ -15,6 +15,7 @@ class cache: self.porttree_root = porttree_root self.eclasses = {} # {"Name": ("location","_mtime_")} + self._eclass_locations = {} # screw with the porttree ordering, w/out having bash inherit match it, and I'll hurt you. # ~harring @@ -38,6 +39,7 @@ class cache: def update_eclasses(self): self.eclasses = {} + self._eclass_locations = {} eclass_len = len(".eclass") for x in [normalize_path(os.path.join(y,"eclass")) for y in self.porttrees]: if not os.path.isdir(x): @@ -48,13 +50,14 @@ class cache: except OSError: continue ys=y[:-eclass_len] - self.eclasses[ys] = (x, long(mtime)) + self.eclasses[ys] = long(mtime) + self._eclass_locations[ys] = x def is_eclass_data_valid(self, ec_dict): if not isinstance(ec_dict, dict): return False - for eclass, tup in ec_dict.iteritems(): - if eclass not in self.eclasses or tuple(tup) != self.eclasses[eclass]: + for eclass, mtime in ec_dict.iteritems(): + if eclass not in self.eclasses or mtime != self.eclasses[eclass]: return False return True @@ -68,7 +71,8 @@ class cache: print "ec=",ec_dict print "inherits=",inherits raise - if from_master_only and self.eclasses[x][0] != self._master_eclass_root: + if from_master_only and \ + self._eclass_locations[x] != self._master_eclass_root: return None return ec_dict diff --git a/pym/portage.py b/pym/portage.py index 84edad8f2..605ff5d00 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1240,12 +1240,15 @@ class config: self.pkeywordsdict[cp][key] = pkgdict[key] #package.license + """ + # Wait until license groups are ready before enabling this. 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( @@ -1339,8 +1342,11 @@ class config: self.regenerate() self.features = portage_util.unique_array(self["FEATURES"].split()) + - self._accept_license = set(self.get("ACCEPT_LICENSE", "*").split()) + # Wait until license groups are ready before enabling this. + #self._accept_license = set(self.get("ACCEPT_LICENSE", "*").split()) + self._accept_license = set(["*"]) if "gpg" in self.features: if not os.path.exists(self["PORTAGE_GPG_DIR"]) or \ @@ -1497,11 +1503,14 @@ class config: if myre.match(filename): try: mydata = string.strip(open(infodir+"/"+filename).read()) - if len(mydata)<2048: + if len(mydata) < 2048 or filename == "USE": if filename == "USE": - self.configdict["pkg"][filename] = "-* "+mydata + binpkg_flags = "-* " + mydata + self.configdict["pkg"][filename] = binpkg_flags + self.configdict["env"][filename] = mydata else: self.configdict["pkg"][filename] = mydata + self.configdict["env"][filename] = mydata # CATEGORY is important because it's used in doebuild # to infer the cpv. If it's corrupted, it leads to # strange errors later on, so we'll validate it and @@ -3955,12 +3964,13 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): settings.setcpv(mycpv, mydb=portdb) acceptable_licenses = settings.acceptable_licenses(mycpv) - def str_matches(myatom): - return myatom in acceptable_licenses - license_req = dep_check(mylicense, None, settings, - str_matches=str_matches)[1] - if license_req: - rValue.append(" ".join(license_req) + " license(s)") + if "*" not in acceptable_licenses: + def str_matches(myatom): + return myatom in acceptable_licenses + license_req = dep_check(mylicense, None, settings, + str_matches=str_matches)[1] + if license_req: + rValue.append(" ".join(license_req) + " license(s)") return rValue diff --git a/pym/portage_const.py b/pym/portage_const.py index 11259e4e2..46b6e1cae 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -48,7 +48,8 @@ CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map" INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES", - "ACCEPT_KEYWORDS", "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", "PRELINK_PATH", + "ACCEPT_KEYWORDS", "ACCEPT_LICENSE", + "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", "PRELINK_PATH", "PRELINK_PATH_MASK"] EBUILD_PHASES = ["setup", "unpack", "compile", "test", "install", "preinst", "postinst", "prerm", "postrm", "other"] -- 2.26.2