3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # This script emulates bsd install and also recognises
6 # two environment variables, with the following semantics :-
8 # $DIST_MANIFEST - if set, the name of the file to append manifest
9 # information in the following format:
10 # File : f mode owner group src target
11 # Directory: d mode owner group target
12 # Symlink : l linkval target
14 # $DIST_ROOT - if set, prepend to target
16 # The sematics of all combinations of these two variables
19 # $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest?
20 # -----------------------------+--------------------------
21 # not set not set | yes no
22 # not set set | yes no
23 # set not set | no yes
27 echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory"
28 echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file"
29 echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory"
30 echo "or $prog -S file target (creates \"target\" symlink)"
32 echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
33 echo "behaviour of this command - see comments in the script."
34 echo "The -D flag is only available for the second usage, and causes"
35 echo "the target directory to be created before installing the file."
43 if [ $# -eq 3 ] ; then
46 if [ $_st -ne 0 ] ; then
47 if [ $REAL_UID != '0' ] ; then
48 if [ ! -f $DIST_ROOT/.chown.quite ] ; then
49 echo '==============================================='
50 echo Ownership of files under ${DIST_ROOT:-/}
51 echo cannot be changed
52 echo '==============================================='
53 if [ -n "$DIST_ROOT" ] ; then
54 touch $DIST_ROOT/.chown.quite
68 echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
82 # default is to install and don't append manifest
86 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
87 [ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
89 [ $# -eq 0 ] && _usage
93 CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
95 CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
98 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
100 while getopts "Dcm:d:S:o:g:" c $*
112 DIRMODE=`expr $OPTARG`
123 dir=$DIST_ROOT/$OPTARG
132 shift `expr $OPTIND - 1`
149 $CHOWN $OWNER $GROUP $dir
152 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
156 # fourth usage (symlink)
164 $LN -s -f $symlink $target
166 $MANIFEST l $symlink ${target#$DIST_ROOT}
179 mkdir -p `dirname $dir`
187 $CHMOD $FILEMODE $dir/$f
191 $CHOWN $OWNER $GROUP $dir/$f
194 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
196 $CHMOD $FILEMODE $dir
200 $CHOWN $OWNER $GROUP $dir
203 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
222 # echo DIR=$dir list=\"$list\"
229 $CHMOD $FILEMODE $dir/$f
233 $CHOWN $OWNER $GROUP $dir/$f
236 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
238 [ $status -ne 0 ] && break