--- emerge 2003-05-01 14:47:56.000000000 +0200 +++ emerge-interactive 2003-05-01 02:32:10.000000000 +0200 @@ -23,13 +23,13 @@ "--changelog", "--columns", "--debug", "--deep", "--emptytree", "--fetchonly", -"--help", "--noconfmem", +"--help", "--interactive", "--noconfmem", "--nodeps", "--noreplace", "--nospinner", "--oneshot", "--onlydeps", "--pretend", "--quiet", "--resume", "--searchdesc", "--selective", -"--update", "--upgradeonly", +"--update", "--upgradeonly", "--usecustom", "--usepkg", "--usepkgonly", "--verbose", "--version" ] @@ -41,7 +41,7 @@ "e":"--emptytree", "f":"--fetchonly", "h":"--help", -"i":"--inject", +"i":"--inject", "I":"--interactive", "k":"--usepkg", "K":"--usepkgonly", "l":"--changelog", "n":"--noreplace", @@ -1095,6 +1095,8 @@ myroot=x[1] #the last argument in the portage.doebuild() tells doebuild to *not* do dep checking #(emerge is already handling that) + + y=portage.portdb.findname(x[2]) if not "--pretend" in myopts: print ">>> emerge ("+str(mergecount)+" of "+str(len(mymergelist))+")",x[2],"to",x[1] @@ -1820,6 +1822,171 @@ print darkgreen("emerge: It seems we have nothing to resume...") sys.exit(0) + if myaction not in ["system","world"]: + if not myfiles: + print "emerge: please tell me what to do." + help() + sys.exit(1) + #we don't have any files to process; skip this step and exit + + # INTERACTIVE MODE + if "--interactive" in myopts: + print ">>> Per packages interactive USE management" + mydepgraph = depgraph (myaction,myopts) + if myaction not in ["system","world"]: + ret,files = mydepgraph.select_files (myfiles) + else: + if not mydepgraph.xcreate(myaction): + print "!!! Depgraph creation failed." + sys.exit(1) + + mygraph = mydepgraph.digraph.copy() + retlist = mygraph.dict.keys() + + files = [] + for i in retlist: + i = string.split (i) + if i[1] == "blocks": + print "!!! Error: Conflict problem..." + sys.exit(1) + if i[3] == "merge": + if myaction not in ["system","world"]: + for j in mygraph.dict.keys(): + try: + files.index(string.split(j,' ')) + except: + files.append(string.split(j,' ')) + else: + try: + files.index(i) + except: + files.append(i) + for x in files: + t=portage.portdb.xmatch("bestmatch-visible",x[2]) + if t != '': + x=t + print ">>> Interactive mode for "+green(x[2]) + + useruse=[] + explode = string.split (x[2],"/") + mycat=explode[0] + mypkg=explode[1] + + if "--update" not in myopts: + whichpkg = mypkg + whichcat = mycat + else: + # we take the old package USECUSTOM + myoldbest=portage.best(portage.db[x[1]]["vartree"].dbapi.match(portage.pkgsplit(x[2])[0])) + myoldbest = string.split (myoldbest,'/') + whichcat = myoldbest[0] + whichpkg = myoldbest[1] + + mydblink = portage.dblink (whichcat,whichpkg,'/var/tmp/portage') + + + usecustom = mydblink.getelements("USECUSTOM") + do_ask=1 + if usecustom != [] and "--usecustom" not in myopts: + to_print = "Use previous USE flags for this package? (" + for u in usecustom: + if u != "": + if u[0] == '-': + to_print = to_print+blue(u) + else: + to_print = to_print+green("+"+u) + to_print = to_print+" " + choice = raw_input (to_print+") [Y/n] ").lower () + if choice != '': + if choice[0] == 'y': + do_ask=0 + elif choice[0] != 'n': + print red("Bad input -- assume no") + else: + do_ask=0 + elif usecustom == [] and "--usecustom" in myopts: + do_ask = 1 + elif usecustom != [] and "--usecustom" in myopts: + do_ask = 0 + + + if do_ask == 0: + for u in usecustom: + if u != "": + if u[0] == '-': + try: + portage.usesplit.remove(u[1:]) + except: + "" + else: + try: + portage.usesplit.remove("-"+u) + except: + "" + try: + portage.usesplit.remove(u) + except: + "" + portage.usesplit.append(u) + + + if do_ask == 1: + for ebuild_iuse in string.split(portage.portdb.aux_get(x[2],["IUSE"])[0], " "): + if ebuild_iuse != "": + to_print = "Use "+ebuild_iuse+"? [" + try: + if (portage.usesplit.index(ebuild_iuse) >= 0) : + default='y' + to_print = to_print+"Y/n" + except ValueError: + if ebuild_iuse != "": + default='n' + to_print = to_print+"y/N" + to_print = to_print+"]" + + choice = raw_input (to_print+" ").lower () + if choice == '': + state=default + else: + choice = choice[0] + if choice != default: + if choice == 'y': + print green('Enabled '+ebuild_iuse) + state='y' + elif choice == 'n': + print blue('Disabled '+ebuild_iuse) + state='n' + else: + print red('Bad input -- reverting to default... ('+default+')') + state=default + else: + state=default + + + # we remove the ebuild from usesplit (it will be append, with his value next) + try: + portage.usesplit.remove(ebuild_iuse) + except: + "" + try: + portage.usesplit.remove('-'+ebuild_iuse) + except: + "" + if state == 'n': + ebuild_iuse = '-'+ebuild_iuse + + portage.usesplit.append(ebuild_iuse) + useruse.append(ebuild_iuse) + + # save use settings to USECUSTOM + print ">>> Save USE settings" + mydblink=portage.dblink(mycat,mypkg,"/var/tmp/portage") + mydblink.setelements(useruse,"USECUSTOM") + + portage.settings.configlist[-1]["USE"]=string.join(portage.usesplit," ") + + print + mydepgraph=depgraph(myaction,myopts) if myaction in ["system","world"]: print "Calculating",myaction,"dependencies ", @@ -1827,12 +1994,7 @@ print "!!! Depgraph creation failed." sys.exit(1) print "\b\b ...done!" - else: - if not myfiles: - print "emerge: please tell me what to do." - help() - sys.exit(1) - #we don't have any files to process; skip this step and exit + if myaction not in ["system","world"]: print "Calculating dependencies ", retval,favorites=mydepgraph.select_files(myfiles) if not retval: