summaryrefslogtreecommitdiff
path: root/geneticone/backend/package.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--geneticone/backend/package.py186
1 files changed, 59 insertions, 127 deletions
diff --git a/geneticone/backend/package.py b/geneticone/backend/package.py
index 522ca08..da2a131 100644
--- a/geneticone/backend/package.py
+++ b/geneticone/backend/package.py
@@ -32,19 +32,32 @@ class Package (gentoolkit.Package):
self._status = portage.getmaskingstatus(self.get_cpv(), settings = gentoolkit.settings)
def is_missing_keyword(self):
+ """Returns True if the package is missing the needed keyword.
+
+ @return: True if keyword is missing; else False
+ @rtype: boolean"""
+
if "missing keyword" in self._status:
return True
return False
def is_testing(self, allowed = False):
+ """Checks whether a package is marked as testing.
+
+ @param allowed: Controls whether possible keywords are taken into account or not.
+ @type allowed: boolean
+ @returns: True if the package is marked as testing; else False.
+ @rtype: boolean"""
+
testArch = "~" + self.get_settings("ARCH")
- if not allowed:
+ if not allowed: # keywords are NOT taken into account
if testArch in self.get_env_var("KEYWORDS").split():
return True
return False
- else:
+
+ else: # keywords are taken into account
status = flags.new_testing_status(self.get_cpv())
- if status == None:
+ if status == None: # we haven't changed it in any way
if testArch+" keyword" in self._status:
return True
return False
@@ -52,38 +65,53 @@ class Package (gentoolkit.Package):
return status
def set_testing(self, enable = True):
+ """Sets the actual testing status of the package.
+
+ @param enable: if True it is masked as stable; if False it is marked as testing
+ @type enable: boolean"""
+
flags.set_testing(self, enable)
def remove_new_testing(self):
+ """Removes possible changed testing status."""
+
flags.remove_new_testing(self.get_cpv())
def is_masked (self):
"""Returns True if either masked by package.mask or by profile.
- @returns: mask-status
+
+ @returns: True if masked / False otherwise
@rtype: boolean"""
- # XXX: Better solution than string comparison?
+
status = flags.new_masking_status(self.get_cpv())
- if status != None:
+ if status != None: # we have locally changed it
if status == "masked": return True
elif status == "unmasked": return False
else:
- debug("BUG in flags.new_masking_status. It returns "+status)
- else:
+ debug("BUG in flags.new_masking_status. It returns",status)
+ else: # we have not touched the status
if "profile" in self._status or "package.mask" in self._status:
return True
return False
def set_masked (self, masking = False):
+ """Sets the masking status of the package.
+
+ @param masking: if True: mask it; if False: unmask it
+ @type masking: boolean"""
+
flags.set_masked(self, masked = masking)
def remove_new_masked (self):
+ """Removes possible changed masking status."""
+
flags.remove_new_masked(self.get_cpv())
def get_all_use_flags (self):
"""Returns a list of _all_ useflags for this package, i.e. all useflags you can set for this package.
@returns: list of use-flags
- @rtype: list"""
+ @rtype: string[]"""
return unique_array(self.get_env_var("IUSE").split())
@@ -91,10 +119,11 @@ class Package (gentoolkit.Package):
"""Returns a list of the useflags enabled at installation time. If package is not installed, it returns an empty list.
@returns: list of useflags enabled at installation time or an empty list
- @rtype: list"""
+ @rtype: string[]"""
+
if self.is_installed():
- uses = self.get_use_flags().split()
- iuses = self.get_all_use_flags()
+ uses = self.get_use_flags().split() # all set at installation time
+ iuses = self.get_all_use_flags() # all you can set for the package
set = []
for u in iuses:
if u in uses:
@@ -107,20 +136,23 @@ class Package (gentoolkit.Package):
"""Returns a list of the new useflags, i.e. these flags which are not written to the portage-system yet.
@returns: list of flags or []
- @rtype: list"""
+ @rtype: string[]"""
+
return flags.get_new_use_flags(self)
def get_actual_use_flags (self):
"""This returns the result of installed_use_flags + new_use_flags. If the package is not installed, it returns only the new flags.
@return: list of flags
- @rtype: list"""
+ @rtype: string[]"""
if self.is_installed():
i_flags = self.get_installed_use_flags()
for f in self.get_new_use_flags():
+
if flags.invert_flag(f) in i_flags:
i_flags.remove(flags.invert_flag(f))
+
elif f not in i_flags:
i_flags.append(f)
return i_flags
@@ -132,24 +164,27 @@ class Package (gentoolkit.Package):
@param flag: the flag to set
@type flag: string"""
+
flags.set_use_flag(self, flag)
def remove_new_use_flags (self):
"""Remove all the new use-flags."""
+
flags.remove_new_use_flags(self)
def get_dep_packages (self):
"""Returns a cpv-list of packages on which this package depends and which have not been installed yet. This does not check the dependencies in a recursive manner.
@returns: list of cpvs on which the package depend
- @rtype: list
+ @rtype: string[]
+
@raises geneticone.BlockedException: when a package in the dependency-list is blocked by an installed one
@raises geneticone.PackageNotFoundException: when a package in the dependency list could not be found in the system
@raises geneticone.DependencyCalcError: when an error occured during executing portage.dep_check()"""
dep_pkgs = [] # the package list
- # check whether we got use-flags which are not visible for portage yet
+ # change the useflags, because we have internally changed some, but not made them visible for portage
newUseFlags = self.get_new_use_flags()
actual = self.get_settings("USE").split()
if newUseFlags:
@@ -164,7 +199,7 @@ class Package (gentoolkit.Package):
# pay attention to any changes here
deps = portage.dep_check (self.get_env_var("RDEPEND")+" "+self.get_env_var("DEPEND")+" "+self.get_env_var("PDEPEND"), vartree.dbapi, self._settings, myuse = actual)
- if not deps: # what is the difference to [1, []] ?
+ if not deps: # FIXME: what is the difference to [1, []] ?
return []
if deps[0] == 0: # error
@@ -203,124 +238,21 @@ class Package (gentoolkit.Package):
def get_cp (self):
"""Returns the cp-string.
+
@returns: category/package.
@rtype: string"""
+
return self.get_category()+"/"+self.get_name()
def matches (self, criterion):
"""This checks, whether this package matches a specific verisioning criterion - e.g.: "<=net-im/foobar-1.2".
+
@param criterion: the criterion to match against
- @type criterion: string"""
+ @type criterion: string
+ @returns: True if matches; False if not
+ @rtype: boolean"""
+
if portage.match_from_list(criterion, [self.get_cpv()]) == []:
return False
else:
return True
-#
-# OBSOLETE DEPENDENCY-CALCULATION-METHODS - kept in the case the above ones do not work
-#
-
- #def own_get_dep_packages (self, old_cpv_dict = {}):
- # # XXX: after having finished this, i realized, that there is already a portage function -.- ;
- # """Returns a list of all packages (i.e. package-cpvs) which this package depends on and which not have been installed yet.
- # Param old_cpv_dict is a {cp: version}-dictionary holding already found deps.
- # Raises a BlockedException if the package is being blocked by another installed package."""
- # # XXX: This won't find blocking dependencies
- # # XXX: Has some problems with modular X (this has a very strange ebuild) ... we should enhance _parse_deps
- # print "Actual: "+self._cpv # debug output
- #
- # uses = [] # list of actual useflags / useflags the package has been installed with
- # dep_packages = [] # list of packages returned
- # dep_cpv_dict = {} # all dependencies are inserted here
- #
- # # get useflags
- # if self.is_installed():
- # uses = self.get_installed_use_flags()
- # else:
- # uses = self.get_settings("USE")
- #
- # # cycle through dependencies
- # for (comp, flags, dep_cpv) in self.get_all_deps():
-
- # # find blocking packages
- # if comp and comp[0] == '!':
- # blocked = find_installed_packages(comp[1:]+dep_cpv)
- # if blocked != []:
- # raise BlockedException, blocked[0].get_cpv()
- # else: # next flag
- # continue
- #
- # # look whether this package is really required
- # needDep = True
- # for flag in flags:
- # if (flag[0] == '!' and flag[1:] in uses) or (flag[0] != '!' and flag not in uses):
- # needDep = False
- # break
-
- # if needDep: # it is ...
- # if find_installed_packages(comp+dep_cpv) == []: # ... and not installed yet
- # d = find_best_match(comp+dep_cpv)
- # if not d: # no package found
- # raise PackageNotFoundException, dep_cpv
- # if d.get_cp() not in old_cpv_dict: # ... and not found already by an other package
- # dep_cpv_dict[d.get_cp()] = d.get_version()
- # print "Dep: "+d.get_cpv() # debug
- # dep_packages.append(d.get_cpv())
- #
- # for dep in dep_packages: # find dependencies for each package
- # old_cpv_dict.update(dep_cpv_dict)
- # old_cpv_dict.update({self.get_cp() : self.get_version()})
- # dep_packages += find_packages("="+dep)[0].own_get_dep_packages(old_cpv_dict)
-
- # return unique_array(dep_packages)
-
- #def get_all_deps (self):
- # """Returns a linearised list of all first-level dependencies for this package, on
- # the form [(comparator, [use flags], cpv), ...]"""
- # return unique_array(self.get_compiletime_deps()+self.get_runtime_deps()+self.get_postmerge_deps())
-
- #def _parse_deps(self,deps,curuse=[],level=0):
- # """Modified method "_parse_deps" of gentoolkit.Package.
- # Do NOT ignore blocks."""
- # # store (comparator, [use predicates], cpv)
- # r = []
- # comparators = ["~","<",">","=","<=",">="]
- # end = len(deps)
- # i = 0
- # while i < end:
- # blocked = False
- # tok = deps[i]
- # if tok == ')':
- # return r,i
- # if tok[-1] == "?":
- # tok = tok.replace("?","")
- # sr,l = self._parse_deps(deps[i+2:],curuse=curuse+[tok],level=level+1)
- # r += sr
- # i += l + 3
- # continue
- # if tok == "||":
- # sr,l = self._parse_deps(deps[i+2:],curuse,level=level+1)
- # r += sr
- # i += l + 3
- # continue
- # # conjonction, like in "|| ( ( foo bar ) baz )" => recurse
- # if tok == "(":
- # sr,l = self._parse_deps(deps[i+1:],curuse,level=level+1)
- # r += sr
- # i += l + 2
- # continue
- # # pkg block "!foo/bar" => ignore it
- # if tok[0] == "!":
- # #i += 1
- # #continue
- # blocked = True # added
- # tok = tok[1:] # added
- # # pick out comparator, if any
- # cmp = ""
- # for c in comparators:
- # if tok.find(c) == 0:
- # cmp = c
- # if blocked: cmp = "!"+cmp # added
- # tok = tok[len(cmp):]
- # r.append((cmp,curuse,tok))
- # i += 1
- # return r,i