#!/bin/ksh # # pkgmake -- make a Solaris package. # Type "pkgmake help=y" for online man page. # # 2002/08/08, Michael Wang, . # * Added "root" feature, adding files outside the basedir. # 2002/07/29, Michael Wang, . # * Added man page. # 2001/05/06, mwang@mindspring.com # * Minor modification. # 2000/12/15, mwang@mindspring.com # * IPO. OPATH=$PATH PATH=/bin function my_getopts { #- version 3.141592, 2002-02-02, Michael Wang . typeset PATH= SEP= i typeset -u _I for i; do _I=$i eval ${_I%%?(:)=*}= unset ${_I%%?(:)=*} case $_I in *[!:]=*) eval $(IFS=$SEP; print ${_I%%=*}=\"${_I#*=}\") ;; *:=*) eval $(IFS=$SEP; print ${_I%%:=*}=\"${i#*:=}\") ;; esac done } my_getopts help=n pkgmk=y pkgtrans=y overwrite=n rmpkg=y "$@" [[ $HELP == @(Y|PDF) ]] && { PATH=$OPATH whence perldoc >/dev/null || { [[ -x /usr/perl5/bin/perldoc ]] && OPATH=$OPATH:/usr/perl5/bin PATH=$OPATH whence perldoc >/dev/null || { print "You need to have perldoc in your PATH." exit 1 } } i= t= unset i t i=$(basename $0 .ksh) t=/tmp/$i.$$.$RANDOM mkdir $t && trap "rm -rf $t" EXIT INT sed -n "s:^## \{0,1\}::p" $0 > $t/$i.pod [[ $HELP == Y ]] && PATH=$OPATH perldoc $t/$i.pod [[ $HELP == PDF ]] && PATH=$OPATH pod2man $t/$i.pod | PATH=$OPATH groff -man | PATH=$OPATH ps2pdf - > $i.pdf exit 0 } PKGFILE=$(basename $PWD) eval $(grep "^PKG" pkginfo) [[ $PKGMK == Y ]] && { { find * -prune -type f -print | while read i; do print i $i done find $(find !(root) -prune -type d -print) -type f -print | pkgproto find root -type f -print | while read i; do pkgproto $i=${i#root} done } > prototype pkgmk -r . -d . -o } [[ $PKGTRANS == Y ]] && { if [[ -f ../UL$PKGFILE.pkg && OVERWRITE == N ]]; then print "../UL$PKGFILE.pkg exists, exit." else print | pkgtrans . ../UL$PKGFILE.pkg fi [[ $RMPKG == Y ]] && rm -rf $PKG } ## =head1 NAME ## ## B - make a Solaris package ## ## =head1 SYNOPSIS ## ## B [I] ## [I] ## [I] ## [I] ## [I] ## ## =head1 DESCRIPTION ## ## B makes a Solaris package by following the following 1-2-3 steps: ## ## First, you need to put all files in a directory. B ## from http://www.unixlabplus.com/ will help you to identify ## newly installed files in /usr/local area from "make install". ## ## The files should be placed in a work area for pkgmake. All the files ## should be relative to BASEDIR specified in "pkginfo". If you ## do have files outside of BASEDIR, you can use root directory. ## For example, to package sendmail, you can specify BASEDIR as /usr ## and place the following files in pkgmake work area: ## ## lib/sendmail ## bin/vacation ## share/man/cat8/sendmail.8 ## root/etc/mail/sendmail.cf ## ## Second, you need to create a file "pkginfo". The easiest way is to ## edit a template. The following is one: ## ## PKG=ULgcc ## NAME=gcc ## VERSION=3.1.1 ## DESC=GNU Compiler Collection ## VENDOR=Free Software Foundation ## PKGSAV=/var/sadm/pkg/ULgcc/save ## HOTLINE=http://gcc.gnu.org/ ## EMAIL= ## ARCH=Solaris 8 sparc ## BASEDIR=/usr/local ## CLASSES=none ## TZ=US/Eastern ## PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin ## OAMBASE=/usr/sadm/sysadm ## CATEGORY=utility ## PSTAMP=mwang@mindspring.com, 2002-07-27 ## ## Third, you run B command. ## ## B first makes a package in file system format. If this step ## is already done, then you can specify "pkgmk=n" option. "pkgmk=y" is ## the default. ## ## Then it translates the file system format to datastream format. ## It puts the datastream file in parent directory, with the name ## "ULI.pkg", where I is taken from the current directory. ## For example, if you put the packages files under gcc-3.1.1 directory, ## the package datastream file name is "ULgcc-3.1.1.pkg". Please do not ## confuse package file name with package name. package name is what you ## specified in "pkginfo" file with "PKG=" line. Package name is limited ## to eight (8) characters up to Solaris 8. package file name is just ## an Unix filename which can be renamed. ## ## If the package file name is already exists, it will overwrite it ## by default. If you do not want to do this, then you specify ## "overwrite=n" option. ## ## After the package is translated to datastream format, it will remove ## the file system format by default. If you do not want to do this, then ## you specify "rmpkg=y" option. ## ## "help=y" will greet you with online man page. ## ## =head1 SEE ALSO ## ## "makeinstall help=y" on http://www.unixlabplus.com/. ## ## =head1 AUTHOR ## ## Michael Wang >. ## ## This is free software. You may copy or redistribute it under the same ## terms as Perl. However, if you modify it, you are required to send the ## modification to the author via email.