class HeaderList:
def selected(self):
l = []
keys = self.packages.keys()
keys.sort()
for name in keys:
if self.packages[name].selected: l.append(self.packages[name])
return l
def conditionalSelect (self, key):
for pkg in self.conditional[key]:
pkg.selected = 1
def conditionalUnselect (self, key):
for pkg in self.conditional[key]:
pkg.selected = 0
def select(self, recurse = 1):
self.selected = 1
for pkg in self.items.keys ():
self.items[pkg].selected = 1
# turn on any conditional packages
for (condition, pkgs) in self.conditional.items ():
if condition.selected:
for pkg in pkgs:
pkg.selected = 1
# components that have conditional packages keyed on this
# component AND are currently selected have those conditional
# packages turned turned on when this component is turned on.
if self.dependents:
for dep in self.dependents:
if dep.selected:
dep.conditionalSelect (self)
if recurse:
for n in self.includes:
if n.requires:
if n.requires.selected:
n.select(recurse)
else:
n.select(recurse)
if n.requires:
if n.requires.selected:
n.select(recurse)
else:
n.select(recurse)
def unselect(self, recurse = 1):
self.selected = 0
for n in self.items.keys ():
self.items[n].selected = 0
# always turn off conditional packages, regardless
# if the condition is met or not.
for (condition, pkgs) in self.conditional.items ():
for pkg in pkgs:
pkg.selected = 0
# now we must turn off conditional packages in components that
# are keyed on this package
if self.dependents:
for dep in self.dependents:
dep.conditionalUnselect (self)
if recurse:
for n in self.includes:
n.unselect(recurse)
exprList = split(expr, 'and')
truth = 1
for expr in exprList:
l = split(expr)
if l[0] == "lang":
if len(l) != 2:
raise ValueError, "too many arguments for lang"
if l[1] != lang:
newTruth = 0
else:
newTruth = 1
elif l[0] == "arch":
if len(l) != 2:
raise ValueError, "too many arguments for arch"
newTruth = self.archMatch(l[1], arch1, arch2)
else:
s = "unknown condition type %s" % (l[0],)
raise ValueError, s
truth = truth and newTruth
return truth
# this checks to see if "item" is one of the archs
def archMatch(self, item, arch1, arch2):
if item == arch1 or (arch2 and item == arch2):
return 1
return 0
file.close()
top = lines[0]
lines = lines[1:]
if (top != "3\n" and top != "4\n"):
raise TypeError, "comp file version 3 or 4 expected"
comp = None
conditional = None
self.comps = []
self.compsDict = {}
for l in lines:
l = strip (l)
if (not l): continue
if (find(l, ":") > -1):
(archList, l) = split(l, ":", 1)
if archList[0] == '(':
l = strip(l)
if not self.exprMatch(archList, arch, arch2):
continue
else:
while (l[0] == " "): l = l[1:]
skipIfFound = 0
if (archList[0] == '!'):
skipIfFound = 1
archList = archList[1:]
archList = split(archList)
found = 0
for n in archList:
if self.archMatch(n, arch, arch2):
found = 1
break
if ((found and skipIfFound) or
(not found and not skipIfFound)):
continue
everything = Component("Everything", 0, 0)
for package in packages.keys ():
if (packages[package]['name'] != 'kernel' and
packages[package]['name'] != 'kernel-BOOT' and
packages[package]['name'] != 'kernel-smp' and
not XFreeServerPackages.has_key(packages[package]['name'])):
everything.addPackage (packages[package])
self.comps.append (everything)
self.compsDict["Everything"] = everything
def __repr__(self):
s = ""
for n in self.comps:
s = s + "{ " + n.name + " [";
for include in n.includes:
s = s + " @" + include.name
for package in n:
s = s + " " + package
s = s + " ] } "