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 pkgPKG=$1case $PKG in
"") echo "USAGE: $0 package";exit;;
*)
VER=`pkgparam $PKG VERSION|sed 's/ //g'`
if [ "$VER" = "" ]; then
echo "Invalid package: $PKG";exit
fi
;;
esacARC=/tmp/${PKG}_${VER}_pkg.tar
LIST=${ARC}_file_list.$$
PKGADM=/var/sadm/pkgcase `uname` in
SCO_SV) PKGADM=/usr/adm/pkg;;
esacfor file in `pkgchk -l $PKG |\
grep Pathname: |\
awk -F: '{print $2}'`
do
if [ -d $file ]; then
continue
else
echo $file
fi
done > $LISTecho "$PKGADM/$PKG">> $LISTecho "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/pkgarcTo create the archive of a specific package, use the syntax:
/usr/bin/pkgarc mypkgThis 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.