repoman: enable dep check with empty KEYWORDS
authorZac Medico <zmedico@gentoo.org>
Tue, 23 Nov 2010 01:22:04 +0000 (17:22 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 24 Nov 2010 02:08:05 +0000 (18:08 -0800)
Since no KEYWORDS are set, and those are normally used to decide
which profiles to check, we use an empty profile with effective
ACCEPT_KEYWORDS set to **.

bin/repoman
pym/portage/package/ebuild/_config/LocationsManager.py

index e6599bfa96c02543f77248b1a98a316f3c055c47..2b0df1268c01a0b40c66395d75ba789a417e4de4 100755 (executable)
@@ -635,9 +635,19 @@ class ProfileDesc(object):
        def __init__(self, arch, status, sub_path, tree_path):
                self.arch = arch
                self.status = status
-               self.sub_path = normalize_path(sub_path.lstrip(os.sep))
+               if sub_path:
+                       sub_path = normalize_path(sub_path.lstrip(os.sep))
+               self.sub_path = sub_path
                self.tree_path = tree_path
-               self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path)
+               if tree_path:
+                       self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path)
+               else:
+                       self.abs_path = tree_path
+
+       def __str__(self):
+               if self.sub_path:
+                       return self.sub_path
+               return 'empty profile'
 
 profile_list = []
 valid_profile_types = frozenset(['dev', 'exp', 'stable'])
@@ -742,6 +752,11 @@ for prof in profile_list:
        profile_sub_paths.add(prof.sub_path)
        profiles.setdefault(prof.arch, []).append(prof)
 
+# Use an empty profile for checking dependencies of
+# packages that have empty KEYWORDS.
+prof = ProfileDesc('**', 'stable', '', '')
+profiles.setdefault(prof.arch, []).append(prof)
+
 for x in repoman_settings.archlist():
        if x[0] == "~":
                continue
@@ -1565,7 +1580,7 @@ for x in scanlist:
                previous_keywords = slot_keywords.get(myaux["SLOT"])
                if previous_keywords is None:
                        slot_keywords[myaux["SLOT"]] = set()
-               elif not live_ebuild:
+               elif ebuild_archs and not live_ebuild:
                        dropped_keywords = previous_keywords.difference(ebuild_archs)
                        if dropped_keywords:
                                stats["KEYWORDS.dropped"] += 1
@@ -1622,6 +1637,10 @@ for x in scanlist:
                                else:
                                        arches.append([keyword, keyword, [keyword]])
                                        allmasked = False
+                       if not arches:
+                               # Use an empty profile for checking dependencies of
+                               # packages that have empty KEYWORDS.
+                               arches.append(['**', '**', ['**']])
 
                baddepsyntax = False
                badlicsyntax = False
@@ -1866,15 +1885,22 @@ for x in scanlist:
                                # just in case, prevent config.reset() from nuking these.
                                dep_settings.backup_changes("ACCEPT_KEYWORDS")
 
-                               for prov_cp in provide_cps:
-                                       if prov_cp not in dep_settings.getvirtuals():
-                                               stats["virtual.unavailable"]+=1
-                                               fails["virtual.unavailable"].append("%s: %s(%s) %s" % \
-                                                       (relative_path, keyword, prof.sub_path, prov_cp))
+                               if prof.sub_path:
+                                       # old-style virtuals currently aren't
+                                       # resolvable with empty profile, since
+                                       # mappings from 'virtuals' files are
+                                       # unavailable (it would be expensive to
+                                       # search for PROVIDE in all ebuilds)
+                                       for prov_cp in provide_cps:
+                                               if prov_cp not in dep_settings.getvirtuals():
+                                                       stats["virtual.unavailable"] += 1
+                                                       fails["virtual.unavailable"].append(
+                                                               "%s: %s(%s) %s" % (relative_path, keyword,
+                                                               prof.sub_path, prov_cp))
 
                                if not baddepsyntax:
-                                       ismasked = os.path.join(catdir, y) not in \
-                                               portdb.xmatch("list-visible", x)
+                                       ismasked = not ebuild_archs or \
+                                               pkg.cp not in portdb.xmatch("list-visible", x)
                                        if ismasked:
                                                if not have_pmasked:
                                                        have_pmasked = bool(dep_settings._getMaskAtom(
@@ -1908,22 +1934,34 @@ for x in scanlist:
 
                                                if success:
                                                        if atoms:
+
+                                                               if not prof.sub_path:
+                                                                       # old-style virtuals currently aren't
+                                                                       # resolvable with empty profile, since
+                                                                       # 'virtuals' mappings are unavailable
+                                                                       # (it would be expensive to search
+                                                                       # for PROVIDE in all ebuilds)
+                                                                       atoms = [atom for atom in atoms if not \
+                                                                               (atom.cp.startswith('virtual/') and \
+                                                                               not portdb.cp_list(atom.cp))]
+
                                                                #we have some unsolvable deps
                                                                #remove ! deps, which always show up as unsatisfiable
                                                                atoms = [str(atom.unevaluated_atom) \
                                                                        for atom in atoms if not atom.blocker]
+
                                                                #if we emptied out our list, continue:
                                                                if not atoms:
                                                                        continue
                                                                stats[mykey]=stats[mykey]+1
                                                                fails[mykey].append("%s: %s(%s) %s" % \
                                                                        (relative_path, keyword,
-                                                                       prof.sub_path, repr(atoms)))
+                                                                       prof, repr(atoms)))
                                                else:
                                                        stats[mykey]=stats[mykey]+1
                                                        fails[mykey].append("%s: %s(%s) %s" % \
                                                                (relative_path, keyword,
-                                                               prof.sub_path, repr(atoms)))
+                                                               prof, repr(atoms)))
 
        # Check for 'all unstable' or 'all masked' -- ACCEPT_KEYWORDS is stripped
        # XXX -- Needs to be implemented in dep code. Can't determine ~arch nicely.
index 83d61050f36172ed480ac29b4b48becaddf02c8f..7c53ac775b20445ce54afec9fa62d93b2a87bced 100644 (file)
@@ -38,7 +38,7 @@ class LocationsManager(object):
                self._check_var_directory("PORTAGE_CONFIGROOT", self.config_root)
                self.abs_user_config = os.path.join(self.config_root, USER_CONFIG_PATH)
 
-               if not config_profile_path:
+               if config_profile_path is None:
                        config_profile_path = \
                                os.path.join(self.config_root, PROFILE_PATH)
                        if os.path.isdir(config_profile_path):
@@ -51,12 +51,16 @@ class LocationsManager(object):
                                else:
                                        self.profile_path = None
                else:
+                       # NOTE: repoman may pass in an empty string
+                       # here, in order to create an empty profile
+                       # for checking dependencies of packages with
+                       # empty KEYWORDS.
                        self.profile_path = config_profile_path
 
 
                # The symlink might not exist or might not be a symlink.
                self.profiles = []
-               if self.profile_path is not None:
+               if self.profile_path:
                        try:
                                self._addProfile(os.path.realpath(self.profile_path))
                        except ParseError as e: