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):
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):
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:
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":
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[:]
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
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"):
import sys
sys.path.insert(0, "/usr/lib/portage/pym")
-
+import os
import portage, string, re
__candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
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)
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))
# 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:
# (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
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":
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)
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"