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 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
101 [ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
103 [ $# -eq 0 ] && _usage
107 CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
109 CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
112 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
114 while getopts "Dcm:d:S:o:g:" c $*
126 DIRMODE=`expr $OPTARG`
137 dir=$DIST_ROOT/$OPTARG
146 shift `expr $OPTIND - 1`
163 $CHOWN $OWNER $GROUP $dir
166 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
170 # fourth usage (symlink)
178 $LN -s -f $symlink $target
180 $MANIFEST l $symlink ${target#$DIST_ROOT}
193 mkdir -p `dirname $dir`
201 $CHMOD $FILEMODE $dir/$f
205 $CHOWN $OWNER $GROUP $dir/$f
208 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
210 $CHMOD $FILEMODE $dir
214 $CHOWN $OWNER $GROUP $dir
217 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
236 # echo DIR=$dir list=\"$list\"
243 $CHMOD $FILEMODE $dir/$f
247 $CHOWN $OWNER $GROUP $dir/$f
250 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
252 [ $status -ne 0 ] && break