apply2sw_inventory [ -d output_dir ] [ -r ]
With apply2sw_inventory it is possible to automatically update a software inventory file in a install script without the need to enter the software inventory information by hand using the swvi command or to write directly to the ..sw_inventory file which format might change in future releases.
For more information about the software inventory creation and maintenance see swvi(1) and sw_report(1).
As in the swvi command, only the entries for SOFTWARE, VERSION, INST_USER and INST_GROUP are compulsory. The sequence of the entries provided is not significant. For a complete list and description of all entries see swvi(1).
See section EXAMPLES for common usages of apply2sw_inventory in an install script.
This are the major parts of a simplified installation script to give an idea of updating/creating the software inventory file without manual intervention.
This installation script installs WA2L/edrc that is available in the package file /dat/sw/apps/edrc-1.5.02/edrc-1.5.02-20070428.sh to the installation directory /opt. All manual input queried by the shell archive edrc-1.5.02-20070428.sh is provided via input redirection. After that the software inventory file is updated using apply2sw_inventory. Because in this case WA2L/edrc is the only software in the installation directory the probably existing software inventory file is cleared using the -r option ahead of writing to it.
#!/bin/sh
#
# My_INSTALL - My Install Script for: EDRC Shell archive 
#
# [00] 21.09.2005 CWa   Initial Version
#
# Const
PATH=$PATH:~edrc/bin ; export PATH
Installbasedir=/opt
Pkgfile=/dat/sw/apps/edrc-1.5.02/edrc-1.5.02-20070428.sh
# package installation
#
cat <<EOM | $Pkgfile
n
$Installbasedir
n
n
y
y
EOM
# update software inventory
#
cat <<EOM | apply2sw_inventory -r -d $Installbasedir/edrc
        SOFTWARE   = EDRC - Enterprise Disaster Recovery Console 
        VERSION    = 1.5.02
        INST_USER  = root
        INST_GROUP = root
        RUN_USER   =
        RUN_GROUP  =
        CFG_DIR    = etc
        VAR_DIR    = var
        LICENSE    = GNU GPL
        LIC_MGMT   =
        WEB        =
        DOC        = ~edrc/doc/edrc_manpages-1.5.02.pdf
        INST_SRC   = $Pkgfile
        PRODUCT    = System
        INSTANCE   =
        COMMENT    = disaster recovery and system administration
EOM
This are the major parts of a simplified installation script to give an idea of updating/creating the software inventory file without manual intervention.
This installation script installs the GNU C compilers that are available in the HP-UX depot file /dat/sw/apps/gcc-3.3.2/gcc-3.3.2-hppa-11.11.depot.gz to the installation directory /usr/local. The installation is performed with the swinstall command of HP-UX. After that the software inventory file is updated using apply2sw_inventory. Due to the fact that in /usr/local often many different software are installed the most likely existing software inventory should not be cleared ahead of writing to it. That's why apply2sw_inventory is called without the remove (clear) option.
#!/bin/sh
#
# My_INSTALL - My Install Script for: GNU C Compiler
#
# [00] 21.09.2005 CWa   Initial Version
#
# Const
PATH=$PATH:~edrc/bin ; export PATH
Installbasedir=/usr/local
Pkgfile=/dat/sw/apps/gcc-3.3.2/gcc-3.3.2-hppa-11.11.depot.gz
# package installation
#
cd /
swinstall -s $Pkgfile gcc
# update software inventory
#
cat <<EOM | apply2sw_inventory -d $Installbasedir
        SOFTWARE   = GNU C Compilers 
        VERSION    = 3.3.2 
        INST_USER  = root
        INST_GROUP = sys
        RUN_USER   =
        RUN_GROUP  =
        CFG_DIR    = 
        VAR_DIR    = 
        LICENSE    = GNU GPL
        LIC_MGMT   =
        WEB        = http://hpux.cs.utah.edu/hppd/hpux/Gnu/gcc-3.3.2
        DOC        = http://gcc.gnu.org 
        INST_SRC   = $Pkgfile
        PRODUCT    = Development
        INSTANCE   =
        COMMENT    =
EOM
This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.