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 [ -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:T:" c $*
128 DIRMODE=`expr $OPTARG`
139 dir=$DIST_ROOT/$OPTARG
152 shift `expr $OPTIND - 1`
169 $CHOWN $OWNER $GROUP $dir
172 $MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
176 # fourth usage (symlink)
184 $LN -s -f $symlink $target
186 $MANIFEST l $symlink ${target#$DIST_ROOT}
190 # -T (install libs built by libtool)
197 # source the libtool variables
198 if [ ! -f $libtool_lai ]
200 echo "$prog: Unable to find libtool library file $libtool_lai"
208 # Loop until we find libfoo.so.x.y.z, then break out.
209 for solib in $library_names
211 # does it have enough parts? libfoo.so.x.y.z == 5
212 cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
215 install_name=$target/$solib
216 $CP $solib $install_name
218 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT}
227 # ln -s libfoo.so.x.y.z to libfoo.so.x
228 from_parts=5 # libfoo.so.x.y.z
229 to_parts=3 # libfoo.so.x
232 # ln -s libfoo.so.x to libfoo.so
233 from_parts=3 # libfoo.so.x
234 to_parts=2 # libfoo.so
237 echo "$prog: -T $lt_install invalid"
242 # Loop until we find the names, then break out.
243 for solib in $library_names
245 # does it have enough parts?
246 cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
247 if [ $cnt -eq $from_parts ]
250 elif [ $cnt -eq $to_parts ]
255 if [ -n "$from_name" ] && [ -n "$to_name" ]
257 install_name=$target/$to_name
258 $LN -s -f $from_name $install_name
260 $MANIFEST l $from_name ${install_name#$DIST_ROOT}
266 install_name=$target/$old_library
267 $CP $old_library $install_name
269 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT}
272 echo "$prog: -T $lt_install invalid"
278 old_lib|so_dot_version)
281 $CHMOD $FILEMODE $install_name
282 $CHOWN $OWNER $GROUP $install_name
299 mkdir -p `dirname $dir`
307 $CHMOD $FILEMODE $dir/$f
311 $CHOWN $OWNER $GROUP $dir/$f
314 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
316 $CHMOD $FILEMODE $dir
320 $CHOWN $OWNER $GROUP $dir
323 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
342 # echo DIR=$dir list=\"$list\"
349 $CHMOD $FILEMODE $dir/$f
353 $CHOWN $OWNER $GROUP $dir/$f
356 $MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
358 [ $status -ne 0 ] && break