home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.3.4.17 [SPARC, PA-RISC]
/
nextstep33_risc.iso
/
NextAdmin
/
Installer.app
/
package
< prev
Wrap
Text File
|
1994-05-05
|
4KB
|
191 lines
#! /bin/csh -ef
set prog = `/usr/bin/basename $0`
set usage = "Usage: $prog [-B] [-f] root-dir info-file [tiff-file] [-d dest-dir]"
set noglob
# Use Installer's tar by default
set tar = /NextAdmin/Installer.app/installer_tar
# gather parameters
if ($#argv == 0) then
echo $usage
exit(1)
endif
while ( $#argv > 0 )
switch ( $argv[1] )
case -d:
if ( $?destDir ) then
echo ${prog}: dest-dir parameter already set to ${destDir}.
echo $usage
exit(1)
else if ( $#argv < 2 ) then
echo ${prog}: -d option requires destination directory.
echo $usage
exit(1)
else
set destDir = $argv[2]
shift; shift
breaksw
endif
case -f:
if ( $?rootDir ) then
echo ${prog}: root-dir parameter already set to ${rootDir}.
echo $usage
exit(1)
else if ( $#argv < 2 ) then
echo ${prog}: -f option requires package root directory.
echo $usage
exit(1)
else
set rootDir = $argv[2]
set fflag
shift; shift
breaksw
endif
case -B:
# We got long file names, better use bigtar instead
set tar = /NextAdmin/Installer.app/installer_bigtar
shift
breaksw
case -*:
echo ${prog}: Unknown option: $argv[1]
echo $usage
exit(1)
case *.info:
if ( $?info ) then
echo ${prog}: info-file parameter already set to ${info}.
echo $usage
exit(1)
else
set info = "$argv[1]"
shift
breaksw
endif
case *.tiff:
if ( $?tiff ) then
echo ${prog}: tiff-file parameter already set to ${tiff}.
echo $usage
exit(1)
else
set tiff = "$argv[1]"
shift
breaksw
endif
default:
if ( $?rootDir ) then
echo ${prog}: unrecognized parameter: $argv[1]
echo $usage
exit(1)
else
set rootDir = "$argv[1]"
shift
breaksw
endif
endsw
end
# check for mandatory parameters
if ( ! $?rootDir ) then
echo ${prog}: missing root-dir parameter.
echo $usage
exit(1)
else if ( ! $?info) then
echo ${prog}: missing info-file parameter.
echo $usage
exit(1)
endif
# destDir gets default value if unset on command line
if ( $?destDir ) then
/bin/mkdirs $destDir
else
set destDir = .
endif
# derive the root name for the package from the root name of the info file
set root = `/usr/bin/basename $info .info`
# create package directory
set pkg = ${destDir}/${root}.pkg
echo Generating Installer package $pkg ...
if ( -e $pkg ) /bin/rm -rf $pkg
/bin/mkdirs -m 755 $pkg
# tar and compress root directory to package archive
set pkgArchive = $pkg/$root.tar.Z
echo -n " creating package archive ... "
if ( $?fflag ) then
set pkgTop = ${rootDir:t}
set parent = ${rootDir:h}
if ( "$parent" == "$pkgTop" ) set parent = "."
else
set parent = $rootDir
set pkgTop = .
endif
(cd $parent; $tar cf - $pkgTop) | /usr/ucb/compress -f -c > $pkgArchive
/bin/chmod 444 $pkgArchive
echo done.
# copy info file to package
set pkgInfo = $pkg/$root.info
echo -n " copying ${info:t} ... "
/bin/cp $info $pkgInfo
/bin/chmod 444 $pkgInfo
echo done.
# copy tiff file to package
if ( $?tiff ) then
set pkgTiff = $pkg/$root.tiff
echo -n " copying ${tiff:t} ... "
/bin/cp $tiff $pkgTiff
/bin/chmod 444 $pkgTiff
echo done.
endif
# generate bom file
set pkgBom = $pkg/$root.bom
echo -n " generating bom file ... "
/bin/rm -f $pkgBom
if ( $?fflag ) then
/usr/etc/mkbom $parent $pkgBom >& /dev/null
else
/usr/etc/mkbom $rootDir $pkgBom >& /dev/null
endif
/bin/chmod 444 $pkgArchive
echo done.
# generate sizes file
set pkgSizes = $pkg/$root.sizes
echo -n " generating sizes file ... "
# compute number of files in package
set numFiles = `/usr/etc/lsbom -s $pkgBom | /usr/ucb/wc -l`
# compute package size when compressed
@ compressedSize = `/bin/du -s $pkg | /bin/awk '{print $1}'`
@ compressedSize += 3 # add 1KB each for sizes, location, status files
@ infoSize = `/bin/ls -s $pkgInfo | /bin/awk '{print $1}'`
@ bomSize = `/bin/ls -s $pkgBom | /bin/awk '{print $1}'`
if ( $?tiff ) then
@ tiffSize = `/bin/ls -s $pkgTiff | /bin/awk '{print $1}'`
else
@ tiffSize = 0
endif
@ installedSize = `/bin/du -s $rootDir | /bin/awk '{print $1}'`
@ installedSize += $infoSize + $bomSize + $tiffSize + 3
# echo size parameters to sizes file
echo NumFiles $numFiles > $pkgSizes
echo InstalledSize $installedSize >> $pkgSizes
echo CompressedSize $compressedSize >> $pkgSizes
echo done.
echo " ... finished generating $pkg."
exit(0)
# end package