3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # This script emulates bsd install and also recognises
20 # two environment variables, with the following semantics :-
22 # $DIST_MANIFEST - if set, the name of the file to append manifest
23 # information in the following format:
24 # File : f mode owner group src target
25 # Directory: d mode owner group target
26 # Symlink : l linkval target
28 # $DIST_ROOT - if set, prepend to target
30 # The sematics of all combinations of these two variables
33 # $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest?
34 # -----------------------------+--------------------------
35 # not set not set | yes no
36 # not set set | yes no
37 # set not set | no yes
41 echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory"
42 echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file"
43 echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory"
44 echo "or $prog -S file target (creates \"target\" symlink)"
46 echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
47 echo "behaviour of this command - see comments in the script."
48 echo "The -D flag is only available for the second usage, and causes"
49 echo "the target directory to be created before installing the file."
57 if [ $# -eq 3 ] ; then
60 if [ $_st -ne 0 ] ; then
61 if [ $REAL_UID != '0' ] ; then
62 if [ ! -f $DIST_ROOT/.chown.quite ] ; then
63 echo '==============================================='
64 echo Ownership of files under ${DIST_ROOT:-/}
65 echo cannot be changed
66 echo '==============================================='
67 if [ -n "$DIST_ROOT" ] ; then
68 touch $DIST_ROOT/.chown.quite
82 echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
96 # default is to install and don't append manifest
100 : ${DIST_ROOT:=${DESTDIR}}
102 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
103 [ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
105 [ $# -eq 0 ] && _usage
109 CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
111 CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
114 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
116 while getopts "Dcm:d:S:o:g:" c $*
128 DIRMODE=`expr $OPTARG`
139 dir=$DIST_ROOT/$OPTARG
148 shift `expr $OPTIND - 1`
165 $CHOWN $OWNER $GROUP $dir
168 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
172 # fourth usage (symlink)
180 $LN -s -f $symlink $target
182 $MANIFEST l $symlink ${target#$DIST_ROOT}
195 mkdir -p `dirname $dir`
203 $CHMOD $FILEMODE $dir/$f
207 $CHOWN $OWNER $GROUP $dir/$f
210 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
212 $CHMOD $FILEMODE $dir
216 $CHOWN $OWNER $GROUP $dir
219 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
238 # echo DIR=$dir list=\"$list\"
245 $CHMOD $FILEMODE $dir/$f
249 $CHOWN $OWNER $GROUP $dir/$f
252 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
254 [ $status -ne 0 ] && break