- add bzip2 compression option
authorsolar <solar@gentoo.org>
Fri, 13 Apr 2007 23:40:24 +0000 (23:40 -0000)
committersolar <solar@gentoo.org>
Fri, 13 Apr 2007 23:40:24 +0000 (23:40 -0000)
svn path=/; revision=387

trunk/src/genpkgindex/genpkgindex

index 2259fb9474ea58247a31f01a21b641c5ad39fd56..6c0ca77df14aae83ad2800ad7aaa31d9e6772f98 100644 (file)
@@ -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 <pkgdir>"
-               print "\t- default dir "+portage.settings["PKGDIR"]+"/All"
-               sys.exit(1)
+               if (sys.argv[1] != "--compress"):
+                       print "Usage:\tgenpkgindex [--compress] <pkgdir>"
+                       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")