From 3b49de4f24b1dca52bd7f56beee57a45adc5511c Mon Sep 17 00:00:00 2001 From: solar Date: Sun, 23 Jul 2006 23:35:48 +0000 Subject: [PATCH] - update code to not write to the Packages file directly untill we have finished successfully. Make sure we always write a timestamp and the number of pkgs in the binrepo. Run eclean-pkg if cleanpkgdir is set in FEATURES= svn path=/; revision=305 --- trunk/src/genpkgindex/genpkgindex | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/trunk/src/genpkgindex/genpkgindex b/trunk/src/genpkgindex/genpkgindex index 43f13ac..faf6486 100644 --- a/trunk/src/genpkgindex/genpkgindex +++ b/trunk/src/genpkgindex/genpkgindex @@ -3,6 +3,10 @@ # Distributed under the terms of the GNU General Public License v2 import os, string, stat, sys, time + +for x in ['CFLAGS','LDFLAGS','USE']: + os.environ[x]='' + import xpak, portage, portage_checksum, portage_dep, portage_util argc=len(sys.argv) @@ -17,13 +21,18 @@ if argc >= 2: 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") + os.chdir(All) -portage.writemsg(portage.green(' * ')+'update binary package index %s\n' % All); +portage.writemsg(portage.green(' * ')+'Update binary package index %s\n' % All); start = time.time() # generic name of our package index. -control_file = "Packages" +control_file = ".Packages" try: import re @@ -56,12 +65,14 @@ for pkg in os.listdir('.'): packages.sort() +timestamp=str(start).split(".")[0] # trunc the file and begin write operations. fp = open(control_file, "w") if argc <= 1: fp.write("PROFILE: "+profilever+"\n") fp.write("PACKAGES: "+str(len(packages)) +"\n") + fp.write("TIMESTAMP: "+timestamp+"\n") vmask = [ "AUTOCLEAN", "DISTDIR", "PKGDIR", "PORTDIR" , "PORTAGE_TMPDIR" ] vars = portage_util.grabfile(portage.settings["PORTDIR"]+"/profiles/info_vars") @@ -74,7 +85,11 @@ if argc <= 1: if portage.settings.has_key(x): if (len(portage.settings[x])): fp.write(x+": "+portage.settings[x]+"\n") - fp.write("\n") +else: + fp.write("PACKAGES: "+str(len(packages)) +"\n") + fp.write("TIMESTAMP: "+timestamp+"\n") + +fp.write("\n") for cat, pkg, tbz2, stuff in packages: use = xpak.getitem(stuff, "USE") @@ -123,6 +138,7 @@ for cat, pkg, tbz2, stuff in packages: fp.write("\n") fp.flush() fp.close() +os.rename(".Packages", "Packages") finish = time.time() -- 2.26.2