self._pkgindex_header_keys = set(["ACCEPT_KEYWORDS", "CBUILD",
"CHOST", "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "FEATURES",
"GENTOO_MIRRORS", "INSTALL_MASK", "SYNC", "USE"])
+ self._pkgindex_default_pkg_data = {
+ "EAPI" : "0",
+ "IUSE" : "",
+ "PROVIDE" : "",
+ "SLOT" : "0",
+ "USE" : ""
+ }
def move_ent(self, mylist):
if not self.populated:
dirs.remove("All")
dirs.sort()
dirs.insert(0, "All")
- pkgindex = portage.getbinpkg.PackageIndex()
+ pkgindex = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
pf_index = None
try:
f = open(self._pkgindex_file)
f.close()
del f
if not self._pkgindex_version_supported(pkgindex):
- pkgindex = portage.getbinpkg.PackageIndex()
+ pkgindex = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
header = pkgindex.header
metadata = pkgindex.packages
update_pkgindex = False
urldata = urlparse(base_url)
pkgindex_file = os.path.join(CACHE_PATH, "binhost",
urldata[1] + urldata[2], "Packages")
- pkgindex = portage.getbinpkg.PackageIndex()
+ pkgindex = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
try:
f = open(pkgindex_file)
try:
raise
local_timestamp = pkgindex.header.get("TIMESTAMP", None)
import urllib, urlparse
- rmt_idx = portage.getbinpkg.PackageIndex()
+ rmt_idx = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
try:
f = urllib.urlopen(urlparse.urljoin(base_url, "Packages"))
try:
if self._all_directory and \
self.getname(cpv).split(os.path.sep)[-2] == "All":
self._create_symlink(cpv)
- pkgindex = portage.getbinpkg.PackageIndex()
+ pkgindex = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
try:
f = open(self._pkgindex_file)
except EnvironmentError:
f.close()
del f
if not self._pkgindex_version_supported(pkgindex):
- pkgindex = portage.getbinpkg.PackageIndex()
+ pkgindex = portage.getbinpkg.PackageIndex(
+ default_pkg_data=self._pkgindex_default_pkg_data)
d = digests
d["CPV"] = cpv
d["SLOT"] = slot
class PackageIndex(object):
- def __init__(self):
+ def __init__(self, default_pkg_data=None):
+ self._default_pkg_data = default_pkg_data
self.header = {}
self.packages = {}
self.modified = True
mycpv = d.get("CPV")
if not mycpv:
continue
- d.setdefault("EAPI", "0")
- d.setdefault("IUSE", "")
- d.setdefault("PROVIDE", "")
- d.setdefault("SLOT", "0")
- d.setdefault("USE", "")
+ if self._default_pkg_data:
+ for k, v in self._default_pkg_data.iteritems():
+ d.setdefault(k, v)
if header_chost:
d.setdefault("CHOST", header_chost)
self.packages[mycpv] = d
metadata = self.packages[cpv].copy()
if metadata.get("CHOST") == header_chost:
del metadata["CHOST"]
- if metadata.get("EAPI") == "0":
- del metadata["EAPI"]
- if metadata.get("SLOT") == "0":
- del metadata["SLOT"]
+ if self._default_pkg_data:
+ for k, v in self._default_pkg_data.iteritems():
+ if metadata.get(k) == v:
+ metadata.pop(k, None)
keys = metadata.keys()
keys.sort()
writepkgindex(pkgfile,