summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-08-09 13:34:44 -0700
committerZac Medico <zmedico@gentoo.org>2012-08-09 13:34:44 -0700
commit55a7b859d40e6130217cea63a9027730f6780239 (patch)
tree39c0809f97425d933cd659ec841d420f8844752a /pym
parentf7ec7a4db6543e1fd3a13c341a37ccb667956978 (diff)
downloadportage-55a7b859d40e6130217cea63a9027730f6780239.tar.gz
portage-55a7b859d40e6130217cea63a9027730f6780239.tar.bz2
portage-55a7b859d40e6130217cea63a9027730f6780239.zip
emaint binhost: support compress-index
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/bintree.py46
-rw-r--r--pym/portage/emaint/modules/binhost/binhost.py8
2 files changed, 27 insertions, 27 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 8dd7aadd4..6c01867b6 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -813,9 +813,7 @@ class binarytree(object):
del pkgindex.packages[:]
pkgindex.packages.extend(iter(metadata.values()))
self._update_pkgindex_header(pkgindex.header)
- f = atomic_ofstream(self._pkgindex_file)
- pkgindex.write(f)
- f.close()
+ self._pkgindex_write(pkgindex)
if getbinpkgs and not self.settings["PORTAGE_BINHOST"]:
writemsg(_("!!! PORTAGE_BINHOST unset, but use is requested.\n"),
@@ -1187,28 +1185,34 @@ class binarytree(object):
pkgindex.packages.append(d)
self._update_pkgindex_header(pkgindex.header)
- contents = codecs.getwriter(_encodings['repo.content'])(io.BytesIO())
- pkgindex.write(contents)
- contents = contents.getvalue()
- atime = mtime = long(pkgindex.header["TIMESTAMP"])
-
- pkgindex_filename = os.path.join(self.pkgdir, "Packages")
- output_files = [(atomic_ofstream(pkgindex_filename, mode="wb"), pkgindex_filename, None)]
- if "compress-index" in self.settings.features:
- gz_fname = pkgindex_filename + ".gz"
- fileobj = atomic_ofstream(gz_fname, mode="wb")
- output_files.append((GzipFile(filename='', mode="wb", fileobj=fileobj, mtime=mtime), gz_fname, fileobj))
- for f, fname, f_close in output_files:
- f.write(contents)
- f.close()
- if f_close is not None:
- f_close.close()
- # some seconds might have elapsed since TIMESTAMP
- os.utime(fname, (atime, mtime))
+ self._pkgindex_write(pkgindex)
+
finally:
if pkgindex_lock:
unlockfile(pkgindex_lock)
+ def _pkgindex_write(self, pkgindex):
+ contents = codecs.getwriter(_encodings['repo.content'])(io.BytesIO())
+ pkgindex.write(contents)
+ contents = contents.getvalue()
+ atime = mtime = long(pkgindex.header["TIMESTAMP"])
+ output_files = [(atomic_ofstream(self._pkgindex_file, mode="wb"),
+ self._pkgindex_file, None)]
+
+ if "compress-index" in self.settings.features:
+ gz_fname = self._pkgindex_file + ".gz"
+ fileobj = atomic_ofstream(gz_fname, mode="wb")
+ output_files.append((GzipFile(filename='', mode="wb",
+ fileobj=fileobj, mtime=mtime), gz_fname, fileobj))
+
+ for f, fname, f_close in output_files:
+ f.write(contents)
+ f.close()
+ if f_close is not None:
+ f_close.close()
+ # some seconds might have elapsed since TIMESTAMP
+ os.utime(fname, (atime, mtime))
+
def _pkgindex_entry(self, cpv):
"""
Performs checksums and evaluates USE flag conditionals.
diff --git a/pym/portage/emaint/modules/binhost/binhost.py b/pym/portage/emaint/modules/binhost/binhost.py
index b540d7686..c297545cc 100644
--- a/pym/portage/emaint/modules/binhost/binhost.py
+++ b/pym/portage/emaint/modules/binhost/binhost.py
@@ -151,12 +151,8 @@ class BinhostHandler(object):
del pkgindex.packages[:]
pkgindex.packages.extend(metadata.values())
- from portage.util import atomic_ofstream
- f = atomic_ofstream(self._pkgindex_file)
- try:
- self._pkgindex.write(f)
- finally:
- f.close()
+ bintree._pkgindex_write(self._pkgindex)
+
finally:
locks.unlockfile(pkgindex_lock)