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 848-854
Link Here
|
848 |
def outdated(self): |
857 |
def outdated(self): |
849 |
return self.outdatedpackages |
858 |
return self.outdatedpackages |
850 |
|
859 |
|
851 |
def merge(self,mylist): |
860 |
def merge(self,mylist,mydigraph=None): |
852 |
returnme=0 |
861 |
returnme=0 |
853 |
#check for blocking dependencies |
862 |
#check for blocking dependencies |
854 |
for x in mylist: |
863 |
for x in mylist: |
Lines 861-961
Link Here
|
861 |
if mylist[x][3]!="nomerge": |
870 |
if mylist[x][3]!="nomerge": |
862 |
mymergelist.append(mylist[x]) |
871 |
mymergelist.append(mylist[x]) |
863 |
|
872 |
|
864 |
mergecount=0 |
873 |
mygraph=None # dependencies not satisfied yet |
865 |
for x in mymergelist: |
874 |
if mydigraph!=None: mygraph=mydigraph.copy() |
866 |
mergecount+=1 |
875 |
mybuiltlist=[] # packages successfully built (in order) |
867 |
myroot=x[1] |
876 |
trycount=0 # number of `try to merge' done |
868 |
#the last argument in the portage.doebuild() tells doebuild to *not* do dep checking |
877 |
passcount=0 # pass number |
869 |
#(emerge is already handling that) |
878 |
passmergecount=0 # number of packages merged in this pass |
870 |
y=portage.portdb.findname(x[2]) |
879 |
# package key filter: should be merged packages only |
871 |
if not "--pretend" in myopts: |
880 |
merge_only_filter=lambda p: string.split(p)[3] == "merge" |
872 |
print ">>> emerge ("+str(mergecount)+" of "+str(len(mymergelist))+")",x[2],"to",x[1] |
881 |
# each pass, packages not successfully built yet are built |
873 |
emergelog(" >>> emerge ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
882 |
# it takes care of dependencies though |
874 |
if x[0]=="ebuild": |
883 |
while 1: |
875 |
if "--fetchonly" in myopts: |
884 |
passmergecount=0 |
876 |
retval=portage.doebuild(y,"fetch",myroot,edebug,("--pretend" in myopts)) |
885 |
for x in mymergelist: |
877 |
if retval: |
886 |
if mygraph!=None and not x[2] in map((lambda xkey: string.split(xkey)[2]), mygraph.allroots(merge_only_filter)): continue |
878 |
print |
887 |
if "--verbose" in myopts: |
879 |
print "!!! Fetch for",y,"failed, continuing..." |
888 |
print "merge starting: "+x[2] |
880 |
print |
889 |
sys.stdout.flush() |
881 |
returnme=1 |
890 |
trycount+=1 |
882 |
elif "--buildpkg" in myopts: |
891 |
myroot=x[1] |
883 |
#create pkg, then merge pkg |
892 |
#the last argument in the portage.doebuild() tells doebuild to *not* do dep checking |
884 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
893 |
#(emerge is already handling that) |
885 |
if retval: |
894 |
y=portage.portdb.findname(x[2]) |
886 |
sys.exit(1) |
895 |
if not "--pretend" in myopts: |
887 |
retval=portage.doebuild(y,"package",myroot,edebug) |
896 |
print ">>> emerge ("+str(trycount)+" of "+str(len(mymergelist))+")",x[2],"to",x[1] |
888 |
if retval: |
897 |
emergelog(" >>> emerge ("+str(trycount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
889 |
sys.exit(1) |
898 |
if x[0]=="ebuild": |
890 |
#dynamically update our database |
899 |
if "--fetchonly" in myopts: |
891 |
portage.db[portage.root]["bintree"].inject(x[2]) |
900 |
retval=portage.doebuild(y,"fetch",myroot,edebug,("--pretend" in myopts)) |
|
|
901 |
if retval: |
902 |
print |
903 |
print "!!! Fetch for",y,"failed, continuing..." |
904 |
print |
905 |
returnme=1 |
906 |
elif "--buildpkg" in myopts: |
907 |
#create pkg, then merge pkg |
908 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
909 |
if retval: |
910 |
if "--firstfail" in myopts: sys.exit(1) |
911 |
else: continue |
912 |
retval=portage.doebuild(y,"package",myroot,edebug) |
913 |
if retval: |
914 |
if "--firstfail" in myopts: sys.exit(1) |
915 |
else: continue |
916 |
#dynamically update our database |
917 |
portage.db[portage.root]["bintree"].inject(x[2]) |
918 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
919 |
retval=portage.pkgmerge(mytbz2,myroot) |
920 |
if retval==None: |
921 |
if "--firstfail" in myopts: sys.exit(1) |
922 |
else: continue |
923 |
else: |
924 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
925 |
if retval: |
926 |
if "--firstfail" in myopts: sys.exit(1) |
927 |
else: continue |
928 |
retval=portage.doebuild(y,"merge",myroot,edebug) |
929 |
if retval: |
930 |
if "--firstfail" in myopts: sys.exit(1) |
931 |
else: continue |
932 |
#dynamically update our database |
933 |
elif x[0]=="binary": |
934 |
#merge the tbz2 |
892 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
935 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
893 |
retval=portage.pkgmerge(mytbz2,myroot) |
936 |
retval=portage.pkgmerge(mytbz2,x[1]) |
894 |
if retval==None: |
937 |
if retval==None: |
895 |
sys.exit(1) |
938 |
sys.exit(1) |
896 |
else: |
939 |
#need to check for errors |
|
|
940 |
portage.db[x[1]]["vartree"].inject(x[2]) |
941 |
myfavkey=portage.cpv_getkey(x[2]) |
942 |
if (not "--fetchonly" in myopts) and (myfavkey in favorites): |
943 |
myfavs=portage.grabfile(myroot+"var/cache/edb/world") |
944 |
myfavdict=genericdict(myfavs) |
945 |
mysysdict=genericdict(syslist) |
946 |
#don't record if already in system profile or already recorded |
947 |
if (not mysysdict.has_key(myfavkey)) and (not myfavdict.has_key(myfavkey)): |
948 |
#we don't have a favorites entry for this package yet; add one |
949 |
myfavdict[myfavkey]=myfavkey |
950 |
print ">>> Recording",myfavkey,"in \"world\" favorites file..." |
951 |
portage.writedict(myfavdict,myroot+"var/cache/edb/world",writekey=0) |
952 |
|
953 |
if "--autoclean" in myopts: |
897 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
954 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
898 |
if retval: |
955 |
if retval: |
899 |
sys.exit(1) |
956 |
sys.exit(1) |
900 |
retval=portage.doebuild(y,"merge",myroot,edebug) |
957 |
|
901 |
if retval: |
958 |
if ("--pretend" not in myopts) and ("--fetchonly" not in myopts): |
902 |
sys.exit(1) |
959 |
# Clean the old package that we have merged over top of it. |
903 |
#dynamically update our database |
960 |
if portage.settings["AUTOCLEAN"] and (portage.settings["AUTOCLEAN"]=="yes"): |
904 |
elif x[0]=="binary": |
961 |
xsplit=portage.pkgsplit(x[2]) |
905 |
#merge the tbz2 |
962 |
emergelog(" >>> AUTOCLEAN: "+xsplit[0]) |
906 |
mytbz2=portage.db[portage.root]["bintree"].getname(x[2]) |
963 |
if not unmerge("clean", [xsplit[0]]): |
907 |
retval=portage.pkgmerge(mytbz2,x[1]) |
964 |
emergelog(" --- AUTOCLEAN: Nothing unmerged.") |
908 |
if retval==None: |
965 |
emergelog(" ::: completed emerge ("+str(trycount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
909 |
sys.exit(1) |
966 |
|
910 |
#need to check for errors |
967 |
mysplit=portage.pkgsplit(x[2]) |
911 |
portage.db[x[1]]["vartree"].inject(x[2]) |
968 |
if mysplit[0]=="sys-apps/portage": |
912 |
myfavkey=portage.cpv_getkey(x[2]) |
969 |
if mysplit[1]+"-"+mysplit[2]!=portage.VERSION: |
913 |
if (not "--fetchonly" in myopts) and (myfavkey in favorites): |
970 |
if len(mymergelist) > trycount: |
914 |
myfavs=portage.grabfile(myroot+"var/cache/edb/world") |
971 |
myargv=sys.argv |
915 |
myfavdict=genericdict(myfavs) |
972 |
myr=0 |
916 |
mysysdict=genericdict(syslist) |
973 |
for myra in range(len(myargv)): |
917 |
#don't record if already in system profile or already recorded |
974 |
print "Considering:",myargv[myr] |
918 |
if (not mysysdict.has_key(myfavkey)) and (not myfavdict.has_key(myfavkey)): |
975 |
if myargv[myr][0:len("portage")]=="portage": |
919 |
#we don't have a favorites entry for this package yet; add one |
976 |
print "deleted:",myargv[myr] |
920 |
myfavdict[myfavkey]=myfavkey |
977 |
del myargv[myr] |
921 |
print ">>> Recording",myfavkey,"in \"world\" favorites file..." |
978 |
myr-=1 |
922 |
portage.writedict(myfavdict,myroot+"var/cache/edb/world",writekey=0) |
979 |
if myargv[myr][0:len("sys-apps/portage")]=="sys-apps/portage": |
923 |
|
980 |
print "deleted:",myargv[myr] |
924 |
if "--autoclean" in myopts: |
981 |
del myargv[myr] |
925 |
retval=portage.doebuild(y,"clean",myroot,edebug) |
982 |
myr-=1 |
926 |
if retval: |
983 |
myr+=1 |
927 |
sys.exit(1) |
984 |
emergelog(" *** RESTARTING emerge via exec() after change of portage version.") |
928 |
|
985 |
os.execv("/usr/lib/portage/bin/emerge", myargv) |
929 |
if ("--pretend" not in myopts) and ("--fetchonly" not in myopts): |
986 |
mybuiltlist.append(x) |
930 |
# Clean the old package that we have merged over top of it. |
987 |
if mygraph!=None: mygraph.delnode(string.join(x)) |
931 |
if portage.settings["AUTOCLEAN"] and (portage.settings["AUTOCLEAN"]=="yes"): |
988 |
passmergecount+=1 |
932 |
xsplit=portage.pkgsplit(x[2]) |
989 |
if len(mybuiltlist)==len(mymergelist): break |
933 |
emergelog(" >>> AUTOCLEAN: "+xsplit[0]) |
990 |
if "--retry" in myopts and passmergecount!=0: |
934 |
if not unmerge("clean", [xsplit[0]]): |
991 |
passcount+=1 |
935 |
emergelog(" --- AUTOCLEAN: Nothing unmerged.") |
992 |
continue |
936 |
emergelog(" ::: completed emerge ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[2]+" to "+x[1]) |
993 |
print "Some packages have not been built:" |
937 |
|
994 |
for p in mymergelist: |
938 |
mysplit=portage.pkgsplit(x[2]) |
995 |
if p in mybuiltlist: |
939 |
if mysplit[0]=="sys-apps/portage": |
996 |
print " "+p[2]+" successfully built" |
940 |
if mysplit[1]+"-"+mysplit[2]!=portage.VERSION: |
997 |
else: |
941 |
if len(mymergelist) > mergecount: |
998 |
print " "+p[2]+" building failure" |
942 |
myargv=sys.argv |
999 |
sys.exit(1) |
943 |
myr=0 |
|
|
944 |
for myra in range(len(myargv)): |
945 |
print "Considering:",myargv[myr] |
946 |
if myargv[myr][0:len("portage")]=="portage": |
947 |
print "deleted:",myargv[myr] |
948 |
del myargv[myr] |
949 |
myr-=1 |
950 |
if myargv[myr][0:len("sys-apps/portage")]=="sys-apps/portage": |
951 |
print "deleted:",myargv[myr] |
952 |
del myargv[myr] |
953 |
myr-=1 |
954 |
myr+=1 |
955 |
emergelog(" *** RESTARTING emerge via exec() after change of portage version.") |
956 |
os.execv("/usr/lib/portage/bin/emerge", myargv) |
957 |
|
1000 |
|
958 |
if ("--pretend" not in myopts) and (mergecount>0): |
1001 |
if ("--pretend" not in myopts) and (trycount>0): |
959 |
portage.env_update() |
1002 |
portage.env_update() |
960 |
|
1003 |
|
961 |
|
1004 |
|
Lines 1532-1544
Link Here
|
1532 |
print "Calculating dependencies ", |
1575 |
print "Calculating dependencies ", |
1533 |
retval,favorites=mydepgraph.select_files(myfiles) |
1576 |
retval,favorites=mydepgraph.select_files(myfiles) |
1534 |
if not retval: |
1577 |
if not retval: |
1535 |
print "\n!!! Error calculating dependancies. Please correct." |
1578 |
print "\n!!! Error calculating dependencies. Please correct." |
1536 |
sys.exit(1) |
1579 |
sys.exit(1) |
1537 |
print "\b\b ...done!" |
1580 |
print "\b\b ...done!" |
1538 |
if ("--pretend" in myopts) and not ("--fetchonly" in myopts): |
1581 |
if ("--pretend" in myopts) and not ("--fetchonly" in myopts): |
1539 |
mydepgraph.display(mydepgraph.altlist()) |
1582 |
mydepgraph.display(mydepgraph.altlist()) |
1540 |
else: |
1583 |
else: |
1541 |
mydepgraph.merge(mydepgraph.altlist()) |
1584 |
if "--retry" in myopts and not "--firstfail" in myopts: |
|
|
1585 |
mydepgraph.merge(mydepgraph.altlist(), mydepgraph.digraph) |
1586 |
else: |
1587 |
mydepgraph.merge(mydepgraph.altlist()) |
1542 |
if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: |
1588 |
if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: |
1543 |
print ">>> Auto-cleaning packages ..." |
1589 |
print ">>> Auto-cleaning packages ..." |
1544 |
unmerge("clean", ["world"]) |
1590 |
unmerge("clean", ["world"]) |