Package com.sun.pkg.client

Provides for client-side access to the Image Packaging System (IPS) for Java clients.

See:
          Description

Class Summary
Catalog A Catalog is the list of packages (Fmris) that are available from an authority.
Fmri An Fmri is an identifier for a package.
Image An Image is a directory tree containing the laid-down contents of a self-consistent graph of Packages.
Image.FmriState An FmriState represents the current state of an Fmri within the image.
Manifest A Manifest is a list of actions within a package.
Version A Version represents the version part of an IPS package FMRI.
Version.DotSequence The DotSequence class represents the x.y.z parts of a Version object.
 

Package com.sun.pkg.client Description

Provides for client-side access to the Image Packaging System (IPS) for Java clients. The primary class for using this API is the Image class.

Usage Examples

This section contains some examples of how to use this API to accomplish some typical tasks.

Install the most recent version of a given package

The objective of this example is to install the most recent version of the "foo" package into the image rooted at "bar" in the user's home directory.
    File dir = new File(System.getProperty("user.home"), "bar");
    Image img = new Image(dir);
    String pkgs[] = {"foo"};
    img.installPackages(pkgs);

Check to see if a given package is installed

The objective of this example is to determine whether the "foo" package has been installed into the image. This example uses the Image object from the previous example.
    List list = img.getInventory(pkgs, false);
    if (list.size() > 0) {
        System.out.println("package foo is installed");
    }

Update the packages in an image

The objective of this example is to print a list of the packages that have available updates in the image and then install those updates. This example uses the Image object from the previous example.
    List list2 = img.getInventory(null, false);
    ArrayList pkgs2 = new ArrayList();
    for (Image.FmriState fs : list2) {
      if (fs.upgradable) {
        pkgs2.add(fs.fmri);
        Fmri p = img.getCatalog().getMatchingFMRI(fs.fmri.getName());
        System.out.println("available update: " + p.toString());
      }
    }
    img.installPackages(pkgs2);

Logging

The pkg Java API generates log information to the com.sun.pkg.client Logger. The following code can be used to manipulate the properties of this logger before calling the various methods of the API:
     Logger cl = Logger.getLogger("com.sun.pkg.client");
     cl.setLevel(Level.FINER);

Limitations

The pkg Java API is not (yet) a complete implementation of the client side capabilities of the Image Packaging System. Here is a partial list of the limitations of the API. The number in parenthesis is the issue that is tracking completion of that feature.

Related Documentation

For overviews, tutorials, examples, guides, and tool documentation, please see: