home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenStep 4.2J
/
os42j.iso
/
usr
/
bin
/
install
< prev
next >
Wrap
Text File
|
1997-04-22
|
4KB
|
225 lines
#!/bin/csh -f
umask 022
set path=($path /etc)
set cmd="cp -p"
set links
set quick
set symlink
set link="ln"
while (1)
switch ($1)
case -s:
set strip="strip -arch all"
shift
breaksw
case -sX:
set strip="strip -arch all -X"
shift
breaksw
case -sx:
set strip="strip -arch all -x"
shift
breaksw
case -sA:
set strip="strip -arch all -A"
shift
breaksw
case -sS:
set strip="strip -arch all -S"
shift
breaksw
case -sSd:
set strip="strip -arch all -S -d $2"
shift
shift
breaksw
case -sgg:
set strip="strip -arch all -gg"
shift
breaksw
case -sAn:
set strip="strip -arch all -A -n"
shift
breaksw
case -r:
set ranlib="ranlib"
shift
breaksw
case -q:
set quick="quick"
shift
breaksw
case -c:
set cmd="cp -p"
shift
breaksw
case -d:
set cmp="cmp"
shift
breaksw
case -v:
set vecho="echo"
shift
breaksw
case -m:
set chmod="chmod $2"
shift
shift
breaksw
case -o:
set chown="chown -f $2"
shift
shift
breaksw
case -g:
set chgrp="chgrp -f $2"
shift
shift
breaksw
case -xc:
set cmd="sed"
set comments='/^[ ]*#/d'
shift
breaksw
case -xs:
set cmd="sed"
set comments='/^[ ]*[#:]/d'
shift
breaksw
case -l:
set links="$links $2"
shift
shift
breaksw
case -u:
set unlink="rm -f"
shift
breaksw
case -V:
set stamp="vers_string -f"
set link="symlink -r -f"
shift
breaksw
case -S:
set save=1
shift
breaksw
default:
break
breaksw
endsw
end
if ( $#argv < 2 ) then
echo "install: no destination specified"
exit(1)
endif
set dest=$argv[$#argv]
if ( $#argv > 2 ) then
if ( ! -d $dest ) then
echo "usage: install f1 f2 or f1 f2 ... dir"
exit(1)
endif
endif
foreach j ($argv)
if ( $j == $dest) break
if ( ! -f $j ) then
echo "install: can't open $j"
exit(1)
endif
if ( -d $dest ) then
set file=$dest/${j:t}
else
set file=$dest
endif
if ( -f $file ) then
if ( `ls -i $file | awk '{print $1}'` == \
`ls -i $j | awk '{print $1}'` ) then
echo "install: can't move $j onto itself"
exit(1)
endif
endif
if ( $?stamp ) then
set symlink=$file
set file=`$stamp $file`
endif
if ( "$cmd" == "sed" ) then
if ( -e $file && $?save ) then
rm -f $file.old
if ( ! { mv $file $file.old } ) exit(1)
endif
if ( $?unlink ) then
$unlink $file
endif
if ($?vecho) then
echo sed -e '<strip comments>' $j ">$file"
endif
sed -e '1s;^#\!;&;p' -e '2s;^#(@)PROG;&;p' \
-e '2s;^#PROG;&;p' -e "$comments" $j >$file
else if ( $?cmp ) then
echo -n CMP $j $file
if ( { cmp -s $j $file } ) then
echo ';'
else
if ( -e $file && $?save ) then
rm -f $file.old
if ( ! { mv $file $file.old } ) exit(1)
endif
if ( $?unlink ) then
$unlink $file
endif
echo " THEN" $cmd
if ( ! { $cmd $j $file } ) exit(1)
endif
else
if ( -e $file && $?save ) then
rm -f $file.old
if ( ! { mv $file $file.old } ) exit(1)
endif
if ( $?unlink ) then
$unlink $file
endif
if ($?vecho) then
echo $cmd $j $file
endif
if ( ! { $cmd $j $file } ) exit(1)
endif
if ( $?strip ) then
if ($?vecho) then
echo $strip $file
endif
if ( ! { $strip $file } ) exit(1)
endif
if ( $?ranlib ) then
if ($?vecho) then
echo $ranlib $file
endif
if ( ! { $ranlib $file } ) exit(1)
endif
if ( $?chmod ) then
if ($?vecho) then
echo $chmod $file
endif
if ( ! { $chmod $file } ) exit(1)
endif
if ( $?chown ) then
if ($?vecho) then
echo $chown $file
endif
if ( ! { $chown $file } ) exit(1)
endif
if ( $?chgrp ) then
if ($?vecho) then
echo $chgrp $file
endif
if ( ! { $chgrp $file } ) exit(1)
endif
end
foreach i ( $symlink $links )
if ($?vecho) then
echo $link $file $i
endif
rm -f $i
if ( ! { $link $file $i } ) exit(1)
end
exit(0)