3 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 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, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like. Any license provided herein, whether implied or
16 # otherwise, applies only to this software file. Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA 94043, or:
29 # For further information regarding this notice, see:
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 # This script emulates bsd install and also recognises
36 # two environment variables, with the following semantics :-
38 # $DIST_MANIFEST - if set, the name of the file to append manifest
39 # information in the following format:
40 # File : f mode owner group src target
41 # Directory: d mode owner group target
42 # Symlink : l linkval target
44 # $DIST_ROOT - if set, prepend to target
46 # The sematics of all combinations of these two variables
49 # $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest?
50 # -----------------------------+--------------------------
51 # not set not set | yes no
52 # not set set | yes no
53 # set not set | no yes
57 echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory"
58 echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file"
59 echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory"
60 echo "or $prog -S file target (creates \"target\" symlink)"
62 echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
63 echo "behaviour of this command - see comments in the script."
64 echo "The -D flag is only available for the second usage, and causes"
65 echo "the target directory to be created before installing the file."
73 if [ $# -eq 3 ] ; then
76 if [ $_st -ne 0 ] ; then
77 if [ $REAL_UID != '0' ] ; then
78 if [ ! -f $DIST_ROOT/.chown.quite ] ; then
79 echo '==============================================='
80 echo Ownership of files under ${DIST_ROOT:-/}
81 echo cannot be changed
82 echo '==============================================='
83 if [ -n "$DIST_ROOT" ] ; then
84 touch $DIST_ROOT/.chown.quite
98 echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
112 # default is to install and don't append manifest
116 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
117 [ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
119 [ $# -eq 0 ] && _usage
123 CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
125 CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
128 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
130 while getopts "Dcm:d:S:o:g:" c $*
142 DIRMODE=`expr $OPTARG`
153 dir=$DIST_ROOT/$OPTARG
162 shift `expr $OPTIND - 1`
179 $CHOWN $OWNER $GROUP $dir
182 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
186 # fourth usage (symlink)
194 $LN -s -f $symlink $target
196 $MANIFEST l $symlink ${target#$DIST_ROOT}
209 mkdir -p `dirname $dir`
217 $CHMOD $FILEMODE $dir/$f
221 $CHOWN $OWNER $GROUP $dir/$f
224 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
226 $CHMOD $FILEMODE $dir
230 $CHOWN $OWNER $GROUP $dir
233 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
252 # echo DIR=$dir list=\"$list\"
259 $CHMOD $FILEMODE $dir/$f
263 $CHOWN $OWNER $GROUP $dir/$f
266 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
268 [ $status -ne 0 ] && break