From 9874b61867c2d631d21bf42f1181e21fa0f8bbf3 Mon Sep 17 00:00:00 2001 From: solar Date: Fri, 13 Apr 2007 23:40:24 +0000 Subject: [PATCH] - add bzip2 compression option svn path=/; revision=387 --- trunk/src/genpkgindex/genpkgindex | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/trunk/src/genpkgindex/genpkgindex b/trunk/src/genpkgindex/genpkgindex index 2259fb9..6c0ca77 100644 --- a/trunk/src/genpkgindex/genpkgindex +++ b/trunk/src/genpkgindex/genpkgindex @@ -6,6 +6,7 @@ import os import stat import sys import time + if getattr(__builtins__, "set", None) is None: from sets import Set as set @@ -29,19 +30,28 @@ except ImportError: argc=len(sys.argv) +compress = bool(os.environ.get("COMPRESSPKGFILE", '')) if argc >= 2: if (sys.argv[1][0] == "-"): - print "Usage:\tgenpkgindex " - print "\t- default dir "+portage.settings["PKGDIR"]+"/All" - sys.exit(1) + if (sys.argv[1] != "--compress"): + print "Usage:\tgenpkgindex [--compress] " + print "\t- default dir "+portage.settings["PKGDIR"]+"/All" + sys.exit(1) + else: + compress=1 + if argc >= 3: + sys.argv[1] = sys.argv[2] + argc = argc - 1; +if argc >= 2: All=sys.argv[1] else: All=portage.settings["PKGDIR"]+"/All" All=os.path.normpath(All) + if os.path.exists("/usr/bin/eclean") and "cleanpkgdir" in portage.settings["FEATURES"]: os.system("/usr/bin/eclean -d packages") @@ -219,7 +229,11 @@ for pkg, tbz2, chksum, st in packages: fp.write("\n") fp.flush() fp.close() -os.rename(".Packages", "Packages") +if (compress): + os.system("bzip2 .Packages") + os.rename(".Packages.bz2", "Packages.bz2") +else: + os.rename(".Packages", "Packages") # Clean up stale cache files os.chdir(portage_const.CACHE_PATH+"/xpak") -- 2.26.2