summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/const.py2
-rw-r--r--pym/portage/dbapi/bintree.py21
2 files changed, 16 insertions, 7 deletions
diff --git a/pym/portage/const.py b/pym/portage/const.py
index ceef5c56b..c2049f871 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -89,7 +89,7 @@ SUPPORTED_FEATURES = frozenset([
"assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy",
"ccache", "chflags", "clean-logs",
"collision-protect", "compress-build-logs", "compressdebug",
- "config-protect-if-modified",
+ "compress-index", "config-protect-if-modified",
"digest", "distcc", "distcc-pump", "distlocks",
"downgrade-backup", "ebuild-locks", "fakeroot",
"fail-clean", "force-mirror", "force-prefix", "getbinpkg",
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 03675031e..77fc0c4ef 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -41,6 +41,7 @@ import sys
import tempfile
import textwrap
import warnings
+from gzip import GzipFile
from itertools import chain
try:
from urllib.parse import urlparse
@@ -1186,13 +1187,21 @@ class binarytree(object):
pkgindex.packages.append(d)
self._update_pkgindex_header(pkgindex.header)
- pkgindex_filename = os.path.join(self.pkgdir, "Packages")
- f = atomic_ofstream(pkgindex_filename)
- pkgindex.write(f)
- f.close()
- # some seconds might have elapsed since TIMESTAMP
+ contents = codecs.getwriter(_encodings['repo.content'])(io.BytesIO())
+ pkgindex.write(contents)
+ contents = contents.getvalue()
atime = mtime = long(pkgindex.header["TIMESTAMP"])
- os.utime(pkgindex_filename, (atime, mtime))
+
+ pkgindex_filename = os.path.join(self.pkgdir, "Packages")
+ output_files = [(atomic_ofstream(pkgindex_filename, mode="wb"), pkgindex_filename)]
+ if "compress-index" in self.settings.features:
+ gz_fname = pkgindex_filename + ".gz"
+ output_files.append((GzipFile(gz_fname, mode="wb"), gz_fname))
+ for f, fname in output_files:
+ f.write(contents)
+ f.close()
+ # some seconds might have elapsed since TIMESTAMP
+ os.utime(fname, (atime, mtime))
finally:
if pkgindex_lock:
unlockfile(pkgindex_lock)