#pager=""
# For emacs-users
-# diff_command="eval emacs -nw --eval=\(ediff\ \"%file1\"\ \"%file2\"\)"
+# diff_command="eval emacs -nw --eval=\'\(ediff\ \"%file1\"\ \"%file2\"\)\'"
#using_editor=1
# vim-users: you CAN use vimdiff for diff_command. (see NOTE_1)
This variable contains the command used for fetching package sources from
the internet. It must contain the full path to the executable as well as the
place\-holders \\${DISTDIR} and \\${URI}.
+Also see \fBRESUMECOMMAND\fR.
.TP
\fBGENTOO_MIRRORS\fR = \fI[URLs]\fR
Insert your space\-seperated list of local mirrors here. These
else:
#this doesn't match the package we're unmerging; keep it.
newworldlist.append(x)
-
+
+ newworldlist.sort()
+
portage.util.ensure_dirs(os.path.join(vardb.root, portage.PRIVATE_PATH),
gid=portage.portage_gid, mode=02770)
- portage.util.write_atomic(world_filename, "\n".join(newworldlist))
+ portage.util.write_atomic(world_filename, "\n".join(newworldlist)+"\n")
def genericdict(mylist):
mynewdict={}
# files to fetch list - avoids counting a same file twice
# in size display (verbose mode)
myfetchlist=[]
+ worldlist = getlist(self.settings, "world")
+
for mylist_index in xrange(len(mylist)):
x, depth, ordered = mylist[mylist_index]
pkg_type = x[0]
myoldbest=myoldbest[:-3]
myoldbest=blue("["+myoldbest+"]")
+ if xs[0] in worldlist:
+ pkgprint = bold
+ else:
+ def pkgprint(pkg):
+ return pkg
+
if x[1]!="/":
if myoldbest:
myoldbest +=" "
if "--columns" in self.myopts:
if "--quiet" in self.myopts:
- myprint=addl+" "+indent+darkgreen(xs[0])
+ myprint=addl+" "+indent+darkgreen(pkgprint(xs[0]))
myprint=myprint+darkblue(" "+xs[1]+xs[2])+" "
myprint=myprint+myoldbest
myprint=myprint+darkgreen("to "+x[1])
else:
- myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(xs[0])
+ myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(pkgprint(xs[0]))
if (newlp-nc_len(myprint)) > 0:
myprint=myprint+(" "*(newlp-nc_len(myprint)))
myprint=myprint+"["+darkblue(xs[1]+xs[2])+"] "
myprint = darkblue("[nomerge ] ")
else:
myprint = "[" + pkg_type + " " + addl + "] "
- myprint += indent + darkgreen(pkg_key) + " " + \
+ myprint += indent + darkgreen(pkrprint(pkg_key)) + " " + \
myoldbest + darkgreen("to " + myroot) + " " + \
verboseadd
else:
if "--columns" in self.myopts:
if "--quiet" in self.myopts:
- myprint=addl+" "+indent+darkgreen(xs[0])
+ myprint=addl+" "+indent+darkgreen(pkgprint(xs[0]))
myprint=myprint+" "+green(xs[1]+xs[2])+" "
myprint=myprint+myoldbest
else:
- myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(xs[0])
+ myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(pkgprint(xs[0]))
if (newlp-nc_len(myprint)) > 0:
myprint=myprint+(" "*(newlp-nc_len(myprint)))
myprint=myprint+green(" ["+xs[1]+xs[2]+"] ")
myprint=myprint+myoldbest+" "+verboseadd
else:
if x[-1] == "nomerge" or not ordered:
- myprint=darkblue("[nomerge ] "+indent+x[2]+" "+myoldbest+" ")+verboseadd
+ myprint=darkblue("[nomerge ] "+indent+pkgprint(x[2])+" "+myoldbest+" ")+verboseadd
else:
- myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(x[2])+" "+myoldbest+" "+verboseadd
+ myprint="["+x[0]+" "+addl+"] "+indent+darkgreen(pkgprint(x[2]))+" "+myoldbest+" "+verboseadd
p.append(myprint)
mysplit = portage.pkgsplit(x[2])
") Updating world file ("+x[pkgindex]+")")
portage.write_atomic(
os.path.join(myroot, portage.WORLD_FILE),
- "\n".join(myfavdict.values()))
+ "\n".join(sorted(myfavdict.values()))+"\n")
if "--pretend" not in self.myopts and \
"--fetchonly" not in self.myopts and \
# check if root user is the current user for the actions where emerge needs this
if portage.secpass < 2:
# We've already allowed "--version" and "--help" above.
- if "--pretend" not in myopts and \
- myaction not in ("search","info"):
+ if "--pretend" not in myopts and myaction not in ("search","info"):
need_superuser = not \
("--fetchonly" in myopts or \
"--fetch-all-uri" in myopts or \
- myaction in ("metadata", "regen"))
+ myaction in ("metadata", "regen") or \
+ (myaction == "sync" and os.access(settings["PORTDIR"], os.W_OK)))
if portage.secpass < 1 or \
need_superuser:
if need_superuser:
def check_config_instance(test):
if not isinstance(test, config):
- # raise TypeError("Invalid type for config object: %s" % test.__class__)
- print "WARNING: Invalid type for config object: %s" % test.__class__
- print "WARNING: no instance of: %s" % config.__class__
+ # raise TypeError("Invalid type for config object: %s (should be %s)" % (test.__class__, config))
+ print "WARNING: Invalid type for config object: %s (should be %s)" % (test.__class__, config)
class config(object):
"""
# Distributed under the terms of the GNU General Public License v2
# $Id: portage_checksum.py 3835 2006-07-11 00:59:10Z zmedico $
-if not hasattr(__builtins__, "set"):
- from sets import Set as set
-
from portage.const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
import os
import errno
import portage.util
import portage.locks
import commands
-import sha
-
-
-# actual hash functions first
+import md5, sha
#dict of all available hash functions
hashfunc_map = {}
+hashorigin_map = {}
-# We _try_ to load this module. If it fails we do the slightly slower fallback.
-try:
- import fchksum
+def _generate_hash_function(hashtype, hashobject, origin="unknown"):
+ def pyhash(filename):
+ """
+ Run a checksum against a file.
- def md5hash(filename):
- return fchksum.fmd5t(filename)
+ @param filename: File to run the checksum against
+ @type filename: String
+ @return: The hash and size of the data
+ """
+ f = open(filename, 'rb')
+ blocksize = HASHING_BLOCKSIZE
+ data = f.read(blocksize)
+ size = 0L
+ sum = hashobject()
+ while data:
+ sum.update(data)
+ size = size + len(data)
+ data = f.read(blocksize)
+ f.close()
-except ImportError:
- import md5
- def md5hash(filename):
- return pyhash(filename, md5)
-hashfunc_map["MD5"] = md5hash
+ return (sum.hexdigest(), size)
+ hashfunc_map[hashtype] = pyhash
+ hashorigin_map[hashtype] = origin
+ return pyhash
+
+# Define hash functions, try to use the best module available. Later definitions
+# override earlier ones
+
+# Use the internal modules as last fallback
+md5hash = _generate_hash_function("MD5", md5.new, origin="internal")
+sha1hash = _generate_hash_function("SHA1", sha.new, origin="internal")
-def sha1hash(filename):
- return pyhash(filename, sha)
-hashfunc_map["SHA1"] = sha1hash
+# Use pycrypto when available, prefer it over the internal fallbacks
+try:
+ from Crypto.Hash import MD5, SHA, SHA256, RIPEMD
-# Keep pycrypto optional for now, there are no internal fallbacks for these
+ md5hash = _generate_hash_function("MD5", MD5.new, origin="pycrypto")
+ sha1hash = _generate_hash_function("SHA1", SHA.new, origin="pycrypto")
+ sha256hash = _generate_hash_function("SHA256", SHA256.new, origin="pycrypto")
+ rmd160hash = _generate_hash_function("RMD160", RIPEMD.new, origin="pycrypto")
+except ImportError, e:
+ pass
+
+# Use hashlib from python-2.5 if available and prefer it over pycrypto and internal fallbacks.
+# Need special handling for RMD160 as it may not always be provided by hashlib.
try:
- import Crypto.Hash.SHA256
+ import hashlib
- def sha256hash(filename):
- return pyhash(filename, Crypto.Hash.SHA256)
- hashfunc_map["SHA256"] = sha256hash
-except ImportError:
+ md5hash = _generate_hash_function("MD5", hashlib.md5, origin="hashlib")
+ sha1hash = _generate_hash_function("SHA1", hashlib.sha1, origin="hashlib")
+ sha256hash = _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib")
+ try:
+ hashlib.new('ripemd160')
+ except ValueError:
+ pass
+ else:
+ def rmd160():
+ return hashlib.new('ripemd160')
+ rmd160hash = _generate_hash_function("RMD160", rmd160, origin="hashlib")
+except ImportError, e:
pass
+
+# Use python-fchksum if available, prefer it over all other MD5 implementations
try:
- import Crypto.Hash.RIPEMD
+ import fchksum
- def rmd160hash(filename):
- return pyhash(filename, Crypto.Hash.RIPEMD)
- hashfunc_map["RMD160"] = rmd160hash
+ def md5hash(filename):
+ return fchksum.fmd5t(filename)
+ hashfunc_map["MD5"] = md5hash
+ hashorigin_map["MD5"] = "python-fchksum"
+
except ImportError:
pass
+# There is only one implementation for size
def getsize(filename):
size = os.stat(filename).st_size
return (size, size)
def get_valid_checksum_keys():
return hashfunc_map.keys()
+def get_hash_origin(hashtype):
+ if not hashtype in hashfunc_map.keys():
+ raise KeyError(hashtype)
+ return hashorigin_map.get(hashtype, "unknown")
+
def verify_all(filename, mydict, calc_prelink=0, strict=0):
"""
Verify all checksums against a file.
break
return file_is_ok,reason
-def pyhash(filename, hashobject):
- """
- Run a checksum against a file.
-
- @param filename: File to run the checksum against
- @type filename: String
- @param hashname: The hash object that will execute the checksum on the file
- @type hashname: Object
- @return: The hash and size of the data
- """
- f = open(filename, 'rb')
- blocksize = HASHING_BLOCKSIZE
- data = f.read(blocksize)
- size = 0L
- sum = hashobject.new()
- while data:
- sum.update(data)
- size = size + len(data)
- data = f.read(blocksize)
- f.close()
-
- return (sum.hexdigest(), size)
-
def perform_checksum(filename, hashname="MD5", calc_prelink=0):
"""
Run a specific checksum against a file.
rVal = {}
for x in hashes:
if x not in hashfunc_map:
- raise portage.exception.DigestException, x+" hash function not available (needs dev-python/pycrypto)"
+ raise portage.exception.DigestException, x+" hash function not available (needs dev-python/pycrypto or >=dev-lang/python-2.5)"
rVal[x] = perform_checksum(filename, x, calc_prelink)[0]
return rVal
accept_keywords = self.mysettings["ACCEPT_KEYWORDS"].split()
pkgdict = self.mysettings.pkeywordsdict
aux_keys = ["KEYWORDS", "LICENSE", "EAPI", "SLOT"]
+
+ # Hack: Need to check the env directly here as otherwise stacking
+ # doesn't work properly as negative values are lost in the config
+ # object (bug #139600)
+ egroups = os.environ.get("ACCEPT_KEYWORDS", "").split()
+
for mycpv in mylist:
try:
keys, licenses, eapi, slot = self.aux_get(mycpv, aux_keys)
matches = match_to_list(cpv_slot, pkgdict[cp].keys())
for atom in matches:
pgroups.extend(pkgdict[cp][atom])
+ pgroups.extend(egroups)
if matches:
# normalize pgroups with incrementals logic so it
# matches ACCEPT_KEYWORDS behavior
if is_owned:
# A new instance of this package claims the file, so
# don't unmerge it.
- writemsg_stdout("--- !owned %s %s\n" % \
+ writemsg_stdout("--- replaced %s %s\n" % \
(file_type, obj))
continue
# next line includes a tweak to protect modules from being unmerged,
"""(baseurl,conn) --- Takes a protocol://site:port/address url, and an
optional connection. If connection is already active, it is passed on.
baseurl is reduced to address and is returned in tuple (conn,address)"""
+
parts = baseurl.split("://",1)
if len(parts) != 2:
raise ValueError, "Provided URL does not contain protocol identifier. '%s'" % baseurl
protocol,url_parts = parts
del parts
- host,address = url_parts.split("/",1)
+
+ url_parts = url_parts.split("/")
+ host = url_parts[0]
+ if len(url_parts) < 2:
+ address = "/"
+ else:
+ address = "/"+"/".join(url_parts[1:])
del url_parts
- address = "/"+address
userpass_host = host.split("@",1)
if len(userpass_host) == 1:
sys.stdout.write("p")
sys.stdout.flush()
- write_atomic(os.path.join(config_root, WORLD_FILE), "\n".join(worldlist))
+ worldlist.sort()
+ write_atomic(os.path.join(config_root, WORLD_FILE), "\n".join(worldlist)+"\n")
protect_obj = ConfigProtect(
config_root, protect, protect_mask)