HP Unix - Create SW Depot

Preface

  • All described commands and examples in this document, are excited on HP-UX server.
  • As well most of the described commands and examples in this document are OS specific.

At HP UX “.depot” files are used for software sharing and installing between servers. The idea is same as at:

  • RHEL like OS is used “.rpm”
  • Debian like OS is using “.deb”
  • Slackware like OS is using “.tgz”
  • ….

According to mentioned way of standard software distribution at HPUX it's common to provide software bundle like “.depot” file.

Assumption

This document will provide example with explanation how to create HPUX deport. This document will not describe how to administrate you of HPUX system. We do expect that the reader of this document is has experience with administration of HPUX system.

Creating HP-UX Depot

Preparation for “.depot” creation

To prevent messing up our file system we'll need to create temporary file where we'll locate:

  • Needed configuration for creating “.depot”
  • SW that need to be installed
  • Installation scripts
  • Uninstallation scripts
  • Script to create “.depot”

Where to create depot

In our case we’ll create directory structure at “/tmp” with same name as the name of our “.depot”.
In this case we’ll create “test-01.00.depot”

[root@hpux:~]# mkdir /tmp/test/                          # Directory including all source data for creating of depot
[root@hpux:~]# mkdir /tmp/test/pkg-root                  # Directory including file structure of installed SW
[root@hpux:~]# mkdir /tmp/test/pkg-root/opt/             # In our case we'll install our SW in to /opt/test/...
[root@hpux:~]# mkdir /tmp/test/pkg-root/opt/test
[root@hpux:~]# mkdir /tmp/test/pkg-root/opt/test/bin     # In this example here we'll locate installation and uninstalltion script
[root@hpux:~]# mkdir /tmp/test/pkg-root/opt/test/data    # In this example here we'll locate just some text file as example

Please make sure that the whole structure of file system, that you'd like to copy on destination server, has exact the same structure at the “pkg-root” directory as it will have on target server.

SW to be installed

The main purpose “.depot” software bundle used at HP-UX is to provide possibility to use standard way for SW distribution. \ Based on this we will now create a simple text file that will present our software or data that will be distributed with help of “.depot” file to target node.

[root@hpux:~]# echo "This is jsut an test: Hello World"> /tmp/test/pkg-root/opt/test/data/Hello_world.txt

Installation Script

In our case we'll locate this script in to: “ /tmp/test/pkg-root/opt/test/bin/config_install”

In some cases it’s needed to execute command or set of commands after pleasing of the software to the file system.

Cases like this are when you’ll need to:

  • Register the software in special way to your application
  • Merge the new SW with existing SW on OS
  • Update OS or Application parameters to accept update
  • Compile code

In our case we’ll create simple shell script to present the possibility to include as well automated action that will be executed during installation of the “.depot”.

[root@hpux:~]# cat /tmp/test/pkg-root/opt/test/bin/config_install               # Location of this script file in our example

#!/bin/sh
# ----------------------------------------------------------------------------
# Created:      2016/11/20
# Modified:     iggy.ttt@gmail.com
# File:         configure
# Description:  Configure script for example of HP-UX depot creation
# Language:     shell (POSIX)
# Package:      test
# ----------------------------------------------------------------------------

############
# Variables
############
file_HW="/opt/test/data/Hello_world.txt" ;                                      # PATH to Origianl file
copy_of_file_HW="/opt/test/data/copy_Hello_world.txt" ;                         # PATH where to copy this file

###########
# What to do
###########
cp $file_HW $copy_of_file_HW ;                                                  # Copy the  file

######################################################################
# end of file: configure
######################################################################

Please make sure after you've created mentioned installation script that it's executable:

[root@hpux:~]# chmod 777 /tmp/test/pkg-root/opt/test/bin/config_install

Unistallation Script

In our case we'll locate this script in to: “ /tmp/test/pkg-root/opt/test/bin/config_remove”

During uninstalling of HPUX “.depot” we have again the possibility to execute a script or set of commands that will be executed before deleting of depot related files will be processed.

In our case we’ll create simple shell script to present the possibility to include as well automated action that will be executed during uninstallation of the “.depot”

[root@hpux:~]# cat /tmp/test/pkg-root/opt/test/bin/config_remove      # Location of this script file in our example

#!/bin/sh
# ----------------------------------------------------------------------------
# Created:      2016/11/20
# Modified:     iggy.ttt@gmail.com
# File:         configure
# Description:  Configure script for example of HP-UX depot creation
# Language:     shell (POSIX)
# Package:      test
# ----------------------------------------------------------------------------

############
# Variables
############
file_HW="/opt/test/data/Hello_world.txt" ;                                      # PATH to Origianl file
copy_of_file_HW="/tmp/copy_Hello_world.txt" ;                                   # PATH where to copy this file

###########
# What to do
###########
cp $file_HW $copy_of_file_HW ;                                                  # Copy the  file

#####################################################################
# end of file: config_remove
#####################################################################

Please make sure after you've created mentioned installation script that it's executable:

[root@hpux:~]# chmod 777 /tmp/test/pkg-root/opt/test/bin/config_remove

Package Specification File

In our case we'll locate this script in to: “ /tmp/test/package.psf ”

To create “.depot” we’ll need to create Specification file that will help us to summarize all relations that will be needed for creation of “.depot” bundle.

[root@hpux:~]# cat /tmp/test/package.psf

#!/bin/sh
# ----------------------------------------------------------------------------         # Update autor information
# Created:      2016/11/20
# Modified:     iggy.ttt@gmail.com
# File:         configure
# Description:  Configure script for example of HP-UX depot creation
# Language:     SD PSF
# Package:      test
# ----------------------------------------------------------------------------
# Depot definition
#-----------------
depot
  tag            Test                                                                  # Change Name of the depot
  title          Test: This is just an test depot bundle                               # Change description
         #-----------------
         # Vendor definition
         #-----------------
         vendor                                                                        # Change Vendor Info
           tag            IggyT
           title          www.IggyT.org
           description    www.IggyT.org
         end
         #--------------------------------------------------------------------
         #Product definition for Rollout_Tools
         #--------------------------------------------------------------------
         product
         tag                 Test                                                      # Change Name of the depot
         data_model_revision 01.00                                                     # Change version of bundle
         instance_id         1
         title          Test: This is just an test depot bundle                        # Change description
         revision       01.00                                                          # Change version of bundle
         os_name        HP-UX
         os_release     ?.1?.*
         is_locatable   false

                #------------------------------------------
                # Fileset definition for Rollout_Tools binaries
                #------------------------------------------
            fileset
                tag             Test                                                   # Change Name of the depot
                instance_id     1
                title           Test                                                   # Change Name of the depot
                revision        01.00                                                  # Change version of bundle
                is_secure       no
                #----------------
                # Control scripts
                #----------------
                configure       ./pkg-root/opt/test/bin/config_install                  # Change PATH to Installation script
                preremove       ./pkg-root/opt/test/bin/config_remove                   # Change PATH to Uninstallation script
                #---------
                # Contents
                #---------
                directory        pkg-root = /
                file_permissions -m 755 -o bin -g bin
                file             *
           end

Script to create ".depot"

In our case we'll locate this script in to: “ /tmp/test/pack.sh ”

The last one file that we will need to create is a simple script that will create for us the HPUX depot. In general it is not needed to create this script as you can run the command “swpackage” directly from CLI. On another hand it's easier to run it as script.

[root@hpux:~]#cat /tmp/test/pack.sh

#!/usr/bin/sh
### get package name & version
PNAME=$(grep -w tag package.psf | head -1 | awk '{print $2}')
PVERSION=$(grep -w revision package.psf | head -1 | awk '{print $2}')
PACKAGE_NAME="$PNAME"_"$PVERSION"".depot"

echo "Package name: $PACKAGE_NAME"
echo "Creating package..."

swpackage -x media_type=tape -s package.psf  @ $PACKAGE_NAME

According to this please create this script and make him executable.

[root@hpux:~]# chmod +x /tmp/test/pack.sh

Creation for “.depot”

In our case we'll get the final “.depot ” file at : “ /tmp/test/Test_01.00.depot ”

As we've have already prepared all that is needed in previous steps, now it's possible to create “.depot” :

[root@hpux:~]# cd /tmp/test                                                 # Go to the directory where we've created the file structure
[root@hpux:/tmp/test]# ./pack.sh                                            # Execute the script that will create a depot

Package name: Test_01.00.depot
Creating package...

=======  Fri, Oct 21, 2016 11:47:45 AM CDT  BEGIN swpackage SESSION

       * Session started for user
         "root@hpux".

       * Source:        hpux:package.psf
       * Target:        hpux:Test_01.00.depot
       * Software selections:
             *

       * Beginning Selection Phase.
       * Reading the Product Specification File (PSF) "package.psf".
       * Reading the product "Test" at line 26.
       * Reading the fileset "Test" at line 40.

NOTE:    The temporary target depot "/var/tmp/pkgAAA016509" has been
         created.
       * Selection Phase succeeded.

       * Beginning Analysis Phase.
       * Analysis Phase succeeded.

       * Beginning Package Phase.
       * Packaging the product "Test".
       * Packaging the fileset "Test.Test".
       * Package Phase succeeded.

       * Beginning Tapemaker Phase.
       * Copying the temporary depot to the tape "Test_01.00.depot".
       * Calculating the tape blocks required to copy the temporary
         depot to the tape "Test_01.00.depot".
NOTE:    The temporary depot requires 20 Kbytes on the tape
         "Test_01.00.depot".
       * Writing the tape "Test_01.00.depot" (tape 1 of 1).
       * Writing the fileset "Test.Test" (1 of 1)
       * Tape #1: CRC-32 checksum & size: 3209190180 20480

       * Removing the temporary depot.
       * Tapemaker Phase succeeded.

=======  Fri, Oct 21, 2016 11:47:45 AM CDT  END swpackage SESSION

Basic usage of “.depot”

Install ".depot" on HP-UX

For not intreractive “.depot ” instalaltion at HP-UX you can use this command

# swinstall -s </path/to/the/.depot> <SW_name>

Example:

[root@hpux:~]# ll /tmp/test/Test_01.00.depot                                               # Location of our ".depot" bundle
-rw-r--r--   1 root       sys          20480 Oct 21 11:47 /tmp/test/Test_01.00.depot

[root@hpux:~]# swinstall -s /tmp/test/Test_01.00.depot Test                                # Installation command to install our ".depot"

=======  Fri, Oct 21, 2016 12:03:59 PM CDT  BEGIN swinstall SESSION
         (non-interactive) (jobid=hpux-2015)

       * Session started for user "root@hpux".

       * Beginning Selection
       * Target connection succeeded for "hpux:/".
       * Source:                 /tmp/test/Test_01.00.depot
       * Targets:                hpux:/
       * Software selections:
             Test.Test,r=01.00
       * Selection succeeded.

       * Beginning Analysis and Execution
       * Session selections have been saved in the file
         "/root/.sw/sessions/swinstall.last".
       * The analysis phase succeeded for "hpux:/".
       * The execution phase succeeded for "hpux:/".
       * Analysis and Execution succeeded.

NOTE:    More information may be found in the agent logfile using the
         command "swjob -a log hpux-2015 @ hpux:/".                                        # In the case that you'd like to see more details
                                                                                           # run command "swjob -a log hpux-2015 @ hpux:/"
=======  Fri, Oct 21, 2016 12:04:21 PM CDT  END swinstall SESSION
         (non-interactive) (jobid=hpux-2015)

More instalaltion details:

[root@hpux:~]# swjob -a log hpux-2015 @ hpux:/                                             # This command was provided during instalaltion of depot
=======  10/21/16 12:03:59 CDT  BEGIN install AGENT SESSION (pid=20129)
         (jobid=hpux-2015)

       * Agent session started for user
         "root@hpux". (pid=20129)

       * Beginning Analysis Phase.
       * Source:           hpux:/tmp/test/Test_01.00.depot
       * Target:           hpux:/
       * Target logfile:   hpux:/var/adm/sw/swagent.log
       * Reading source for product information.
       * Reading source for file information.
       * Executing preDSA command.
NOTE:    The used disk space on filesystem "/opt" is estimated to
         increase by 24 Kbytes.
         This will leave 2567888 Kbytes of available user disk space
         after the installation.
NOTE:    The used disk space on filesystem "/var/adm/sw" is estimated
         to increase by 32 Kbytes.
         This will leave 12793231 Kbytes of available user disk space
         after the installation.

       * Summary of Analysis Phase:
       * 1 of 1 filesets had no Errors or Warnings.
       * The Analysis Phase succeeded.

       * Beginning the Install Execution Phase.
       * Filesets:         1
       * Files:            8
       * Kbytes:           5
       * Installing fileset "Test.Test,r=01.00" (1 of 1).

       * Beginning the Configure Execution Phase.                                    # At this phasse will be executed as well the config_install script
                                                                                     # If there is some output of the script it will be present here
       * Summary of Execution Phase:
       * 1 of 1 filesets had no Errors or Warnings.
       * The Execution Phase succeeded.

=======  10/21/16 12:04:21 CDT  END install AGENT SESSION (pid=20129)
         (jobid=hpux-2015)

Validate instalaltion:

[root@hpux:~]# find /opt/test/*                                         # In this example we will just check if all files are located on the right place
/opt/test/bin
/opt/test/bin/config_install
/opt/test/bin/config_remove
/opt/test/data
/opt/test/data/Hello_world.txt
/opt/test/data/copy_Hello_world.txt                                     # As well it's possible to see that the "config_install" script was executed

[root@hpux:~]#ll /opt/test/data
total 32
-rwxr-xr-x   1 root       sys             34 Oct 21 12:04 copy_Hello_world.txt
-rwxr-xr-x   1 bin        bin             34 Oct 21 10:17 Hello_world.txt

[root@hpux:~]#cat /opt/test/data/*
This is jsut an test: Hello World
This is jsut an test: Hello World

Uninstall ".depot" from HP-UX

For not intreractive “.depot ” uninstalaltion at HP-UX you can use this command

# swremove <SW_name>

Example:

[root@hpux:~]# swremove Test                                                        # Uninstall depot Test

=======  Fri, Oct 21, 2016 12:35:39 PM CDT  BEGIN swremove SESSION
         (non-interactive) (jobid=hpux-2016)

       * Session started for user "root@hpux".

       * Beginning Selection
       * Target connection succeeded for "hpux:/".
       * Software selections:
             Test.Test,l=/,r=01.00
       * Selection succeeded.

       * Beginning Analysis
       * Session selections have been saved in the file
         "/root/.sw/sessions/swremove.last".
       * The analysis phase succeeded for "hpux:/".
       * Analysis succeeded.

       * Beginning Execution                                                              # Executing script config_remove
       * The execution phase succeeded for "hpux:/".
       * Execution succeeded.

NOTE:    More information may be found in the agent logfile using the
         command "swjob -a log hpux-2016 @ hpux:/".                                       # For more detials please execute command:
                                                                                          # "swjob -a log hpux-2016 @ hpux:/"
=======  Fri, Oct 21, 2016 12:35:55 PM CDT  END swremove SESSION
         (non-interactive) (jobid=hpux-2016)

More details:

[root@hpux:~]# swjob -a log hpux-2016 @ hpux:/                                           # At end of the remove command is possible to see hint for this command
=======  10/21/16 12:35:40 CDT  BEGIN remove AGENT SESSION (pid=26603)
         (jobid=hpux-2016)

       * Agent session started for user
         "root@hpux". (pid=26603)

       * Beginning Analysis Phase.
       * Target:           hpux:/
       * Target logfile:   hpux:/var/adm/sw/swagent.log
       * Reading source for file information.

       * Summary of Analysis Phase:
       * 1 of 1 filesets had no Errors or Warnings.
       * The Analysis Phase succeeded.

       * Beginning the Unconfigure Execution Phase.
       * Filesets:         1
       * Files:            8
       * Kbytes:           5

       * Beginning the Remove Execution Phase.
       * Removing fileset "Test.Test,l=/,r=01.00" (1 of 1).

       * Summary of Execution Phase:
       * 1 of 1 filesets had no Errors or Warnings.
       * The Execution Phase succeeded.

=======  10/21/16 12:35:55 CDT  END remove AGENT SESSION (pid=26603)
         (jobid=hpux-2016)

Validation:

[root@hpux:~]# swlist | grep -i test                                                    # Check if depot is still registered
[root@hpux:~]#

[root@hpux:~]# find /opt/test                                                           # Check if files included in the depot have been removed
/opt/test
/opt/test/bin
/opt/test/data
/opt/test/data/copy_Hello_world.txt                                                     # This was created with help of "config_install" script

[root@hpux:~]#ll /tmp/copy_Hello_world.txt                                              # Check if "config_remove" script was executed
-rwxr-xr-x   1 root       sys             34 Oct 21 12:35 /tmp/copy_Hello_world.txt     # as it's possible to see it was executed

List of installed “.depot” on HP-UX

For getting information about installed package you can use command:

# swlist

Options:

[root@hpux:~]# swlist -h
swlist: illegal option -- h
Usage: swlist [options] [software_selections] [@ target_selections]

Options include:

    -v                write verbose output to stdout
    -r                target selections are alternate root directories
    -d                target selections are software depots
    -R                shorthand for -l bundle -l subproduct -l fileset
    -l level          levels of objects to view, one of: "depot",
                      "bundle", "product", "subproduct", "fileset",
                      "file", "root", "shroot", "prroot",
                      "category", "patch", "control_file"
    -a attribute      list this attribute (multiple -a options can be
                      specified)
    -s source         read the software selections from this source
    -x option=value   set the option to value
    -X option_file    read option definitions from this file
    -f software_file  read software selections from this file
    -t target_file    read target selections from this file
    -C session_file   user saved session file
    -S session_file   read options, software selections, and target
                      selections from this file

Software selections are specified as:

    product[.subproduct][.fileset][,version] ...

where version is either

    [r=revision][,a=arch][,v=vendor][,l=location]
    instance_id

Target selections are specified as:

    @ [host][:][path] ...

Example: Simple

[root@hpux:~]# swlist | grep -i test
  Test                                                          01.00          Test: This is just an test depot bundle

Example: More details

[root@hpux:~]# swlist -v Test
# Initializing...
# Contacting target "hpux"...
#
# swlist   Installed Software Table of Contents
#
# For host:  hpux:/
#
# Date:  Fri, Oct 21, 2016 12:28:47 PM
#

# Test
product
tag                    Test
software_spec          Test,l=/,r=01.00
data_model_revision    2.40
instance_id            1
control_directory      Test
size                   4698
revision               01.00
title                  Test: This is just an test depot bundle
description
mod_date               Fri, Oct 21, 2016 12:04:20 PM
mod_time               1477069460
create_date            Fri, Oct 21, 2016 12:04:00 PM
create_time            1477069440
install_date           201610211204.20
architecture
machine_type
os_name                HP-UX
os_release             ?.1?.*
os_version
install_source         hpux:/tmp/test/Test_01.00.depot
install_type           physical
is_patch               false
supersedes
category_tag
vendor_tag
directory              /
qualifier
postkernel
layout_version         1.0
all_filesets           Test
is_locatable           false
location               /
copyright
share_link
readme
job_file
number

  Test.Test
fileset
tag                    Test
software_spec          Test.Test,l=/,r=01.00
data_model_revision    2.40
instance_id            1
control_directory      Test
size                   4698
revision               01.00
title                  Test
description
mod_date               Fri, Oct 21, 2016 12:04:20 PM
mod_time               1477069460
create_date            Fri, Oct 21, 2016 12:04:00 PM
create_time            1477069440
install_date           201610211204.20
architecture
machine_type
os_name
os_release
os_version
install_source         hpux:/tmp/test/Test_01.00.depot
is_patch               false
supersedes
category_tag
state                  configured
is_kernel              false
is_reboot              false
is_secure              false
ancestor
media_sequence_number
partial_file
partial_pipe_size
partial_state_path
is_sparse              false
applied_patches
is_locatable
location               /
dynamic_module
is_drd_safe
Navigation
Print/export
QR Code
QR Code wiki:os:hp_unix:index-hp_unix:hp_unix-create_sw_depot (generated for current page)