diff --git a/branches/ucs-4.0/ucs-4.0-4/base/univention-updater/modules/univention/updater/mirror.py b/branches/ucs-4.0/ucs-4.0-4/base/univention-updater/modules/univention/updater/mirror.py index 2d0da13..2c6c2a2 100644 --- a/branches/ucs-4.0/ucs-4.0-4/base/univention-updater/modules/univention/updater/mirror.py +++ b/branches/ucs-4.0/ucs-4.0-4/base/univention-updater/modules/univention/updater/mirror.py @@ -39,6 +39,7 @@ import itertools import logging from operator import itemgetter from debian.deb822 import Packages +from apt import apt_pkg from tools import UniventionUpdater, UCS_Version, NullHandler try: @@ -274,11 +275,26 @@ class UniventionMirror( UniventionUpdater ): def _compress(self, filename): self.log.debug('Compressing %s ...', filename) - subprocess.call( + sorter = subprocess.Popen( + ('apt-sortpkgs', filename), + stdout=subprocess.PIPE, + ) + compressor = subprocess.Popen( ('gzip',), - stdin=open(filename, 'rb'), + stdin=subprocess.PIPE, stdout=open(filename + '.gz', 'wb'), ) + prev = None + for pkg in Packages.iter_paragraphs(sorter.stdout): + if prev: + if prev["Package"] != pkg["Package"]: + compressor.stdin.write("%s\n" % prev) + elif apt_pkg.version_compare(prev["Version"], pkg["Version"]) >= 0: + continue + prev = pkg + if prev: + compressor.stdin.write("%s\n" % prev) + compressor.stdin.close() def _release(self, outdir, dist, archs, version): rel_name = os.path.join(outdir, 'dists', dist, 'Release') diff --git a/branches/ucs-4.1/ucs-4.1-1/base/univention-updater/modules/univention/updater/mirror.py b/branches/ucs-4.1/ucs-4.1-1/base/univention-updater/modules/univention/updater/mirror.py index 9abf547..bdf5988 100644 --- a/branches/ucs-4.1/ucs-4.1-1/base/univention-updater/modules/univention/updater/mirror.py +++ b/branches/ucs-4.1/ucs-4.1-1/base/univention-updater/modules/univention/updater/mirror.py @@ -39,6 +39,7 @@ import itertools import logging from operator import itemgetter from debian.deb822 import Packages +from apt import apt_pkg from tools import UniventionUpdater, NullHandler from ucs_version import UCS_Version @@ -275,11 +276,26 @@ class UniventionMirror(UniventionUpdater): def _compress(self, filename): self.log.debug('Compressing %s ...', filename) - subprocess.call( + sorter = subprocess.Popen( + ('apt-sortpkgs', filename), + stdout=subprocess.PIPE, + ) + compressor = subprocess.Popen( ('gzip',), - stdin=open(filename, 'rb'), + stdin=subprocess.PIPE, stdout=open(filename + '.gz', 'wb'), ) + prev = None + for pkg in Packages.iter_paragraphs(sorter.stdout): + if prev: + if prev["Package"] != pkg["Package"]: + compressor.stdin.write("%s\n" % prev) + elif apt_pkg.version_compare(prev["Version"], pkg["Version"]) >= 0: + continue + prev = pkg + if prev: + compressor.stdin.write("%s\n" % prev) + compressor.stdin.close() def _release(self, outdir, dist, archs, version): rel_name = os.path.join(outdir, 'dists', dist, 'Release')