Wednesday, October 3, 2012

Unattended SVr4 package install

SVr4 relocatable and non-relocatable packages add/removal can be fully automated.
This is accomplished by CLI options for response and administration files.
For simplicity, assume /pkg/out as the current directory on all that follows.
   
# cd /pkg/out
    
A response file is required if the package uses an interactive request script.
If so, the pkgask command is used to record all the answers in this file.
That's the case with my sample relocatable package PHXapp1.
    
# pkgask -r ./PHXapp1.response -d ./PHXapp1.pkg PHXapp1 all
Processing package instance <PHXapp1> from </pkg/out/PHXapp1.pkg>
Relocatable sample package(i386,sparc) 1.0
Copyright (c) 2012 ...
Enter path to package base directory (q to quit) [/opt/PHXapp1] <ENTER>
Response file </pkg/out/PHXapp1.response> was created.
Processing of request script was successful.
   
# cat PHXapp1.response
BASEDIR=/opt/PHXapp1
   
Otherwise the following error message appears explaining the situation.
That's the case for my sample non-relocatable SMF service package PHXsvc1:
   
# pkgask -r ./PHXsvc1.response -d ./PHXsvc1.pkg PHXsvc1
pkgask: ERROR: ... does not contain an interactive request script
      
In general an administration file, admin(4), is required.
This is specially required if the package contains or references other scripts.
Basically and at a minimum, the following entries seem enough:
   
# cat PHX.admin
setuid=nocheck
action=nocheck
  
The above files make unattended package operations possible.

Option -r is for specifying the response file to pkgadd.
Option -a is for specifying the administration file to both pkgadd and pkgrm.
Optionally, the listing of the package contents can be omitted with option -n.

For the sample non-relocatable SMF service package PHXsvc1 it looks like:

# pkgadd -n -a ./PHX.admin -d ./PHXsvc1.pkg all
Copyright (c) 2012 ...
Installation of <PHXsvc1> was successful.

# pkgrm -n -a ./PHX.admin PHXsvc1
Waiting up to 30 seconds for svc:/site/phx-svc:default to stop...
Removal of <PHXsvc1> was successful.

For the sample relocatable application package PHXapp1 it looks like:

# pkgadd
  -n
  -a ./PHX.admin
  -r ./PHXapp1.response
  -d ./PHXapp1.pkg
  all
Copyright (c) 2012 ... 
Installation of <PHXapp1> was successful.

# pkgrm -n -a ./PHX.admin PHXapp1
Removing package base directory.
Removal of <PHXapp1> was successful.