#!/usr/bin/ksh # # This script creates a simple solaris package by interactively # prompting for the basic values of a package. It assumes that # you already have the files installed on the system in the proper # location, with the desired ownerships and permissions. # # Andy Welter # Version 1.0 # 2005 # # copyScript () { if [ "$2" = "" ]; then return elif [ -d $1 ]; then cp $1/$2 $TMPDIR print "i $2=./$2" >> prototype elif [ -f $1 ]; then cp $1 $TMPDIR/$2 print "i $2=./$2" >> prototype else print "ERROR! bad file name or path $1" fi }; print "Creating pkginfo file..." print "Enter values for solaris package variables: " print -n "Package name (8 chars or less, no spaces [PKG]: " read pkg TMPDIR="/var/spool/pkg/$pkg.$$" if [ -d $TMPDIR ]; then print "ERROR: $TMPDIR already exists" exit 1 else mkdir $TMPDIR cd $TMPDIR fi print "PKG=$pkg" > pkginfo print -n "\t Package long name [NAME]: " read name print "NAME=$name" >> pkginfo print -n "\t package CATEGORY: [ex. utility, application] " read cat print "CATEGORY=$cat" >> pkginfo print "ARCH=sparc" >> pkginfo print -n "\t VERSION: " read version print "VERSION=$version" >> pkginfo print -n "\t VENDOR: " read vendor print "VENDOR=$vendor" >> pkginfo #print -n "\t BASEDIR: " #read basedir basedir="/" print "BASEDIR=$basedir" >> pkginfo print "EMAIL=" >> pkginfo print "Creating package prototype file..." cat /dev/null > prototype print "Solaris packages can run scripts at 3 points" print "= a 'checkinstall' script for checking package dependencies" print "= a 'preinstall' script that prepares a system for the installation of the files" print "= a 'postinstall' script that runs after the other package files have been installed" print "The files must be named checkinstall, preinstall, or postinstall." print print "Enter the FULL path name to any checkinstall script you wish to run (optional): " read script copyScript $script checkinstall print "Enter the path name to any preinstall script you wish to run (optional): " read script copyScript $script preinstall print "Enter the path name to any postinstall script you wish to run (optional): " read script copyScript $script postinstall print -n "Enter the name of a file containing a list of the package files: " read manifest if [ -f "$manifest" ]; then print "i pkginfo=./pkginfo" >> prototype cat $manifest | pkgproto >> prototype else print "ERROR: Must specify a file listing the contents of the package" exit 1 fi 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