--- a/src/modules/actions/license.py Thu Apr 28 09:00:44 2011 -0700
+++ b/src/modules/actions/license.py Thu Apr 28 11:34:47 2011 -0700
@@ -169,11 +169,15 @@
return indices
- def get_text(self, img, pfmri):
+ def get_text(self, img, pfmri, alt_pub=None):
"""Retrieves and returns the payload of the license (which
should be text). This may require remote retrieval of
resources and so this could raise a TransportError or other
- ApiException."""
+ ApiException.
+
+ 'alt_pub' is an optional alternate Publisher to use for
+ any required transport operations.
+ """
opener = self.get_local_opener(img, pfmri)
if opener:
@@ -181,8 +185,10 @@
return opener().read()
try:
- pub = img.get_publisher(pfmri.publisher)
- return img.transport.get_content(pub, self.hash,
+ if not alt_pub:
+ alt_pub = img.get_publisher(pfmri.publisher)
+ assert pfmri.publisher == alt_pub.prefix
+ return img.transport.get_content(alt_pub, self.hash,
fmri=pfmri)
finally:
img.cleanup_downloads()
--- a/src/modules/api_common.py Thu Apr 28 09:00:44 2011 -0700
+++ b/src/modules/api_common.py Thu Apr 28 11:34:47 2011 -0700
@@ -21,7 +21,7 @@
#
#
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
#
# Visible changes to classes here require an update to
# doc/client_api_versions.txt and/or doc/server_api_versions.txt.
@@ -37,8 +37,9 @@
"""A class representing the license information a package
provides. Not intended for instantiation by API consumers."""
- def __init__(self, pfmri, act, img=None, text=None):
+ def __init__(self, pfmri, act, img=None, text=None, alt_pub=None):
self.__action = act
+ self.__alt_pub = alt_pub
self.__fmri = pfmri
self.__img = img
self.__text = text
@@ -54,7 +55,8 @@
if not self.__img:
return self.__text
- return self.__action.get_text(self.__img, self.__fmri)
+ return self.__action.get_text(self.__img, self.__fmri,
+ alt_pub=self.__alt_pub)
@property
def fmri(self):
--- a/src/modules/client/api.py Thu Apr 28 09:00:44 2011 -0700
+++ b/src/modules/client/api.py Thu Apr 28 11:34:47 2011 -0700
@@ -1274,13 +1274,13 @@
immediate=immediate, pubs=pubs,
progtrack=self.__progresstracker)
- def __licenses(self, pfmri, mfst):
+ def __licenses(self, pfmri, mfst, alt_pub=None):
"""Private function. Returns the license info from the
manifest mfst."""
license_lst = []
for lic in mfst.gen_actions_by_type("license"):
license_lst.append(LicenseInfo(pfmri, lic,
- img=self._img))
+ img=self._img, alt_pub=alt_pub))
return license_lst
@_LockedCancelable()
@@ -2516,7 +2516,7 @@
if mfst is not None:
if PackageInfo.LICENSES in info_needed:
licenses = self.__licenses(pfmri,
- mfst)
+ mfst, alt_pub=alt_pub)
if PackageInfo.SIZE in info_needed:
size = mfst.get_size(
--- a/src/tests/cli/t_pkg_temp_sources.py Thu Apr 28 09:00:44 2011 -0700
+++ b/src/tests/cli/t_pkg_temp_sources.py Thu Apr 28 11:34:47 2011 -0700
@@ -1,4 +1,3 @@
-#!/usr/bin/python
#
# CDDL HEADER START
#
@@ -77,6 +76,11 @@
add depend type=incorporate [email protected],5.11-0.2
close """
+ licensed_pkg = """
+ open pkg://test2/[email protected]
+ add license tmp/LICENSE license=sample_license
+ close """
+
signed_pkg = """
open pkg://test/[email protected]
add depend type=require [email protected]
@@ -183,7 +187,7 @@
def setUp(self):
pkg5unittest.ManyDepotTestCase.setUp(self, ["test", "test",
- "empty"])
+ "empty", "test2"])
self.make_misc_files(self.misc_files)
# First repository will contain all packages.
@@ -195,6 +199,9 @@
# Third will be empty.
self.empty_rurl = self.dcs[3].get_repo_url()
+ # Fourth will be for license packages only.
+ self.licensed_rurl = self.dcs[4].get_repo_url()
+
# Setup base test paths.
self.path_to_certs = os.path.join(self.ro_data_root,
"signing_certs", "produced")
@@ -247,6 +254,10 @@
self.quux01 = plist[4]
self.quux10 = plist[5]
+ # Handle license package specially.
+ self.licensed10 = self.pkgsend_bulk(self.licensed_rurl,
+ self.licensed_pkg)[0]
+
def test_00_list(self):
"""Verify that the list operation works as expected for
temporary origins.
@@ -560,6 +571,10 @@
self.pkg("uninstall \*")
self.pkg("info -r \*", exit=1)
+ # Verify that --license works as expected with -g.
+ self.pkg("info -g %s --license licensed" % self.licensed_rurl)
+ self.assertEqualDiff("tmp/LICENSE\n", self.output)
+
# Cleanup.
self.image_destroy()