diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-06-10 05:04:17 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-06-10 05:04:17 -0700 |
commit | e445fcfd94100fcf83ad39454bfcdcb801a56721 (patch) | |
tree | b2ff28b6cb047a7311a818b14dbcf92c99a8f7ab | |
parent | e47b87636a060358a83430701135e25c2350aa4f (diff) | |
download | portage-e445fcfd94100fcf83ad39454bfcdcb801a56721.tar.gz portage-e445fcfd94100fcf83ad39454bfcdcb801a56721.tar.bz2 portage-e445fcfd94100fcf83ad39454bfcdcb801a56721.zip |
bintree: always populate pkgindex REPO header
The previous code would only populate it when there was no existing
index file. Now, the default will be populated even if the file exists
already. If an existing pkgindex header already defines these keys,
then they will appropriately override our defaults.
-rw-r--r-- | pym/portage/dbapi/bintree.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index ffa296c29..756ea6711 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -270,9 +270,23 @@ class binarytree(object): "REQUIRED_USE" : "" } self._pkgindex_inherited_keys = ["CHOST", "repository"] + + # Populate the header with appropriate defaults. self._pkgindex_default_header_data = { - "repository":"" + "VERSION" : str(self._pkgindex_version), + "repository" : "", } + + # It is especially important to populate keys like + # "repository" that save space when entries can + # inherit them from the header. If an existing + # pkgindex header already defines these keys, then + # they will appropriately override our defaults. + main_repo = self.settings.repositories.mainRepo() + if main_repo is not None: + self._pkgindex_default_header_data["repository"] = \ + main_repo.name + self._pkgindex_translated_keys = ( ("DESCRIPTION" , "DESC"), ("repository" , "REPO"), @@ -284,7 +298,6 @@ class binarytree(object): self._pkgindex_hashes, self._pkgindex_default_pkg_data, self._pkgindex_inherited_keys, - self._pkgindex_default_header_data, chain(*self._pkgindex_translated_keys) )) @@ -1280,14 +1293,7 @@ class binarytree(object): mode='r', encoding=_encodings['repo.content'], errors='replace') except EnvironmentError: - # We're creating a new file, so populate the header - # with appropriate defaults. This is especially - # important for keys like REPO that save space when - # entries can inherit them from the header. - pkgindex.header["VERSION"] = str(self._pkgindex_version) - main_repo = self.settings.repositories.mainRepo() - if main_repo is not None: - pkgindex.header["REPO"] = main_repo.name + pass else: try: pkgindex.read(f) |