- update code to not write to the Packages file directly untill we have finished...
authorsolar <solar@gentoo.org>
Sun, 23 Jul 2006 23:35:48 +0000 (23:35 -0000)
committersolar <solar@gentoo.org>
Sun, 23 Jul 2006 23:35:48 +0000 (23:35 -0000)
svn path=/; revision=305

trunk/src/genpkgindex/genpkgindex

index 43f13ac14a893ae54ef072fa3d6bc45895e5480b..faf6486c202a97108393d0c3f303faf1d38c7a54 100644 (file)
@@ -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()