#!/bin/ksh # # Re-create a Solaris package installation file from it's installed # components. # # Andy Welter # www.the-welters.com # # Limitations: # This script will only capture files that have entires in the # /var/sadm/install/contents file. It will not capture other files such # as config files that were added for the package later. It will also # not capture any pre or post install scripts that may have been used # when the package was originally installed. # # The file ownerships and permissions in the new package are will be the # same as the actual file ownerships and permissions, not what they were # when the file was originally installed. # DIR=/tmp USAGE="repack " if [ $# -lt 1 ]; then echo "$USAGE" exit 1 fi PKG=$1 pkginfo $PKG if [ $? -ne 0 ]; then echo "No such package $PKG." exit 1 fi TMPDIR=$DIR/$PKG.$$ if [ ! -d $TMPDIR ]; then mkdir $TMPDIR else echo "$TMPDIR already exists. Exiting" exit 1 fi cd $TMPDIR echo "PKG=$PKG" > pkginfo echo 'BASEDIR="/"' >> pkginfo pkginfo -l $PKG | while read KEYWORD VALUE; do case $KEYWORD in NAME:) # make sure the name reflects the fact that this # is a repackaged Solaris package. echo "NAME=$VALUE - repackaged" >> pkginfo ;; CATEGORY:) echo "CATEGORY=$VALUE" >> pkginfo ;; ARCH:) echo "ARCH=$VALUE" >> pkginfo ;; VERSION:) # make sure the version reflects the fact that this # is a repackaged Solaris package. echo "VERSION=$VALUE - repackaged" >> pkginfo ;; VENDOR:) echo "VENDOR=$VALUE" >> pkginfo ;; EMAIL:) echo "EMAIL=$VALUE" >> pkginfo ;; esac done echo "i pkginfo=./pkginfo" > prototype grep $PKG /var/sadm/install/contents | cut -f1 -d" "| pkgproto >> prototype if [ -d /var/spool/pkg/$PKG ]; then echo "Package already exists in /var/spool/pkg." echo "Do you want to over write this package? " read ANS if [ "$ANS" = "y" -o \ "$ANS" = "yes" ]; then pkgmk -o -r / else echo "Ok, exiting" exit 1 fi else pkgmk -r / fi cd /var/spool/pkg rm -r $TMPDIR echo "Do you want to turn the pkg directory into a single package file? " read ANS if [ "$ANS" = "y" -o \ "$ANS" = "yes" ]; then pkgtrans -s /var/spool/pkg $PKG.pkg rm -r /var/spool/pkg/$PKG fi