--suffix)
[[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
- set -e
- tmpdir="${T}"/.ecompress$$.${RANDOM}
- mkdir "${tmpdir}"
- cd "${tmpdir}"
- # we have to fill the file enough so that there is something
- # to compress as some programs will refuse to do compression
- # if it cannot actually compress the file
- echo {0..1000} > compressme
- ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
- suffix=$(ls compressme*)
- suffix=${suffix#compressme}
- cd /
- rm -rf "${tmpdir}"
- echo "${suffix}"
+ if [[ ! -e ${T}/.ecompress.suffix ]] ; then
+ set -e
+ tmpdir="${T}"/.ecompress$$.${RANDOM}
+ mkdir "${tmpdir}"
+ cd "${tmpdir}"
+ # we have to fill the file enough so that there is something
+ # to compress as some programs will refuse to do compression
+ # if it cannot actually compress the file
+ echo {0..1000} > compressme
+ ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
+ suffix=$(ls compressme*)
+ suffix=${suffix#compressme}
+ cd /
+ rm -rf "${tmpdir}"
+ echo "${suffix}" > "${T}/.ecompress.suffix"
+ fi
+ cat "${T}/.ecompress.suffix"
;;
--bin)
[[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2
import errno, signal, sys, os
def quickpkg_main(options, args, eout):
- from portage import dblink, dep_expand, catsplit, isvalidatom, xpak
+ from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
+ from portage.dep import use_reduce, paren_reduce
from portage.util import ensure_dirs
- from portage.exception import InvalidData
- from portage.dbapi.vartree import tar_contents
+ from portage.exception import InvalidData, InvalidDependString
+ from portage.dbapi.vartree import dblink, tar_contents
import tarfile
import portage
root = portage.settings["ROOT"]
if not dblnk.exists():
# unmerged by a concurrent process
continue
- iuse, use = vardb.aux_get(cpv, ["IUSE","USE"])
+ iuse, use, restrict = vardb.aux_get(cpv,
+ ["IUSE","USE","RESTRICT"])
iuse = [ x.lstrip("+-") for x in iuse.split() ]
use = use.split()
+ try:
+ restrict = flatten(use_reduce(
+ paren_reduce(restrict), uselist=use))
+ except InvalidDependString, e:
+ eout.eerror("Invalid RESTRICT metadata " + \
+ "for '%s': %s; skipping" % (cpv, str(e)))
+ del e
+ continue
if "bindist" in iuse and "bindist" not in use:
eout.ewarn("%s: package was emerged with USE=-bindist!" % cpv)
eout.ewarn("%s: it may not be legal to redistribute this." % cpv)
+ elif "bindist" in restrict:
+ eout.ewarn("%s: package has RESTRICT=bindist!" % cpv)
+ eout.ewarn("%s: it may not be legal to redistribute this." % cpv)
eout.ebegin("Building package for %s" % cpv)
pkgs_for_arg += 1
contents = dblnk.getcontents()
del x[mykey]
def __getitem__(self,mykey):
- match = ''
- for x in self.lookuplist:
- if x is None:
- writemsg("!!! lookuplist is null.\n")
- elif x.has_key(mykey):
- match = x[mykey]
- break
- return match
+ for d in self.lookuplist:
+ if mykey in d:
+ return d[mykey]
+ return '' # for backward compat, don't raise KeyError
+
+ def get(self, k, x=None):
+ for d in self.lookuplist:
+ if k in d:
+ return d[k]
+ return x
def has_key(self,mykey):
return mykey in self
return False
def setdefault(self, k, x=None):
- if k in self:
- return self[k]
+ v = self.get(k)
+ if v is not None:
+ return v
else:
self[k] = x
return x
- def get(self, k, x=None):
- if k in self:
- return self[k]
- else:
- return x
-
def keys(self):
return list(self)
def __iter__(self):
keys = set()
for d in self.lookuplist:
- for k in d:
- if k in keys:
- continue
- keys.add(k)
- yield k
+ keys.update(d)
+ return iter(keys)
+
+ def iterkeys(self):
+ return iter(self)
def __setitem__(self,mykey,myvalue):
"set a value; will be thrown away at reset() time"
def _delitem(self, cpv):
del self.__db[cpv]
- def iterkeys(self):
+ def __iter__(self):
return iter(self.__db)
def __contains__(self, cpv):
return os.path.exists(os.path.join(self.location, cpv))
- def iterkeys(self):
+ def __iter__(self):
"""generator for walking the dir struct"""
dirs = [self.location]
len_base = len(self.location)
return os.path.exists(os.path.join(self._base, cpv))
- def iterkeys(self):
+ def __iter__(self):
"""generator for walking the dir struct"""
dirs = [self._base]
len_base = len(self._base)
return False
return True
- def iterkeys(self):
+ def __iter__(self):
s = set()
- for cpv in self.db_rw.iterkeys():
- if self.has_key(cpv): # validates whiteout when necessary
+ for cpv in self.db_rw:
+ if cpv in self: # validates whiteout when necessary
yield cpv
# set includes whiteouts so they won't be yielded later
s.add(cpv)
- for cpv in self.db_ro.iterkeys():
+ for cpv in self.db_ro:
if cpv not in s:
yield cpv
return self.con.rowcount > 0
- def iterkeys(self):
+ def __iter__(self):
if not self.autocommits:
try: self.commit()
except self._BaseError, e:
else:
raise cache_errors.CacheCorruption(cpv, "key is not unique")
- def iterkeys(self):
+ def __iter__(self):
"""generator for walking the dir struct"""
cursor = self._db_cursor
cursor.execute("SELECT %s FROM %s" % \
return tuple(self.iterkeys())
def iterkeys(self):
- raise NotImplementedError
+ return iter(self)
def iteritems(self):
for x in self.iterkeys():
raise NotImplementedError
return self.has_key(cpv)
+ def __iter__(self):
+ """This method should always be overridden. It is provided only for
+ backward compatibility with modules that override iterkeys instead. It
+ will automatically raise a NotImplementedError if iterkeys has not been
+ overridden."""
+ if self.iterkeys is database.iterkeys:
+ # prevent a possible recursive loop
+ raise NotImplementedError(self)
+ return self.iterkeys()
+
+ def get(self, k, x=None):
+ try:
+ return self[k]
+ except KeyError:
+ return x
+
def get_matches(self, match_dict):
"""generic function for walking the entire cache db, matching restrictions to
filter what cpv's are returned. Derived classes should override this if they
else:
noise=verbose_instance
- dead_nodes = set(trg_cache.iterkeys())
+ dead_nodes = set(trg_cache)
count=0
if not trg_cache.autocommits:
config.pop("gid", None)
super(database, self).__init__(*args, **config)
self._data = {}
- self.iterkeys = self._data.iterkeys
+ self.__iter__ = self._data.__iter__
self._delitem = self._data.__delitem__
self.__contains__ = self._data.__contains__