Technical article 127275

How can I create an archive of a older pkgadd (PKG) style package that is installed on my system before replacing it with a newer version?

OpenServer 6.0.0OpenServer 5.0.7UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1UnixWare 7.1.3UnixWare 7.1.4

Written · Last revised

Problem

I would like to have a fallback option if I have problems
upgrading a pkgadd (PKG) style package on my system, but I
am unable to locate the version of the package that I
currently have installed.  I would like to create an
archive of the currently installed package before removing or
replacing it so that I can revert back to it in case there are
problems with the new package on my system.

Alternatively, I would like to install the same version of a currently installed pkgadd (PKG) style package on another system, but I am unable to locate it on the internet or elsewhere.

Solution

Use the following script to create a tar archive of the files
related to the currently installed PKG package.  Save as
/usr/bin/pkgarc, with root ownership and root only execute
permissions as it will require root privileges to create
the archive.

Please note this procedure is for pkgadd (PKG) style packages only and will not work with custom (VOL) style packages for SCOadmin Software Manager.

Note:  The following script may not work with all pkgadd (PKG) style
packages.  Some packages use preinstall and postinstall scripts
to do additional configuration such as building driver modules
or relinking the kernel.  These scripts should be examined to
determine if there are special considerations for using this
archive method.  It may be necessary to perform some steps
taken in these preinstall/postinstall script manually for the
restored package archive to work correctly.
Note:  If the package has been patched by either an escalation fix
or by another supplement, then the archive will also contain this
fix and not the original files for the package.
----- cut here -----
#! /bin/sh
# /usr/bin/pkgarc - create tar archive of existing pkg
PKG=$1
case $PKG in
    "") echo "USAGE: $0 package";exit;;
    *)
        VER=`pkgparam $PKG VERSION|sed 's/ //g'`
        if [ "$VER" = "" ]; then
           echo "Invalid package: $PKG";exit
        fi
     ;;
esac
ARC=/tmp/${PKG}_${VER}_pkg.tar
LIST=${ARC}_file_list.$$
PKGADM=/var/sadm/pkg
case `uname` in
    SCO_SV) PKGADM=/usr/adm/pkg;;
esac
for file in `pkgchk -l $PKG |\
    grep Pathname: |\
    awk -F: '{print $2}'`
do
  if [ -d $file ]; then
     continue
  else
    echo $file
  fi
done > $LIST
echo "$PKGADM/$PKG">> $LIST
echo "Creating $ARC"
tar cvf $ARC `cat $LIST`
echo "Created $ARC"
# uncomment this remove statement to remove temporary file list.
#rm $LIST
----- cut here -----

Save as /usr/bin/pkgarc and make it executable by root only, using:

chown root:sys /usr/bin/pkgarc
chmod 744 /usr/bin/pkgarc

To create the archive of a specific package, use the syntax:

/usr/bin/pkgarc mypkg
This will create a tar archive of the package 'mypkg' in
/tmp.  To revert back to this version of the package,
restore the tar archive.

To determine if additional configuration steps are needed examine the preinstall/postinstall scripts found in: /var/sadm/pkg/mypkg/install/

Under OpenServer5, the path is /usr/adm/pkg/mypkg/install/.
Note:  The script does not save the file list for the package as
stored in /var/sadm/install/contents.  If the archive is restored to
a system that never had the package, then pkgchk will be unable to
list the contents of the package.  This will also prevent you from
making a second archive from the system where the package was
restored.

From the Xinuos technical article database, record 127275. Reproduced with permission. The original is at www.sco.com/ta/127275, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.