commit:     f31405557db59f7127a8bbeea52da36172a4b75b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 19 23:00:43 2014 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Sep 20 17:40:45 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f3140555

_quickpkg_dblink: fix bug #523152

This fixes the unmerge-backup and downgrade-backup features to be
compatible with the new setup.py quickpkg install location, while
preserving compatibility for running from a source tree (for unit tests
or developement purposes). If not running from a source tree, then the
PATH variable is used to locate the quickpkg binary.

X-Gentoo-Bug: 523152
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523152

---
 pym/portage/dbapi/vartree.py            | 10 ++++++++++
 pym/portage/tests/emerge/test_simple.py | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 8bc6073..b46ba0b 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -25,6 +25,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
                '_merge_unicode_error', '_spawn_phase',
        'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs',
        'portage.package.ebuild._ipc.QueryCommand:QueryCommand',
+       'portage.process:find_binary',
        'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \
                
'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \
                'grabdict,normalize_path,new_protect_filename',
@@ -5011,6 +5012,15 @@ class dblink(object):
                        quickpkg_binary = 
os.path.join(self.settings["PORTAGE_BIN_PATH"],
                                "quickpkg")
 
+                       if not os.access(quickpkg_binary, os.X_OK):
+                               # If not running from the source tree, use PATH.
+                               quickpkg_binary = find_binary("quickpkg")
+                               if quickpkg_binary is None:
+                                       self._display_merge(
+                                               _("%s: command not found") % 
"quickpkg",
+                                               level=logging.ERROR, 
noiselevel=-1)
+                                       return 127
+
                        # Let quickpkg inherit the global vartree config's env.
                        env = dict(self.vartree.settings.items())
                        env["__PORTAGE_INHERIT_VARDB_LOCK"] = "1"

diff --git a/pym/portage/tests/emerge/test_simple.py 
b/pym/portage/tests/emerge/test_simple.py
index 9c1b1bf..0bb83ae 100644
--- a/pym/portage/tests/emerge/test_simple.py
+++ b/pym/portage/tests/emerge/test_simple.py
@@ -243,6 +243,12 @@ pkg_preinst() {
                        emerge_cmd + ("--metadata",),
                        rm_cmd + ("-rf", cachedir),
                        emerge_cmd + ("--oneshot", "virtual/foo"),
+                       lambda: self.assertFalse(os.path.exists(
+                               os.path.join(pkgdir, "virtual", "foo-0.tbz2"))),
+                       ({"FEATURES" : "unmerge-backup"},) + \
+                               emerge_cmd + ("--unmerge", "virtual/foo"),
+                       lambda: self.assertTrue(os.path.exists(
+                               os.path.join(pkgdir, "virtual", "foo-0.tbz2"))),
                        emerge_cmd + ("--pretend", "dev-libs/A"),
                        ebuild_cmd + (test_ebuild, "manifest", "clean", 
"package", "merge"),
                        emerge_cmd + ("--pretend", "--tree", 
"--complete-graph", "dev-libs/A"),
@@ -395,6 +401,10 @@ move dev-util/git dev-vcs/git
 
                        for args in test_commands:
 
+                               if hasattr(args, '__call__'):
+                                       args()
+                                       continue
+
                                if isinstance(args[0], dict):
                                        local_env = env.copy()
                                        local_env.update(args[0])

Reply via email to