3
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5
# This script emulates bsd install and also recognises
6
# two environment variables, with the following semantics :-
8
# $DIST_MANIFEST - if set, the name of the file to append manifest
9
# information in the following format:
10
# File : f mode owner group src target
11
# Directory: d mode owner group target
12
# Symlink : l linkval target
14
# $DIST_ROOT - if set, prepend to target
16
# The sematics of all combinations of these two variables
19
# $DIST_MANIFEST? $DIST_ROOT? | Copy? Append Manifest?
20
# -----------------------------+--------------------------
21
# not set not set | yes no
22
# not set set | yes no
23
# set not set | no yes
27
echo "Usage: $prog [-o owner] [-g group] [-m mode] -d directory"
28
echo "or $prog [-D] [-o owner] [-g group] [-m mode] file directory/file"
29
echo "or $prog [-o owner] [-g group] [-m mode] file [file ...] directory"
30
echo "or $prog -S file target (creates \"target\" symlink)"
31
echo "or $prog -T lt_arg [-o owner] [-g group] [-m mode] libtool.lai directory"
33
echo "The \$DIST_MANIFEST and \$DIST_ROOT environment variables affect the"
34
echo "behaviour of this command - see comments in the script."
35
echo "The -D flag is only available for the second usage, and causes"
36
echo "the target directory to be created before installing the file."
44
if [ $# -eq 3 ] ; then
47
if [ $_st -ne 0 ] ; then
48
if [ $REAL_UID != '0' ] ; then
49
if [ ! -f $DIST_ROOT/.chown.quiet ] ; then
50
echo '==============================================='
51
echo Ownership of files under ${DIST_ROOT:-/}
52
echo cannot be changed
53
echo '==============================================='
54
if [ -n "$DIST_ROOT" ] ; then
55
touch $DIST_ROOT/.chown.quiet
69
echo $* | sed -e 's/\/\//\//g' >>${DIST_MANIFEST:-/dev/null}
84
# default is to install and don't append manifest
88
[ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL=false
89
[ -n "$DIST_MANIFEST" ] && MANIFEST="_manifest"
91
[ $# -eq 0 ] && _usage
95
CP=cp; LN=ln; MKDIR=mkdir; CHMOD=chmod; CHOWN=_chown
97
CP=true; LN=true; MKDIR=true; CHMOD=true; CHOWN=true
100
[ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN=true
102
while getopts "Dcm:d:S:o:g:T:" c $*
114
DIRMODE=`expr $OPTARG`
125
dir=$DIST_ROOT/$OPTARG
138
shift `expr $OPTIND - 1`
155
$CHOWN $OWNER $GROUP $dir
158
$MANIFEST d $DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
162
# fourth usage (symlink)
170
$LN -s -f $symlink $target
172
$MANIFEST l $symlink ${target#$DIST_ROOT}
176
# -T (install libs built by libtool)
183
# source the libtool variables
184
if [ ! -f $libtool_lai ]
186
echo "$prog: Unable to find libtool library file $libtool_lai"
194
# Loop until we find libfoo.so.x.y.z, then break out.
195
for solib in $library_names
197
# does it have enough parts? libfoo.so.x.y.z == 5
198
cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
201
install_name=$target/$solib
202
$CP $solib $install_name
204
$MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT}
213
# ln -s libfoo.so.x.y.z to libfoo.so.x
214
from_parts=5 # libfoo.so.x.y.z
215
to_parts=3 # libfoo.so.x
218
# ln -s libfoo.so.x to libfoo.so
219
from_parts=3 # libfoo.so.x
220
to_parts=2 # libfoo.so
223
echo "$prog: -T $lt_install invalid"
228
# Loop until we find the names, then break out.
229
for solib in $library_names
231
# does it have enough parts?
232
cnt=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
233
if [ $cnt -eq $from_parts ]
236
elif [ $cnt -eq $to_parts ]
241
if [ -n "$from_name" ] && [ -n "$to_name" ]
243
install_name=$target/$to_name
244
$LN -s -f $from_name $install_name
246
$MANIFEST l $from_name ${install_name#$DIST_ROOT}
252
install_name=$target/$old_library
253
$CP $old_library $install_name
255
$MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT}
258
echo "$prog: -T $lt_install invalid"
264
old_lib|so_dot_version)
267
$CHMOD $FILEMODE $install_name
268
$CHOWN $OWNER $GROUP $install_name
285
mkdir -p `dirname $dir`
293
$CHMOD $FILEMODE $dir/$f
297
$CHOWN $OWNER $GROUP $dir/$f
300
$MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
302
$CHMOD $FILEMODE $dir
306
$CHOWN $OWNER $GROUP $dir
309
$MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
328
# echo DIR=$dir list=\"$list\"
335
$CHMOD $FILEMODE $dir/$f
339
$CHOWN $OWNER $GROUP $dir/$f
342
$MANIFEST f $FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
344
[ $status -ne 0 ] && break