Go to main content

Copying and Creating Package Repositories in Oracle® Solaris 11.3

Exit Print View

Updated: September 2018

How to Update a Local IPS Package Repository

Note -  You do not need to perform this procedure if you use the svc:/application/pkg/mirror SMF service to periodically update your repository. See How to Automatically Copy a Repository From the Internet for instructions for using the mirror service.

Use the following steps to minimize disruption to clients. With this procedure, the update takes place out of sight, replacing the repository with the updated repository is fast, and clients do not need to change their solaris publisher origin or add a new origin.

  1. Make a ZFS snapshot of the package repository.

    Make sure you have a current snapshot of the repository to be updated.

    Note -  This step is especially important if you are going to use pkgrecv --clone to update the repository, because the clone operation leaves the destination repository altered if an error occurs.
    $ zfs list -rt all rpool/VARSHARE/pkgrepos/solaris
    NAME                                          USED  AVAIL  REFER  MOUNTPOINT
    rpool/VARSHARE/pkgrepos/solaris              17.6G  78.4G    34K  /var/share/pkgrepos/solaris
    rpool/VARSHARE/pkgrepos/solaris@initial          0      -  17.6G  -

    If you already have a snapshot of the repository, use the zfs diff command to check whether the snapshot is the same as the repository dataset.

    $ zfs diff rpool/VARSHARE/pkgrepos/solaris@initial

    If the zfs diff command produces no output, then the snapshot is the same as its parent dataset, and you can use that snapshot for the update.

    If the zfs diff command produces output, or if you do not have a snapshot of the repository, then take a new snapshot as shown in Step 6 in How to Explicitly Copy a Repository From the Internet. Use this new snapshot for the update.

  2. Make a ZFS clone of the snapshot.

    Clone the repository snapshot to create a copy of the repository that you can update.

    $ zfs clone rpool/VARSHARE/pkgrepos/solaris@initial rpool/VARSHARE/pkgrepos/solaris_tmp

    The %ipsrepo in the following listing is the share from How to Enable Users to Retrieve Packages Using a File Interface.

    $ zfs list -rt all rpool/VARSHARE/pkgrepos
    NAME                                          USED  AVAIL  REFER  MOUNTPOINT
    rpool/VARSHARE/pkgrepos                      17.6G  78.4G    33K  /var/share/pkgrepos
    rpool/VARSHARE/pkgrepos%ipsrepo                  -      -      -  /var/share/pkgrepos
    rpool/VARSHARE/pkgrepos/solaris              17.6G  78.4G  17.6G  /var/share/pkgrepos/solaris
    rpool/VARSHARE/pkgrepos/solaris@initial          0      -  17.6G  -
    rpool/VARSHARE/pkgrepos/solaris_tmp            76K  78.4G  17.6G  /var/share/pkgrepos/solaris_tmp
  3. Update the ZFS clone of the package repository.

    Just as you created the original repository either from a file or from an HTTP location, you can update your repository either from a file or from an HTTP location.

    (Optional) To minimize the size of the repository, replace the repository rather than add packages with every repository update. Use one of the following two methods to replace the repository in the snapshot clone:

    • Use the --clone option of the pkgrecv command as described in "Update from a repository" below.

    • Remove all solaris content from the repository and add only the content that is needed to support current systems. Do not try to select a subset of repository content to remove. Remove all solaris content and then add all content that you need for current systems according to the list in Minimal Required Repository. Do not remove all content from the clone; remove only the content under the publisher/solaris directory as shown in the following command:

      $ rm -rf /var/share/pkgrepos/solaris_tmp/publisher/solaris/*

    Use one of the following methods to update the repository in the snapshot clone:

    • Update from a zip file.
      1. Follow the instructions in Example 2, Adding to an Existing Repository From a zip File.

        Specify the -v option to the install-repo.ksh script to verify the repository.

        If the specified destination already contains a package repository, the content of the zip file is added to the content of the existing repository, and a pkgrepo rebuild is performed to update catalogs and indexes.

      2. Continue with Step 6 below.
    • Update from an ISO file.
      1. Create the ISO file.

        Create an .iso file from the repository .zip files using the -I option as described in Example 1, Creating a New Repository From a zip File.

      2. Mount the ISO image.
        $ mount -F hsfs ./sol-11_3-incr-repo.iso /mnt
      3. Copy the ISO file content to the repository clone.

        Use either rsync or tar as shown in How to Copy a Repository From an iso File.

        $ rsync -aP /mnt/repo/ /var/share/pkgrepos/solaris_tmp
      4. Unmount the ISO image.
    • Update from a repository.

      Copy content from another repository to the repository clone. If you are copying from a secure site, ensure that the required SSL certificate and key are installed, and specify the required certificate and key options.

      $ pkgrecv -s https://pkg.oracle.com/solaris/support \
      -d /var/share/pkgrepos/solaris_tmp \
      --key /path-to/key-file --cert /path-to/certificate-file '*'

      See the pkgrecv(1) man page for more information about the pkgrecv command. Only packages that have changed are updated, so the time to update your repository can be much less than the time to populate the original repository. See the performance tips in Performance Considerations for Copying Repositories.

      The --clone option of the pkgrecv command makes the repository copy significantly faster by performing a differences-only update of the destination repository instead of a series of incremental additions. The --clone option makes an exact copy of the source repository, including deleting packages from the destination repository that are not in the source repository. If you use the --clone option, make sure the source repository contains everything you need according to the list in Minimal Required Repository. If an error occurs, roll back to the most recent repository snapshot.

      If the pkgrecv operation is interrupted, follow the instructions in Resuming an Interrupted Package Receive.

  4. Verify the updated repository.

    Use the pkgrepo verify command to verify the updated repository. See the pkgrepo(1) man page for more information about the pkgrepo verify and pkgrepo fix commands.

  5. Catalog new packages and update search indexes.

    Catalog any new packages found in the newly updated repository and update all search indexes.

    $ pkgrepo refresh -s /var/share/pkgrepos/solaris_tmp
  6. Make a ZFS snapshot the newly updated clone of the package repository.
    $ zfs snapshot rpool/VARSHARE/pkgrepos/solaris_tmp@S11U3SRU2
  7. Replace the working repository with the updated clone.
    $ svcadm disable -st pkg/server:solaris
    $ zfs promote rpool/VARSHARE/pkgrepos/solaris_tmp
    $ zfs rename rpool/VARSHARE/pkgrepos/solaris rpool/VARSHARE/pkgrepos/solaris_old
    $ zfs rename rpool/VARSHARE/pkgrepos/solaris_tmp rpool/VARSHARE/pkgrepos/solaris

    See the svcadm(1M) man page for more information about the svcadm command.

  8. Restart the SMF service.

    If you are providing the repository through an HTTP interface, restart the SMF service. Be sure to specify the appropriate service instance when you restart the service.

    $ svcadm restart pkg/server:solaris
  9. Remove the old repository.

    When you are satisfied that your updated repository is working correctly, you can remove the old repository.

    $ zfs destroy rpool/VARSHARE/pkgrepos/solaris_old