diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-06-20 02:02:55 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-06-20 02:02:55 -0700 |
commit | 217710df4570af5c36a53c144647e0d95c4ff2a8 (patch) | |
tree | f1b1a1807d487135bf7dfe0e56356d7238b113d0 | |
parent | 0f16a6aa3e7e1f9a601eee88e117fbd141735828 (diff) | |
download | portage-217710df4570af5c36a53c144647e0d95c4ff2a8.tar.gz portage-217710df4570af5c36a53c144647e0d95c4ff2a8.tar.bz2 portage-217710df4570af5c36a53c144647e0d95c4ff2a8.zip |
ResolverPlayground: support binary packages
-rw-r--r-- | pym/portage/tests/emerge/test_simple.py | 6 | ||||
-rw-r--r-- | pym/portage/tests/resolver/ResolverPlayground.py | 35 | ||||
-rw-r--r-- | pym/portage/tests/resolver/test_simple.py | 20 | ||||
-rw-r--r-- | pym/portage/xpak.py | 2 |
4 files changed, 51 insertions, 12 deletions
diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py index 28ac09843..f87170a71 100644 --- a/pym/portage/tests/emerge/test_simple.py +++ b/pym/portage/tests/emerge/test_simple.py @@ -1,4 +1,4 @@ -# Copyright 2011 Gentoo Foundation +# Copyright 2011-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import subprocess @@ -259,8 +259,8 @@ pkg_preinst() { emerge_cmd + ("-C", "--quiet", "dev-libs/B"), ) - distdir = os.path.join(eprefix, "distdir") - pkgdir = os.path.join(eprefix, "pkgdir") + distdir = playground.distdir + pkgdir = playground.pkgdir fake_bin = os.path.join(eprefix, "bin") portage_tmpdir = os.path.join(eprefix, "var", "tmp", "portage") profile_path = settings.profile_path diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 140b25d6e..1e2d64d7b 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from itertools import permutations @@ -9,9 +9,6 @@ from portage import os from portage import shutil from portage.const import (GLOBAL_CONFIG_PATH, PORTAGE_BASE_PATH, USER_CONFIG_PATH) -from portage.dbapi.vartree import vartree -from portage.dbapi.porttree import portagetree -from portage.dbapi.bintree import binarytree from portage.dep import Atom, _repo_separator from portage.package.ebuild.config import config from portage.package.ebuild.digestgen import digestgen @@ -56,7 +53,7 @@ class ResolverPlayground(object): </pkgmetadata> """ - def __init__(self, ebuilds={}, installed={}, profile={}, repo_configs={}, \ + def __init__(self, ebuilds={}, binpkgs={}, installed={}, profile={}, repo_configs={}, \ user_config={}, sets={}, world=[], world_sets=[], distfiles={}, debug=False): """ ebuilds: cpv -> metadata mapping simulating available ebuilds. @@ -68,6 +65,7 @@ class ResolverPlayground(object): self.eprefix = normalize_path(tempfile.mkdtemp()) self.eroot = self.eprefix + os.sep self.distdir = os.path.join(self.eroot, "var", "portage", "distfiles") + self.pkgdir = os.path.join(self.eprefix, "pkgdir") self.portdir = os.path.join(self.eroot, "usr/portage") self.vdbdir = os.path.join(self.eroot, "var/db/pkg") os.makedirs(self.portdir) @@ -82,6 +80,7 @@ class ResolverPlayground(object): self._create_distfiles(distfiles) self._create_ebuilds(ebuilds) + self._create_binpkgs(binpkgs) self._create_installed(installed) self._create_profile(ebuilds, installed, profile, repo_configs, user_config, sets) self._create_world(world, world_sets) @@ -205,6 +204,27 @@ class ResolverPlayground(object): if not digestgen(mysettings=tmpsettings, myportdb=portdb): raise AssertionError('digest creation failed for %s' % ebuild_path) + def _create_binpkgs(self, binpkgs): + for cpv, metadata in binpkgs.items(): + a = Atom("=" + cpv, allow_repo=True) + repo = a.repo + if repo is None: + repo = "test_repo" + + cat, pf = catsplit(a.cpv) + metadata = metadata.copy() + metadata.setdefault("SLOT", "0") + metadata.setdefault("KEYWORDS", "x86") + metadata["CATEGORY"] = cat + metadata["PF"] = pf + + repo_dir = self.pkgdir + category_dir = os.path.join(repo_dir, cat) + binpkg_path = os.path.join(category_dir, pf + ".tbz2") + ensure_dirs(category_dir) + t = portage.xpak.tbz2(binpkg_path) + t.recompose_mem(portage.xpak.xpak_mem(metadata)) + def _create_installed(self, installed): for cpv in installed: a = Atom("=" + cpv, allow_repo=True) @@ -473,7 +493,7 @@ class ResolverPlayground(object): env = { "ACCEPT_KEYWORDS": "x86", "DISTDIR" : self.distdir, - "PKGDIR": os.path.join(self.eroot, "usr/portage/packages"), + "PKGDIR": self.pkgdir, "PORTDIR": self.portdir, "PORTDIR_OVERLAY": " ".join(portdir_overlay), 'PORTAGE_TMPDIR' : os.path.join(self.eroot, 'var/tmp'), @@ -511,6 +531,9 @@ class ResolverPlayground(object): elif options.get("--prune"): action = "prune" + if "--usepkgonly" in options: + options["--usepkg"] = True + global_noiselimit = portage.util.noiselimit global_emergelog_disable = _emerge.emergelog._disable try: diff --git a/pym/portage/tests/resolver/test_simple.py b/pym/portage/tests/resolver/test_simple.py index 4c2e97ef2..62a589259 100644 --- a/pym/portage/tests/resolver/test_simple.py +++ b/pym/portage/tests/resolver/test_simple.py @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from portage.tests import TestCase @@ -17,6 +17,9 @@ class SimpleResolverTestCase(TestCase): "app-misc/X-1": {}, "app-misc/W-1": {}, } + binpkgs = { + "dev-libs/B-1.2": {}, + } installed = { "dev-libs/A-1": {}, "dev-libs/B-1.1": {}, @@ -43,13 +46,26 @@ class SimpleResolverTestCase(TestCase): mergelist = ["dev-libs/B-1.2"]), ResolverPlaygroundTestCase( + ["dev-libs/B"], + options = {"--update": True, "--usepkg": True}, + success = True, + mergelist = ["dev-libs/B-1.2"]), + + ResolverPlaygroundTestCase( + ["dev-libs/B"], + options = {"--update": True, "--usepkgonly": True}, + success = True, + mergelist = ["dev-libs/B-1.2"]), + + ResolverPlaygroundTestCase( ["app-misc/Z"], success = True, ambiguous_merge_order = True, mergelist = [("app-misc/W-1", "app-misc/X-1"), "app-misc/Z-1"]), ) - playground = ResolverPlayground(ebuilds=ebuilds, installed=installed) + playground = ResolverPlayground(ebuilds=ebuilds, + binpkgs=binpkgs, installed=installed) try: for test_case in test_cases: playground.run_TestCase(test_case) diff --git a/pym/portage/xpak.py b/pym/portage/xpak.py index 32623263e..73f84ab75 100644 --- a/pym/portage/xpak.py +++ b/pym/portage/xpak.py @@ -324,7 +324,7 @@ class tbz2(object): """ self.scan() # Don't care about condition... We'll rewrite the data anyway. - if break_hardlinks and self.filestat.st_nlink > 1: + if break_hardlinks and self.filestat and self.filestat.st_nlink > 1: tmp_fname = "%s.%d" % (self.file, os.getpid()) shutil.copyfile(self.file, tmp_fname) try: |