3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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)"
45 echo "or $prog -T lt_arg [-o owner] [-g group] [-m mode] libtool.lai directory"
47 echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
48 echo "behaviour of this command - see comments in the script."
49 echo "The -D flag is only available for the second usage, and causes"
50 echo "the target directory to be created before installing the file."
58 if [ $# -eq 3 ] ; then
61 if [ $_st -ne 0 ] ; then
62 if [ $REAL_UID != '0' ] ; then
63 if [ ! -f $DIST_ROOT/.chown.quiet ] ; then
64 echo '==============================================='
65 echo Ownership of files under ${DIST_ROOT:-/}
66 echo cannot be changed
67 echo '==============================================='
68 if [ -n "$DIST_ROOT" ] ; then
69 touch $DIST_ROOT/.chown.quiet
83 echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
98 # default is to install and don't append manifest
102 : ${DIST_ROOT:=${DESTDIR}}
104 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
105 [ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
107 [ $# -eq 0 ] && _usage
111 CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
113 CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
116 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
118 while getopts "Dcm:d:S:o:g:T:" c $*
130 DIRMODE=`expr $OPTARG`
141 dir=$DIST_ROOT/$OPTARG
154 shift `expr $OPTIND - 1`
171 $CHOWN $OWNER $GROUP $dir
174 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
178 # fourth usage (symlink)
186 $LN -s -f $symlink $target
188 $MANIFEST l $symlink ${target#$DIST_ROOT}
192 # -T (install libs built by libtool)
199 # source the libtool variables
200 if [ ! -f $libtool_lai ]
202 echo "$prog: Unable to find libtool library file $libtool_lai"
210 # Loop until we find libfoo.so.x.y.z, then break out.
211 for solib in $library_names
213 # does it have enough parts? libfoo.so.x.y.z == 5
214 cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
217 install_name=$target/$solib
218 $CP $solib $install_name
220 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT}
229 # ln -s libfoo.so.x.y.z to libfoo.so.x
230 from_parts=5 # libfoo.so.x.y.z
231 to_parts=3 # libfoo.so.x
234 # ln -s libfoo.so.x to libfoo.so
235 from_parts=3 # libfoo.so.x
236 to_parts=2 # libfoo.so
239 echo "$prog: -T $lt_install invalid"
244 # Loop until we find the names, then break out.
245 for solib in $library_names
247 # does it have enough parts?
248 cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
249 if [ $cnt -eq $from_parts ]
252 elif [ $cnt -eq $to_parts ]
257 if [ -n "$from_name" ] && [ -n "$to_name" ]
259 install_name=$target/$to_name
260 $LN -s -f $from_name $install_name
262 $MANIFEST l $from_name ${install_name#$DIST_ROOT}
268 install_name=$target/$old_library
269 $CP $old_library $install_name
271 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT}
274 echo "$prog: -T $lt_install invalid"
280 old_lib|so_dot_version)
283 $CHMOD $FILEMODE $install_name
284 $CHOWN $OWNER $GROUP $install_name
301 mkdir -p `dirname $dir`
309 $CHMOD $FILEMODE $dir/$f
313 $CHOWN $OWNER $GROUP $dir/$f
316 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
318 $CHMOD $FILEMODE $dir
322 $CHOWN $OWNER $GROUP $dir
325 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
344 # echo DIR=$dir list=\"$list\"
351 $CHMOD $FILEMODE $dir/$f
355 $CHOWN $OWNER $GROUP $dir/$f
358 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
360 [ $status -ne 0 ] && break