15777 pkgdep resolve should provide an option to only resolve against the manifests provided
authorBrock Pytlik <bpytlik@sun.com>
Wed, 05 May 2010 16:17:52 -0700
changeset 1886 650a8de627ae
parent 1885 9e58f09823c0
child 1887 757d613561da
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
src/man/pkgdepend.1.txt
src/modules/publish/dependencies.py
src/pkgdep.py
src/tests/api/t_api_search.py
src/tests/cli/t_pkgdep.py
src/tests/cli/t_pkgdep_resolve.py
src/tests/pkg5unittest.py
--- a/src/man/pkgdepend.1.txt	Wed May 05 08:30:29 2010 +0100
+++ b/src/man/pkgdepend.1.txt	Wed May 05 16:17:52 2010 -0700
@@ -10,7 +10,7 @@
      /usr/bin/pkgdepend generate [-IMm] [-D name=value] [-k path] manifest_path
          proto_dir
 
-     /usr/bin/pkgdepend resolve [-dmosv] manifest_path ...
+     /usr/bin/pkgdepend resolve [-dmosSv] manifest_path ...
 
 DESCRIPTION
      pkgdepend(1) is used to generate and resolve dependencies for
@@ -84,6 +84,9 @@
           will be added to the argument if not provided) to the basename
           of the file that was the source of the resolved dependencies.
 
+          With -S, only resolve against the manifests given on the command
+          line and not against those installed on the system.
+
           With -v, include additional package dependency debugging
           metadata.
 
--- a/src/modules/publish/dependencies.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/modules/publish/dependencies.py	Wed May 05 16:17:52 2010 -0700
@@ -424,7 +424,7 @@
         return [(a, v) for a, v in res if a not in multiple_path_errs], \
             dep_vars, errs
 
-def find_package(delivered, installed, file_dep, pkg_vars):
+def find_package(delivered, installed, file_dep, pkg_vars, use_system):
         """Find the packages which resolve the dependency. It returns a list of
         dependency actions with the fmri tag resolved.
 
@@ -441,7 +441,7 @@
         # First try to resolve the dependency against the delivered files.
         res, dep_vars, errs = find_package_using_delivered_files(delivered,
                 file_dep, dep_vars, orig_dep_vars)
-        if res and dep_vars.is_satisfied():
+        if (res and dep_vars.is_satisfied()) or not use_system:
                 return res, dep_vars, errs
         # If the dependency isn't fully satisfied, resolve it against the
         # files installed in the current image.
@@ -648,7 +648,7 @@
                      if not k.startswith(base.Dependency.DEPEND_DEBUG_PREFIX))
         return actions.depend.DependencyAction(**attrs)
 
-def resolve_deps(manifest_paths, api_inst, prune_attrs=False):
+def resolve_deps(manifest_paths, api_inst, prune_attrs=False, use_system=True):
         """For each manifest given, resolve the file dependencies to package
         dependencies. It returns a mapping from manifest_path to a list of
         dependencies and a list of unresolved dependencies.
@@ -705,12 +705,13 @@
 
         # Build a list of all files delivered in the packages installed on
         # the system.
-        for (pub, stem, ver), summ, cats, states in api_inst.get_pkg_list(
-            api.ImageInterface.LIST_INSTALLED):
-                pfmri = fmri.PkgFmri("pkg:/%s@%s" % (stem, ver))
-                mfst = api_inst.get_manifest(pfmri, all_variants=True)
-                add_fmri_path_mapping(installed_files, pfmri.get_short_fmri(),
-                                      mfst)
+        if use_system:
+                for (pub, stem, ver), summ, cats, states in \
+                    api_inst.get_pkg_list(api.ImageInterface.LIST_INSTALLED):
+                        pfmri = fmri.PkgFmri("pkg:/%s@%s" % (stem, ver))
+                        mfst = api_inst.get_manifest(pfmri, all_variants=True)
+                        add_fmri_path_mapping(installed_files,
+                            pfmri.get_short_fmri(), mfst)
 
         pkg_deps = {}
         errs = []
@@ -721,7 +722,7 @@
                         continue
                 pkg_res = [
                     (d, find_package(delivered_files, installed_files,
-                        d, pkg_vars))
+                        d, pkg_vars, use_system))
                     for d in mfst.gen_actions_by_type("depend")
                     if is_file_dependency(d)
                 ]
--- a/src/pkgdep.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/pkgdep.py	Wed May 05 16:17:52 2010 -0700
@@ -189,8 +189,9 @@
         output_to_screen = False
         suffix = None
         verbose = False
+        use_system_to_resolve = True
         try:
-            opts, pargs = getopt.getopt(args, "d:mos:v")
+            opts, pargs = getopt.getopt(args, "d:mos:Sv")
         except getopt.GetoptError, e:
             usage(_("illegal global option -- %s") % e.opt)
         for opt, arg in opts:
@@ -202,6 +203,8 @@
                         output_to_screen = True
                 elif opt == "-s":
                         suffix = arg
+                elif opt == "-S":
+                        use_system_to_resolve = False
                 elif opt == "-v":
                         verbose = True
 
@@ -253,7 +256,7 @@
 
         try:
             pkg_deps, errs = dependencies.resolve_deps(manifest_paths, api_inst,
-                prune_attrs=not verbose)
+                prune_attrs=not verbose, use_system=use_system_to_resolve)
         except (actions.MalformedActionError, actions.UnknownActionError), e:
             error(_("Could not parse one or more manifests because of the " +
                 "following line:\n%s") % e.actionstr)
--- a/src/tests/api/t_api_search.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/tests/api/t_api_search.py	Wed May 05 16:17:52 2010 -0700
@@ -1212,26 +1212,6 @@
                 if os.path.exists(ind_dir_tmp):
                         self.assert_(0)
 
-        def _do_install(self, api_obj, pkg_list, **kwargs):
-                self.debug("install %s" % " ".join(pkg_list))
-                api_obj.plan_install(pkg_list, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_uninstall(self, api_obj, pkg_list, **kwargs):
-                self.debug("uninstall %s" % " ".join(pkg_list))
-                api_obj.plan_uninstall(pkg_list, False, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_image_update(self, api_obj, **kwargs):
-                self.debug("planning image-update")
-                api_obj.plan_update_all(sys.argv[0], verbose=False, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_finish(self, api_obj):
-                api_obj.prepare()
-                api_obj.execute_plan()
-                api_obj.reset()
-
         @staticmethod
         def validateAssertRaises(ex_type, validate_func, func, *args, **kwargs):
                 try:
@@ -1286,7 +1266,7 @@
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
 
                 self._run_full_local_tests(api_obj)
 
@@ -1295,7 +1275,7 @@
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
 
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
                 shutil.rmtree(index_dir)
@@ -1313,13 +1293,13 @@
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["[email protected]"])
-                self._do_uninstall(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["[email protected]"])
+                self._api_uninstall(api_obj, ["example_pkg"])
 
                 for i in range(1, repeat):
-                        self._do_install(api_obj, ["example_pkg"])
+                        self._api_install(api_obj, ["example_pkg"])
                         self._run_local_tests(api_obj)
-                        self._do_uninstall(api_obj, ["example_pkg"])
+                        self._api_uninstall(api_obj, ["example_pkg"])
                         api_obj.reset()
                         self._run_local_empty_tests(api_obj)
 
@@ -1328,7 +1308,7 @@
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
                 self._search_op(api_obj, False, "fooo", set(), True)
                 self._search_op(api_obj, False, "fo*", set(), True)
                 self._search_op(api_obj, False, "bar", set(), True)
@@ -1342,7 +1322,7 @@
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
 
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
 
@@ -1372,7 +1352,7 @@
                 Bug 2753"""
                 durl = self.dc.get_depot_url()
                 api_obj = self.image_create(durl)
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
 
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
 
@@ -1401,13 +1381,13 @@
                         self._overwrite_version_number(orig_path)
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_uninstall, api_obj, ["example_pkg"])
+                            self._api_uninstall, api_obj, ["example_pkg"])
                         api_obj.reset()
                         self._search_op(api_obj, False, "example_pkg", set())
                         self._overwrite_version_number(orig_path)
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_install, api_obj, ["example_pkg"])
+                            self._api_install, api_obj, ["example_pkg"])
                         api_obj.reset()
                         self._search_op(api_obj, False, "example_pkg",
                             self.res_local_pkg)
@@ -1426,7 +1406,7 @@
                     self.res_local_pkg)
                 self._overwrite_hash(ffh_path)
                 self.assertRaises(api_errors.WrapSuccessfulIndexingException,
-                    self._do_uninstall, api_obj, ["example_pkg"])
+                    self._api_uninstall, api_obj, ["example_pkg"])
                 self._search_op(api_obj, False, "example_pkg", set())
 
         def test_080_weird_patterns(self):
@@ -1451,9 +1431,9 @@
 
                 tmp_dir = os.path.join(self.img_path, "var", "pkg", "index",
                     "TMP")
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
                 api_obj.rebuild_search_index()
-                self._do_install(api_obj, ["fat"])
+                self._api_install(api_obj, ["fat"])
                 self.assert_(not os.path.exists(tmp_dir))
                 self._run_local_tests(api_obj)
 
@@ -1472,7 +1452,7 @@
 
                 self._search_op(api_obj, remote, "fat:::*",
                     self.res_remote_fat10_star)
-                self._do_install(api_obj, ["fat"])
+                self._api_install(api_obj, ["fat"])
                 remote = False
                 self._search_op(api_obj, remote, "fat:::*",
                     self.res_local_fat10_i386_star)
@@ -1491,7 +1471,7 @@
 
                 self._search_op(api_obj, remote, "fat:::*",
                     self.res_remote_fat10_star)
-                self._do_install(api_obj, ["fat"])
+                self._api_install(api_obj, ["fat"])
                 remote = False
                 self._search_op(api_obj, remote, "fat:::*",
                     self.res_local_fat10_sparc_star)
@@ -1520,7 +1500,7 @@
                 self._run_remove_root_search(self._search_op_multi, True,
                     api_obj, ip)
 
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
                 # Do local searches
                 self._run_remove_root_search(self._search_op_multi, False,
                     api_obj, ip)
@@ -1537,13 +1517,13 @@
                 self.pkgsend_bulk(durl, self.space_pkg10)
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["space_pkg"])
+                self._api_install(api_obj, ["space_pkg"])
                 time.sleep(1)
 
                 self.pkgsend_bulk(durl, self.space_pkg10, optional=False)
                 api_obj.refresh(immediate=True)
 
-                self._do_install(api_obj, ["space_pkg"])
+                self._api_install(api_obj, ["space_pkg"])
 
                 remote = False
                 self._search_op(api_obj, remote, 'with', set())
@@ -1580,29 +1560,30 @@
                 api_obj = self.image_create(durl)
 
                 self._check_no_index()
-                self._do_install(api_obj, ["example_pkg"], update_index=False)
+                self._api_install(api_obj, ["example_pkg"], update_index=False)
                 self._check_no_index()
                 api_obj.rebuild_search_index()
                 self._run_local_tests(api_obj)
-                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
+                self._api_uninstall(api_obj, ["example_pkg"], update_index=False)
                 # Running empty test because search will notice the index
                 # does not match the installed packages and complain.
                 self.assertRaises(api_errors.IncorrectIndexFileHash,
                     self._search_op, api_obj, False, "example_pkg", set())
                 api_obj.rebuild_search_index()
                 self._run_local_empty_tests(api_obj)
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
                 self._run_local_tests(api_obj)
                 self.pkgsend_bulk(durl, self.example_pkg11)
                 api_obj.refresh(immediate=True)
-                self._do_image_update(api_obj, update_index=False)
+                self._api_image_update(api_obj, update_index=False)
                 # Running empty test because search will notice the index
                 # does not match the installed packages and complain.
                 self.assertRaises(api_errors.IncorrectIndexFileHash,
                     self._search_op, api_obj, False, "example_pkg", set())
                 api_obj.rebuild_search_index()
                 self._run_local_tests_example11_installed(api_obj)
-                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
+                self._api_uninstall(api_obj, ["example_pkg"],
+                    update_index=False)
                 # Running empty test because search will notice the index
                 # does not match the installed packages and complain.
                 self.assertRaises(api_errors.IncorrectIndexFileHash,
@@ -1622,13 +1603,13 @@
 
                         shutil.copytree(index_dir, index_dir_tmp)
 
-                        self._do_install(api_obj, ["example_pkg"])
+                        self._api_install(api_obj, ["example_pkg"])
 
                         f(index_dir, index_dir_tmp)
 
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_uninstall, api_obj, ["example_pkg"])
+                            self._api_uninstall, api_obj, ["example_pkg"])
 
                         self.image_destroy()
 
@@ -1638,19 +1619,19 @@
                 for f in self._dir_restore_functions:
                         api_obj = self.image_create(durl)
 
-                        self._do_install(api_obj, ["example_pkg"])
+                        self._api_install(api_obj, ["example_pkg"])
 
                         index_dir, index_dir_tmp = self._get_index_dirs()
 
                         shutil.copytree(index_dir, index_dir_tmp)
 
-                        self._do_install(api_obj, ["another_pkg"])
+                        self._api_install(api_obj, ["another_pkg"])
 
                         f(index_dir, index_dir_tmp)
 
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_uninstall, api_obj, ["another_pkg"])
+                            self._api_uninstall, api_obj, ["another_pkg"])
 
                         self.image_destroy()
 
@@ -1661,19 +1642,19 @@
                 for f in self._dir_restore_functions:
                         api_obj = self.image_create(durl)
 
-                        self._do_install(api_obj, ["[email protected],5.11-0"])
+                        self._api_install(api_obj, ["[email protected],5.11-0"])
 
                         index_dir, index_dir_tmp = self._get_index_dirs()
 
                         shutil.copytree(index_dir, index_dir_tmp)
 
-                        self._do_install(api_obj, ["example_pkg"])
+                        self._api_install(api_obj, ["example_pkg"])
 
                         f(index_dir, index_dir_tmp)
 
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_uninstall, api_obj, ["example_pkg"])
+                            self._api_uninstall, api_obj, ["example_pkg"])
 
                         self.image_destroy()
 
@@ -1684,19 +1665,19 @@
                 for f in self._dir_restore_functions:
                         api_obj = self.image_create(durl)
 
-                        self._do_install(api_obj, ["another_pkg"])
+                        self._api_install(api_obj, ["another_pkg"])
 
                         index_dir, index_dir_tmp = self._get_index_dirs()
 
                         shutil.copytree(index_dir, index_dir_tmp)
 
-                        self._do_install(api_obj, ["[email protected],5.11-0"])
+                        self._api_install(api_obj, ["[email protected],5.11-0"])
 
                         f(index_dir, index_dir_tmp)
 
                         self.assertRaises(
                             api_errors.WrapSuccessfulIndexingException,
-                            self._do_image_update, api_obj)
+                            self._api_image_update, api_obj)
 
                         self.image_destroy()
 
@@ -1769,17 +1750,17 @@
                 _run_cat3_tests(self, remote)
 
                 remote = False
-                self._do_install(api_obj, ["cat"])
+                self._api_install(api_obj, ["cat"])
                 _run_cat_tests(self, remote)
 
-                self._do_install(api_obj, ["cat2"])
+                self._api_install(api_obj, ["cat2"])
                 _run_cat2_tests(self, remote)
 
-                self._do_install(api_obj, ["cat3"])
+                self._api_install(api_obj, ["cat3"])
                 _run_cat3_tests(self, remote)
 
-                self._do_install(api_obj, ["badcat"])
-                self._do_install(api_obj, ["badcat2"])
+                self._api_install(api_obj, ["badcat"])
+                self._api_install(api_obj, ["badcat2"])
                 _run_cat_tests(self, remote)
                 _run_cat2_tests(self, remote)
                 _run_cat3_tests(self, remote)
@@ -1859,12 +1840,12 @@
                     get_file_name())
                 dest_fn = orig_fn + "TMP"
 
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
                 api_obj.rebuild_search_index()
 
                 portable.rename(orig_fn, dest_fn)
                 self.assertRaises(api_errors.WrapSuccessfulIndexingException,
-                    self._do_uninstall, api_obj, ["example_pkg"])
+                    self._api_uninstall, api_obj, ["example_pkg"])
 
         def test_bug_8492(self):
                 """Tests that field queries and phrase queries work together.
@@ -1879,7 +1860,7 @@
                 self._search_op(api_obj, True, "b1:set::'image packaging'",
                     self.res_8492_1)
 
-                self._do_install(api_obj, ["b1", "b2"])
+                self._api_install(api_obj, ["b1", "b2"])
 
                 self._search_op(api_obj, False, "set::'image packaging'",
                     self.res_8492_1 | self.res_8492_2)
@@ -2081,7 +2062,7 @@
 
                 remote = True
                 run_tests(api_obj, remote)
-                self._do_install(api_obj, ["pfoo"])
+                self._api_install(api_obj, ["pfoo"])
                 remote = False
                 run_tests(api_obj, remote)
                 api_obj.rebuild_search_index()
@@ -2103,12 +2084,12 @@
                 self.pkgsend_bulk(durl, self.example_pkg10)
                 api_obj = self.image_create(durl)
 
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
 
                 self.pkgsend_bulk(durl, self.example_pkg11)
                 api_obj.refresh(immediate=True)
 
-                self._do_image_update(api_obj)
+                self._api_image_update(api_obj)
 
                 self._run_local_tests_example11_installed(api_obj)
 
@@ -2199,20 +2180,20 @@
 
                 # Test that if a package is installed, its version and newer
                 # versions are shown.
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
                 self._search_op(api_obj, True, "/bin", res_both_actions)
                 self._search_op(api_obj, True, "/bin", res_both_actions,
                     prune_versions=False)
 
                 # Check that after uninstall, back to returning all versions.
-                self._do_uninstall(api_obj, ["example_pkg"])
+                self._api_uninstall(api_obj, ["example_pkg"])
                 self._search_op(api_obj, True, "/bin", res_both_actions)
                 self._search_op(api_obj, True, "/bin", res_both_packages,
                     return_actions=False)
 
                 # Test that if a package is installed, its version and newer
                 # versions are shown.  Older versions should not be shown.
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
                 self._search_op(api_obj, True, "/bin", res_11_action)
                 self._search_op(api_obj, True, "</bin>", res_11_package,
                     return_actions=False)
@@ -2222,11 +2203,11 @@
                     return_actions=False, prune_versions=False)
                 
                 # Check that after uninstall, back to returning all versions.
-                self._do_uninstall(api_obj, ["example_pkg"])
+                self._api_uninstall(api_obj, ["example_pkg"])
                 self._search_op(api_obj, True, "/bin", res_both_actions)
 
                 # Check that only the incorporated package is returned.
-                self._do_install(api_obj, ["[email protected]"])
+                self._api_install(api_obj, ["[email protected]"])
                 self._search_op(api_obj, True, "/bin", res_10_action)
                 self._search_op(api_obj, True, "/bin", res_10_package,
                     return_actions=False)
@@ -2237,7 +2218,7 @@
 
                 # Should now show the 1.1 version of example_pkg since the
                 # version has been upgraded.
-                self._do_install(api_obj, ["incorp_pkg"])
+                self._api_install(api_obj, ["incorp_pkg"])
                 self._search_op(api_obj, True, "/bin", res_11_action)
                 self._search_op(api_obj, True, "</bin>", res_11_package,
                     return_actions=False)
@@ -2248,11 +2229,12 @@
 
                 # Should now show both again since the incorporation has been
                 # removed.
-                self._do_uninstall(api_obj, ["incorp_pkg"])
+                self._api_uninstall(api_obj, ["incorp_pkg"])
                 self._search_op(api_obj, True, "/bin", res_both_actions)
 
                 # Check that installed and incorporated work correctly together.
-                self._do_install(api_obj, ["[email protected]", "[email protected]"])
+                self._api_install(api_obj,
+                    ["[email protected]", "[email protected]"])
                 self._search_op(api_obj, True, "/bin", res_10_action)
                 self._search_op(api_obj, True, "</bin>", res_10_package,
                     return_actions=False)
@@ -2262,7 +2244,7 @@
                     return_actions=False, prune_versions=False)
 
                 # And that it works after the incorporation has been changed.
-                self._do_install(api_obj, ["incorp_pkg"])
+                self._api_install(api_obj, ["incorp_pkg"])
                 self._search_op(api_obj, True, "/bin", res_11_action)
                 self._search_op(api_obj, True, "</bin>", res_11_package,
                     return_actions=False)
@@ -2385,7 +2367,7 @@
                             "open pkg%[email protected],5.11-0\nclose\n" % i)
                         pkg_list.append("pkg%s" % i)
                 api_obj = self.image_create(durl)
-                self._do_install(api_obj, pkg_list)
+                self._api_install(api_obj, pkg_list)
 
         def test_bug_9729_2(self):
                 """Test that installing more than
@@ -2406,7 +2388,7 @@
                     "fast_remove.v1")
                 api_obj.rebuild_search_index()
                 for p in pkg_list:
-                        self._do_install(api_obj, [p])
+                        self._api_install(api_obj, [p])
                 # Test for bug 11104. The fast_add.v1 file was not being updated
                 # correctly by install or image update, it was growing with
                 # each modification.
@@ -2425,7 +2407,7 @@
                             "open pkg%[email protected],5.11-0\nclose\n" % i)
                         pkg_list.append("pkg%s" % i)
                 api_obj.refresh(immediate=True)
-                self._do_image_update(api_obj)
+                self._api_image_update(api_obj)
                 self._check(set((
                     _remove_extra_info(v)
                     for v in self._get_lines(fast_add_loc)
@@ -2442,7 +2424,7 @@
                             "open pkg%[email protected],5.11-0\nclose\n" % i)
                         pkg_list.append("pkg%s" % i)
                 api_obj.refresh(immediate=True)
-                self._do_image_update(api_obj)
+                self._api_image_update(api_obj)
                 self._check(set((
                     _remove_extra_info(v)
                     for v in self._get_lines(fast_add_loc)
@@ -2505,26 +2487,6 @@
             'set name=pkg.fmri value=pkg://test2/[email protected],5.11-0:')
         ])
 
-        def _do_install(self, api_obj, pkg_list, **kwargs):
-                self.debug("install %s" % " ".join(pkg_list))
-                api_obj.plan_install(pkg_list, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_uninstall(self, api_obj, pkg_list, **kwargs):
-                self.debug("uninstall %s" % " ".join(pkg_list))
-                api_obj.plan_uninstall(pkg_list, False, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_image_update(self, api_obj, **kwargs):
-                self.debug("planning image-update")
-                api_obj.plan_update_all(sys.argv[0], verbose=False, **kwargs)
-                self._do_finish(api_obj)
-
-        def _do_finish(self, api_obj):
-                api_obj.prepare()
-                api_obj.execute_plan()
-                api_obj.reset()
-
         def setUp(self):
                 pkg5unittest.ManyDepotTestCase.setUp(self, ["test1", "test2",
                     "test3"], debug_features=["headers"])
@@ -2592,7 +2554,7 @@
                 progresstracker = progress.NullProgressTracker()
                 api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
                     progresstracker, lambda x: False, PKG_CLIENT_NAME)
-                self._do_install(api_obj, ["example_pkg"])
+                self._api_install(api_obj, ["example_pkg"])
 
                 # Test for bug 10690 by checking whether the fmri names
                 # for packages installed from the non-preferred publisher
@@ -2612,7 +2574,7 @@
                     self.res_alternate_server_local)
                 self._search_op(api_obj, False, "set::test2/*",
                     self.res_alternate_server_local)
-                self._do_uninstall(api_obj, ["example_pkg"])
+                self._api_uninstall(api_obj, ["example_pkg"])
 
         def test_bug_8318(self):
                 progresstracker = progress.NullProgressTracker()
--- a/src/tests/cli/t_pkgdep.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/tests/cli/t_pkgdep.py	Wed May 05 16:17:52 2010 -0700
@@ -35,10 +35,15 @@
 import tempfile
 import unittest
 
+import pkg.client.api as api
+import pkg.client.progress as progress
 import pkg.flavor.base as base
 import pkg.flavor.depthlimitedmf as mf
 import pkg.portable as portable
 
+API_VERSION = 37
+PKG_CLIENT_NAME = "pkg"
+
 class TestPkgdepBasics(pkg5unittest.SingleDepotTestCase):
 
         test_manf_1 = """\
@@ -490,6 +495,23 @@
         pyver_test_manf_1_non_ex = """\
 file NOHASH group=bin mode=0644 owner=root path=usr/lib/python%(py_ver)s/vendor-packages/pkg/client/indexer.py \
 """
+
+        inst_pkg = """\
+open [email protected],5.11-0
+add file tmp/foo mode=0555 owner=root group=bin path=/usr/bin/python2.6
+close"""
+
+        multi_deps = """\
+file NOHASH group=bin mode=0755 owner=root path=usr/lib/python2.6/v-p/pkg/client/indexer.py
+depend fmri=__TBD pkg.debug.depend.file=usr/bin/python2.6 pkg.debug.depend.reason=usr/lib/python2.6/v-p/pkg/client/indexer.py pkg.debug.depend.type=script type=require
+depend fmri=__TBD pkg.debug.depend.file=usr/lib/python2.6/v-p/pkg/misc.py pkg.debug.depend.reason=usr/lib/python2.6/v-p/pkg/client/indexer.py pkg.debug.depend.type=python type=require
+"""
+
+        misc_manf = """\
+set name=fmri value=pkg:/[email protected],5.11-0.117
+file NOHASH group=bin mode=0444 owner=root path=usr/lib/python2.6/v-p/pkg/misc.py
+"""
+
         def make_pyver_python_res(self, ver, proto_area=None):
                 """Create the python dependency results with paths expected for
                 the pyver tests.
@@ -709,7 +731,8 @@
 
                 res_path = self.make_manifest(self.output)
 
-                self.pkgdepend_resolve("-o %s" % res_path, exit=1)
+                # Check that -S doesn't prevent the resolution from happening.
+                self.pkgdepend_resolve("-S -o %s" % res_path, exit=1)
                 self.check_res("%s" % res_path, self.output)
                 self.check_res(self.resolve_error % {
                         "manf_path": res_path,
@@ -1269,5 +1292,27 @@
                                 self.pkg("install dup-v-deps")
                                 self.image_destroy()
 
+        def test_bug_15777(self):
+                """Test that -S switch disables resolving dependencies against
+                the installed system."""
+
+                durl = self.dc.get_depot_url()
+                self.make_misc_files(["tmp/foo"])
+                self.pkgsend_bulk(durl, self.inst_pkg)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(),
+                    API_VERSION, progresstracker, lambda x: False,
+                    PKG_CLIENT_NAME)
+                api_obj.refresh(immediate=True)
+                self._api_install(api_obj, ["example2_pkg"])
+
+                m1_path = self.make_manifest(self.multi_deps)
+                m2_path = self.make_manifest(self.misc_manf)
+
+                self.pkgdepend_resolve("-o %s %s" % (m1_path, m2_path))
+                self.pkgdepend_resolve("-o -S %s %s" % (m1_path, m2_path),
+                    exit=1)
+
+
 if __name__ == "__main__":
         unittest.main()
--- a/src/tests/cli/t_pkgdep_resolve.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/tests/cli/t_pkgdep_resolve.py	Wed May 05 16:17:52 2010 -0700
@@ -227,27 +227,6 @@
                     API_VERSION, progresstracker, lambda x: False,
                     PKG_CLIENT_NAME)
 
-        @staticmethod
-        def _do_install(api_obj, pkg_list, **kwargs):
-                api_obj.plan_install(pkg_list, **kwargs)
-                TestApiDependencies._do_finish(api_obj)
-
-        @staticmethod
-        def _do_uninstall(api_obj, pkg_list, **kwargs):
-                api_obj.plan_uninstall(pkg_list, False, **kwargs)
-                TestApiDependencies._do_finish(api_obj)
-
-        @staticmethod
-        def _do_image_update(api_obj, **kwargs):
-                api_obj.plan_update_all(sys.argv[0], **kwargs)
-                TestApiDependencies._do_finish(api_obj)
-
-        @staticmethod
-        def _do_finish(api_obj):
-                api_obj.prepare()
-                api_obj.execute_plan()
-                api_obj.reset()
-
         def test_resolve_cross_package(self):
                 """test that cross dependencies between published packages
                 works."""
@@ -280,7 +259,7 @@
 
                 self.pkgsend_bulk(self.durl, self.inst_pkg)
                 self.api_obj.refresh(immediate=True)
-                self._do_install(self.api_obj, ["example2_pkg"])
+                self._api_install(self.api_obj, ["example2_pkg"])
 
                 m1_path = self.make_manifest(self.multi_deps)
                 m2_path = self.make_manifest(self.misc_manf)
@@ -307,6 +286,37 @@
                                     "%s for in dependency %s" %
                                     (d.attrs["fmri"], d))
 
+                # Check that with use_system set to false, the system is not
+                # resolved against.  Bug 15777
+                pkg_deps, errs = dependencies.resolve_deps(
+                    [m1_path, m2_path], self.api_obj, use_system=False)
+                self.assertEqual(len(pkg_deps), 2)
+                self.assertEqual(len(pkg_deps[m1_path]), 1)
+                self.assertEqual(len(pkg_deps[m2_path]), 0)
+                self.assertEqual(len(errs), 1)
+                for d in pkg_deps[m1_path]:
+                        if d.attrs["fmri"] == p2_name:
+                                self.assertEqual(
+                                    d.attrs["%s.file" % self.depend_dp],
+                                    ["usr/lib/python2.6/v-p/pkg/misc.py"])
+                        elif d.attrs["fmri"] == p3_name:
+                                self.assertEqual(
+                                    d.attrs["%s.file" % self.depend_dp],
+                                    ["usr/bin/python2.6"])
+                        else:
+                                raise RuntimeError("Got unexpected fmri "
+                                    "%s for in dependency %s" %
+                                    (d.attrs["fmri"], d))
+                for e in errs:
+                        if isinstance(e,
+                            dependencies.UnresolvedDependencyError):
+                                self.assertEqual(e.path, m1_path)
+                                self.assertEqual(e.file_dep.attrs[
+                                    "%s.file" % self.depend_dp],
+                                    "usr/bin/python2.6")
+                        else:
+                                raise RuntimeError("Unexpected error:%s" % e)
+                        
         def test_simple_variants_1(self):
                 """Test that variants declared on the actions work correctly
                 when resolving dependencies."""
@@ -507,7 +517,7 @@
 
                 self.pkgsend_bulk(self.durl, self.var_pkg)
                 self.api_obj.refresh(immediate=True)
-                self._do_install(self.api_obj, ["variant_pkg"])
+                self._api_install(self.api_obj, ["variant_pkg"])
 
                 m1_path = self.make_manifest(self.simp_manf)
                 p2_name = "pkg:/[email protected]"
--- a/src/tests/pkg5unittest.py	Wed May 05 08:30:29 2010 +0100
+++ b/src/tests/pkg5unittest.py	Wed May 05 16:17:52 2010 -0700
@@ -1708,6 +1708,26 @@
                 self.debug("start_depot: started")
                 return dc
 
+        def _api_install(self, api_obj, pkg_list, **kwargs):
+                self.debug("install %s" % " ".join(pkg_list))
+                api_obj.plan_install(pkg_list, **kwargs)
+                self._api_finish(api_obj)
+
+        def _api_uninstall(self, api_obj, pkg_list, **kwargs):
+                self.debug("uninstall %s" % " ".join(pkg_list))
+                api_obj.plan_uninstall(pkg_list, False, **kwargs)
+                self._api_finish(api_obj)
+
+        def _api_image_update(self, api_obj, **kwargs):
+                self.debug("planning image-update")
+                api_obj.plan_update_all(sys.argv[0], verbose=False, **kwargs)
+                self._api_finish(api_obj)
+
+        def _api_finish(self, api_obj):
+                api_obj.prepare()
+                api_obj.execute_plan()
+                api_obj.reset()
+
 class ManyDepotTestCase(CliTestCase):
 
         def __init__(self, methodName='runTest'):