From c5142aadedee5b1917607f10d5018b763ef2419b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 22 Jun 2012 16:49:46 -0700 Subject: [PATCH] Enable /etc/portage/sets for stable, bug #384061. --- pym/_emerge/actions.py | 30 +++++++++++++------ pym/_emerge/depgraph.py | 11 +++++-- pym/_emerge/main.py | 9 ++---- pym/portage/_sets/__init__.py | 12 +++++++- pym/portage/_sets/files.py | 13 ++++---- pym/portage/const.py | 5 +--- pym/portage/tests/resolver/test_autounmask.py | 6 +--- 7 files changed, 50 insertions(+), 36 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 7ad28e62d..af42828d1 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -31,7 +31,7 @@ from portage import shutil from portage import eapi_is_supported, _unicode_decode from portage.cache.cache_errors import CacheError from portage.const import GLOBAL_CONFIG_PATH -from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG +from portage.const import _ENABLE_DYN_LINK_MAP from portage.dbapi.dep_expand import dep_expand from portage.dbapi._expand_new_virt import expand_new_virt from portage.dep import Atom, extended_cp_match @@ -76,6 +76,9 @@ from _emerge.userquery import userquery if sys.hexversion >= 0x3000000: long = int + _unicode = str +else: + _unicode = unicode def action_build(settings, trees, mtimedb, myopts, myaction, myfiles, spinner): @@ -1297,12 +1300,21 @@ def action_deselect(settings, trees, opts, atoms): break if discard_atoms: for atom in sorted(discard_atoms): + if pretend: - print(">>> Would remove %s from \"world\" favorites file..." % \ - colorize("INFORM", str(atom))) + action_desc = "Would remove" + else: + action_desc = "Removing" + + if atom.startswith(SETPREFIX): + filename = "world_sets" else: - print(">>> Removing %s from \"world\" favorites file..." % \ - colorize("INFORM", str(atom))) + filename = "world" + + writemsg_stdout( + ">>> %s %s from \"%s\" favorites file...\n" % + (action_desc, colorize("INFORM", _unicode(atom)), + filename), noiselevel=-1) if '--ask' in opts: prompt = "Would you like to remove these " + \ @@ -1466,11 +1478,11 @@ def action_info(settings, trees, myopts, myfiles): append("Repositories: %s" % \ " ".join(repo.name for repo in repos)) - if _ENABLE_SET_CONFIG: + installed_sets = sorted(s for s in + root_config.sets['selected'].getNonAtoms() if s.startswith(SETPREFIX)) + if installed_sets: sets_line = "Installed sets: " - sets_line += ", ".join(s for s in \ - sorted(root_config.sets['selected'].getNonAtoms()) \ - if s.startswith(SETPREFIX)) + sets_line += ", ".join(installed_sets) append(sets_line) if "--verbose" in myopts: diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 2547fa4e4..92c10611f 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -74,6 +74,9 @@ from _emerge.resolver.output import Display if sys.hexversion >= 0x3000000: basestring = str long = int + _unicode = str +else: + _unicode = unicode class _scheduler_graph_config(object): def __init__(self, trees, pkg_cache, graph, mergelist): @@ -6719,9 +6722,13 @@ class depgraph(object): all_added.extend(added_favorites) all_added.sort() for a in all_added: + if a.startswith(SETPREFIX): + filename = "world_sets" + else: + filename = "world" writemsg_stdout( - ">>> Recording %s in \"world\" favorites file...\n" % \ - colorize("INFORM", str(a)), noiselevel=-1) + ">>> Recording %s in \"%s\" favorites file...\n" % + (colorize("INFORM", _unicode(a)), filename), noiselevel=-1) if all_added: world_set.update(all_added) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index efd954bb9..35401383f 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1370,14 +1370,9 @@ def clean_logs(settings): "PORT_LOGDIR_CLEAN usage instructions.") def setconfig_fallback(root_config): - from portage._sets.base import DummyPackageSet - from portage._sets.files import WorldSelectedSet - from portage._sets.profiles import PackagesSystemSet setconfig = root_config.setconfig - setconfig.psets['world'] = DummyPackageSet(atoms=['@selected', '@system']) - setconfig.psets['selected'] = WorldSelectedSet(root_config.settings['EROOT']) - setconfig.psets['system'] = \ - PackagesSystemSet(root_config.settings.profiles) + setconfig._create_default_config() + setconfig._parse(update=True) root_config.sets = setconfig.getSets() def get_missing_sets(root_config): diff --git a/pym/portage/_sets/__init__.py b/pym/portage/_sets/__init__.py index 88a4b3b1b..c3b590e92 100644 --- a/pym/portage/_sets/__init__.py +++ b/pym/portage/_sets/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2007-2011 Gentoo Foundation +# Copyright 2007-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -111,16 +111,26 @@ class SetConfig(object): """ parser = self._parser + parser.remove_section("world") parser.add_section("world") parser.set("world", "class", "portage.sets.base.DummyPackageSet") parser.set("world", "packages", "@selected @system") + parser.remove_section("selected") parser.add_section("selected") parser.set("selected", "class", "portage.sets.files.WorldSelectedSet") + parser.remove_section("system") parser.add_section("system") parser.set("system", "class", "portage.sets.profiles.PackagesSystemSet") + parser.remove_section("usersets") + parser.add_section("usersets") + parser.set("usersets", "class", "portage.sets.files.StaticFileSet") + parser.set("usersets", "multiset", "true") + parser.set("usersets", "directory", "%(PORTAGE_CONFIGROOT)setc/portage/sets") + parser.set("usersets", "world-candidate", "true") + def update(self, setname, options): parser = self._parser self.errors = [] diff --git a/pym/portage/_sets/files.py b/pym/portage/_sets/files.py index f19ecf6ce..b891ea4f4 100644 --- a/pym/portage/_sets/files.py +++ b/pym/portage/_sets/files.py @@ -1,4 +1,4 @@ -# Copyright 2007-2011 Gentoo Foundation +# Copyright 2007-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import errno @@ -11,7 +11,6 @@ from portage import _unicode_decode from portage import _unicode_encode from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path from portage.const import USER_CONFIG_PATH, WORLD_FILE, WORLD_SETS_FILE -from portage.const import _ENABLE_SET_CONFIG from portage.localization import _ from portage.locks import lockfile, unlockfile from portage import portage_gid @@ -231,9 +230,8 @@ class WorldSelectedSet(EditablePackageSet): write_atomic(self._filename, "".join(sorted("%s\n" % x for x in self._atoms))) - if _ENABLE_SET_CONFIG: - write_atomic(self._filename2, - "".join(sorted("%s\n" % x for x in self._nonatoms))) + write_atomic(self._filename2, + "".join(sorted("%s\n" % x for x in self._nonatoms))) def load(self): atoms = [] @@ -263,9 +261,8 @@ class WorldSelectedSet(EditablePackageSet): else: atoms.extend(self._atoms) - if _ENABLE_SET_CONFIG: - changed2, nonatoms = self._load2() - atoms_changed |= changed2 + changed2, nonatoms = self._load2() + atoms_changed |= changed2 if atoms_changed: self._setAtoms(atoms+nonatoms) diff --git a/pym/portage/const.py b/pym/portage/const.py index 3744e111f..3607df0e0 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -1,5 +1,5 @@ # portage: Constants -# Copyright 1998-2011 Gentoo Foundation +# Copyright 1998-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import os @@ -175,6 +175,3 @@ if not _ENABLE_PRESERVE_LIBS: SUPPORTED_FEATURES = set(SUPPORTED_FEATURES) SUPPORTED_FEATURES.remove("preserve-libs") SUPPORTED_FEATURES = frozenset(SUPPORTED_FEATURES) - -if not _ENABLE_SET_CONFIG: - WORLD_SETS_FILE = '/dev/null' diff --git a/pym/portage/tests/resolver/test_autounmask.py b/pym/portage/tests/resolver/test_autounmask.py index 84182ba6a..6acac9984 100644 --- a/pym/portage/tests/resolver/test_autounmask.py +++ b/pym/portage/tests/resolver/test_autounmask.py @@ -1,7 +1,6 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -from portage.const import _ENABLE_SET_CONFIG from portage.tests import TestCase from portage.tests.resolver.ResolverPlayground import ResolverPlayground, ResolverPlaygroundTestCase @@ -340,9 +339,6 @@ class AutounmaskTestCase(TestCase): def testAutounmaskAndSets(self): - if not _ENABLE_SET_CONFIG: - return - ebuilds = { #ebuilds to test use changes "dev-libs/A-1": { }, -- 2.26.2