Go to main content

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

Exit Print View

Updated: November 2020
 
 

Moving Unpackaged Files on Directory Removal

This example shows how to use IPS to salvage unpackaged content to another packaged directory.

In this example, the package myapp@1.0 installs the directory /opt/myapp/logfiles. The myapp application writes log files to that directory.

The myapp@2.0 package delivers the /opt/myapp/history directory and does not deliver the /opt/myapp/logfiles directory. Users who update their installed myapp@1.0 package to myapp@2.0 will no longer have an /opt/myapp/logfiles directory. These users will see a message at the end of their pkg update output telling them that content from /opt/myapp/logfiles has been saved in /var/pkg/lost+found/opt/myapp/logfiles.

To use IPS to move the file content from /opt/myapp/logfiles to /opt/myapp/history at the time the myapp package is updated, use the salvage-from attribute on the /opt/myapp/history directory. Your pkgmogrify input file needs the following entry:

<transform dir path=opt/myapp/history -> \
    add salvage-from /opt/myapp/logfiles>

After you run pkgmogrify, your package manifest action for this directory will look like the following:

dir  path=opt/myapp/history owner=root group=bin mode=0755 \
    salvage-from=/opt/myapp/logfiles

After a user runs pkg update myapp, the /opt/myapp/logfiles directory is gone, the new /opt/myapp/history directory is installed, and the file content from /opt/myapp/logfiles is in /opt/myapp/history.

See How to Migrate Unshared Content to a Shared Area shows another example that uses the salvage-from attribute.