Go to main content

Packaging and Delivering Software With the Image Packaging System in Oracle® Solaris 11.4

Exit Print View

Updated: November 2018
 
 

Modifying Packages that You Did Not Originate

You might need to modify a package that you did not produce. For example, you might need to override attributes, replace a portion of the package with an internal implementation, or remove binaries that are not permitted on your systems.


Caution

Caution  - Running a system with a modified package could adversely affect your support if any relationship is suspected between observed problems and the modified package.


Republishing Packages

IPS enables you to easily republish an existing package with your modifications, even if you did not originally publish the package. You can also republish new versions of the modified package so that pkg update continues to work as users expect.

Use the following steps to modify and republish a package:

  1. Use pkgrecv to download the package to be republished in a raw format to a specified directory. All of the files are named by their hash value, and the manifest is named manifest. Remember to set any required proxy configuration in the http_proxy environment variable.

  2. Use pkgmogrify to make the necessary modifications to the manifest. See Add Necessary Metadata to the Generated Manifest and Modifying Package Manifests Programmatically.

    • Remove any time stamp from the internal package FMRI to prevent confusion during publication.

    • Remove any signature actions.

  3. Use pkglint to verify the resulting package.

  4. Use pkgsend to republish the package. Republication strips the package of any signatures that are present and ignores any time stamp specified by pkg.fmri. To prevent a warning message, remove signature actions in the pkgmogrify step.

    If you do not have permission to publish to the original source of the package, use pkgrepo to create a repository, and then use the following command to set the new publisher ahead of the original publisher in the publisher search order:

    $ pkg set-publisher --search-before=original_publisher new_publisher
  5. If necessary, use pkgsign to sign the package. To prevent client caching issues, sign the package before you install the package, even for testing. See Signing IPS Packages.

Changing Package Metadata

In the following example, the original pkg.summary value is changed to be “IPS has lots of features.” The package is downloaded using the --raw option of pkgrecv. By default, only the newest version of the package is downloaded. The package is then republished to a new repository.

$ mkdir republish; cd republish
$ pkgrecv -d . --raw -s http://pkg.oracle.com/solaris/release package/pkg
$ cd package* # The package name contains a '/' and is url-encoded.
$ cd *
$ cat > fix-pkg
# Change the value of pkg.summary
<transform set name=pkg.summary -> edit value '.*' "IPS has lots of features">
# Delete any signature actions
<transform signature -> drop>
# Remove the time stamp from the fmri so that the new package gets a new time stamp
<transform set name=pkg.fmri -> edit value ":20.+" "">
^D
$ pkgmogrify manifest fix-pkg > new-manifest
$ pkgrepo create ./mypkg
$ pkgsend -s ./mypkg publish -d . new-manifest

Changing Package Publisher

Another common use case is to republish packages under a new publisher name. One case when this is useful is to consolidate packages from multiple repositories into a single repository. For example, you might want to consolidate packages from repositories of several different development teams into a single repository for integration testing.

To republish under a new publisher name, use the pkgrecv, pkgmogrify, pkgrepo, and pkgsend steps shown in the previous example.

The following sample transform changes the publisher to mypublisher:

<transform set name=pkg.fmri -> edit value pkg://[^/]+/ pkg://mypublisher/>

You can use a simple shell script to iterate over all packages in the repository. Use the output from pkgrecv --newest to process only the newest packages from the repository.

The following script saves the above transform in a file named change-pub.mog, and then republishes from development-repo to a new repository new-repo, changing the package publisher along the way:

#!/usr/bin/ksh93
pkgrepo create new-repo
pkgrepo -s new-repo set publisher/prefix=mypublisher
mkdir incoming
for package in $(pkgrecv -s ./development-repo --newest); do
    pkgrecv -s development-repo -d incoming --raw $package
done
for pdir in incoming/*/* ; do
    pkgmogrify $pdir/manifest change-pub.mog > $pdir/manifest.newpub
    pkgsend -s new-repo publish -d $pdir $pdir/manifest.newpub
done

This script could be modified to do tasks such as select only certain packages, make additional changes to the versioning scheme of the packages, and show progress as it republishes each package.