Wednesday Mar 05, 2014

Preserving Unpacked Software During a Package Uninstall

I love it when I can wriggle out of the unintended side effects created by an automated system designed to simplify my life.

Here's a side effect created by the very good Image Packaging System (IPS) in our beloved Oracle Solaris 11. If you use the IPS to uninstall all packaged content from a directory, it also removes the directory. Not good if you also kinda sorta loaded unpackaged content into that directory.

For instance, let's say you worked with a third-party IPS package that installed its software into /usr/local. After a pause to polish the chrome on your custom Softail Deluxe, you install a second application into /usr/local from a tar file. What happens to that second application when you use IPS to remove the third-party IPS package from the /usr/local directory? Yup. IPS dumps the directory on the asphalt and high-sides the unpackaged content all the way to /var/pkg/lost+found.

Thank goodness somebody watches out for those of us who don't follow directions. Alta Elstad, from the Solaris Documentation Team at Oracle, is one of them. Here's how she suggests you avoid this problem.

How to Preserve the Directory

To prevent the packaged directory from being removed along with its content, package the directory separately. Create an IPS package that delivers only the one directory or directory structure that you want. Then that directory structure will remain in place until you uninstall that specific package. Uninstalling a different package that delivers content to that directory will not remove the directory.

Here's a detailed example.

  1. Create the directory structure you want to deliver. This example shows /usr/local. You could easily expand this to include /usr/local/bin and other subdirectories if necessary.
    $ mkdir -p usrlocal/usr/local
  2. Create the initial package manifest.
    $ pkgsend generate usrlocal | pkgfmt > usrlocal.p5m.1
    $ cat usrlocal.p5m.1
    dir path=usr owner=root group=bin mode=0755
    dir path=usr/local owner=root group=bin mode=0755
  3. Create a pkgmogrify input file to add metadata and to exclude delivering /usr since that directory is already delivered by Oracle Solaris. You might also want to add transforms to change directory ownership or permissions.
    $ cat usrlocal.mog
    set name=pkg.fmri value=pkg://site/usrlocal@1.0
    set name=pkg.summary value="Create the /usr/local directory."
    set name=pkg.description value="This package installs the /usr/local \
    directory so that /usr/local remains available for unpackaged files."
    set name=variant.arch value=$(ARCH)
    <transform dir path=usr$->drop>
    
  4. Apply the changes to the initial manifest.
    $ pkgmogrify -DARCH=`uname -p` usrlocal.p5m.1 usrlocal.mog | 
      pkgfmt > usrlocal.p5m.2
    $ cat usrlocal.p5m.2
    set name=pkg.fmri value=pkg://site/usrlocal@1.0
    set name=pkg.summary value="Create the /usr/local directory."
    set name=pkg.description value="This package installs the /usr/local \
    directory so that /usr/local remains available for unpackaged files."
    set name=variant.arch value=$(ARCH)
    <transform dir path=usr$->drop> 
    
  5. Check your work.
    $ pkglint usrlocal.p5m.2
    Lint engine setup...
    Starting lint run...
    $
    
  6. Publish the package to your repository.
    $ pkgsend -s yourlocalrepo publish -d usrlocal usrlocal.p5m.2
    pkg://site/usrlocal@1.0,5.11:20140303T180555Z
    PUBLISHED
    
    
    
  7. Make sure you can see the new package that you want to install.
    $ pkg refresh site
    $ pkg list -a usrlocal
    NAME (PUBLISHER)      VERSION      IFO
    usrlocal (site)       1.0          --- 
    
  8. Install the package.
    $ pkg install -v usrlocal
               Packages to install:         1
         Estimated space available:  20.66 GB
    Estimated space to be consumed: 454.42 MB
           Create boot environment:        No
    Create backup boot environment:        No
              Rebuild boot archive:        No
    
    Changed packages:
    site
      usrlocal
        None -> 1.0,5.11:20140303T180555Z
    PHASE                                          ITEMS
    Installing new actions                           5/5
    Updating package state database                 Done
    Updating package cache                           0/0
    Updating image state                            Done
    Creating fast lookup database                   Done
    Reading search index                            Done
    Updating search index                            1/1
    
  9. Make sure the package is installed.
    $ pkg list usrlocal
    NAME (PUBLISHER)      VERSION      IFO
    usrlocal (site)       1.0          i-- 
    $ pkg info usrlocal
              Name: usrlocal
           Summary: Create the /usr/local directory.
       Description: This package installs the /usr/local directory so that
                    /usr/local remains available for unpackaged files.
             State: Installed
         Publisher: site
           Version: 1.0
     Build Release: 5.11
            Branch: None
    Packaging Date: March  3, 2014 06:05:55 PM
              Size: 0.00 B
              FMRI: pkg://site/usrlocal@1.0,5.11:20140303T180555Z
    $ ls -ld /usr/local
    drwxr-xr-x   2 root     bin            2 Mar  3 10:17 /usr/local/
    

For More Information

About the Photograph

Photograph of Vancouver's laughing statues courtesy of BMK via Wikipedia Commons Creative Commons License 2.0

- Rick

Follow me on:
Blog | Facebook | Twitter | YouTube | The Great Peruvian Novel

Thursday Nov 21, 2013

How to Limit Upgrades Beyond a Prescribed Version of Oracle Solaris

by Bart Smaalders and Alta Elstad

The Oracle Solaris 11 Image Packaging System (IPS) provides various methods to control the operating system version to which a server can be upgraded. One method is to provide a custom incorporation package.

An incorporation package specifies the versions of other packages that can be installed. An incorporation package ensures that if you install an incorporate dependency package of that incorporation package, only the prescribed version of the dependent package can be installed. You can create your own custom incorporation package to specify the constraints you want. Using a custom incorporation to control the version of software that can be installed enables you to easily maintain different versions of Oracle Solaris on different machines without maintaining multiple package repositories. Each image can install a different version of the custom upgrade control incorporation package. All systems share the same package repository that contains all versions of software needed by any of the systems.

In the example in this article, a system has been newly installed with Oracle Solaris 11.1. The solaris publisher origin is the Oracle Solaris support repository, which includes many updates since Oracle Solaris 11.1 was released. The IT department in the example company has not yet qualified the most current support updates, and they want to limit administrators to upgrading to only the latest update that is qualified for their environments, not the latest update that is available from the package repository.

Create a Custom Incorporation Package

The versions of core operating system packages that can be installed in an image are controlled by the pkg:/entire incorporation package. To control system upgrades, create a package that specifies a particular version of the pkg:/entire package as an incorporate dependency.

The following example shows a manifest named upgradectrl.p5m for a custom incorporation package that controls the version of the pkg:/entire package that can be installed. Some of the settings in this manifest are described below.

set name=pkg.fmri value=upgradectrl@1.0
set name=pkg.summary value="Incorporation to constrain the version of the OS"
set name=pkg.description value="This package controls the version of \
pkg://solaris/entire that can be installed."
set name=info.classification value="org.opensolaris.category.2008:Meta Packages/Incorporations"
set name=pkg.depend.install-hold value=core-os
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=sparc value=i386
depend fmri=feature/package/dependency/self type=parent variant.opensolaris.zone=nonglobal
depend fmri=pkg://solaris/entire type=require
depend fmri=pkg://solaris/entire@0.5.11,5.11-0.175.1.0 type=incorporate
  • pkg.depend.install-hold This setting ensures that if a user updates the upgradectrl package, the pkg:/entire package is automatically updated as well.

  • variant.opensolaris.zone This setting enables this package to be installed in both global and non-global zones. See also the description of the parent dependency.

  • variant.arch This setting enables this package to be installed on both SPARC and x86 systems.

  • parent dependency This package can be installed in a non-global zone only if it is already installed in the global zone.

  • require dependency The upgradectrl package can be installed only if the pkg://solaris/entire package is already installed or can be installed in this same operation.

  • incorporate dependency The pkg://solaris/entire package must be installed at the specified version. More than one version can satisfy an incorporate dependency, depending on how many places of accuracy are specified. In this example, 0.175.1.0 specifies Oracle Solaris 11.1 SRU 0. This upgrade control package will keep systems at the newly installed Oracle Solaris 11.1 version, no support updates. This upgrade control package will, however, allow packages that are not contrained by the pkg:/entire incorporation to be updated.

Publish the upgradectrl package to a local file-based repository. This repository is for developing and testing this new package. If you create a repository for general use, you should include additional steps such as creating a separate file system for the repository. For information about creating package repositories for general use, see Copying and Creating Package Repositories in Oracle Solaris 11.2.

Create a package development repository on your system. See the pkgrepo(1) man page for more information about the pkgrepo command.

$ pkgrepo create myrepo

Set the default publisher for this repository. The default publisher is the value of the publisher/prefix property of the repository.

$ pkgrepo -s myrepo set publisher/prefix=site

Publish the upgradectrl package to the development repository.

$ pkgsend -s myrepo publish upgradectrl.p5m
pkg://site/upgradectrl@1.0,5.11:20131120T010105Z
PUBLISHED

Notice that the repository default publisher has been applied to the package FMRI.

Examine the repository to confirm that the package was published.

$ pkgrepo -s myrepo list
PUBLISHER NAME                                       O VERSION
site      upgradectrl                                  1.0,5.11:20131120T010105Z
$ pkg list -vg myrepo
FMRI                                                                         IFO
pkg://site/upgradectrl@1.0,5.11:20131120T010105Z                             ---

Deliver the package to a local repository in a separate ZFS file system in a shared location.

$ pkgrecv -s myrepo -d /export/IPSpkgrepos/Solaris upgradectrl
Processing packages for publisher site ...
Retrieving and evaluating 1 package(s)...
PROCESS                                         ITEMS    GET (MB)   SEND (MB)
Completed                                         1/1     0.0/0.0     0.0/0.0

Verify the package in the repository and the version of pkg:/entire that it incorporates.

$ pkg info -g /export/IPSpkgrepos/Solaris upgradectrl
          Name: upgradectrl
       Summary: Incorporation to constrain the version of the OS
   Description: This package controls the version of pkg://solaris/entire that
                can be installed.
      Category: Meta Packages/Incorporations
         State: Not installed
     Publisher: site
       Version: 1.0
 Build Release: 5.11
        Branch: None
Packaging Date: November 20, 2013 01:01:05 AM 
          Size: 0.00 B
          FMRI: pkg://site/upgradectrl@1.0,5.11:20131120T010105Z
$ pkg contents -Hro fmri -t depend -a type=incorporate upgradectrl
pkg://solaris/entire@0.5.11,5.11-0.175.1.0

See “Creating and Publishing a Package” in Packaging and Delivering Software With the Image Packaging System in Oracle Solaris 11.2 for more detailed information about creating and delivering IPS packages.

Set the origin for the site publisher.

$ pkg set-publisher -g /export/IPSpkgrepos/Solaris site
$ pkg publisher
PUBLISHER              TYPE     STATUS P LOCATION
solaris                origin   online F https://pkg.oracle.com/solaris/support/
site                   origin   online F file:///export/IPSpkgrepos/Solaris/

Install the Upgrade Control Package

Install the upgrade control package. In this case, few changes should be made because the installed version of pkg:/entire is the same as the version incorporated by the upgrade control package.

$ pkg list -v entire
FMRI                                                                         IFO
pkg://solaris/entire@0.5.11,5.11-0.175.1.0.0.24.2:20120919T190135Z           i--
$ zoneadm list
global
z1
$ pkg install upgradectrl
           Packages to install:  1
       Create boot environment: No
Create backup boot environment: No

Planning linked: 0/1 done; 1 working: zone:z1
Planning linked: 1/1 done
Downloading linked: 0/1 done; 1 working: zone:z1
Downloading linked: 1/1 done
PHASE                                          ITEMS
Installing new actions                           9/9
Updating package state database                 Done 
Updating image state                            Done 
Creating fast lookup database                   Done 
Reading search index                            Done 
Updating search index                            1/1 
Executing linked: 0/1 done; 1 working: zone:z1
Executing linked: 1/1 done

The following commands show that versions of pkg:/entire that are newer than the installed version are available from the configured solaris publisher, but an attempt to upgrade is controlled by the newly-installed upgrade control package.

$ pkg list -af entire
NAME (PUBLISHER)                                  VERSION                    IFO
entire                                            0.5.11-0.175.1.13.0.6.0    ---
entire                                            0.5.11-0.175.1.12.0.5.0    ---
entire                                            0.5.11-0.175.1.11.0.4.0    ---
entire                                            0.5.11-0.175.1.10.0.6.0    ---
entire                                            0.5.11-0.175.1.10.0.5.0    ---
...
$ pkg update
pkg update: No solution was found to satisfy constraints
Plan Creation: Package solver has not found a solution to update to latest available versions.
This may indicate an overly constrained set of packages are installed.
latest incorporations:
...
Try specifying expected results to obtain more detailed error messages.
$ pkg update -nv entire@0.5.11-0.175.1.13.0.6.0
pkg update: No matching version of entire can be installed:
  Reject:  pkg://solaris/entire@0.5.11,5.11-0.175.1.13.0.6.0:20131108T211557Z
  Reason:  This version is excluded by installed incorporation pkg://site/upgradectrl@1.0,5.11:20131120T010105Z

Update the Upgrade Control Package

When you are ready to allow users to upgrade their systems to a new version, update the upgradectrl.p5m manifest, and republish and redeliver the new upgrade control package. In the following manifest, the version of the upgrade control package and the version of the pkg:/entire incorporation are updated. As an aid for users, the version of the upgrade control package matches the updated version of the pkg:/entire package.

set name=pkg.fmri value=upgradectrl@1.10
set name=pkg.summary value="Incorporation to constrain the version of the OS"
set name=pkg.description value="This package controls the version of \
pkg://solaris/entire that can be installed."
set name=info.classification value="org.opensolaris.category.2008:Meta Packages/Incorporations"
set name=pkg.depend.install-hold value=core-os
set name=variant.opensolaris.zone value=global value=nonglobal
set name=variant.arch value=sparc value=i386
depend fmri=feature/package/dependency/self type=parent variant.opensolaris.zone=nonglobal
depend fmri=pkg://solaris/entire type=require
depend fmri=pkg://solaris/entire@0.5.11,5.11-0.175.1.10 type=incorporate

The following commands republish and redeliver the upgrade control package:

$ pkgsend -s myrepo publish upgradectrl.p5m
pkg://site/upgradectrl@1.10,5.11:20131120T021902Z
PUBLISHED
$ pkgrepo -s myrepo list
PUBLISHER NAME                                      O VERSION
site      upgradectrl                                 1.10,5.11:20131120T021902Z
site      upgradectrl                                 1.0,5.11:20131120T010105Z
$ pkgrecv -s myrepo -d /export/IPSpkgrepos/Solaris upgradectrl
Processing packages for publisher site ...
Retrieving and evaluating 1 package(s)...
PROCESS                                         ITEMS    GET (MB)   SEND (MB)
Completed                                         1/1     0.0/0.0     0.0/0.0
$ pkg refresh site
$ pkg list -af pkg://site/upgradectrl
NAME (PUBLISHER)                                  VERSION                    IFO
upgradectrl (site)                                1.10                       ---
upgradectrl (site)                                1.0                        i--

Upgrade the Image

The following pkg update command updates all packages to the newest available versions allowed because no packages are specified. The command updates to the newest available version of the upgrade control package, which upgrades the image because the pkg.depend.install-hold setting in the upgradectrl package causes the pkg:/entire package to be updated when the upgradectrl package is updated. The image is upgraded to the version of the pkg:/entire incorporation that is specified in the new upgradectrl incorporation.

$ pkg update --be-name s11u1_10
            Packages to remove:   1
            Packages to update: 186
           Mediators to change:   1
       Create boot environment: Yes
Create backup boot environment:  No

Planning linked: 0/1 done; 1 working: zone:z1
Linked image 'zone:z1' output:
|  Packages to remove:  1
| Packages to install:  3
|  Packages to update: 73
| Mediators to change:  1
|  Services to change:  3
`
Planning linked: 1/1 done
DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                            187/187   16139/16139  507.9/507.9  562k/s

Downloading linked: 0/1 done; 1 working: zone:z1
Downloading linked: 1/1 done
PHASE                                          ITEMS
Removing old actions                       1473/1473
Installing new actions                     3451/3451
Updating modified actions                16378/16378
Updating package state database                 Done 
Updating package cache                       187/187 
Updating image state                            Done 
Creating fast lookup database                   Done 
Reading search index                            Done 
Building new search index                    851/851 
Executing linked: 0/1 done; 1 working: zone:z1
Executing linked: 1/1 done

A clone of s11u1_0 exists and has been updated and activated.
On the next boot the Boot Environment s11u1_10 will be
mounted on '/'.  Reboot when ready to switch to this updated BE.
$ pkg list entire upgradectrl
NAME (PUBLISHER)                                  VERSION                    IFO
entire                                            0.5.11-0.175.1.0.0.24.2    i--
upgradectrl (site)                                1.0                        i--
$ pkg -R /mnt list entire upgradectrl
NAME (PUBLISHER)                                  VERSION                    IFO
entire                                            0.5.11-0.175.1.10.0.6.0    i--
upgradectrl (site)                                1.10                       i--
$ beadm unmount s11u1_10

See Also

Bart Smaalders’ blog

Packaging and Delivering Software With the Image Packaging System in Oracle Solaris 11.2

Copying and Creating Package Repositories in Oracle Solaris 11.2

About the Authors

Bart Smaalders is one of the senior engineers in the Oracle Solaris Core OS group, and led development of the IPS packaging system.

Alta Elstad is a technical writer supporting Oracle Solaris 11 packaging.

photograph of strange plants copyright Beth Ramsey

Follow OTN on:
Blog | Facebook | Twitter | YouTube

Tuesday May 28, 2013

What If I Want to Update Just Java?

Sometimes all you want to update is Java, and not your entire Oracle Solaris environment. But Java is packaged as part of the Oracle Solaris systems software, and Oracle recommends that you update all the system software at once, since it was tested together.

What can you do?

How to Update Only Java in Your Oracle Solaris Environment

by Peter Dennis and Alta Elstad

This article describes how to update one piece of software that is constrained by an incorporation without altering any other software that is constrained by that incorporation, and still end up with a supported system. This article by Peter Dennis and Alta Elstad explains how to do that. It focuses on Java, but you can use the same technique for other software.

More Information About Oracle Solaris Packaging

- Rick

Follow me on:
Blog | Facebook | Twitter | YouTube | The Great Peruvian Novel

Monday Feb 13, 2012

OMG! What Did I Just Install?

Quick Quiz:

Q: What's in this Solaris 10 package: SUNWlibstdcxx4S?
A: You cheated. You googled it and found the link to the Oracle Solaris 10 documentation.

You're in luck, because each release of the Solaris 10 documentation contains a Package List for that release. For example:

Now try this:

Q: What's in this Solaris 11 package: compress/p7zip?
A: buzzer!

The Solaris 11 documentation does not include a package list. You can find mentions of some packages through google, but it's hit and miss. And you still don't get the rest of the info about the package that the Solaris 10 documentation included. So how do you find out what Solaris 11 packages you just installed? Here are two methods.

The pkg list Command

The pkg list command lists all the packages currently installed on your system. If you use it, redirect the output to a file so your screen doesn't wind up looking like a scene out of The Matrix. Since package naming is hierarchical, you are likely to find similar packages grouped together in the list. For example:

$ pkg list
.
.
.
compress/bzip2
compress/gzip
compress/p7zip
compress/unzip
compress/zip
.
.
.
editor/gedit
editor/nano
editor/vim

You can just list a subset of the packages you are interested in:

$ pkg list driver/network/ethernet/*

By the way, to list all packages that are available for you to install, add -a to the pkg-list command. This example asks for the name of all the packages you can install in the editor group:

$ pkg list -a editor/*

One you have a list of the packages, you can use one of the commands below to get additional info about each package.

The pkg info and pkginfo Commands

The pkg info command provides detailed information about a particular IPS package. For example:
$ pkg info p7zip
          Name: compress/p7zip
       Summary: The p7zip compression and archiving utility
   Description: P7zip is a unix port of the 7-Zip utility.  It has support for
                numerous compression algorithms, including LZMA and LZMA2, as
                well as for various archive and compression file formats,
                including 7z, xz, bzip2, gzip, tar, zip (read-write) and cab,
                cpio, deb, lzh, rar, and rpm (read-only).
      Category: System/Core
         State: Installed
     Publisher: solaris
       Version: 9.20.1
 Build Release: 5.11
        Branch: 0.175.0.0.0.2.537
Packaging Date: Wed Oct 19 09:13:22 2011
          Size: 6.73 MB
          FMRI: pkg://solaris/compress/p7zip@9.20.1,5.11-0.175.0.0.0.2.537:20111019T091322Z 

Here's another example:

$ pkg info -r solaris-large-server
          Name: group/system/solaris-large-server
       Summary: Oracle Solaris Large Server
   Description: Provides an Oracle Solaris large server environment
      Category: Meta Packages/Group Packages
         State: Not installed
     Publisher: solaris
       Version: 0.5.11
 Build Release: 5.11
        Branch: 0.175.1.0.0.9.2627
Packaging Date: Mon Feb 06 22:33:56 2012
          Size: 5.45 kB
          FMRI: pkg://solaris/group/system/solaris-large-server@0.5.11,5.11-0.175.1.0.0.9.2627:20120206T223356Z

The pkginfo command does the same for any SVR4 packages you may have installed on the same system.

For More Information

- Rick Ramsey with Alta Elstad

Website

Newsletter

Facebook

Twitter

About

Contributors:
Rick Ramsey
Kemer Thomson
and members of the OTN community

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Blogs We Like