123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- #!/bin/sh
- doit="${DOITPROG-}"
- mvprog="${MVPROG-mv}"
- cpprog="${CPPROG-cp}"
- chmodprog="${CHMODPROG-chmod}"
- chownprog="${CHOWNPROG-chown}"
- chgrpprog="${CHGRPPROG-chgrp}"
- stripprog="${STRIPPROG-strip}"
- rmprog="${RMPROG-rm}"
- mkdirprog="${MKDIRPROG-mkdir}"
- transformbasename=""
- transform_arg=""
- instcmd="$mvprog"
- chmodcmd="$chmodprog 0755"
- chowncmd=""
- chgrpcmd=""
- stripcmd=""
- rmcmd="$rmprog -f"
- mvcmd="$mvprog"
- src=""
- dst=""
- dir_arg=""
- while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
- -d) dir_arg=true
- shift
- continue;;
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
- -s) stripcmd="$stripprog"
- shift
- continue;;
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
- *) if [ x"$src" = x ]
- then
- src=$1
- else
-
- :
- dst=$1
- fi
- shift
- continue;;
- esac
- done
- if [ x"$src" = x ]
- then
- echo "install: no input file specified"
- exit 1
- else
- :
- fi
- if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- chmodcmd=""
- else
- instcmd=$mkdirprog
- fi
- else
- if [ -f "$src" ] || [ -d "$src" ]
- then
- :
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- :
- fi
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- :
- fi
- fi
- dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
- if [ ! -d "$dstdir" ]; then
- defaultIFS='
- '
- IFS="${IFS-${defaultIFS}}"
- oIFS="${IFS}"
- IFS='%'
- set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
- IFS="${oIFS}"
- pathcomp=''
- while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- :
- fi
- pathcomp="${pathcomp}/"
- done
- fi
- if [ x"$dir_arg" != x ]
- then
- $doit $instcmd $dst &&
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
- else
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- :
- fi
- dsttmp=$dstdir/
- $doit $instcmd $src $dsttmp &&
- trap "rm -f ${dsttmp}" 0 &&
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
- fi &&
- exit 0
|