Lines 2-11
Link Here
|
2 |
# portage.py -- core Portage functionality |
2 |
# portage.py -- core Portage functionality |
3 |
# Copyright 1998-2004 Gentoo Foundation |
3 |
# Copyright 1998-2004 Gentoo Foundation |
4 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# Distributed under the terms of the GNU General Public License v2 |
5 |
# $Header: /cvsroot/portage/pym/portage.py,v 1.1.1.5 2005/03/21 09:47:18 haubi Exp $ |
5 |
# $Header: /cvsroot/portage/pym/portage.py,v 1.5 2005/03/25 14:51:36 haubi Exp $ |
6 |
cvs_id_string="$Id: portage.py,v 1.1.1.5 2005/03/21 09:47:18 haubi Exp $"[5:-2] |
6 |
cvs_id_string="$Id: portage.py,v 1.5 2005/03/25 14:51:36 haubi Exp $"[5:-2] |
7 |
|
7 |
|
8 |
VERSION="$Revision: 1.1.1.5 $"[11:-2] + "-cvs" |
8 |
VERSION="$Revision: 1.5 $"[11:-2] + "-cvs" |
9 |
|
9 |
|
10 |
# =========================================================================== |
10 |
# =========================================================================== |
11 |
# START OF IMPORTS -- START OF IMPORTS -- START OF IMPORTS -- START OF IMPORT |
11 |
# START OF IMPORTS -- START OF IMPORTS -- START OF IMPORTS -- START OF IMPORT |
Lines 91-97
Link Here
|
91 |
MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \ |
91 |
MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \ |
92 |
DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \ |
92 |
DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \ |
93 |
INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, SANDBOX_PIDS_FILE, CONFIG_MEMORY_FILE,\ |
93 |
INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, SANDBOX_PIDS_FILE, CONFIG_MEMORY_FILE,\ |
94 |
INCREMENTALS, STICKIES |
94 |
INCREMENTALS, STICKIES, MYROOT, ROOT |
95 |
|
95 |
|
96 |
from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \ |
96 |
from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \ |
97 |
portage_uid, portage_gid |
97 |
portage_uid, portage_gid |
Lines 115-125
Link Here
|
115 |
except SystemExit, e: |
115 |
except SystemExit, e: |
116 |
raise |
116 |
raise |
117 |
except Exception, e: |
117 |
except Exception, e: |
|
|
118 |
raise |
118 |
sys.stderr.write("\n\n") |
119 |
sys.stderr.write("\n\n") |
119 |
sys.stderr.write("!!! Failed to complete portage imports. There are internal modules for\n") |
120 |
sys.stderr.write("!!! Failed to complete portage imports. There are internal modules for\n") |
120 |
sys.stderr.write("!!! portage and failure here indicates that you have a problem with your\n") |
121 |
sys.stderr.write("!!! portage and failure here indicates that you have a problem with your\n") |
121 |
sys.stderr.write("!!! installation of portage. Please try a rescue portage located in the\n") |
122 |
sys.stderr.write("!!! installation of portage. Please try a rescue portage located in the\n") |
122 |
sys.stderr.write("!!! portage tree under '/usr/portage/sys-apps/portage/files/' (default).\n") |
123 |
sys.stderr.write("!!! portage tree under '@prefix@/portage/sys-apps/portage/files/' (default).\n") |
123 |
sys.stderr.write("!!! There is a README.RESCUE file that details the steps required to perform\n") |
124 |
sys.stderr.write("!!! There is a README.RESCUE file that details the steps required to perform\n") |
124 |
sys.stderr.write("!!! a recovery of portage.\n") |
125 |
sys.stderr.write("!!! a recovery of portage.\n") |
125 |
|
126 |
|
Lines 374-384
Link Here
|
374 |
|
375 |
|
375 |
#move this to config. |
376 |
#move this to config. |
376 |
def env_update(root,makelinks=1): |
377 |
def env_update(root,makelinks=1): |
377 |
if not os.path.exists(root+"etc/env.d"): |
378 |
if not os.path.exists(root("etc/env.d")): |
378 |
prevmask=os.umask(0) |
379 |
prevmask=os.umask(0) |
379 |
os.makedirs(root+"etc/env.d",0755) |
380 |
os.makedirs(root("etc/env.d"),0755) |
380 |
os.umask(prevmask) |
381 |
os.umask(prevmask) |
381 |
fns=listdir(root+"etc/env.d") |
382 |
fns=listdir(root("etc/env.d")) |
382 |
fns.sort() |
383 |
fns.sort() |
383 |
pos=0 |
384 |
pos=0 |
384 |
while (pos<len(fns)): |
385 |
while (pos<len(fns)): |
Lines 409-415
Link Here
|
409 |
# don't process backup files |
410 |
# don't process backup files |
410 |
if x[-1]=='~' or x[-4:]==".bak": |
411 |
if x[-1]=='~' or x[-4:]==".bak": |
411 |
continue |
412 |
continue |
412 |
myconfig=getconfig(root+"etc/env.d/"+x) |
413 |
myconfig=getconfig(root("etc/env.d/"+x)) |
413 |
if myconfig==None: |
414 |
if myconfig==None: |
414 |
writemsg("!!! Parsing error in "+str(root)+"etc/env.d/"+str(x)+"\n") |
415 |
writemsg("!!! Parsing error in "+str(root)+"etc/env.d/"+str(x)+"\n") |
415 |
#parse error |
416 |
#parse error |
Lines 426-433
Link Here
|
426 |
for myenv in myconfig.keys(): |
427 |
for myenv in myconfig.keys(): |
427 |
env[myenv]=varexpand(myconfig[myenv]) |
428 |
env[myenv]=varexpand(myconfig[myenv]) |
428 |
|
429 |
|
429 |
if os.path.exists(root+"etc/ld.so.conf"): |
430 |
if os.path.exists(root("etc/ld.so.conf")): |
430 |
myld=open(root+"etc/ld.so.conf") |
431 |
myld=open(root("etc/ld.so.conf")) |
431 |
myldlines=myld.readlines() |
432 |
myldlines=myld.readlines() |
432 |
myld.close() |
433 |
myld.close() |
433 |
oldld=[] |
434 |
oldld=[] |
Lines 436-442
Link Here
|
436 |
if x[0]=="#": |
437 |
if x[0]=="#": |
437 |
continue |
438 |
continue |
438 |
oldld.append(x[:-1]) |
439 |
oldld.append(x[:-1]) |
439 |
# os.rename(root+"etc/ld.so.conf",root+"etc/ld.so.conf.bak") |
440 |
# os.rename(root("etc/ld.so.conf"),root("etc/ld.so.conf.bak")) |
440 |
# Where is the new ld.so.conf generated? (achim) |
441 |
# Where is the new ld.so.conf generated? (achim) |
441 |
else: |
442 |
else: |
442 |
oldld=None |
443 |
oldld=None |
Lines 449-457
Link Here
|
449 |
newld=specials["LDPATH"] |
450 |
newld=specials["LDPATH"] |
450 |
if (oldld!=newld): |
451 |
if (oldld!=newld): |
451 |
#ld.so.conf needs updating and ldconfig needs to be run |
452 |
#ld.so.conf needs updating and ldconfig needs to be run |
452 |
myfd=open(root+"etc/ld.so.conf","w") |
453 |
myfd=open(root("etc/ld.so.conf"),"w") |
453 |
myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n") |
454 |
myfd.write("# ld.so.conf autogenerated by env-update; make all changes to\n") |
454 |
myfd.write("# contents of /etc/env.d directory\n") |
455 |
myfd.write("# contents of "+root("etc/env.d")+" directory\n") |
455 |
for x in specials["LDPATH"]: |
456 |
for x in specials["LDPATH"]: |
456 |
myfd.write(x+"\n") |
457 |
myfd.write(x+"\n") |
457 |
myfd.close() |
458 |
myfd.close() |
Lines 459-469
Link Here
|
459 |
|
460 |
|
460 |
# Update prelink.conf if we are prelink-enabled |
461 |
# Update prelink.conf if we are prelink-enabled |
461 |
if prelink_capable: |
462 |
if prelink_capable: |
462 |
newprelink=open(root+"etc/prelink.conf","w") |
463 |
newprelink=open(root("etc/prelink.conf"),"w") |
463 |
newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n") |
464 |
newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n") |
464 |
newprelink.write("# contents of /etc/env.d directory\n") |
465 |
newprelink.write("# contents of "+root("etc/env.d")+" directory\n") |
465 |
|
466 |
|
466 |
for x in ["/bin","/sbin","/usr/bin","/usr/sbin","/lib","/usr/lib"]: |
467 |
for x in [MYROOT("bin"),MYROOT("sbin"),MYROOT.prefix("/bin"),MYROOT.prefix("/sbin"),MYROOT("lib"),MYROOT.prefix("/lib")]: |
467 |
newprelink.write("-l "+x+"\n"); |
468 |
newprelink.write("-l "+x+"\n"); |
468 |
for x in specials["LDPATH"]+specials["PATH"]+specials["PRELINK_PATH"]: |
469 |
for x in specials["LDPATH"]+specials["PATH"]+specials["PRELINK_PATH"]: |
469 |
if not x: |
470 |
if not x: |
Lines 486-492
Link Here
|
486 |
if not mtimedb.has_key("ldpath"): |
487 |
if not mtimedb.has_key("ldpath"): |
487 |
mtimedb["ldpath"]={} |
488 |
mtimedb["ldpath"]={} |
488 |
|
489 |
|
489 |
for x in specials["LDPATH"]+['/usr/lib','/lib']: |
490 |
for x in specials["LDPATH"]+[MYROOT.prefix('/lib'),MYROOT('lib'),'/usr/lib','/lib']: |
490 |
try: |
491 |
try: |
491 |
newldpathtime=os.stat(x)[stat.ST_MTIME] |
492 |
newldpathtime=os.stat(x)[stat.ST_MTIME] |
492 |
except SystemExit, e: |
493 |
except SystemExit, e: |
Lines 508-521
Link Here
|
508 |
# an older package installed ON TOP of a newer version will cause ldconfig |
509 |
# an older package installed ON TOP of a newer version will cause ldconfig |
509 |
# to overwrite the symlinks we just made. -X means no links. After 'clean' |
510 |
# to overwrite the symlinks we just made. -X means no links. After 'clean' |
510 |
# we can safely create links. |
511 |
# we can safely create links. |
511 |
writemsg(">>> Regenerating "+str(root)+"etc/ld.so.cache...\n") |
512 |
writemsg(">>> Regenerating "+root("etc/ld.so.cache")+"...\n") |
512 |
cwd="/" |
513 |
cwd="/" |
513 |
try: cwd=os.getcwd() |
514 |
try: cwd=os.getcwd() |
514 |
except (OSError, IOError): pass |
515 |
except (OSError, IOError): pass |
515 |
if makelinks: |
516 |
if makelinks: |
516 |
portage_exec.spawn("/sbin/ldconfig -r "+root) |
517 |
portage_exec.spawn("/sbin/ldconfig -r "+root()) |
517 |
else: |
518 |
else: |
518 |
portage_exec.spawn("/sbin/ldconfig -X -r "+root) |
519 |
portage_exec.spawn("/sbin/ldconfig -X -r "+root()) |
519 |
try: os.chdir(cwd) |
520 |
try: os.chdir(cwd) |
520 |
except OSError: pass |
521 |
except OSError: pass |
521 |
|
522 |
|
Lines 524-534
Link Here
|
524 |
penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n" |
525 |
penvnotice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n" |
525 |
penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n" |
526 |
penvnotice += "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES\n" |
526 |
cenvnotice = penvnotice |
527 |
cenvnotice = penvnotice |
527 |
penvnotice += "# GO INTO /etc/profile NOT /etc/profile.env\n\n" |
528 |
penvnotice += "# GO INTO "+root("etc/profile")+" NOT "+root("etc/profile.env")+"\n\n" |
528 |
cenvnotice += "# GO INTO /etc/csh.cshrc NOT /etc/csh.env\n\n" |
529 |
cenvnotice += "# GO INTO "+root("etc/csh.cshrc")+" NOT "+root("etc/csh.env")+"\n\n" |
529 |
|
530 |
|
530 |
#create /etc/profile.env for bash support |
531 |
#create /etc/profile.env for bash support |
531 |
outfile=open(root+"/etc/profile.env","w") |
532 |
outfile=open(root("etc/profile.env"),"w") |
532 |
outfile.write(penvnotice) |
533 |
outfile.write(penvnotice) |
533 |
|
534 |
|
534 |
for path, values in specials.items(): |
535 |
for path, values in specials.items(): |
Lines 549-555
Link Here
|
549 |
outfile.close() |
550 |
outfile.close() |
550 |
|
551 |
|
551 |
#create /etc/csh.env for (t)csh support |
552 |
#create /etc/csh.env for (t)csh support |
552 |
outfile=open(root+"/etc/csh.env","w") |
553 |
outfile=open(root("etc/csh.env"),"w") |
553 |
outfile.write(cenvnotice) |
554 |
outfile.write(cenvnotice) |
554 |
|
555 |
|
555 |
for path, values in specials.items(): |
556 |
for path, values in specials.items(): |
Lines 758-764
Link Here
|
758 |
if not isinstance(mysettings, config): |
759 |
if not isinstance(mysettings, config): |
759 |
raise TypeError, "Invalid type for config object: %s" % mysettings.__class_ |
760 |
raise TypeError, "Invalid type for config object: %s" % mysettings.__class_ |
760 |
|
761 |
|
761 |
custommirrors=grabdict(CUSTOM_MIRRORS_FILE) |
762 |
custommirrors=grabdict(MYROOT(CUSTOM_MIRRORS_FILE)) |
762 |
|
763 |
|
763 |
mymirrors=[] |
764 |
mymirrors=[] |
764 |
|
765 |
|
Lines 1327-1333
Link Here
|
1327 |
"!!! Most likely a temporary problem. Try 'emerge sync' again later.\n"+ |
1328 |
"!!! Most likely a temporary problem. Try 'emerge sync' again later.\n"+ |
1328 |
"!!! If you are certain of the authenticity of the file then you may type\n"+ |
1329 |
"!!! If you are certain of the authenticity of the file then you may type\n"+ |
1329 |
"!!! the following to generate a new digest:\n"+ |
1330 |
"!!! the following to generate a new digest:\n"+ |
1330 |
"!!! ebuild /usr/portage/category/package/package-version.ebuild digest\n", |
1331 |
"!!! ebuild @prefix@/portage/category/package/package-version.ebuild digest\n", |
1331 |
verbosity) |
1332 |
verbosity) |
1332 |
return 0 |
1333 |
return 0 |
1333 |
myfile=os.path.normpath(basedir+"/"+x) |
1334 |
myfile=os.path.normpath(basedir+"/"+x) |
Lines 1410-1416
Link Here
|
1410 |
return 0 |
1411 |
return 0 |
1411 |
|
1412 |
|
1412 |
if manifest_files and strict: |
1413 |
if manifest_files and strict: |
1413 |
for x in grabfile(USER_CONFIG_PATH+"/manifest_excludes"): |
1414 |
for x in grabfile(MYROOT(USER_CONFIG_PATH+"/manifest_excludes")): |
1414 |
if x in manifest_files: |
1415 |
if x in manifest_files: |
1415 |
#writemsg(yellow(">>>")+" md5-ignore: "+x,verbosity) |
1416 |
#writemsg(yellow(">>>")+" md5-ignore: "+x,verbosity) |
1416 |
manifest_files.remove(x) |
1417 |
manifest_files.remove(x) |
Lines 1437-1449
Link Here
|
1437 |
# setup |
1438 |
# setup |
1438 |
def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,use_cache=1,\ |
1439 |
def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,use_cache=1,\ |
1439 |
fetchall=0,tree="porttree",allstages=True,use_info_env=True,verbosity=0): |
1440 |
fetchall=0,tree="porttree",allstages=True,use_info_env=True,verbosity=0): |
1440 |
|
|
|
1441 |
retval = ebuild.ebuild_handler().process_phase(mydo,mysettings,myebuild,myroot, debug=debug, listonly=listonly, \ |
1441 |
retval = ebuild.ebuild_handler().process_phase(mydo,mysettings,myebuild,myroot, debug=debug, listonly=listonly, \ |
1442 |
fetchonly=fetchonly, cleanup=cleanup, use_cache=use_cache, fetchall=fetchall, tree=tree, allstages=allstages, \ |
1442 |
fetchonly=fetchonly, cleanup=cleanup, use_cache=use_cache, fetchall=fetchall, tree=tree, allstages=allstages, \ |
1443 |
use_info_env=use_info_env,verbosity=verbosity) |
1443 |
use_info_env=use_info_env,verbosity=verbosity) |
1444 |
|
1444 |
|
1445 |
#def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,use_cache=1,fetchall=0,tree="porttree",allstages=True,use_info_env=True): |
|
|
1446 |
# retval=ebuild.ebuild_handler().process_phase(mydo, mysettings,myebuild,myroot,debug=debug,listonly=listonly,fetchonly=fetchonly,cleanup=cleanup,dbkey=None,use_cache=1,fetchall=0,tree="porttree",allstages=allstages,use_info_env=use_info_env) |
1447 |
return retval |
1445 |
return retval |
1448 |
|
1446 |
|
1449 |
|
1447 |
|
Lines 1647-1662
Link Here
|
1647 |
##if vardbapi: |
1645 |
##if vardbapi: |
1648 |
## mydbapi=vardbapi |
1646 |
## mydbapi=vardbapi |
1649 |
##else: |
1647 |
##else: |
1650 |
## mydbapi=db[root]["vartree"].dbapi |
1648 |
## mydbapi=db[root()]["vartree"].dbapi |
1651 |
mydbapi=db[root]["vartree"].dbapi |
1649 |
mydbapi=db[root()]["vartree"].dbapi |
1652 |
|
1650 |
|
1653 |
if db["/"].has_key("porttree"): |
1651 |
if db[MYROOT()].has_key("porttree"): |
1654 |
myportapi=db["/"]["porttree"].dbapi |
1652 |
myportapi=db[MYROOT()]["porttree"].dbapi |
1655 |
else: |
1653 |
else: |
1656 |
myportapi=None |
1654 |
myportapi=None |
1657 |
|
1655 |
|
1658 |
if use_binaries and db["/"].has_key("bintree"): |
1656 |
if use_binaries and db[MYROOT()].has_key("bintree"): |
1659 |
mybinapi=db["/"]["bintree"].dbapi |
1657 |
mybinapi=db[MYROOT()]["bintree"].dbapi |
1660 |
writemsg("Using bintree...\n",2) |
1658 |
writemsg("Using bintree...\n",2) |
1661 |
else: |
1659 |
else: |
1662 |
mybinapi=None |
1660 |
mybinapi=None |
Lines 2163-2169
Link Here
|
2163 |
|
2161 |
|
2164 |
def counter_tick_core(self,myroot,incrementing=1,mycpv=None): |
2162 |
def counter_tick_core(self,myroot,incrementing=1,mycpv=None): |
2165 |
"This method will grab the next COUNTER value and record it back to the global file. Returns new counter value." |
2163 |
"This method will grab the next COUNTER value and record it back to the global file. Returns new counter value." |
2166 |
cpath=myroot+"var/cache/edb/counter" |
2164 |
cpath=myroot(CACHE_PATH+"/counter") |
2167 |
changed=0 |
2165 |
changed=0 |
2168 |
min_counter = 0 |
2166 |
min_counter = 0 |
2169 |
if mycpv: |
2167 |
if mycpv: |
Lines 2191-2197
Link Here
|
2191 |
counter=long(cfile.readline()) |
2189 |
counter=long(cfile.readline()) |
2192 |
except (ValueError,OverflowError): |
2190 |
except (ValueError,OverflowError): |
2193 |
try: |
2191 |
try: |
2194 |
counter=long(portage_exec.spawn_get_output("for FILE in $(find /"+VDB_PATH+" -type f -name COUNTER); do echo $(<${FILE}); done | sort -n | tail -n1 | tr -d '\n'",spawn_type=portage_exec.spawn_bash)[1]) |
2192 |
counter=long(portage_exec.spawn_get_output("for FILE in $(find "+MYROOT(VDB_PATH)+" -type f -name COUNTER); do echo $(<${FILE}); done | sort -n | tail -n1 | tr -d '\n'",spawn_type=portage_exec.spawn_bash)[1]) |
2195 |
writemsg("!!! COUNTER was corrupted; resetting to value of %d\n" % counter) |
2193 |
writemsg("!!! COUNTER was corrupted; resetting to value of %d\n" % counter) |
2196 |
changed=1 |
2194 |
changed=1 |
2197 |
except (ValueError,OverflowError): |
2195 |
except (ValueError,OverflowError): |
Lines 2202-2208
Link Here
|
2202 |
cfile.close() |
2200 |
cfile.close() |
2203 |
else: |
2201 |
else: |
2204 |
try: |
2202 |
try: |
2205 |
counter=long(portage_exec.spawn_get_output("for FILE in $(find /"+VDB_PATH+" -type f -name COUNTER); do echo $(<${FILE}); done | sort -n | tail -n1 | tr -d '\n'",spawn_type=portage_exec.spawn_bash)[1]) |
2203 |
counter=long(portage_exec.spawn_get_output("for FILE in $(find "+MYROOT(VDB_PATH)+" -type f -name COUNTER); do echo $(<${FILE}); done | sort -n | tail -n1 | tr -d '\n'",spawn_type=portage_exec.spawn_bash)[1]) |
2206 |
writemsg("!!! Global counter missing. Regenerated from counter files to: %s\n" % counter) |
2204 |
writemsg("!!! Global counter missing. Regenerated from counter files to: %s\n" % counter) |
2207 |
except SystemExit, e: |
2205 |
except SystemExit, e: |
2208 |
raise |
2206 |
raise |
Lines 2338-2349
Link Here
|
2338 |
|
2336 |
|
2339 |
def cpv_exists(self,mykey): |
2337 |
def cpv_exists(self,mykey): |
2340 |
"Tells us whether an actual ebuild exists on disk (no masking)" |
2338 |
"Tells us whether an actual ebuild exists on disk (no masking)" |
2341 |
return os.path.exists(self.root+VDB_PATH+"/"+mykey) |
2339 |
return os.path.exists(self.root(VDB_PATH+"/"+mykey)) |
2342 |
|
2340 |
|
2343 |
def cpv_counter(self,mycpv): |
2341 |
def cpv_counter(self,mycpv): |
2344 |
"This method will grab the COUNTER. Returns a counter value." |
2342 |
"This method will grab the COUNTER. Returns a counter value." |
2345 |
cdir=self.root+VDB_PATH+"/"+mycpv |
2343 |
cdir=self.root(VDB_PATH+"/"+mycpv) |
2346 |
cpath=self.root+VDB_PATH+"/"+mycpv+"/COUNTER" |
2344 |
cpath=self.root(VDB_PATH+"/"+mycpv+"/COUNTER") |
2347 |
|
2345 |
|
2348 |
# We write our new counter value to a new file that gets moved into |
2346 |
# We write our new counter value to a new file that gets moved into |
2349 |
# place to avoid filesystem corruption on XFS (unexpected reboot.) |
2347 |
# place to avoid filesystem corruption on XFS (unexpected reboot.) |
Lines 2372-2387
Link Here
|
2372 |
except SystemExit, e: |
2370 |
except SystemExit, e: |
2373 |
raise |
2371 |
raise |
2374 |
except Exception, e: |
2372 |
except Exception, e: |
2375 |
writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n") |
2373 |
writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in "+MYROOT("var/db")+".\n") |
2376 |
writemsg("!!! Please run /usr/lib/portage/bin/fix-db.pl or\n") |
2374 |
writemsg("!!! Please run @PORTAGE_BASE@/bin/fix-db.pl or\n") |
2377 |
writemsg("!!! Please run /usr/lib/portage/bin/fix-db.py or\n") |
2375 |
writemsg("!!! Please run @PORTAGE_BASE@/bin/fix-db.py or\n") |
2378 |
writemsg("!!! unmerge this exact version.\n") |
2376 |
writemsg("!!! unmerge this exact version.\n") |
2379 |
writemsg("!!! %s\n" % e) |
2377 |
writemsg("!!! %s\n" % e) |
2380 |
sys.exit(1) |
2378 |
sys.exit(1) |
2381 |
else: |
2379 |
else: |
2382 |
writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n") |
2380 |
writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in "+MYROOT("var/db")+".\n") |
2383 |
writemsg("!!! Please run /usr/lib/portage/bin/fix-db.pl or\n") |
2381 |
writemsg("!!! Please run @PORTAGE_BASE@/bin/fix-db.pl or\n") |
2384 |
writemsg("!!! Please run /usr/lib/portage/bin/fix-db.py or\n") |
2382 |
writemsg("!!! Please run @PORTAGE_BASE@/bin/fix-db.py or\n") |
2385 |
writemsg("!!! remerge the package.\n") |
2383 |
writemsg("!!! remerge the package.\n") |
2386 |
sys.exit(1) |
2384 |
sys.exit(1) |
2387 |
else: |
2385 |
else: |
Lines 2398-2415
Link Here
|
2398 |
|
2396 |
|
2399 |
def cpv_inject(self,mycpv): |
2397 |
def cpv_inject(self,mycpv): |
2400 |
"injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist" |
2398 |
"injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist" |
2401 |
os.makedirs(self.root+VDB_PATH+"/"+mycpv) |
2399 |
os.makedirs(self.root(VDB_PATH+"/"+mycpv)) |
2402 |
counter=db[self.root]["vartree"].dbapi.counter_tick(self.root,mycpv=mycpv) |
2400 |
counter=db[self.root()]["vartree"].dbapi.counter_tick(self.root,mycpv=mycpv) |
2403 |
# write local package counter so that emerge clean does the right thing |
2401 |
# write local package counter so that emerge clean does the right thing |
2404 |
lcfile=open(self.root+VDB_PATH+"/"+mycpv+"/COUNTER","w") |
2402 |
lcfile=open(self.root(VDB_PATH+"/"+mycpv+"/COUNTER"),"w") |
2405 |
lcfile.write(str(counter)) |
2403 |
lcfile.write(str(counter)) |
2406 |
lcfile.close() |
2404 |
lcfile.close() |
2407 |
|
2405 |
|
2408 |
def isInjected(self,mycpv): |
2406 |
def isInjected(self,mycpv): |
2409 |
if self.cpv_exists(mycpv): |
2407 |
if self.cpv_exists(mycpv): |
2410 |
if os.path.exists(self.root+VDB_PATH+"/"+mycpv+"/INJECTED"): |
2408 |
if os.path.exists(self.root(VDB_PATH+"/"+mycpv+"/INJECTED")): |
2411 |
return True |
2409 |
return True |
2412 |
if not os.path.exists(self.root+VDB_PATH+"/"+mycpv+"/CONTENTS"): |
2410 |
if not os.path.exists(self.root(VDB_PATH+"/"+mycpv+"/CONTENTS")): |
2413 |
return True |
2411 |
return True |
2414 |
return False |
2412 |
return False |
2415 |
|
2413 |
|
Lines 2426-2439
Link Here
|
2426 |
if mycpsplit[3]!="r0": |
2424 |
if mycpsplit[3]!="r0": |
2427 |
mynewcpv += "-"+mycpsplit[3] |
2425 |
mynewcpv += "-"+mycpsplit[3] |
2428 |
mycpsplit_new = portage_versions.catpkgsplit(mynewcpv) |
2426 |
mycpsplit_new = portage_versions.catpkgsplit(mynewcpv) |
2429 |
origpath=self.root+VDB_PATH+"/"+mycpv |
2427 |
origpath=self.root(VDB_PATH+"/"+mycpv) |
2430 |
if not os.path.exists(origpath): |
2428 |
if not os.path.exists(origpath): |
2431 |
continue |
2429 |
continue |
2432 |
writemsg("@") |
2430 |
writemsg("@") |
2433 |
if not os.path.exists(self.root+VDB_PATH+"/"+mynewcat): |
2431 |
if not os.path.exists(self.root(VDB_PATH+"/"+mynewcat)): |
2434 |
#create the directory |
2432 |
#create the directory |
2435 |
os.makedirs(self.root+VDB_PATH+"/"+mynewcat) |
2433 |
os.makedirs(self.root(VDB_PATH+"/"+mynewcat)) |
2436 |
newpath=self.root+VDB_PATH+"/"+mynewcpv |
2434 |
newpath=self.root(VDB_PATH+"/"+mynewcpv) |
2437 |
if os.path.exists(newpath): |
2435 |
if os.path.exists(newpath): |
2438 |
#dest already exists; keep this puppy where it is. |
2436 |
#dest already exists; keep this puppy where it is. |
2439 |
continue |
2437 |
continue |
Lines 2452-2458
Link Here
|
2452 |
catfile.write(mynewcat+"\n") |
2450 |
catfile.write(mynewcat+"\n") |
2453 |
catfile.close() |
2451 |
catfile.close() |
2454 |
|
2452 |
|
2455 |
dbdir = self.root+VDB_PATH |
2453 |
dbdir = self.root(VDB_PATH) |
2456 |
for catdir in listdir(dbdir): |
2454 |
for catdir in listdir(dbdir): |
2457 |
catdir = dbdir+"/"+catdir |
2455 |
catdir = dbdir+"/"+catdir |
2458 |
if os.path.isdir(catdir): |
2456 |
if os.path.isdir(catdir): |
Lines 2470-2476
Link Here
|
2470 |
if not origmatches: |
2468 |
if not origmatches: |
2471 |
return |
2469 |
return |
2472 |
for mycpv in origmatches: |
2470 |
for mycpv in origmatches: |
2473 |
origpath=self.root+VDB_PATH+"/"+mycpv |
2471 |
origpath=self.root(VDB_PATH+"/"+mycpv) |
2474 |
if not os.path.exists(origpath): |
2472 |
if not os.path.exists(origpath): |
2475 |
continue |
2473 |
continue |
2476 |
|
2474 |
|
Lines 2491-2504
Link Here
|
2491 |
if mysplit[0] == '*': |
2489 |
if mysplit[0] == '*': |
2492 |
mysplit[0] = mysplit[0][1:] |
2490 |
mysplit[0] = mysplit[0][1:] |
2493 |
try: |
2491 |
try: |
2494 |
mystat=os.stat(self.root+VDB_PATH+"/"+mysplit[0])[stat.ST_MTIME] |
2492 |
mystat=os.stat(self.root(VDB_PATH+"/"+mysplit[0]))[stat.ST_MTIME] |
2495 |
except OSError: |
2493 |
except OSError: |
2496 |
mystat=0 |
2494 |
mystat=0 |
2497 |
if use_cache and self.cpcache.has_key(mycp): |
2495 |
if use_cache and self.cpcache.has_key(mycp): |
2498 |
cpc=self.cpcache[mycp] |
2496 |
cpc=self.cpcache[mycp] |
2499 |
if cpc[0]==mystat: |
2497 |
if cpc[0]==mystat: |
2500 |
return cpc[1] |
2498 |
return cpc[1] |
2501 |
list=listdir(self.root+VDB_PATH+"/"+mysplit[0]) |
2499 |
list=listdir(self.root(VDB_PATH+"/"+mysplit[0])) |
2502 |
|
2500 |
|
2503 |
if (list==None): |
2501 |
if (list==None): |
2504 |
return [] |
2502 |
return [] |
Lines 2509-2515
Link Here
|
2509 |
continue |
2507 |
continue |
2510 |
ps=portage_versions.pkgsplit(x) |
2508 |
ps=portage_versions.pkgsplit(x) |
2511 |
if not ps: |
2509 |
if not ps: |
2512 |
self.invalidentry(self.root+VDB_PATH+"/"+mysplit[0]+"/"+x) |
2510 |
self.invalidentry(self.root(VDB_PATH+"/"+mysplit[0]+"/"+x)) |
2513 |
continue |
2511 |
continue |
2514 |
if len(mysplit) > 1: |
2512 |
if len(mysplit) > 1: |
2515 |
if ps[0]==mysplit[1]: |
2513 |
if ps[0]==mysplit[1]: |
Lines 2524-2530
Link Here
|
2524 |
return list(self.iter_cpv_all(use_cache=use_cache)) |
2522 |
return list(self.iter_cpv_all(use_cache=use_cache)) |
2525 |
|
2523 |
|
2526 |
def iter_cpv_all(self,use_cache=1): |
2524 |
def iter_cpv_all(self,use_cache=1): |
2527 |
basepath = self.root+VDB_PATH+"/" |
2525 |
basepath = self.root(VDB_PATH+"/") |
2528 |
|
2526 |
|
2529 |
mycats = self.categories |
2527 |
mycats = self.categories |
2530 |
if mycats == None: |
2528 |
if mycats == None: |
Lines 2546-2552
Link Here
|
2546 |
y = y[1:] |
2544 |
y = y[1:] |
2547 |
mysplit=portage_versions.catpkgsplit(y) |
2545 |
mysplit=portage_versions.catpkgsplit(y) |
2548 |
if not mysplit: |
2546 |
if not mysplit: |
2549 |
self.invalidentry(self.root+VDB_PATH+"/"+y) |
2547 |
self.invalidentry(self.root(VDB_PATH+"/"+y)) |
2550 |
continue |
2548 |
continue |
2551 |
mykey=mysplit[0]+"/"+mysplit[1] |
2549 |
mykey=mysplit[0]+"/"+mysplit[1] |
2552 |
d[mysplit[0]+"/"+mysplit[1]] = None |
2550 |
d[mysplit[0]+"/"+mysplit[1]] = None |
Lines 2566-2572
Link Here
|
2566 |
del self.matchcache[mycat] |
2564 |
del self.matchcache[mycat] |
2567 |
return portage_dep.match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) |
2565 |
return portage_dep.match_from_list(mydep,self.cp_list(mykey,use_cache=use_cache)) |
2568 |
try: |
2566 |
try: |
2569 |
curmtime=os.stat(self.root+VDB_PATH+"/"+mycat)[stat.ST_MTIME] |
2567 |
curmtime=os.stat(self.root(VDB_PATH+"/"+mycat))[stat.ST_MTIME] |
2570 |
except SystemExit, e: |
2568 |
except SystemExit, e: |
2571 |
raise |
2569 |
raise |
2572 |
except: |
2570 |
except: |
Lines 2587-2593
Link Here
|
2587 |
if not self.cpv_exists(mycpv): |
2585 |
if not self.cpv_exists(mycpv): |
2588 |
return [] |
2586 |
return [] |
2589 |
for x in wants: |
2587 |
for x in wants: |
2590 |
myfn = self.root+VDB_PATH+"/"+str(mycpv)+"/"+str(x) |
2588 |
myfn = self.root(VDB_PATH+"/"+str(mycpv)+"/"+str(x)) |
2591 |
if os.access(myfn,os.R_OK): |
2589 |
if os.access(myfn,os.R_OK): |
2592 |
myf = open(myfn, "r") |
2590 |
myf = open(myfn, "r") |
2593 |
myd = myf.read() |
2591 |
myd = myf.read() |
Lines 2622-2630
Link Here
|
2622 |
def get_provide(self,mycpv): |
2620 |
def get_provide(self,mycpv): |
2623 |
myprovides=[] |
2621 |
myprovides=[] |
2624 |
try: |
2622 |
try: |
2625 |
mylines = grabfile(self.root+VDB_PATH+"/"+mycpv+"/PROVIDE") |
2623 |
mylines = grabfile(self.root(VDB_PATH+"/"+mycpv+"/PROVIDE")) |
2626 |
if mylines: |
2624 |
if mylines: |
2627 |
myuse = grabfile(self.root+VDB_PATH+"/"+mycpv+"/USE") |
2625 |
myuse = grabfile(self.root(VDB_PATH+"/"+mycpv+"/USE")) |
2628 |
myuse = " ".join(myuse).split() |
2626 |
myuse = " ".join(myuse).split() |
2629 |
mylines = " ".join(mylines) |
2627 |
mylines = " ".join(mylines) |
2630 |
mylines = flatten(portage_dep.use_reduce(portage_dep.paren_reduce(mylines), uselist=myuse)) |
2628 |
mylines = flatten(portage_dep.use_reduce(portage_dep.paren_reduce(mylines), uselist=myuse)) |
Lines 2638-2644
Link Here
|
2638 |
raise |
2636 |
raise |
2639 |
except Exception, e: |
2637 |
except Exception, e: |
2640 |
print |
2638 |
print |
2641 |
print "Check " + self.root+VDB_PATH+"/"+mycpv+"/PROVIDE and USE." |
2639 |
print "Check " + self.root(VDB_PATH+"/"+mycpv+"/")+"PROVIDE and USE." |
2642 |
print "Possibly Invalid: " + str(mylines) |
2640 |
print "Possibly Invalid: " + str(mylines) |
2643 |
print "Exception: "+str(e) |
2641 |
print "Exception: "+str(e) |
2644 |
print |
2642 |
print |
Lines 2690-2700
Link Here
|
2690 |
a=portage_versions.catpkgsplit(cpv) |
2688 |
a=portage_versions.catpkgsplit(cpv) |
2691 |
if not a: |
2689 |
if not a: |
2692 |
return 0 |
2690 |
return 0 |
2693 |
mylist=listdir(self.root+VDB_PATH+"/"+a[0]) |
2691 |
mylist=listdir(self.root(VDB_PATH+"/"+a[0])) |
2694 |
for x in mylist: |
2692 |
for x in mylist: |
2695 |
b=portage_versions.pkgsplit(x) |
2693 |
b=portage_versions.pkgsplit(x) |
2696 |
if not b: |
2694 |
if not b: |
2697 |
self.dbapi.invalidentry(self.root+VDB_PATH+"/"+a[0]+"/"+x) |
2695 |
self.dbapi.invalidentry(self.root(VDB_PATH+"/"+a[0]+"/"+x)) |
2698 |
continue |
2696 |
continue |
2699 |
if a[1]==b[0]: |
2697 |
if a[1]==b[0]: |
2700 |
return 1 |
2698 |
return 1 |
Lines 2702-2720
Link Here
|
2702 |
|
2700 |
|
2703 |
def getebuildpath(self,fullpackage): |
2701 |
def getebuildpath(self,fullpackage): |
2704 |
cat,package=fullpackage.split("/") |
2702 |
cat,package=fullpackage.split("/") |
2705 |
return self.root+VDB_PATH+"/"+fullpackage+"/"+package+".ebuild" |
2703 |
return self.root(VDB_PATH+"/"+fullpackage+"/"+package+".ebuild") |
2706 |
|
2704 |
|
2707 |
def getnode(self,mykey,use_cache=1): |
2705 |
def getnode(self,mykey,use_cache=1): |
2708 |
mykey=key_expand(mykey,mydb=self.dbapi,use_cache=use_cache) |
2706 |
mykey=key_expand(mykey,mydb=self.dbapi,use_cache=use_cache) |
2709 |
if not mykey: |
2707 |
if not mykey: |
2710 |
return [] |
2708 |
return [] |
2711 |
mysplit=mykey.split("/") |
2709 |
mysplit=mykey.split("/") |
2712 |
mydirlist=listdir(self.root+VDB_PATH+"/"+mysplit[0]) |
2710 |
mydirlist=listdir(self.root(VDB_PATH+"/"+mysplit[0])) |
2713 |
returnme=[] |
2711 |
returnme=[] |
2714 |
for x in mydirlist: |
2712 |
for x in mydirlist: |
2715 |
mypsplit=portage_versions.pkgsplit(x) |
2713 |
mypsplit=portage_versions.pkgsplit(x) |
2716 |
if not mypsplit: |
2714 |
if not mypsplit: |
2717 |
self.dbapi.invalidentry(self.root+VDB_PATH+"/"+mysplit[0]+"/"+x) |
2715 |
self.dbapi.invalidentry(self.root(VDB_PATH+"/"+mysplit[0]+"/"+x)) |
2718 |
continue |
2716 |
continue |
2719 |
if mypsplit[0]==mysplit[1]: |
2717 |
if mypsplit[0]==mysplit[1]: |
2720 |
appendme=[mysplit[0]+"/"+x,[mysplit[0],mypsplit[0],mypsplit[1],mypsplit[2]]] |
2718 |
appendme=[mysplit[0]+"/"+x,[mysplit[0],mypsplit[0],mypsplit[1],mypsplit[2]]] |
Lines 2726-2732
Link Here
|
2726 |
"Get a slot for a catpkg; assume it exists." |
2724 |
"Get a slot for a catpkg; assume it exists." |
2727 |
myslot = "" |
2725 |
myslot = "" |
2728 |
try: |
2726 |
try: |
2729 |
myslot=" ".join(grabfile(self.root+VDB_PATH+"/"+mycatpkg+"/SLOT")) |
2727 |
myslot=" ".join(grabfile(self.root(VDB_PATH+"/"+mycatpkg+"/SLOT"))) |
2730 |
except SystemExit, e: |
2728 |
except SystemExit, e: |
2731 |
raise |
2729 |
raise |
2732 |
except Exception, e: |
2730 |
except Exception, e: |
Lines 2737-2747
Link Here
|
2737 |
"""Does the particular node (cat/pkg key) exist?""" |
2735 |
"""Does the particular node (cat/pkg key) exist?""" |
2738 |
mykey=key_expand(mykey,mydb=self.dbapi,use_cache=use_cache) |
2736 |
mykey=key_expand(mykey,mydb=self.dbapi,use_cache=use_cache) |
2739 |
mysplit=mykey.split("/") |
2737 |
mysplit=mykey.split("/") |
2740 |
mydirlist=listdir(self.root+VDB_PATH+"/"+mysplit[0]) |
2738 |
mydirlist=listdir(self.root(VDB_PATH+"/"+mysplit[0])) |
2741 |
for x in mydirlist: |
2739 |
for x in mydirlist: |
2742 |
mypsplit=portage_versions.pkgsplit(x) |
2740 |
mypsplit=portage_versions.pkgsplit(x) |
2743 |
if not mypsplit: |
2741 |
if not mypsplit: |
2744 |
self.dbapi.invalidentry(self.root+VDB_PATH+"/"+mysplit[0]+"/"+x) |
2742 |
self.dbapi.invalidentry(self.root(VDB_PATH+"/"+mysplit[0]+"/"+x)) |
2745 |
continue |
2743 |
continue |
2746 |
if mypsplit[0]==mysplit[1]: |
2744 |
if mypsplit[0]==mysplit[1]: |
2747 |
return 1 |
2745 |
return 1 |
Lines 2813-2819
Link Here
|
2813 |
self.auxdbmodule = self.mysettings.load_best_module("portdbapi.auxdbmodule") |
2811 |
self.auxdbmodule = self.mysettings.load_best_module("portdbapi.auxdbmodule") |
2814 |
self.auxdb = {} |
2812 |
self.auxdb = {} |
2815 |
for x in self.porttrees: |
2813 |
for x in self.porttrees: |
2816 |
self.auxdb[x] = self.auxdbmodule(x, filtered_auxdbkeys, basepath=portage_const.DEPCACHE_PATH, |
2814 |
self.auxdb[x] = self.auxdbmodule(x, filtered_auxdbkeys, basepath=MYROOT(DEPCACHE_PATH), |
2817 |
gid=portage_gid) |
2815 |
gid=portage_gid) |
2818 |
|
2816 |
|
2819 |
|
2817 |
|
Lines 3386-3392
Link Here
|
3386 |
#we need to update this next line when we have fully integrated the new db api |
3384 |
#we need to update this next line when we have fully integrated the new db api |
3387 |
auxerr=0 |
3385 |
auxerr=0 |
3388 |
try: |
3386 |
try: |
3389 |
myaux=db["/"]["porttree"].dbapi.aux_get(mycpv, ["KEYWORDS"]) |
3387 |
myaux=db[MYROOT()]["porttree"].dbapi.aux_get(mycpv, ["KEYWORDS"]) |
3390 |
except (KeyError,IOError,TypeError): |
3388 |
except (KeyError,IOError,TypeError): |
3391 |
continue |
3389 |
continue |
3392 |
if not myaux[0]: |
3390 |
if not myaux[0]: |
Lines 3716-3722
Link Here
|
3716 |
self.mysplit = portage_versions.pkgsplit(self.mycpv) |
3714 |
self.mysplit = portage_versions.pkgsplit(self.mycpv) |
3717 |
self.treetype = treetype |
3715 |
self.treetype = treetype |
3718 |
|
3716 |
|
3719 |
self.dbroot = os.path.normpath(myroot+VDB_PATH) |
3717 |
self.dbroot = os.path.normpath(myroot(VDB_PATH)) |
3720 |
self.dbcatdir = self.dbroot+"/"+cat |
3718 |
self.dbcatdir = self.dbroot+"/"+cat |
3721 |
self.dbpkgdir = self.dbcatdir+"/"+pkg |
3719 |
self.dbpkgdir = self.dbcatdir+"/"+pkg |
3722 |
self.dbtmpdir = self.dbcatdir+"/-MERGING-"+pkg |
3720 |
self.dbtmpdir = self.dbcatdir+"/-MERGING-"+pkg |
Lines 3755-3761
Link Here
|
3755 |
return os.path.exists(self.dbdir) |
3753 |
return os.path.exists(self.dbdir) |
3756 |
|
3754 |
|
3757 |
def create(self): |
3755 |
def create(self): |
3758 |
"create the skeleton db directory structure. No contents, virtuals, provides or anything. Also will create /var/db/pkg if necessary." |
3756 |
"create the skeleton db directory structure. No contents, virtuals, provides or anything. Also will create "+MYROOT("var/db/pkg")+" if necessary." |
3759 |
# XXXXX Delete this eventually |
3757 |
# XXXXX Delete this eventually |
3760 |
raise Exception, "This is bad. Don't use it." |
3758 |
raise Exception, "This is bad. Don't use it." |
3761 |
if not os.path.exists(self.dbdir): |
3759 |
if not os.path.exists(self.dbdir): |
Lines 3797-3803
Link Here
|
3797 |
# we do this so we can remove from non-root filesystems |
3795 |
# we do this so we can remove from non-root filesystems |
3798 |
# (use the ROOT var to allow maintenance on other partitions) |
3796 |
# (use the ROOT var to allow maintenance on other partitions) |
3799 |
try: |
3797 |
try: |
3800 |
mydat[1]=os.path.normpath(root+mydat[1][1:]) |
3798 |
mydat[1]=os.path.normpath(root.root(mydat[1][1:])) |
3801 |
if mydat[0]=="obj": |
3799 |
if mydat[0]=="obj": |
3802 |
#format: type, mtime, md5sum |
3800 |
#format: type, mtime, md5sum |
3803 |
pkgfiles[" ".join(mydat[1:-2])]=[mydat[0], mydat[-1], mydat[-2]] |
3801 |
pkgfiles[" ".join(mydat[1:-2])]=[mydat[0], mydat[-1], mydat[-2]] |
Lines 3838-3853
Link Here
|
3838 |
#do some config file management prep |
3836 |
#do some config file management prep |
3839 |
self.protect=[] |
3837 |
self.protect=[] |
3840 |
for x in self.settings["CONFIG_PROTECT"].split(): |
3838 |
for x in self.settings["CONFIG_PROTECT"].split(): |
3841 |
ppath=normpath(self.myroot+x)+"/" |
3839 |
for ppath in [ normpath(self.myroot.root(x))+"/" |
3842 |
if os.path.isdir(ppath): |
3840 |
, normpath(self.myroot(x))+"/" |
3843 |
self.protect.append(ppath) |
3841 |
]: |
|
|
3842 |
if os.path.isdir(ppath): |
3843 |
self.protect.append(ppath) |
3844 |
|
3844 |
|
3845 |
self.protectmask=[] |
3845 |
self.protectmask=[] |
3846 |
for x in self.settings["CONFIG_PROTECT_MASK"].split(): |
3846 |
for x in self.settings["CONFIG_PROTECT_MASK"].split(): |
3847 |
ppath=normpath(self.myroot+x)+"/" |
3847 |
for ppath in [ normpath(self.myroot.root(x))+"/" |
3848 |
if os.path.isdir(ppath): |
3848 |
, normpath(self.myroot(x))+"/" |
3849 |
self.protectmask.append(ppath) |
3849 |
]: |
3850 |
#if it doesn't exist, silently skip it |
3850 |
if os.path.isdir(ppath): |
|
|
3851 |
self.protectmask.append(ppath) |
3852 |
#if it doesn't exist, silently skip it |
3851 |
|
3853 |
|
3852 |
def isprotected(self,obj): |
3854 |
def isprotected(self,obj): |
3853 |
"""Checks if obj is in the current protect/mask directories. Returns |
3855 |
"""Checks if obj is in the current protect/mask directories. Returns |
Lines 4060-4075
Link Here
|
4060 |
#step 5: well, removal of package objects is complete, now for package *meta*-objects.... |
4062 |
#step 5: well, removal of package objects is complete, now for package *meta*-objects.... |
4061 |
|
4063 |
|
4062 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
4064 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
4063 |
db[self.myroot]["vartree"].zap(self.mycpv) |
4065 |
db[self.myroot()]["vartree"].zap(self.mycpv) |
4064 |
|
4066 |
|
4065 |
# New code to remove stuff from the world and virtuals files when unmerged. |
4067 |
# New code to remove stuff from the world and virtuals files when unmerged. |
4066 |
if trimworld: |
4068 |
if trimworld: |
4067 |
worldlist=grabfile(self.myroot+WORLD_FILE) |
4069 |
worldlist=grabfile(self.myroot(WORLD_FILE)) |
4068 |
mykey=cpv_getkey(self.mycpv) |
4070 |
mykey=cpv_getkey(self.mycpv) |
4069 |
newworldlist=[] |
4071 |
newworldlist=[] |
4070 |
for x in worldlist: |
4072 |
for x in worldlist: |
4071 |
if portage_dep.dep_getkey(x)==mykey: |
4073 |
if portage_dep.dep_getkey(x)==mykey: |
4072 |
matches=db[self.myroot]["vartree"].dbapi.match(x,use_cache=0) |
4074 |
matches=db[self.myroot()]["vartree"].dbapi.match(x,use_cache=0) |
4073 |
if not matches: |
4075 |
if not matches: |
4074 |
#zap our world entry |
4076 |
#zap our world entry |
4075 |
pass |
4077 |
pass |
Lines 4087-4099
Link Here
|
4087 |
# (spanky noticed bug) |
4089 |
# (spanky noticed bug) |
4088 |
# XXX: dumb question, but abstracting the root uid might be wise/useful for |
4090 |
# XXX: dumb question, but abstracting the root uid might be wise/useful for |
4089 |
# 2nd pkg manager installation setups. |
4091 |
# 2nd pkg manager installation setups. |
4090 |
if not os.path.exists(os.path.dirname(self.myroot+WORLD_FILE)): |
4092 |
if not os.path.exists(os.path.dirname(self.myroot(WORLD_FILE))): |
4091 |
pdir = os.path.dirname(self.myroot + WORLD_FILE) |
4093 |
pdir = os.path.dirname(self.myroot(WORLD_FILE)) |
4092 |
os.makedirs(pdir, mode=0755) |
4094 |
os.makedirs(pdir, mode=0755) |
4093 |
os.chown(pdir, 0, portage_gid) |
4095 |
os.chown(pdir, 0, portage_gid) |
4094 |
os.chmod(pdir, 02770) |
4096 |
os.chmod(pdir, 02770) |
4095 |
|
4097 |
|
4096 |
myworld=open(self.myroot+WORLD_FILE,"w") |
4098 |
myworld=open(self.myroot(WORLD_FILE),"w") |
4097 |
for x in newworldlist: |
4099 |
for x in newworldlist: |
4098 |
myworld.write(x+"\n") |
4100 |
myworld.write(x+"\n") |
4099 |
myworld.close() |
4101 |
myworld.close() |
Lines 4153-4159
Link Here
|
4153 |
|
4155 |
|
4154 |
# check for package collisions |
4156 |
# check for package collisions |
4155 |
otherversions=[] |
4157 |
otherversions=[] |
4156 |
for v in db[self.myroot]["vartree"].dbapi.cp_list(self.mysplit[0]): |
4158 |
for v in db[self.myroot()]["vartree"].dbapi.cp_list(self.mysplit[0]): |
4157 |
otherversions.append(v.split("/")[1]) |
4159 |
otherversions.append(v.split("/")[1]) |
4158 |
|
4160 |
|
4159 |
if self.pkg in otherversions: |
4161 |
if self.pkg in otherversions: |
Lines 4266-4291
Link Here
|
4266 |
|
4268 |
|
4267 |
# Step2: filter out libs from the packages states RDEPEND |
4269 |
# Step2: filter out libs from the packages states RDEPEND |
4268 |
if len(checklist): |
4270 |
if len(checklist): |
4269 |
rdep=portage_dep.paren_reduce(db[self.myroot][self.treetype].dbapi.aux_get( \ |
4271 |
rdep=portage_dep.paren_reduce(db[self.myroot()][self.treetype].dbapi.aux_get( \ |
4270 |
self.mycpv,["RDEPEND"])[0]) |
4272 |
self.mycpv,["RDEPEND"])[0]) |
4271 |
rdep=portage_util.unique_array(flatten(portage_dep.use_reduce(rdep, \ |
4273 |
rdep=portage_util.unique_array(flatten(portage_dep.use_reduce(rdep, \ |
4272 |
uselist=self.settings["USE"],matchall=False))) |
4274 |
uselist=self.settings["USE"],matchall=False))) |
4273 |
|
4275 |
|
4274 |
r=[] |
4276 |
r=[] |
4275 |
for x in rdep: |
4277 |
for x in rdep: |
4276 |
r.extend(db[self.myroot]["vartree"].dbapi.match(x)) |
4278 |
r.extend(db[self.myroot()]["vartree"].dbapi.match(x)) |
4277 |
|
4279 |
|
4278 |
rdep=r |
4280 |
rdep=r |
4279 |
|
4281 |
|
4280 |
# filter first package rdeps, then virtual/.?libc, then gcc |
4282 |
# filter first package rdeps, then virtual/.?libc, then gcc |
4281 |
|
4283 |
|
4282 |
lm = db[self.myroot]["vartree"].dbapi.match("virtual/glibc") |
4284 |
lm = db[self.myroot()]["vartree"].dbapi.match("virtual/glibc") |
4283 |
lm.extend(db[self.myroot]["vartree"].dbapi.match("virtual/libc")) |
4285 |
lm.extend(db[self.myroot()]["vartree"].dbapi.match("virtual/libc")) |
4284 |
lm = portage_util.unique_array(lm) |
4286 |
lm = portage_util.unique_array(lm) |
4285 |
|
4287 |
|
4286 |
for rd,msg in [(r,"%s/%s's RDEPEND" % (self.cat,self.pkg)), \ |
4288 |
for rd,msg in [(r,"%s/%s's RDEPEND" % (self.cat,self.pkg)), \ |
4287 |
(lm, "virtual/glibc, virtual/libc"), \ |
4289 |
(lm, "virtual/glibc, virtual/libc"), \ |
4288 |
(db[self.myroot]["vartree"].dbapi.match("gcc"), "gcc")]: |
4290 |
(db[self.myroot()]["vartree"].dbapi.match("gcc"), "gcc")]: |
4289 |
|
4291 |
|
4290 |
print green("*")+" Parsing %s contents" % msg |
4292 |
print green("*")+" Parsing %s contents" % msg |
4291 |
|
4293 |
|
Lines 4351-4362
Link Here
|
4351 |
|
4353 |
|
4352 |
if len(checklist): |
4354 |
if len(checklist): |
4353 |
# append this nodes rdepend. |
4355 |
# append this nodes rdepend. |
4354 |
rdep,u=db[self.myroot]["vartree"].dbapi.aux_get(r,["RDEPEND","USE"]) |
4356 |
rdep,u=db[self.myroot()]["vartree"].dbapi.aux_get(r,["RDEPEND","USE"]) |
4355 |
pd=flatten(portage_dep.use_reduce(portage_dep.paren_reduce(rdep),\ |
4357 |
pd=flatten(portage_dep.use_reduce(portage_dep.paren_reduce(rdep),\ |
4356 |
uselist=u,matchall=False)) |
4358 |
uselist=u,matchall=False)) |
4357 |
pd=portage_util.unique_array(pd) |
4359 |
pd=portage_util.unique_array(pd) |
4358 |
for x in pd: |
4360 |
for x in pd: |
4359 |
for y in db["/"]["vartree"].dbapi.match(x): |
4361 |
for y in db[MYROOT()]["vartree"].dbapi.match(x): |
4360 |
if y not in candidates_checked: |
4362 |
if y not in candidates_checked: |
4361 |
candidate.append(y) |
4363 |
candidate.append(y) |
4362 |
candidate=portage_util.unique_array(flatten(candidate)) |
4364 |
candidate=portage_util.unique_array(flatten(candidate)) |
Lines 4435-4441
Link Here
|
4435 |
# get current counter value (counter_tick also takes care of incrementing it) |
4437 |
# get current counter value (counter_tick also takes care of incrementing it) |
4436 |
# XXX Need to make this destroot, but it needs to be initialized first. XXX |
4438 |
# XXX Need to make this destroot, but it needs to be initialized first. XXX |
4437 |
# XXX bis: leads to some invalidentry() call through cp_all(). |
4439 |
# XXX bis: leads to some invalidentry() call through cp_all(). |
4438 |
counter = db["/"]["vartree"].dbapi.counter_tick(self.myroot,mycpv=self.mycpv) |
4440 |
counter = db[MYROOT()]["vartree"].dbapi.counter_tick(self.myroot,mycpv=self.mycpv) |
4439 |
# write local package counter for recording |
4441 |
# write local package counter for recording |
4440 |
lcfile = open(self.dbtmpdir+"/COUNTER","w") |
4442 |
lcfile = open(self.dbtmpdir+"/COUNTER","w") |
4441 |
lcfile.write(str(counter)) |
4443 |
lcfile.write(str(counter)) |
Lines 4447-4454
Link Here
|
4447 |
self.updateprotect() |
4449 |
self.updateprotect() |
4448 |
|
4450 |
|
4449 |
#if we have a file containing previously-merged config file md5sums, grab it. |
4451 |
#if we have a file containing previously-merged config file md5sums, grab it. |
4450 |
if os.path.exists(destroot+CONFIG_MEMORY_FILE): |
4452 |
if os.path.exists(destroot(CONFIG_MEMORY_FILE)): |
4451 |
cfgfiledict=grabdict(destroot+CONFIG_MEMORY_FILE) |
4453 |
cfgfiledict=grabdict(destroot(CONFIG_MEMORY_FILE)) |
4452 |
else: |
4454 |
else: |
4453 |
cfgfiledict={} |
4455 |
cfgfiledict={} |
4454 |
if self.settings.has_key("NOCONFMEM"): |
4456 |
if self.settings.has_key("NOCONFMEM"): |
Lines 4463-4469
Link Here
|
4463 |
|
4465 |
|
4464 |
# we do a first merge; this will recurse through all files in our srcroot but also build up a |
4466 |
# we do a first merge; this will recurse through all files in our srcroot but also build up a |
4465 |
# "second hand" of symlinks to merge later |
4467 |
# "second hand" of symlinks to merge later |
4466 |
if self.mergeme(srcroot,destroot,outfile,secondhand,"",cfgfiledict,mymtime): |
4468 |
if self.mergeme(srcroot,destroot.root(),outfile,secondhand,"",cfgfiledict,mymtime): |
4467 |
return 1 |
4469 |
return 1 |
4468 |
|
4470 |
|
4469 |
# now, it's time for dealing our second hand; we'll loop until we can't merge anymore. The rest are |
4471 |
# now, it's time for dealing our second hand; we'll loop until we can't merge anymore. The rest are |
Lines 4474-4480
Link Here
|
4474 |
# couldn't get merged will be added to thirdhand. |
4476 |
# couldn't get merged will be added to thirdhand. |
4475 |
|
4477 |
|
4476 |
thirdhand=[] |
4478 |
thirdhand=[] |
4477 |
self.mergeme(srcroot,destroot,outfile,thirdhand,secondhand,cfgfiledict,mymtime) |
4479 |
self.mergeme(srcroot,destroot.root(),outfile,thirdhand,secondhand,cfgfiledict,mymtime) |
4478 |
|
4480 |
|
4479 |
#swap hands |
4481 |
#swap hands |
4480 |
lastlen=len(secondhand) |
4482 |
lastlen=len(secondhand) |
Lines 4486-4492
Link Here
|
4486 |
|
4488 |
|
4487 |
if len(secondhand): |
4489 |
if len(secondhand): |
4488 |
# force merge of remaining symlinks (broken or circular; oh well) |
4490 |
# force merge of remaining symlinks (broken or circular; oh well) |
4489 |
self.mergeme(srcroot,destroot,outfile,None,secondhand,cfgfiledict,mymtime) |
4491 |
self.mergeme(srcroot,destroot.root(),outfile,None,secondhand,cfgfiledict,mymtime) |
4490 |
|
4492 |
|
4491 |
#restore umask |
4493 |
#restore umask |
4492 |
os.umask(prevmask) |
4494 |
os.umask(prevmask) |
Lines 4514-4524
Link Here
|
4514 |
del cfgfiledict["IGNORE"] |
4516 |
del cfgfiledict["IGNORE"] |
4515 |
|
4517 |
|
4516 |
# XXXX: HACK! PathSpec is very necessary here. |
4518 |
# XXXX: HACK! PathSpec is very necessary here. |
4517 |
if not os.path.exists(destroot+PRIVATE_PATH): |
4519 |
if not os.path.exists(destroot(PRIVATE_PATH)): |
4518 |
os.makedirs(destroot+PRIVATE_PATH) |
4520 |
os.makedirs(destroot(PRIVATE_PATH)) |
4519 |
os.chown(destroot+PRIVATE_PATH,os.getuid(),portage_gid) |
4521 |
os.chown(destroot(PRIVATE_PATH),os.getuid(),portage_gid) |
4520 |
os.chmod(destroot+PRIVATE_PATH,02770) |
4522 |
os.chmod(destroot(PRIVATE_PATH),02770) |
4521 |
dirlist = prefix_array(listdir(destroot+PRIVATE_PATH),destroot+PRIVATE_PATH+"/") |
4523 |
dirlist = prefix_array(listdir(destroot(PRIVATE_PATH)),destroot(PRIVATE_PATH+"/")) |
4522 |
while dirlist: |
4524 |
while dirlist: |
4523 |
dirlist.sort() |
4525 |
dirlist.sort() |
4524 |
dirlist.reverse() # Gets them in file-before basedir order |
4526 |
dirlist.reverse() # Gets them in file-before basedir order |
Lines 4526-4535
Link Here
|
4526 |
if os.path.isdir(x): |
4528 |
if os.path.isdir(x): |
4527 |
dirlist += prefix_array(listdir(x),x+"/") |
4529 |
dirlist += prefix_array(listdir(x),x+"/") |
4528 |
continue |
4530 |
continue |
4529 |
os.unlink(destroot+PRIVATE_PATH+"/"+x) |
4531 |
os.unlink(destroot(PRIVATE_PATH+"/"+x)) |
4530 |
|
4532 |
|
4531 |
mylock = portage_locks.lockfile(destroot+CONFIG_MEMORY_FILE) |
4533 |
mylock = portage_locks.lockfile(destroot(CONFIG_MEMORY_FILE)) |
4532 |
writedict(cfgfiledict,destroot+CONFIG_MEMORY_FILE) |
4534 |
writedict(cfgfiledict,destroot(CONFIG_MEMORY_FILE)) |
4533 |
portage_locks.unlockfile(mylock) |
4535 |
portage_locks.unlockfile(mylock) |
4534 |
|
4536 |
|
4535 |
#do postinst script |
4537 |
#do postinst script |
Lines 4970-5023
Link Here
|
4970 |
cleanup_pkgmerge(mypkg,origdir) |
4972 |
cleanup_pkgmerge(mypkg,origdir) |
4971 |
return returnme |
4973 |
return returnme |
4972 |
|
4974 |
|
|
|
4975 |
# for pym's not yet using portage.ROOT |
4976 |
root = ROOT |
4973 |
|
4977 |
|
4974 |
if os.environ.has_key("ROOT"): |
4978 |
def check_root(root=MYROOT): |
4975 |
root=os.environ["ROOT"] |
4979 |
mroot = root() |
4976 |
if not len(root): |
4980 |
if mroot != "/": |
4977 |
root="/" |
4981 |
if not os.path.exists(mroot[:-1]): |
4978 |
elif root[-1]!="/": |
4982 |
writemsg("!!! Error: ROOT "+mroot+" does not exist. Please correct this.\n") |
4979 |
root=root+"/" |
4983 |
writemsg("!!! Exiting.\n\n") |
4980 |
else: |
4984 |
sys.exit(1) |
4981 |
root="/" |
4985 |
elif not os.path.isdir(mroot[:-1]): |
4982 |
if root != "/": |
4986 |
writemsg("!!! Error: ROOT "+mroot[:-1]+" is not a directory. Please correct this.\n") |
4983 |
if not os.path.exists(root[:-1]): |
4987 |
writemsg("!!! Exiting.\n\n") |
4984 |
writemsg("!!! Error: ROOT "+root+" does not exist. Please correct this.\n") |
4988 |
sys.exit(1) |
4985 |
writemsg("!!! Exiting.\n\n") |
4989 |
|
4986 |
sys.exit(1) |
4990 |
#create tmp and var/tmp if they don't exist; read config |
4987 |
elif not os.path.isdir(root[:-1]): |
4991 |
checkdirs={ "tmp": 01777 |
4988 |
writemsg("!!! Error: ROOT "+root[:-1]+" is not a directory. Please correct this.\n") |
4992 |
, "var": 0755 |
4989 |
writemsg("!!! Exiting.\n\n") |
4993 |
, "var/tmp": 01777 |
4990 |
sys.exit(1) |
4994 |
, "var/log": 0755 |
4991 |
|
4995 |
, "var/lib": 0755 |
4992 |
#create tmp and var/tmp if they don't exist; read config |
4996 |
, "var/lib/portage": 0755 |
4993 |
os.umask(0) |
4997 |
} |
4994 |
if not os.path.exists(root+"tmp"): |
4998 |
os.umask(0) |
4995 |
writemsg(">>> "+root+"tmp doesn't exist, creating it...\n") |
4999 |
# hash array does not keep ordering, so list explicit |
4996 |
os.mkdir(root+"tmp",01777) |
5000 |
for d in ["tmp","var","var/tmp","var/log","var/lib","var/lib/portage"]: |
4997 |
if not os.path.exists(root+"var/tmp"): |
5001 |
dir=os.path.join(mroot,d) |
4998 |
writemsg(">>> "+root+"var/tmp doesn't exist, creating it...\n") |
5002 |
if not os.path.exists(dir): |
4999 |
try: |
5003 |
writemsg(">>> "+dir+" doesn't exist, creating it...\n") |
5000 |
os.mkdir(root+"var",0755) |
5004 |
try: |
5001 |
except (OSError,IOError): |
5005 |
os.mkdir(dir, checkdirs[d]) |
5002 |
pass |
5006 |
except SystemExit, e: |
5003 |
try: |
5007 |
raise |
5004 |
os.mkdir(root+"var/tmp",01777) |
5008 |
except: |
5005 |
except SystemExit, e: |
5009 |
writemsg("portage: could not create "+dir+"; exiting.\n") |
5006 |
raise |
5010 |
sys.exit(1) |
5007 |
except: |
5011 |
elif not os.path.isdir(dir): |
5008 |
writemsg("portage: couldn't create /var/tmp; exiting.\n") |
5012 |
writemsg("portage: "+dir+" is not a directory; exiting.\n") |
5009 |
sys.exit(1) |
5013 |
sys.exit(1) |
5010 |
|
5014 |
|
|
|
5015 |
check_root(ROOT) |
5011 |
|
5016 |
|
5012 |
##################################### |
5017 |
##################################### |
5013 |
# Deprecation Checks |
5018 |
# Deprecation Checks |
5014 |
|
5019 |
|
5015 |
os.umask(022) |
5020 |
os.umask(022) |
5016 |
profiledir=None |
5021 |
profiledir=None |
5017 |
if os.path.isdir(PROFILE_PATH): |
5022 |
if os.path.isdir(MYROOT(PROFILE_PATH)): |
5018 |
profiledir = PROFILE_PATH |
5023 |
profiledir = MYROOT(PROFILE_PATH) |
5019 |
if os.access(DEPRECATED_PROFILE_FILE, os.R_OK): |
5024 |
if os.access(MYROOT(DEPRECATED_PROFILE_FILE), os.R_OK): |
5020 |
deprecatedfile = open(DEPRECATED_PROFILE_FILE, "r") |
5025 |
deprecatedfile = open(MYROOT(DEPRECATED_PROFILE_FILE), "r") |
5021 |
dcontent = deprecatedfile.readlines() |
5026 |
dcontent = deprecatedfile.readlines() |
5022 |
deprecatedfile.close() |
5027 |
deprecatedfile.close() |
5023 |
newprofile = dcontent[0] |
5028 |
newprofile = dcontent[0] |
Lines 5030-5038
Link Here
|
5030 |
writemsg(myline) |
5035 |
writemsg(myline) |
5031 |
writemsg("\n\n") |
5036 |
writemsg("\n\n") |
5032 |
|
5037 |
|
5033 |
if os.path.exists(USER_VIRTUALS_FILE): |
5038 |
if os.path.exists(MYROOT(USER_VIRTUALS_FILE)): |
5034 |
writemsg(red("\n!!! /etc/portage/virtuals is deprecated in favor of\n")) |
5039 |
writemsg(red("\n!!! "+MYROOT(USER_VIRTUALS_FILE)+" is deprecated in favor of\n")) |
5035 |
writemsg(red("!!! /etc/portage/profile/virtuals. Please move it to\n")) |
5040 |
writemsg(red("!!! "+MYROOT(CUSTOM_PROFILE_PATH+"/virtuals")+". Please move it to\n")) |
5036 |
writemsg(red("!!! this new location.\n\n")) |
5041 |
writemsg(red("!!! this new location.\n\n")) |
5037 |
|
5042 |
|
5038 |
# |
5043 |
# |
Lines 5045-5051
Link Here
|
5045 |
# ----------------------------------------------------------------------------- |
5050 |
# ----------------------------------------------------------------------------- |
5046 |
# We're going to lock the global config to prevent changes, but we need |
5051 |
# We're going to lock the global config to prevent changes, but we need |
5047 |
# to ensure the global settings are right. |
5052 |
# to ensure the global settings are right. |
5048 |
settings=config(config_profile_path=PROFILE_PATH,config_incrementals=portage_const.INCREMENTALS) |
5053 |
settings=config(config_profile_path=MYROOT(PROFILE_PATH),config_incrementals=portage_const.INCREMENTALS) |
5049 |
|
5054 |
|
5050 |
# useful info |
5055 |
# useful info |
5051 |
settings["PORTAGE_MASTER_PID"]=str(os.getpid()) |
5056 |
settings["PORTAGE_MASTER_PID"]=str(os.getpid()) |
Lines 5053-5059
Link Here
|
5053 |
|
5058 |
|
5054 |
def do_vartree(mysettings): |
5059 |
def do_vartree(mysettings): |
5055 |
global virts, virts_p, db |
5060 |
global virts, virts_p, db |
5056 |
virts=mysettings.getvirtuals("/") |
5061 |
virts=mysettings.getvirtuals(MYROOT) |
5057 |
virts_p={} |
5062 |
virts_p={} |
5058 |
|
5063 |
|
5059 |
if virts: |
5064 |
if virts: |
Lines 5062-5074
Link Here
|
5062 |
vkeysplit=x.split("/") |
5067 |
vkeysplit=x.split("/") |
5063 |
if not virts_p.has_key(vkeysplit[1]): |
5068 |
if not virts_p.has_key(vkeysplit[1]): |
5064 |
virts_p[vkeysplit[1]]=virts[x] |
5069 |
virts_p[vkeysplit[1]]=virts[x] |
5065 |
db["/"]={ |
5070 |
db[MYROOT()]={ |
5066 |
"virtuals":virts, |
5071 |
"virtuals":virts, |
5067 |
"vartree":vartree("/",virts), |
5072 |
"vartree":vartree(MYROOT,virts), |
5068 |
} |
5073 |
} |
5069 |
if root!="/": |
5074 |
if ROOT()!=MYROOT(): |
5070 |
virts=mysettings.getvirtuals(root) |
5075 |
virts=mysettings.getvirtuals(root) |
5071 |
db[root]={ |
5076 |
db[root()]={ |
5072 |
"virtuals":virts, |
5077 |
"virtuals":virts, |
5073 |
"vartree":vartree(root,virts)} |
5078 |
"vartree":vartree(root,virts)} |
5074 |
#We need to create the vartree first, then load our settings, and then set up our other trees |
5079 |
#We need to create the vartree first, then load our settings, and then set up our other trees |
Lines 5105-5113
Link Here
|
5105 |
else: |
5110 |
else: |
5106 |
selinux_enabled=0 |
5111 |
selinux_enabled=0 |
5107 |
|
5112 |
|
5108 |
cachedirs=[CACHE_PATH] |
5113 |
cachedirs=[MYROOT(CACHE_PATH)] |
5109 |
if root!="/": |
5114 |
if ROOT()!=MYROOT(): |
5110 |
cachedirs.append(root+CACHE_PATH) |
5115 |
cachedirs.append(root(CACHE_PATH)) |
5111 |
if not os.environ.has_key("SANDBOX_ACTIVE"): |
5116 |
if not os.environ.has_key("SANDBOX_ACTIVE"): |
5112 |
for cachedir in cachedirs: |
5117 |
for cachedir in cachedirs: |
5113 |
if not os.path.exists(cachedir): |
5118 |
if not os.path.exists(cachedir): |
Lines 5146-5152
Link Here
|
5146 |
"version", "starttime", |
5151 |
"version", "starttime", |
5147 |
"resume", "ldpath" |
5152 |
"resume", "ldpath" |
5148 |
] |
5153 |
] |
5149 |
mtimedbfile=root+"var/cache/edb/mtimedb" |
5154 |
mtimedbfile=root(CACHE_PATH+"/mtimedb") |
5150 |
try: |
5155 |
try: |
5151 |
mypickle=cPickle.Unpickler(open(mtimedbfile)) |
5156 |
mypickle=cPickle.Unpickler(open(mtimedbfile)) |
5152 |
mypickle.find_global=None |
5157 |
mypickle.find_global=None |
Lines 5176-5182
Link Here
|
5176 |
writemsg("\n\n") |
5181 |
writemsg("\n\n") |
5177 |
writemsg(green("Performing Global Updates: ")+bold(mykey)+"\n") |
5182 |
writemsg(green("Performing Global Updates: ")+bold(mykey)+"\n") |
5178 |
writemsg("(Could take a couple of minutes if you have a lot of binary packages.)\n") |
5183 |
writemsg("(Could take a couple of minutes if you have a lot of binary packages.)\n") |
5179 |
writemsg(" "+bold(".")+"='update pass' "+bold("*")+"='binary update' "+bold("@")+"='/var/db move'\n"+" "+bold("s")+"='/var/db SLOT move' "+bold("S")+"='binary SLOT move' "+bold("p")+"='update /etc/portage/package.*'\n") |
5184 |
writemsg(" "+bold(".")+"='update pass' "+bold("*")+"='binary update' "+bold("@")+"='/var/db move'\n"+" "+bold("s")+"='/var/db SLOT move' "+bold("S")+"='binary SLOT move' "+bold("p")+"='update "+MYROOT(USER_CONFIG_PATH)+"/package.*'\n") |
5180 |
processed=1 |
5185 |
processed=1 |
5181 |
#remove stale virtual entries (mappings for packages that no longer exist) |
5186 |
#remove stale virtual entries (mappings for packages that no longer exist) |
5182 |
|
5187 |
|
Lines 5186-5192
Link Here
|
5186 |
myxfiles = myxfiles + prefix_array(myxfiles, "profile/") |
5191 |
myxfiles = myxfiles + prefix_array(myxfiles, "profile/") |
5187 |
for x in myxfiles: |
5192 |
for x in myxfiles: |
5188 |
try: |
5193 |
try: |
5189 |
myfile = open("/etc/portage/"+x,"r") |
5194 |
myfile = open(MYROOT("etc/portage/"+x),"r") |
5190 |
file_contents[x] = myfile.readlines() |
5195 |
file_contents[x] = myfile.readlines() |
5191 |
myfile.close() |
5196 |
myfile.close() |
5192 |
except IOError: |
5197 |
except IOError: |
Lines 5194-5202
Link Here
|
5194 |
del file_contents[x] |
5199 |
del file_contents[x] |
5195 |
continue |
5200 |
continue |
5196 |
|
5201 |
|
5197 |
worldlist=grabfile("/"+WORLD_FILE) |
5202 |
worldlist=grabfile(MYROOT(WORLD_FILE)) |
5198 |
myupd=grabfile(mykey) |
5203 |
myupd=grabfile(mykey) |
5199 |
db["/"]["bintree"]=binarytree("/",settings["PKGDIR"],virts) |
5204 |
db[MYROOT()]["bintree"]=binarytree(MYROOT,settings["PKGDIR"],virts) |
5200 |
for myline in myupd: |
5205 |
for myline in myupd: |
5201 |
mysplit=myline.split() |
5206 |
mysplit=myline.split() |
5202 |
if not len(mysplit): |
5207 |
if not len(mysplit): |
Lines 5217-5224
Link Here
|
5217 |
sys.stdout.flush() |
5222 |
sys.stdout.flush() |
5218 |
|
5223 |
|
5219 |
if mysplit[0]=="move": |
5224 |
if mysplit[0]=="move": |
5220 |
db["/"]["vartree"].dbapi.move_ent(mysplit) |
5225 |
db[MYROOT()]["vartree"].dbapi.move_ent(mysplit) |
5221 |
db["/"]["bintree"].move_ent(mysplit) |
5226 |
db[MYROOT()]["bintree"].move_ent(mysplit) |
5222 |
#update world entries: |
5227 |
#update world entries: |
5223 |
for x in range(0,len(worldlist)): |
5228 |
for x in range(0,len(worldlist)): |
5224 |
#update world entries, if any. |
5229 |
#update world entries, if any. |
Lines 5238-5252
Link Here
|
5238 |
sys.stdout.flush() |
5243 |
sys.stdout.flush() |
5239 |
|
5244 |
|
5240 |
elif mysplit[0]=="slotmove": |
5245 |
elif mysplit[0]=="slotmove": |
5241 |
db["/"]["vartree"].dbapi.move_slot_ent(mysplit) |
5246 |
db[MYROOT()]["vartree"].dbapi.move_slot_ent(mysplit) |
5242 |
db["/"]["bintree"].move_slot_ent(mysplit,settings["PORTAGE_TMPDIR"]+"/tbz2") |
5247 |
db[MYROOT()]["bintree"].move_slot_ent(mysplit,settings["PORTAGE_TMPDIR"]+"/tbz2") |
5243 |
|
5248 |
|
5244 |
for x in update_files: |
5249 |
for x in update_files: |
5245 |
mydblink = dblink('','','/',settings) |
5250 |
mydblink = dblink('','','/',settings) |
5246 |
if mydblink.isprotected("/etc/portage/"+x): |
5251 |
if mydblink.isprotected(MYROOT("etc/portage/"+x)): |
5247 |
updating_file=new_protect_filename("/etc/portage/"+x)[0] |
5252 |
updating_file=new_protect_filename(MYROOT("etc/portage/"+x))[0] |
5248 |
else: |
5253 |
else: |
5249 |
updating_file="/etc/portage/"+x |
5254 |
updating_file=MYROOT("etc/portage/"+x) |
5250 |
try: |
5255 |
try: |
5251 |
myfile=open(updating_file,"w") |
5256 |
myfile=open(updating_file,"w") |
5252 |
myfile.writelines(file_contents[x]) |
5257 |
myfile.writelines(file_contents[x]) |
Lines 5257-5270
Link Here
|
5257 |
# We gotta do the brute force updates for these now. |
5262 |
# We gotta do the brute force updates for these now. |
5258 |
if (settings["PORTAGE_CALLER"] in ["fixpackages"]) or \ |
5263 |
if (settings["PORTAGE_CALLER"] in ["fixpackages"]) or \ |
5259 |
("fixpackages" in features): |
5264 |
("fixpackages" in features): |
5260 |
db["/"]["bintree"].update_ents(myupd,settings["PORTAGE_TMPDIR"]+"/tbz2") |
5265 |
db[MYROOT()]["bintree"].update_ents(myupd,settings["PORTAGE_TMPDIR"]+"/tbz2") |
5261 |
else: |
5266 |
else: |
5262 |
do_upgrade_packagesmessage = 1 |
5267 |
do_upgrade_packagesmessage = 1 |
5263 |
|
5268 |
|
5264 |
if processed: |
5269 |
if processed: |
5265 |
#update our internal mtime since we processed all our directives. |
5270 |
#update our internal mtime since we processed all our directives. |
5266 |
mtimedb["updates"][mykey]=os.stat(mykey)[stat.ST_MTIME] |
5271 |
mtimedb["updates"][mykey]=os.stat(mykey)[stat.ST_MTIME] |
5267 |
myworld=open("/"+WORLD_FILE,"w") |
5272 |
myworld=open(MYROOT(WORLD_FILE),"w") |
5268 |
for x in worldlist: |
5273 |
for x in worldlist: |
5269 |
myworld.write(x+"\n") |
5274 |
myworld.write(x+"\n") |
5270 |
myworld.close() |
5275 |
myworld.close() |
Lines 5378-5396
Link Here
|
5378 |
|
5383 |
|
5379 |
|
5384 |
|
5380 |
#continue setting up other trees |
5385 |
#continue setting up other trees |
5381 |
db["/"]["porttree"]=portagetree("/",virts) |
5386 |
db[MYROOT()]["porttree"]=portagetree(MYROOT,virts) |
5382 |
db["/"]["bintree"]=binarytree("/",settings["PKGDIR"],virts) |
5387 |
db[MYROOT()]["bintree"]=binarytree(MYROOT,settings["PKGDIR"],virts) |
5383 |
if root!="/": |
5388 |
if ROOT()!=MYROOT(): |
5384 |
db[root]["porttree"]=portagetree(root,virts) |
5389 |
db[root()]["porttree"]=portagetree(root,virts) |
5385 |
db[root]["bintree"]=binarytree(root,settings["PKGDIR"],virts) |
5390 |
db[root()]["bintree"]=binarytree(root,settings["PKGDIR"],virts) |
5386 |
thirdpartymirrors=grabdict(settings["PORTDIR"]+"/profiles/thirdpartymirrors") |
5391 |
thirdpartymirrors=grabdict(settings["PORTDIR"]+"/profiles/thirdpartymirrors") |
5387 |
|
5392 |
|
5388 |
if not os.path.exists(settings["PORTAGE_TMPDIR"]): |
5393 |
if not os.path.exists(settings["PORTAGE_TMPDIR"]): |
5389 |
writemsg("portage: the directory specified in your PORTAGE_TMPDIR variable, \""+settings["PORTAGE_TMPDIR"]+",\"\n") |
5394 |
writemsg("portage: the directory specified in your PORTAGE_TMPDIR variable, \""+settings["PORTAGE_TMPDIR"]+"\",\n") |
5390 |
writemsg("does not exist. Please create this directory or correct your PORTAGE_TMPDIR setting.\n") |
5395 |
writemsg("does not exist. Please create this directory or correct your PORTAGE_TMPDIR setting.\n") |
5391 |
sys.exit(1) |
5396 |
sys.exit(1) |
5392 |
if not os.path.isdir(settings["PORTAGE_TMPDIR"]): |
5397 |
if not os.path.isdir(settings["PORTAGE_TMPDIR"]): |
5393 |
writemsg("portage: the directory specified in your PORTAGE_TMPDIR variable, \""+settings["PORTAGE_TMPDIR"]+",\"\n") |
5398 |
writemsg("portage: the directory specified in your PORTAGE_TMPDIR variable, \""+settings["PORTAGE_TMPDIR"]+"\",\n") |
5394 |
writemsg("is not a directory. Please correct your PORTAGE_TMPDIR setting.\n") |
5399 |
writemsg("is not a directory. Please correct your PORTAGE_TMPDIR setting.\n") |
5395 |
sys.exit(1) |
5400 |
sys.exit(1) |
5396 |
|
5401 |
|
Lines 5453-5460
Link Here
|
5453 |
return fetcher |
5458 |
return fetcher |
5454 |
return transports.bundled_lib.BundledConnection() |
5459 |
return transports.bundled_lib.BundledConnection() |
5455 |
|
5460 |
|
5456 |
if not os.path.islink(PROFILE_PATH) and os.path.exists(settings["PORTDIR"]+"/profiles"): |
5461 |
if not os.path.islink(MYROOT(PROFILE_PATH)) and os.path.exists(settings["PORTDIR"]+"/profiles"): |
5457 |
writemsg(red("\a\n\n!!! "+PROFILE_PATH+" is not a symlink and will probably prevent most merges.\n")) |
5462 |
writemsg(red("\a\n\n!!! "+MYROOT(PROFILE_PATH)+" is not a symlink and will probably prevent most merges.\n")) |
5458 |
writemsg(red("!!! It should point into a profile within %s/profiles/\n" % settings["PORTDIR"])) |
5463 |
writemsg(red("!!! It should point into a profile within %s/profiles/\n" % settings["PORTDIR"])) |
5459 |
writemsg(red("!!! (You can safely ignore this message when syncing. It's harmless.)\n\n\n")) |
5464 |
writemsg(red("!!! (You can safely ignore this message when syncing. It's harmless.)\n\n\n")) |
5460 |
time.sleep(3) |
5465 |
time.sleep(3) |