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

Wednesday Sep 14, 2011

OTN Sysadmin Day - Seattle

OTN Sysadmin Day held in Sacramento on Sep 8 was the first time we presented two tracks of hands-on labs:

Time Session
8:00 am System Shakedown
9:00 am Oracle's Dual OS Strategy / Overview of OTN
 

Oracle Solaris Track

Oracle Linux Track

10:00 am HOL: ZFS HOL: managing packages, configuring services
11:30 am HOL: Exploring OS, network, and storage virtualization HOL on Storage Part I: managing storage and file systems
1:00 pm Lunch Break
2:00 pm HOL: Managing software with IPS HOL on Storage Part II: Device Mapper, BTRFS
3:00 pm Presentation: Oracle Enterprise Manager Ops Center 11g
4:00 pm Discussion: What are the most pressing issues for sysadmins today?
5:00 pm We all go home

Participants found the hands-on labs particularly valuable. You get to learn by doing. And what you get to do is install, configure, and manage the technologies of Oracle Solaris 11 and Oracle Linux in the same way as you would in the real world.

Next Sysadmin Day

We are doing another one in Seattle, on September 22nd. From 8:00 am to 5:00 pm. It's free, but you must register. Please stay for the feedback session at the end. They tend to be pretty spirited, and you might win a neat prize. I'll tell you more if you make it to Seattle.

Our next Sysadmin Day won't happen till January 18 (Salt Lake City), so do what you can to make it to Seattle. It's being held at the Seattle Westin Hotel, 1900 5th Avenue.

If you'd like to see some pictures from the Sacramento event, go to the "OTN Sysadmin Day Sacramento" photo folder on the OTN Garage on Facebook.

- Rick
Website
Newsletter
Facebook
Twitter

Monday Nov 15, 2010

Solaris 11 Express Resources for Sysadmins


























The Beast is here.

Oracle Solaris 11 Express is a big change for Solaris, particularly in:

To help you manage it, we've assembled the following resources:

You can find these links in a tidy package on OTN's Solaris 11 Express Product Page:

Solaris 11 Express Product Page on OTN

Provides technical resources about Solaris 11 Express, including latest white papers and other publication, documentation, download instructions, and other resources for sysadmins, developers, and IT managers.

We've also got a few resources for application developers, and I'll point you to them over the next few days.

- Rick

Monday Nov 08, 2010

Solaris Summit - Watch It On Video









photo courtesy of www.digitaltrends.com










If you can't be at LISA in person but still want to catch the Solaris 11 Express Summit, tune into the Live Stream. It starts at at 9:00 am US Pacific Time Tuesday morning.

During the breaks, catch some of these motorcycle racing crash videos ....

- Rick
(Oracle Technology Network - System Admin and Developer Community)

Tuesday Oct 19, 2010

A Peak Experience













photo courtesy of www.everestnews.com














The peak experience of the year for Solaris sysadmins will happen all day Tuesday, Nov 9, at the Solaris Summit of the LISA Conference in ballrooms A4 and A5 of the San Jose Convention Center

We have gathered the engineers who designed and built the capabilities in Oracle Solaris 11 Express that are most significant to sysadmins, and they are going to spend the entire day walking you through them:

9:00 - 9:30 am
Introduction to Oracle Solaris 11 Express, by Markus Flierl

9:30 - 11:00 am
Image Packaging Systems, by Bart Smaalders

11:00 am - 12:30 pm
Deploying Oracle Solaris 11 in the Enterprise, by Dave Miner

12:30 pm - 1:30 pm
LUNCH BREAK

1:30 pm - 2:30 pm
Advances in Solaris Networking with Crossbow and Beyond, by Nicolas Droux

2:30 pm - 3:00 pm
Oracle Solaris Containers in Oracle Solaris 11 Express, by Dan Price

3:00 pm - 3:15 pm
BREAK

3:15 pm - 4:15 pm
ZFS Features in Oracle Solaris Express, by Cindy Swearingen

4:15 pm - 4:45 pm
New Security Features in Oracle Solaris 11 Express, by Glenn Faden

4:45 pm - 5:30 pm
Deploying Applications Using SMF and Other Solaris 11 Features, by Liane Praza

5:30 pm - 6:30 pm
Beer and Snacks Reception for ALL

The event is free if you're already attending LISA, but you must register beforehand.

Don't be left hanging. Register now.

- Rick









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