Shawn,
Writing privately to ask you:
Should I be able to do prepare() and execute(). I wanted to test it on my desktop PC running normal OpenSolaris (not in the Slim
microroot) and look at the resulting sizes.
Thanks,
William
Shawn,
On 03/23/10 06:04 PM, Shawn Walker wrote:
On 03/23/10 11:50 AM, William Schumann wrote:
I have been experimenting with the pkg.client.api API to get the
expected disk usage for the installer, given a set of packages. There
are no examples in the documentation, which is in "pydoc
pkg.client.api", but I came up with this (some code removed):
api_inst = api.ImageInterface(img_dir, CLIENT_API_VERSION,
progresstracker, None, PKG_CLIENT_NAME)
api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, img_dir,
IMG_TYPE_ENTIRE, False,
repo_uri="http://ipkg.sfbay/dev",
progtrack=progress.QuietProgressTracker(), mirrors = mirrors,
force=True)
image_create() returns an ImageInterface object for the image that was
created, so there's no reason for the first assignment line.
The first line you have would only be used if the image already
existed, and the image_create() only if the image did not already exist.
Well, if I omit the ImageInterface call, this assertion results:
Traceback (most recent call last):
File "/export/home/ws199450/api.py", line 75, in <module>
api_inst = api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, img_dir, IMG_TYPE_ENTIRE, False,
repo_uri="http://ipkg.sfbay/dev", progtrack=progress.QuietProgressTracker(), mirrors = mirrors, force=True)
File "/usr/lib/python2.6/vendor-packages/pkg/client/api.py", line 2771, in
image_create
variants=variants)
File "/usr/lib/python2.6/vendor-packages/pkg/client/image.py", line 680, in
create
progtrack=progtrack)
File "/usr/lib/python2.6/vendor-packages/pkg/client/image.py", line 967, in
add_publisher
self.save_config()
File "/usr/lib/python2.6/contextlib.py", line 23, in __exit__
self.gen.next()
File "/usr/lib/python2.6/vendor-packages/pkg/client/image.py", line 286, in
locked_op
self.history.log_operation_end(error=error)
File "/usr/lib/python2.6/vendor-packages/pkg/client/history.py", line 702, in
log_operation_end
self.operation_result = result
File "/usr/lib/python2.6/vendor-packages/pkg/client/history.py", line 338, in
__setattr__
self.__save()
File "/usr/lib/python2.6/vendor-packages/pkg/client/history.py", line 562, in
__save
self.__serialize_client_data(d)
File "/usr/lib/python2.6/vendor-packages/pkg/client/history.py", line 490, in
__serialize_client_data
assert self.client_name is not None
AssertionError
Updated code:
api.ImageInterface(img_dir, CLIENT_API_VERSION, progresstracker, None,
PKG_CLIENT_NAME)
api_inst = api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, img_dir, IMG_TYPE_ENTIRE, False, repo_uri="http://ipkg.sfbay/dev",
progtrack=progress.QuietProgressTracker(), mirrors = mirrors, force=True)
api_inst.plan_install(pkglist,refresh_catalogs=True,noexecute=False,verbose=True,
update_index=True)
plan = api_inst.describe()
new_pkg_list = [dest.fmri for src, dest in plan.get_changes()]
ret = api_inst.info(new_pkg_list, False, frozenset([api.PackageInfo.SIZE]))
pis = ret[api.ImageInterface.INFO_FOUND]
size = 0;
for i, pi in enumerate(pis):
size = size + pi.size
Also, how is "pkg_client_name" used? What should it be?
Thanks,
William
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss