summaryrefslogtreecommitdiff
path: root/geneticone/backend
diff options
context:
space:
mode:
authornecoro <>2006-10-05 20:29:58 +0000
committernecoro <>2006-10-05 20:29:58 +0000
commit1e9ddc03e5667e5a9297508f7bec8b7f3ea46dc9 (patch)
treef6536d496e0cba2f57c92a6d281ed8b8d67fc2bc /geneticone/backend
parent7dba8ff93310e61c71b7124fad6df13bbf500b53 (diff)
downloadportato-1e9ddc03e5667e5a9297508f7bec8b7f3ea46dc9.tar.gz
portato-1e9ddc03e5667e5a9297508f7bec8b7f3ea46dc9.tar.bz2
portato-1e9ddc03e5667e5a9297508f7bec8b7f3ea46dc9.zip
Added first support for the masking stuff ... and hoping that it is going to work properly ;)
Diffstat (limited to '')
-rw-r--r--geneticone/backend/flags.py125
-rw-r--r--geneticone/backend/package.py33
-rw-r--r--geneticone/backend/portage_helper.py5
3 files changed, 93 insertions, 70 deletions
diff --git a/geneticone/backend/flags.py b/geneticone/backend/flags.py
index 3065fbe..1251bfd 100644
--- a/geneticone/backend/flags.py
+++ b/geneticone/backend/flags.py
@@ -22,6 +22,7 @@ from portage_util import unique_array
CONFIG = {
"usefile" : "geneticone",
+ "maskfile" : "geneticone",
"usePerVersion" : True
}
@@ -85,6 +86,14 @@ def set_config (cfg):
for i in CONFIG:
CONFIG[i] = cfg[i]
+def generate_path (cpv, exp):
+
+ cat, pkg, ver, rev = split_package_name(cpv)
+
+ if exp.find("$(") != -1:
+ exp = exp.replace("$(cat)",cat).replace("$(pkg)",pkg).replace("$(cat-1)",cat.split("-")[0]).replace("$(cat-2)",cat.split("-")[1])
+ return exp
+
### USE FLAG PART ###
USE_PATH = os.path.join(portage.USER_CONFIG_PATH,"package.use")
USE_PATH_IS_DIR = os.path.isdir(USE_PATH)
@@ -168,7 +177,7 @@ def set_use_flag (pkg, flag):
if not added:
path = USE_PATH
if USE_PATH_IS_DIR:
- path = os.path.join(USE_PATH,CONFIG["usefile"])
+ path = os.path.join(USE_PATH,generate_path(cpv, CONFIG["usefile"]))
try:
newUseFlags[cpv].remove((path, -1, invFlag, False))
@@ -310,7 +319,7 @@ UNMASK_PATH_IS_DIR = os.path.isdir(UNMASK_PATH)
new_masked = {}
new_unmasked = {}
-def set_masked (pkg):
+def set_masked (pkg, masked = True):
global new_masked, newunmasked
if not isinstance(pkg, package.Package):
pkg = package.Package(pkg)
@@ -321,84 +330,80 @@ def set_masked (pkg):
new_unmasked[cpv] = []
if not cpv in new_masked:
new_masked[cpv] = []
-
- nu = new_unmasked[cpv][:]
- for file, line in nu:
- if line == "-1":
- new_unmasked[cpv].remove(file, line)
- nm = new_masked[cpv][:]
- for file, line in nm:
+ if masked:
+ link_neq = new_masked
+ link_eq = new_unmasked
+ path = UNMASK_PATH
+ else:
+ link_neq = new_unmasked
+ link_eq = new_masked
+ path = MASK_PATH
+
+ copy = link_eq[cpv]
+ for file, line in copy:
+ if line == "-1":
+ link_eq[cpv].remove((file, line))
+
+ copy = link_neq[cpv][:]
+ for file, line in copy:
if line != "-1":
- new_masked[cpv].remove(file, line)
+ link_neq[cpv].remove(file, line)
- if pkg.is_masked():
+ if masked == pkg.is_masked():
return
- unmasked = get_data(pkg, UNMASK_PATH)
- debug("data (unmasked): "+str(unmasked))
+ data = get_data(pkg, path)
+ debug("data: "+str(link_eq))
done = False
- for file, line, crit, flags in unmasked:
+ for file, line, crit, flags in data:
if pkg.matches(crit):
- new_unmasked[cpv].append((file, line))
+ link_eq[cpv].append((file, line))
done = True
if done: return
- if MASK_PATH_IS_DIR:
- file = os.path.join(MASK_PATH, "geneticone")
+ if masked:
+ is_dir = MASK_PATH_IS_DIR
+ path = MASK_PATH
else:
- file = MASK_PATH
-
- new_masked[cpv].append((file, "-1"))
- new_masked[cpv] = unique_array(new_masked[cpv])
- debug("new_masked: "+str(new_masked))
+ is_dir = UNMASK_PATH_IS_DIR
+ path = UNMASK_PATH
-def set_unmasked (pkg):
- global new_masked, new_unmasked
- if not isinstance(pkg, package.Package):
- pkg = package.Package(pkg)
+ if is_dir:
+ file = os.path.join(path, generate_path(cpv, CONFIG["usefile"]))
+ else:
+ file = path
- cpv = pkg.get_cpv()
+ link_neq[cpv].append((file, "-1"))
+ link_neq[cpv] = unique_array(link_neq[cpv])
+ debug("new_(un)masked: "+str(link_neq))
- if not cpv in new_unmasked:
- new_unmasked[cpv] = []
- if not cpv in new_masked:
- new_masked[cpv] = []
-
- nu = new_unmasked[cpv][:]
- for file, line in nu:
- if line != "-1":
- new_unmasked[cpv].remove(file, line)
+def remove_new_masked (cpv):
+ if isinstance(cpv, package.Package):
+ cpv = cpv.get_cpv()
- nm = new_masked[cpv][:]
- for file, line in nm:
- if line == "-1":
- new_masked[cpv].remove(file, line)
-
- if not pkg.is_masked():
- return
-
- masked = get_data(pkg, MASK_PATH)
- debug("data (masked): "+str(masked))
- done = False
- for file, line, crit, fl in masked:
- if pkg.matches(crit):
- new_masked[cpv].append((file, line))
- done = True
+ try:
+ del new_masked[cpv]
+ except KeyError:
+ pass
- if done: return
+ try:
+ del new_unmasked[cpv]
+ except KeyError:
+ pass
- if UNMASK_PATH_IS_DIR:
- file = os.path.join(UNMASK_PATH, "geneticone")
- else:
- file = UNMASK_PATH
+def new_masking_status (cpv):
+ if isinstance(cpv, package.Package):
+ cpv = cpv.get_cpv()
- new_unmasked[cpv].append((file, "-1"))
- new_unmasked[cpv] = unique_array(new_unmasked[cpv])
- debug("new_unmasked: "+str(new_unmasked))
+ if cpv in new_masked and new_masked[cpv]:
+ return "masked"
+ elif cpv in new_unmasked and new_unmasked[cpv]:
+ return "unmasked"
+ else: return None
-def write_masked_unmasked ():
+def write_masked ():
global new_unmasked, new_masked
file_cache = {}
diff --git a/geneticone/backend/package.py b/geneticone/backend/package.py
index 20e65fd..fec346d 100644
--- a/geneticone/backend/package.py
+++ b/geneticone/backend/package.py
@@ -50,6 +50,29 @@ class Package (gentoolkit.Package):
pkgmask = pkgmask + 2
return pkgmask
+ def is_masked (self):
+ """Returns True if either masked by package.mask or by profile.
+ @returns: mask-status
+ @rtype: boolean"""
+ # XXX: Better solution than string comparison?
+ status = flags.new_masking_status(self.get_cpv())
+ if status != None:
+ if status == "masked": return True
+ elif status == "unmasked": return False
+ else:
+ debug("BUG in flags.new_masking_status. It returns "+status)
+ else:
+ status = portage.getmaskingstatus(self._cpv, settings = gentoolkit.settings)
+ if "profile" in status or "package.mask" in status:
+ return True
+ return False
+
+ def set_masked (self, masking = False):
+ flags.set_masked(self, masked = masking)
+
+ def remove_new_masked (self):
+ 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.
@@ -165,16 +188,6 @@ class Package (gentoolkit.Package):
@rtype: string"""
return self.get_category()+"/"+self.get_name()
- def is_masked (self):
- """Returns True if either masked by package.mask or by profile.
- @returns: mask-status
- @rtype: boolean"""
- # XXX: Better solution than string comparison?
- status = portage.getmaskingstatus(self._cpv)
- if "profile" in status or "package.mask" in status:
- return True
- return False
-
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
diff --git a/geneticone/backend/portage_helper.py b/geneticone/backend/portage_helper.py
index 5703875..aae7c19 100644
--- a/geneticone/backend/portage_helper.py
+++ b/geneticone/backend/portage_helper.py
@@ -11,6 +11,7 @@
import re
import os
+import copy
import gentoolkit
import portage
@@ -136,6 +137,10 @@ def sort_package_list(pkglist):
"""Sorts a package list in the same manner portage does."""
return gentoolkit.sort_package_list(pkglist)
+def reload_settings ():
+ # XXX: what the hack are we doing here Oo
+ gentoolkit.settings = portage.config(config_incrementals = copy.deepcopy(gentoolkit.settings.incrementals))
+
use_descs = {}
local_use_descs = {}
def get_use_desc (flag, package = None):