Lines 15-22
Link Here
|
15 |
merged=0 |
15 |
merged=0 |
16 |
params=["selective", "deep", "self", "recurse", "empty"] |
16 |
params=["selective", "deep", "self", "recurse", "empty"] |
17 |
actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean"] |
17 |
actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean"] |
18 |
options=["--autoclean", "--deep", "--selective", "--buildpkg", "--debug", "--nodeps", "--emptytree", "--fetchonly", "--changelog", |
18 |
options=["--autoclean", "--deep", "--selective", "--buildpkg", "--debug", "--nodeps", "--emptytree", "--fetchonly", "--changelog", "--firstfail", |
19 |
"--noreplace", "--onlydeps", "--pretend", "--usepkg", "--usepkgonly", "--searchdesc", "--verbose", "--update", "--help", "--oneshot", "--version"] |
19 |
"--noreplace", "--onlydeps", "--pretend", "--retry", "--usepkg", "--usepkgonly", "--searchdesc", "--verbose", "--update", "--help", "--oneshot", "--version"] |
20 |
|
20 |
|
21 |
shortmapping={"a":"--autoclean", "b":"--buildpkg", "c":"clean", "C":"unmerge", "e":"--emptytree", "d":"--debug", "f":"--fetchonly", |
21 |
shortmapping={"a":"--autoclean", "b":"--buildpkg", "c":"clean", "C":"unmerge", "e":"--emptytree", "d":"--debug", "f":"--fetchonly", |
22 |
"h":"--help", "k":"--usepkg", "K":"--usepkgonly", "n":"--noreplace", "o":"--onlydeps", "p":"--pretend", "P":"prune", "s":"search", |
22 |
"h":"--help", "k":"--usepkg", "K":"--usepkgonly", "n":"--noreplace", "o":"--onlydeps", "p":"--pretend", "P":"prune", "s":"search", |
Lines 427-434
Link Here
|
427 |
#IUSE-aware emerge |
427 |
#IUSE-aware emerge |
428 |
#"no downgrade" emerge |
428 |
#"no downgrade" emerge |
429 |
jbigkey=string.join(mybigkey) |
429 |
jbigkey=string.join(mybigkey) |
|
|
430 |
#this conditional is needed to prevent infinite recursion on already-processed deps |
430 |
if self.digraph.hasnode(jbigkey+" merge") or self.digraph.hasnode(jbigkey+" nomerge"): |
431 |
if self.digraph.hasnode(jbigkey+" merge") or self.digraph.hasnode(jbigkey+" nomerge"): |
431 |
#this conditional is needed to prevent infinite recursion on already-processed deps |
432 |
# just make sure myparent is registered |
|
|
433 |
if myparent==None: return 1 |
434 |
for mymergetype in ["merge", "nomerge"]: |
435 |
existingkey=jbigkey+" "+mymergetype |
436 |
if not self.digraph.hasnode(existingkey): continue |
437 |
if myparent in self.digraph.parents(existingkey): return 1 |
438 |
self.digraph.addnode(existingkey,myparent) |
439 |
return 1 |
440 |
print "should not reach this point" |
432 |
return 1 |
441 |
return 1 |
433 |
|
442 |
|
434 |
update_spinner() |
443 |
update_spinner() |
Lines 854-860
Link Here
|
854 |
def outdated(self): |
863 |
def outdated(self): |
855 |
return self.outdatedpackages |
864 |
return self.outdatedpackages |
856 |
|
865 |
|
857 |
def merge(self,mylist): |
866 |
def merge(self,mylist,mydigraph=None): |
858 |
returnme=0 |
867 |
returnme=0 |
859 |
#check for blocking dependencies |
868 |
#check for blocking dependencies |
860 |
for x in mylist: |
869 |
for x in mylist: |
Lines 867-967
Link Here
|
867 |
if mylist[x][3]!="nomerge": |
876 |
if mylist[x][3]!="nomerge": |
868 |
mymergelist.append(mylist[x]) |
877 |
mymergelist.append(mylist[x]) |
869 |
|
878 |
|
870 |
mergecount=0 |
879 |
mygraph=None # dependencies not satisfied yet |
871 |
for x in mymergelist: |
880 |
if mydigraph!=None: mygraph=mydigraph.copy() |
872 |
mergecount+=1 |
881 |
mybuiltlist=[] # packages successfully built (in order) |
873 |
myroot=x[1] |
882 |
trycount=0 # number of `try to merge' done |
874 |
#the last argument in the portage.doebuild() tells doebuild to *not* do dep checking |
883 |
passcount=0 # pass number |
875 |
#(emerge is already handling that) |
884 |
passmergecount=0 # number of packages merged in this pass |
876 |
y=portage.portdb.findname(x[2]) |
885 |
# package key filter: should be merged packages only |
877 |
if not "--pretend" in myopts: |
886 |
merge_only_filter=lambda p: string.split(p)[3] == "merge" |
878 |
print ">>> emerge ("+str(mergecount)+" of "+str(len(mymergelist))+")",x[2],"to",x[1] |
887 |
# each pass, packages not successfully built yet are built |
879 |
emergelog(" >>> emerge ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
888 |
# it takes care of dependencies though |
880 |
if x[0]=="ebuild": |
889 |
while 1: |
881 |
if "--fetchonly" in myopts: |
890 |
passmergecount=0 |
882 |
retval=portage.doebuild(y,"fetch",myroot,edebug,("--pretend" in myopts)) |
891 |
for x in mymergelist: |
883 |
if retval: |
892 |
if mygraph!=None and not x[2] in map((lambda xkey: string.split(xkey)[2]), mygraph.allroots(merge_only_filter)): continue |
884 |
print |
893 |
if "--verbose" in myopts: |
885 |
print "!!! Fetch for",y,"failed, continuing..." |
894 |
print "merge starting: "+x[2] |
886 |
print |
895 |
sys.stdout.flush() |
887 |
returnme=1 |
896 |
trycount+=1 |
888 |
elif "--buildpkg" in myopts: |
897 |
myroot=x[1] |
889 |
#create pkg, then merge pkg |
898 |
#the last argument in the portage.doebuild() tells doebuild to *not* do dep checking |
890 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
899 |
#(emerge is already handling that) |
891 |
if retval: |
900 |
y=portage.portdb.findname(x[2]) |
892 |
sys.exit(1) |
901 |
if not "--pretend" in myopts: |
893 |
retval=portage.doebuild(y,"package",myroot,edebug) |
902 |
print ">>> emerge ("+str(trycount)+" of "+str(len(mymergelist))+")",x[2],"to",x[1] |
894 |
if retval: |
903 |
emergelog(" >>> emerge ("+str(trycount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
895 |
sys.exit(1) |
904 |
if x[0]=="ebuild": |
896 |
#dynamically update our database |
905 |
if "--fetchonly" in myopts: |
897 |
portage.db[portage.root]["bintree"].inject(x[2]) |
906 |
retval=portage.doebuild(y,"fetch",myroot,edebug,("--pretend" in myopts)) |
|
|
907 |
if retval: |
908 |
print |
909 |
print "!!! Fetch for",y,"failed, continuing..." |
910 |
print |
911 |
returnme=1 |
912 |
elif "--buildpkg" in myopts: |
913 |
#create pkg, then merge pkg |
914 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
915 |
if retval: |
916 |
if "--firstfail" in myopts: sys.exit(1) |
917 |
else: continue |
918 |
retval=portage.doebuild(y,"package",myroot,edebug) |
919 |
if retval: |
920 |
if "--firstfail" in myopts: sys.exit(1) |
921 |
else: continue |
922 |
#dynamically update our database |
923 |
portage.db[portage.root]["bintree"].inject(x[2]) |
924 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
925 |
retval=portage.pkgmerge(mytbz2,myroot) |
926 |
if retval==None: |
927 |
if "--firstfail" in myopts: sys.exit(1) |
928 |
else: continue |
929 |
else: |
930 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
931 |
if retval: |
932 |
if "--firstfail" in myopts: sys.exit(1) |
933 |
else: continue |
934 |
retval=portage.doebuild(y,"merge",myroot,edebug) |
935 |
if retval: |
936 |
if "--firstfail" in myopts: sys.exit(1) |
937 |
else: continue |
938 |
#dynamically update our database |
939 |
elif x[0]=="binary": |
940 |
#merge the tbz2 |
898 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
941 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
899 |
retval=portage.pkgmerge(mytbz2,myroot) |
942 |
retval=portage.pkgmerge(mytbz2,x[1]) |
900 |
if retval==None: |
943 |
if retval==None: |
901 |
sys.exit(1) |
944 |
sys.exit(1) |
902 |
else: |
945 |
#need to check for errors |
|
|
946 |
portage.db[x[1]]["vartree"].inject(x[2]) |
947 |
myfavkey=portage.cpv_getkey(x[2]) |
948 |
if (not "--fetchonly" in myopts) and (myfavkey in favorites): |
949 |
myfavs=portage.grabfile(myroot+"var/cache/edb/world") |
950 |
myfavdict=genericdict(myfavs) |
951 |
mysysdict=genericdict(syslist) |
952 |
#don't record if already in system profile or already recorded |
953 |
if (not mysysdict.has_key(myfavkey)) and (not myfavdict.has_key(myfavkey)): |
954 |
#we don't have a favorites entry for this package yet; add one |
955 |
myfavdict[myfavkey]=myfavkey |
956 |
print ">>> Recording",myfavkey,"in \"world\" favorites file..." |
957 |
portage.writedict(myfavdict,myroot+"var/cache/edb/world",writekey=0) |
958 |
|
959 |
if "--autoclean" in myopts: |
903 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
960 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
904 |
if retval: |
961 |
if retval: |
905 |
sys.exit(1) |
962 |
sys.exit(1) |
906 |
retval=portage.doebuild(y,"merge",myroot,edebug) |
963 |
|
907 |
if retval: |
964 |
if ("--pretend" not in myopts) and ("--fetchonly" not in myopts): |
908 |
sys.exit(1) |
965 |
# Clean the old package that we have merged over top of it. |
909 |
#dynamically update our database |
966 |
if portage.settings["AUTOCLEAN"] and (portage.settings["AUTOCLEAN"]=="yes"): |
910 |
elif x[0]=="binary": |
967 |
xsplit=portage.pkgsplit(x[2]) |
911 |
#merge the tbz2 |
968 |
emergelog(" >>> AUTOCLEAN: "+xsplit[0]) |
912 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
969 |
if not unmerge("clean", [xsplit[0]]): |
913 |
retval=portage.pkgmerge(mytbz2,x[1]) |
970 |
emergelog(" --- AUTOCLEAN: Nothing unmerged.") |
914 |
if retval==None: |
971 |
emergelog(" ::: completed emerge ("+str(trycount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
915 |
sys.exit(1) |
972 |
|
916 |
#need to check for errors |
973 |
mysplit=portage.pkgsplit(x[2]) |
917 |
portage.db[x[1]]["vartree"].inject(x[2]) |
974 |
if mysplit[0]=="sys-apps/portage": |
918 |
myfavkey=portage.cpv_getkey(x[2]) |
975 |
if mysplit[1]+"-"+mysplit[2]!=portage.VERSION: |
919 |
if (not "--fetchonly" in myopts) and (myfavkey in favorites): |
976 |
if len(mymergelist) > trycount: |
920 |
myfavs=portage.grabfile(myroot+"var/cache/edb/world") |
977 |
myargv=sys.argv |
921 |
myfavdict=genericdict(myfavs) |
978 |
myr=0 |
922 |
mysysdict=genericdict(syslist) |
979 |
for myra in range(len(myargv)): |
923 |
#don't record if already in system profile or already recorded |
980 |
print "Considering:",myargv[myr] |
924 |
if (not mysysdict.has_key(myfavkey)) and (not myfavdict.has_key(myfavkey)): |
981 |
if myargv[myr][0:len("portage")]=="portage": |
925 |
#we don't have a favorites entry for this package yet; add one |
982 |
print "deleted:",myargv[myr] |
926 |
myfavdict[myfavkey]=myfavkey |
983 |
del myargv[myr] |
927 |
print ">>> Recording",myfavkey,"in \"world\" favorites file..." |
984 |
myr-=1 |
928 |
portage.writedict(myfavdict,myroot+"var/cache/edb/world",writekey=0) |
985 |
if myargv[myr][0:len("sys-apps/portage")]=="sys-apps/portage": |
929 |
|
986 |
print "deleted:",myargv[myr] |
930 |
if "--autoclean" in myopts: |
987 |
del myargv[myr] |
931 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
988 |
myr-=1 |
932 |
if retval: |
989 |
myr+=1 |
933 |
sys.exit(1) |
990 |
emergelog(" *** RESTARTING emerge via exec() after change of portage version.") |
934 |
|
991 |
os.execv("/usr/lib/portage/bin/emerge", myargv) |
935 |
if ("--pretend" not in myopts) and ("--fetchonly" not in myopts): |
992 |
mybuiltlist.append(x) |
936 |
# Clean the old package that we have merged over top of it. |
993 |
if mygraph!=None: mygraph.delnode(string.join(x)) |
937 |
if portage.settings["AUTOCLEAN"] and (portage.settings["AUTOCLEAN"]=="yes"): |
994 |
passmergecount+=1 |
938 |
xsplit=portage.pkgsplit(x[2]) |
995 |
if len(mybuiltlist)==len(mymergelist): break |
939 |
emergelog(" >>> AUTOCLEAN: "+xsplit[0]) |
996 |
if "--retry" in myopts and passmergecount!=0: |
940 |
if not unmerge("clean", [xsplit[0]]): |
997 |
passcount+=1 |
941 |
emergelog(" --- AUTOCLEAN: Nothing unmerged.") |
998 |
continue |
942 |
emergelog(" ::: completed emerge ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
999 |
print "Some packages have not been built:" |
943 |
|
1000 |
for p in mymergelist: |
944 |
mysplit=portage.pkgsplit(x[2]) |
1001 |
if p in mybuiltlist: |
945 |
if mysplit[0]=="sys-apps/portage": |
1002 |
print " "+p[2]+" successfully built" |
946 |
if mysplit[1]+"-"+mysplit[2]!=portage.VERSION: |
1003 |
else: |
947 |
if len(mymergelist) > mergecount: |
1004 |
print " "+p[2]+" building failure" |
948 |
myargv=sys.argv |
1005 |
sys.exit(1) |
949 |
myr=0 |
|
|
950 |
for myra in range(len(myargv)): |
951 |
print "Considering:",myargv[myr] |
952 |
if myargv[myr][0:len("portage")]=="portage": |
953 |
print "deleted:",myargv[myr] |
954 |
del myargv[myr] |
955 |
myr-=1 |
956 |
if myargv[myr][0:len("sys-apps/portage")]=="sys-apps/portage": |
957 |
print "deleted:",myargv[myr] |
958 |
del myargv[myr] |
959 |
myr-=1 |
960 |
myr+=1 |
961 |
emergelog(" *** RESTARTING emerge via exec() after change of portage version.") |
962 |
os.execv("/usr/lib/portage/bin/emerge", myargv) |
963 |
|
1006 |
|
964 |
if ("--pretend" not in myopts) and (mergecount>0): |
1007 |
if ("--pretend" not in myopts) and (trycount>0): |
965 |
portage.env_update() |
1008 |
portage.env_update() |
966 |
|
1009 |
|
967 |
|
1010 |
|
Lines 1538-1550
Link Here
|
1538 |
print "Calculating dependencies ", |
1581 |
print "Calculating dependencies ", |
1539 |
retval,favorites=mydepgraph.select_files(myfiles) |
1582 |
retval,favorites=mydepgraph.select_files(myfiles) |
1540 |
if not retval: |
1583 |
if not retval: |
1541 |
print "\n!!! Error calculating dependancies. Please correct." |
1584 |
print "\n!!! Error calculating dependencies. Please correct." |
1542 |
sys.exit(1) |
1585 |
sys.exit(1) |
1543 |
print "\b\b ...done!" |
1586 |
print "\b\b ...done!" |
1544 |
if ("--pretend" in myopts) and not ("--fetchonly" in myopts): |
1587 |
if ("--pretend" in myopts) and not ("--fetchonly" in myopts): |
1545 |
mydepgraph.display(mydepgraph.altlist()) |
1588 |
mydepgraph.display(mydepgraph.altlist()) |
1546 |
else: |
1589 |
else: |
1547 |
mydepgraph.merge(mydepgraph.altlist()) |
1590 |
if "--retry" in myopts and not "--firstfail" in myopts: |
|
|
1591 |
mydepgraph.merge(mydepgraph.altlist(), mydepgraph.digraph) |
1592 |
else: |
1593 |
mydepgraph.merge(mydepgraph.altlist()) |
1548 |
if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: |
1594 |
if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: |
1549 |
print ">>> Auto-cleaning packages ..." |
1595 |
print ">>> Auto-cleaning packages ..." |
1550 |
unmerge("clean", ["world"]) |
1596 |
unmerge("clean", ["world"]) |