corrected some nasty bugs, reworked USE flags management, added --ask option
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@182 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -3,11 +3,11 @@ TODO list (for developers only):
|
||||
- add proper SLOTS, FETCH_RESTRICTION support to enzyme, getBestAtom and so on... (maybe directly using emerge output?)
|
||||
- do not append download URLs directly into the .etp files
|
||||
- activator should care about the removal of the old packages
|
||||
- build() on enzyme, check for duplicates and filter them out?
|
||||
- world(), on enzyme, add the option to recompile all the installed packages
|
||||
- build() on enzyme, when calculating runtime dependencies, please check if there's a broken link too and report as warning
|
||||
- build() on enzyme, also trap einfo and ewarn ?
|
||||
- build() on enzyme, also integrate a sort of revdep-rebuild ?
|
||||
- build() on enzyme, implement --ask option
|
||||
- Sabayon Linux USE flags: remove all server related use flags
|
||||
|
||||
Project Status:
|
||||
- entropy: not yet started, nothing to say then
|
||||
|
||||
@@ -53,6 +53,7 @@ def print_help():
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--deep")+"\t\t\t analyze the dependencies deeply")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--use")+"\t\t\t show packages USE flags")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--pretend")+"\t\t just show what should be done")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--ask")+"\t\t just ask before doing what should be done")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--ignore-conflicts")+"\t ignore conflicts between packages")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--no-interaction")+"\t disable user interaction, automatic driving")
|
||||
entropyTools.print_info(" \t\t"+entropyTools.red("--simulate-building")+"\t compilations are simulated only")
|
||||
|
||||
+60
-38
@@ -35,7 +35,7 @@ initializePortageTree()
|
||||
|
||||
# colours support
|
||||
import output
|
||||
from output import bold, colorize, green, red, yellow, blue, darkblue, nocolor
|
||||
from output import bold, colorize, green, darkred, red, yellow, blue, darkblue, nocolor
|
||||
import re
|
||||
import sys
|
||||
import random
|
||||
@@ -78,17 +78,54 @@ def calculateFullAtomsDependencies(atoms, deep = False):
|
||||
deepOpt = "-Du"
|
||||
deplist = []
|
||||
blocklist = []
|
||||
cmd = "USE='"+getUSEFlags()+"' "+cdbRunEmerge+" --pretend --color=n --quiet "+deepOpt+" "+atoms
|
||||
|
||||
try:
|
||||
useflags = "USE='"+os.environ['USE']+"' "
|
||||
except:
|
||||
useflags = ""
|
||||
cmd = useflags+cdbRunEmerge+" --pretend --color=n --quiet "+deepOpt+" "+atoms
|
||||
result = commands.getoutput(cmd).split("\n")
|
||||
for line in result:
|
||||
if line.startswith("[ebuild"):
|
||||
line = line.split("] ")[1].split(" [")[0].strip()
|
||||
line = line.split("] ")[1].split(" [")[0].split()[0].strip()
|
||||
deplist.append(line)
|
||||
if line.startswith("[blocks"):
|
||||
line = line.split("] ")[1].split()[0].strip()
|
||||
blocklist.append(line)
|
||||
return deplist, blocklist
|
||||
|
||||
def calculateAtomUSEFlags(atom):
|
||||
try:
|
||||
useflags = "USE='"+os.environ['USE']+"' "
|
||||
except:
|
||||
useflags = ""
|
||||
cmd = useflags+cdbRunEmerge+" --pretend --color=n --nodeps --quiet --verbose "+atom
|
||||
result = commands.getoutput(cmd).split("\n")
|
||||
useparm = ""
|
||||
for line in result:
|
||||
if line.startswith("[ebuild"):
|
||||
useparm = line.split('USE="')[len(line.split('USE="'))-1].split('"')[0].strip()
|
||||
useparm = useparm.split()
|
||||
_useparm = []
|
||||
for use in useparm:
|
||||
# -cups
|
||||
if use.startswith("-") and (not use.endswith("*")):
|
||||
use = darkblue(use)
|
||||
# -cups*
|
||||
elif use.startswith("-") and (use.endswith("*")):
|
||||
use = yellow(use)
|
||||
# use flag not available
|
||||
elif use.startswith("("):
|
||||
use = blue(use)
|
||||
# cups*
|
||||
elif use.endswith("*"):
|
||||
use = green(use)
|
||||
else:
|
||||
use = darkred(use)
|
||||
_useparm.append(use)
|
||||
useparm = string.join(_useparm," ")
|
||||
return useparm
|
||||
|
||||
# should be only used when a pkgcat/pkgname <-- is not specified (example: db, amarok, AND NOT media-sound/amarok)
|
||||
def getAtomCategory(atom):
|
||||
try:
|
||||
@@ -161,6 +198,10 @@ def getInstalledAtom(atom):
|
||||
else:
|
||||
return None
|
||||
|
||||
# INFO: there is get_slot too :)
|
||||
def getEbuildDbPath(atom):
|
||||
return portage.db['/']['vartree'].getebuildpath(atom)
|
||||
|
||||
def getInstalledAtoms(atom):
|
||||
rc = portage.db['/']['vartree'].dep_match(str(atom))
|
||||
if (rc != []):
|
||||
@@ -182,8 +223,8 @@ def unmerge(atom):
|
||||
|
||||
# TO THIS FUNCTION:
|
||||
# must be provided a valid and complete atom
|
||||
# FIXME: needs some love !
|
||||
def extractPkgNameVer(atom):
|
||||
package = dep_getcpv(atom)
|
||||
package = atom.split("/")[len(atom.split("/"))-1]
|
||||
package = package.split("-")
|
||||
pkgname = ""
|
||||
@@ -392,40 +433,6 @@ def getUSEFlags():
|
||||
def getPackageIUSE(atom):
|
||||
return getPackageVar(atom,"IUSE")
|
||||
|
||||
# you must provide a complete atom
|
||||
def getPackageUSEList(atom):
|
||||
if (not atom.startswith("=")):
|
||||
atom = "="+atom
|
||||
myUseFlags = getPackageVar(atom[1:],"IUSE").split()
|
||||
useFlags = getUSEFlags().split()
|
||||
uselist = []
|
||||
for myuse in myUseFlags:
|
||||
useFind = False
|
||||
for use in useFlags:
|
||||
if (myuse == use):
|
||||
useFind = True
|
||||
break
|
||||
if (useFind):
|
||||
uselist.append(myuse)
|
||||
else:
|
||||
uselist.append("-"+myuse)
|
||||
|
||||
# order
|
||||
_uselist = []
|
||||
for use in uselist:
|
||||
if (not use.startswith("-")):
|
||||
_uselist.append(red(use))
|
||||
for use in uselist:
|
||||
if use.startswith("-"):
|
||||
_uselist.append(darkblue(use))
|
||||
uselist = _uselist
|
||||
|
||||
if len(uselist) > 0:
|
||||
import string
|
||||
return string.join(uselist," ")
|
||||
else:
|
||||
return ""
|
||||
|
||||
def getPackageVar(atom,var):
|
||||
if atom.startswith("="):
|
||||
atom = atom[1:]
|
||||
@@ -595,6 +602,21 @@ def umountProc():
|
||||
else:
|
||||
return True
|
||||
|
||||
def askquestion(prompt):
|
||||
responses, colours = ["Yes", "No"], [green, red]
|
||||
print green(prompt),
|
||||
try:
|
||||
while True:
|
||||
response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
|
||||
for key in responses:
|
||||
# An empty response will match the first value in responses.
|
||||
if response.upper()==key[:len(response)].upper():
|
||||
return key
|
||||
print "I cannot understand '%s'" % response,
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
print "Interrupted."
|
||||
sys.exit(1)
|
||||
|
||||
def print_error(msg):
|
||||
print red(">>")+" "+msg
|
||||
|
||||
|
||||
+27
-14
@@ -142,6 +142,7 @@ def build(atoms):
|
||||
enzymeRequestDeep = False
|
||||
enzymeRequestUse = False
|
||||
enzymeRequestPretendAll = False
|
||||
enzymeRequestAsk = False
|
||||
enzymeRequestIgnoreConflicts = False
|
||||
enzymeRequestInteraction = True
|
||||
enzymeRequestSimulation = False
|
||||
@@ -157,6 +158,8 @@ def build(atoms):
|
||||
enzymeRequestIgnoreConflicts = True
|
||||
elif ( i == "--pretend" ):
|
||||
enzymeRequestPretendAll = True
|
||||
elif ( i == "--ask" ):
|
||||
enzymeRequestAsk = True
|
||||
elif ( i == "--deep" ):
|
||||
enzymeRequestDeep = True
|
||||
enzymeRequestForceRebuild = True
|
||||
@@ -230,9 +233,18 @@ def build(atoms):
|
||||
|
||||
# Check if they conflicts each others
|
||||
if len(toBeBuilt) > 1:
|
||||
atoms = string.join(toBeBuilt," =")
|
||||
cleanatomlist = []
|
||||
for atom in toBeBuilt:
|
||||
if (not atom.startswith(">")) and (not atom.startswith("<")):
|
||||
cleanatomlist.append("="+atom)
|
||||
else:
|
||||
cleanatomlist.append(atom)
|
||||
atoms = string.join(cleanatomlist," ")
|
||||
else:
|
||||
atoms = "="+atoms[0]
|
||||
if atoms[0].startswith(">") or atoms[0].startswith("<"):
|
||||
atoms = atoms[0]
|
||||
else:
|
||||
atoms = "="+atoms[0]
|
||||
print_info(green(" Sanity check on packages..."))
|
||||
atomdeps, atomconflicts = calculateFullAtomsDependencies(atoms,enzymeRequestDeep)
|
||||
for conflict in atomconflicts:
|
||||
@@ -259,6 +271,7 @@ def build(atoms):
|
||||
if(enzymeRequestVerbose): print_info("\tfiltering "+atom+" related packages...")
|
||||
|
||||
for dep in atomdeps:
|
||||
dep = dep.split()[0]
|
||||
dep = "="+dep
|
||||
if(enzymeRequestVerbose): print_info("\tchecking for: "+red(dep[1:]))
|
||||
wantedAtom = getBestAtom(dep)
|
||||
@@ -269,7 +282,6 @@ def build(atoms):
|
||||
# then append - because it's not installed !
|
||||
if(enzymeRequestVerbose) and (installedAtom is None): print_info("\t\t"+dep+" is not installed, adding")
|
||||
if(enzymeRequestVerbose) and (enzymeRequestForceRebuild): print_info("\t\t"+dep+" - rebuild forced")
|
||||
# do not taint if dep == atom
|
||||
PackagesDependencies.append(dep[1:])
|
||||
else:
|
||||
print "'"+wantedAtom+"'"
|
||||
@@ -299,38 +311,39 @@ def build(atoms):
|
||||
print_info(yellow(" *")+" These are the actions that will be taken, in order:")
|
||||
for i in PackagesDependencies:
|
||||
#print "'"+i+"'"
|
||||
useflags = ""
|
||||
if enzymeRequestUse: useflags = bold(" [")+yellow("USE: ")+calculateAtomUSEFlags("="+i)+bold("]")
|
||||
pkgstatus = "[?]"
|
||||
pkguse = ""
|
||||
if (getInstalledAtom(dep_getkey(i)) == None):
|
||||
pkgstatus = green("[N]")
|
||||
if (enzymeRequestUse) and (getPackageUSEList(i) != ""): pkguse = bold(" [")+yellow("USE:")+" "+getPackageUSEList(i)+bold("]")
|
||||
elif (compareAtoms(i,getInstalledAtom(dep_getkey(i))) == 0):
|
||||
pkgstatus = yellow("[R]")
|
||||
if (enzymeRequestUse) and (getPackageUSEList(i) != ""): pkguse = bold(" [")+yellow("USE:")+" "+getPackageUSEList(i)+bold("]")
|
||||
elif (compareAtoms(i,getInstalledAtom(dep_getkey(i))) > 0):
|
||||
pkgstatus = blue("[U]")
|
||||
if (enzymeRequestUse) and (getPackageUSEList(i) != ""): pkguse = bold(" [")+yellow("USE:")+" "+getPackageUSEList(i)+bold("]")
|
||||
elif (compareAtoms(i,getInstalledAtom(dep_getkey(i))) < 0):
|
||||
pkgstatus = darkblue("[D]")
|
||||
if (enzymeRequestUse) and (getPackageUSEList(i) != ""): pkguse = bold(" [")+yellow("USE:")+" "+getPackageUSEList(i)+bold("]")
|
||||
print_info(red(" *")+bold(" [")+red("BUILD")+bold("] ")+pkgstatus+" "+i+pkguse)
|
||||
print_info(red(" *")+bold(" [")+red("BUILD")+bold("] ")+pkgstatus+" "+i+useflags)
|
||||
|
||||
for i in PackagesQuickpkg:
|
||||
pkguse = ""
|
||||
if (enzymeRequestUse) and (getPackageUSEList(i) != ""): pkguse = bold(" [")+yellow("USE:")+" "+getPackageUSEList(i.split("|")[len(i.split("|"))-1])+bold("]")
|
||||
useflags = ""
|
||||
if enzymeRequestUse: useflags = bold(" [")+yellow("USE: ")+calculateAtomUSEFlags("="+i)+bold("]")
|
||||
if i.startswith("quick|"):
|
||||
print_info(green(" *")+bold(" [")+green("QUICK")+bold("] ")+yellow("[R] ") +i.split("quick|")[len(i.split("quick|"))-1]+pkguse)
|
||||
print_info(green(" *")+bold(" [")+green("QUICK")+bold("] ")+yellow("[R] ") +i.split("quick|")[len(i.split("quick|"))-1])
|
||||
elif i.startswith("avail|"):
|
||||
print_info(yellow(" *")+bold(" [")+yellow("NOACT")+bold("] ")+yellow("[R] ")+i.split("avail|")[len(i.split("avail|"))-1]+pkguse)
|
||||
print_info(yellow(" *")+bold(" [")+yellow("NOACT")+bold("] ")+yellow("[R] ")+i.split("avail|")[len(i.split("avail|"))-1])
|
||||
else:
|
||||
# I should never get here
|
||||
print_info(green(" *")+bold(" [?????] ")+i)
|
||||
print_info(green(" *")+bold(" [?????] ")+i+useflags)
|
||||
else:
|
||||
print_info(green(" *")+" Nothing to do...")
|
||||
|
||||
|
||||
if (enzymeRequestPretendAll):
|
||||
sys.exit(0)
|
||||
elif (enzymeRequestAsk):
|
||||
rc = askquestion("\n Would you like to run the steps above ?")
|
||||
if rc == "No":
|
||||
sys.exit(0)
|
||||
|
||||
# when the compilation ends, enzyme runs reagent
|
||||
packagesPaths = []
|
||||
|
||||
Reference in New Issue
Block a user