Remove the leading / from WORLD_FILE for better cooperation with os.path.join (see...
authorZac Medico <zmedico@gentoo.org>
Mon, 6 Mar 2006 00:38:34 +0000 (00:38 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 6 Mar 2006 00:38:34 +0000 (00:38 -0000)
svn path=/main/trunk/; revision=2818

bin/emaint
bin/emerge
bin/regenworld
pym/portage.py
pym/portage_const.py

index e6d11fc1595728c2d71325e7ddc95990a7234097..472656bc78c6d3fc69153db349fee97363898e12 100755 (executable)
@@ -18,9 +18,10 @@ class WorldHandler(object):
                self.invalid = []
                self.not_installed = []
                self.okay = []
-               self.found = os.access(portage_const.WORLD_FILE, os.R_OK)
+               self.world_file = os.path.join("/", portage_const.WORLD_FILE)
+               self.found = os.access(self.world_file, os.R_OK)
 
-               for atom in open(portage_const.WORLD_FILE).read().split():
+               for atom in open(self.world_file).read().split():
                        if not portage.isvalidatom(atom):
                                self.invalid.append(atom)
                        elif not portage.db["/"]["vartree"].dbapi.match(atom):
@@ -34,15 +35,15 @@ class WorldHandler(object):
                        errors += map(lambda x: "'%s' is not a valid atom" % x, self.invalid)
                        errors += map(lambda x: "'%s' is not installed" % x, self.not_installed)
                else:
-                       errors.append(portage_const.WORLD_FILE + " could not be opened for reading")
+                       errors.append(self.world_file + " could not be opened for reading")
                return errors
 
        def fix(self):
                errors = []
                try:
-                       portage.write_atomic(portage_const.WORLD_FILE,"\n".join(self.okay))
+                       portage.write_atomic(self.world_file, "\n".join(self.okay))
                except OSError:
-                       errors.append(portage_const.WORLD_FILE + " could not be opened for writing")
+                       errors.append(self.world_file + " could not be opened for writing")
                return errors
 
 class VdbKeyHandler(object):
index 4afe24432956143717fac3693d28f02a73614515..d0682aabd334e960b372fc8e01af8fe381b87ab9 100755 (executable)
@@ -835,7 +835,7 @@ def getlist(mode):
                mylines=portage.settings.packages
        elif mode=="world":
                try:
-                       myfile=open(portage.root+portage.WORLD_FILE,"r")
+                       myfile = open(os.path.join(portage.root, portage.WORLD_FILE), "r")
                        mylines=myfile.readlines()
                        myfile.close()
                except OSError:
@@ -1843,7 +1843,7 @@ class depgraph:
                                        print red("!!!        the merge operation manually.")
                                        sys.exit(1)
                else:
-                       myfavs=portage.grabfile(portage.root+portage.WORLD_FILE)
+                       myfavs = portage.grabfile(os.path.join(portage.root, portage.WORLD_FILE))
                        myfavdict=genericdict(myfavs)
                        for x in range(len(mylist)):
                                if mylist[x][3]!="nomerge":
@@ -1862,7 +1862,7 @@ class depgraph:
                                                        print ">>> Recording",myfavkey,"in \"world\" favorites file..."
                        if not "--fetchonly" in myopts:
                                portage.write_atomic(
-                               os.path.join(portage.root, portage.WORLD_FILE.lstrip(os.sep)),
+                               os.path.join(portage.root, portage.WORLD_FILE),
                                "\n".join(myfavdict.values()))
 
                        portage.mtimedb["resume"]["mergelist"]=mymergelist[:]
@@ -2025,7 +2025,7 @@ class depgraph:
                                portage.db[x[1]]["vartree"].inject(x[2])
                                myfavkey=portage.cpv_getkey(x[2])
                                if "--fetchonly" not in myopts and "--fetch-all-uri" not in myopts and myfavkey in favorites:
-                                       myfavs=portage.grabfile(myroot+portage.WORLD_FILE)
+                                       myfavs = portage.grabfile(os.path.join(myroot, portage.WORLD_FILE))
                                        myfavdict=genericdict(myfavs)
                                        mysysdict=genericdict(syslist)
                                        #don't record if already in system profile or already recorded
@@ -2035,7 +2035,7 @@ class depgraph:
                                                print ">>> Recording",myfavkey,"in \"world\" favorites file..."
                                                emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Updating world file ("+x[pkgindex]+")")
                                                portage.write_atomic(
-                                               os.path.join(myroot, portage.WORLD_FILE.lstrip(os.sep)),
+                                               os.path.join(myroot, portage.WORLD_FILE),
                                                "\n".join(myfavdict.values()))
 
                                if ("noclean" not in portage.features) and (x[0] != "binary"):
index 8723d7f203d98c5187320e41389ae69b2d74ba0c..221412dd5f05336a7178c152c9971d9ac20f1c77 100755 (executable)
@@ -5,7 +5,7 @@
 
 import sys
 sys.path.insert(0, "/usr/lib/portage/pym")
-
+import os
 import portage, string, re
 
 __candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
@@ -44,7 +44,7 @@ if len(sys.argv) >= 2 and sys.argv[1] in ["-h", "--help"]:
        print "your existing world file (%s) before using this tool." % portage.WORLD_FILE
        sys.exit(0)
 
-worldlist = portage.grabfile(portage.WORLD_FILE)
+worldlist = portage.grabfile(os.path.join("/", portage.WORLD_FILE))
 syslist = portage.settings.packages
 syslist = filter(issyspkg, syslist)
 
@@ -88,4 +88,4 @@ for mykey in biglist:
                        print "add to world:",myfavkey
                        worldlist.append(myfavkey)
 
-portage.write_atomic(portage.WORLD_FILE,"\n".join(worldlist))
+portage.write_atomic(os.path.join("/", portage.WORLD_FILE), "\n".join(worldlist))
index 850800f89a2007697f9bd0de17f8d3dbcc7f34dc..f2bf9d6d6400e9255b2ae03dc407d6ec7e58b12c 100644 (file)
@@ -5797,7 +5797,7 @@ class dblink:
 
                # New code to remove stuff from the world and virtuals files when unmerged.
                if trimworld:
-                       worldlist=grabfile(self.myroot+WORLD_FILE)
+                       worldlist = grabfile(os.path.join(self.myroot, WORLD_FILE))
                        mykey=cpv_getkey(self.mycpv)
                        newworldlist=[]
                        for x in worldlist:
@@ -5820,13 +5820,13 @@ class dblink:
                        # (spanky noticed bug)
                        # XXX: dumb question, but abstracting the root uid might be wise/useful for
                        # 2nd pkg manager installation setups.
-                       if not os.path.exists(os.path.dirname(self.myroot+WORLD_FILE)):
-                               pdir = os.path.dirname(self.myroot + WORLD_FILE)
-                               os.makedirs(pdir, mode=0755)
-                               os.chown(pdir, 0, portage_gid)
-                               os.chmod(pdir, 02770)
+                       my_private_path = os.path.join(self.myroot, PRIVATE_PATH)
+                       if not os.path.exists(my_private_path):
+                               os.makedirs(my_private_path, mode=0755)
+                               os.chown(my_private_path, 0, portage_gid)
+                               os.chmod(my_private_path, 02770)
 
-                       write_atomic(os.path.join(self.myroot, WORLD_FILE.lstrip(os.sep)),
+                       write_atomic(os.path.join(self.myroot, WORLD_FILE),
                        "\n".join(newworldlist))
 
                #do original postrm
@@ -6811,7 +6811,7 @@ def update_config_files(update_iter):
                        if file_contents.has_key(x):
                                del file_contents[x]
                        continue
-       worldlist = grabfile(WORLD_FILE)
+       worldlist = grabfile(os.path.join("/", WORLD_FILE))
 
        for update_cmd in update_iter:
                if update_cmd[0] == "move":
@@ -6834,7 +6834,7 @@ def update_config_files(update_iter):
                                                sys.stdout.write("p")
                                                sys.stdout.flush()
 
-       write_atomic(WORLD_FILE,"\n".join(worldlist))
+       write_atomic(os.path.join("/", WORLD_FILE), "\n".join(worldlist))
 
        for x in update_files:
                mydblink = dblink('','','/',settings)
index c3c768620919dc0430d1895877af4e544f0ed76c..99082a77c8741f1df97f0488e741577ad86b32cb 100644 (file)
@@ -29,7 +29,7 @@ BASH_BINARY             = "/bin/bash"
 MOVE_BINARY             = "/bin/mv"
 PRELINK_BINARY          = "/usr/sbin/prelink"
 
-WORLD_FILE              = "/" + PRIVATE_PATH + "/world"
+WORLD_FILE              = PRIVATE_PATH + "/world"
 MAKE_CONF_FILE          = "/etc/make.conf"
 MAKE_DEFAULTS_FILE      = PROFILE_PATH + "/make.defaults"
 DEPRECATED_PROFILE_FILE = PROFILE_PATH+"/deprecated"