]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/install-sh
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 : ${DIST_ROOT:=${DESTDIR}}
90 [ -n "$DIST_MANIFEST" -a -z "$DIST_ROOT" ] && INSTALL
=false
91 [ -n "$DIST_MANIFEST" ] && MANIFEST
="_manifest"
93 [ $# -eq 0 ] && _usage
97 CP
=cp; LN
=ln; MKDIR
=mkdir
; CHMOD
=chmod; CHOWN
=_chown
99 CP
=true
; LN
=true
; MKDIR
=true
; CHMOD
=true
; CHOWN
=true
102 [ -n "$DIST_ROOT" -a $REAL_UID -ne 0 ] && CHOWN
=true
104 while getopts "Dcm:d:S:o:g:T:" c $
*
116 DIRMODE
=`expr $OPTARG`
127 dir
=$DIST_ROOT/$OPTARG
140 shift `expr $OPTIND - 1`
157 $CHOWN $OWNER $GROUP $dir
160 $MANIFEST d
$DIRMODE $OWNER $GROUP ${dir#$DIST_ROOT}
164 # fourth usage (symlink)
172 $LN -s -f $symlink $target
174 $MANIFEST l
$symlink ${target#$DIST_ROOT}
178 # -T (install libs built by libtool)
185 # source the libtool variables
186 if [ ! -f $libtool_lai ]
188 echo "$prog: Unable to find libtool library file $libtool_lai"
196 # Loop until we find libfoo.so.x.y.z, then break out.
197 for solib
in $library_names
199 # does it have enough parts? libfoo.so.x.y.z == 5
200 cnt
=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
203 install_name
=$target/$solib
204 $CP $solib $install_name
206 $MANIFEST f
$FILEMODE $OWNER $GROUP $HERE/$solib ${install_name#$DIST_ROOT}
215 # ln -s libfoo.so.x.y.z to libfoo.so.x
216 from_parts
=5 # libfoo.so.x.y.z
217 to_parts
=3 # libfoo.so.x
220 # ln -s libfoo.so.x to libfoo.so
221 from_parts
=3 # libfoo.so.x
222 to_parts
=2 # libfoo.so
225 echo "$prog: -T $lt_install invalid"
230 # Loop until we find the names, then break out.
231 for solib
in $library_names
233 # does it have enough parts?
234 cnt
=`echo "$solib" | sed -e 's/\./ /g' | wc -w`
235 if [ $cnt -eq $from_parts ]
238 elif [ $cnt -eq $to_parts ]
243 if [ -n "$from_name" ] && [ -n "$to_name" ]
245 install_name
=$target/$to_name
246 $LN -s -f $from_name $install_name
248 $MANIFEST l
$from_name ${install_name#$DIST_ROOT}
254 install_name
=$target/$old_library
255 $CP $old_library $install_name
257 $MANIFEST f
$FILEMODE $OWNER $GROUP $HERE/$old_library ${install_name#$DIST_ROOT}
260 echo "$prog: -T $lt_install invalid"
266 old_lib|so_dot_version
)
269 $CHMOD $FILEMODE $install_name
270 $CHOWN $OWNER $GROUP $install_name
287 mkdir
-p `dirname $dir`
295 $CHMOD $FILEMODE $dir/$f
299 $CHOWN $OWNER $GROUP $dir/$f
302 $MANIFEST f
$FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
304 $CHMOD $FILEMODE $dir
308 $CHOWN $OWNER $GROUP $dir
311 $MANIFEST f
$FILEMODE $OWNER $GROUP $HERE/$dir ${dir#$DIST_ROOT}
330 # echo DIR=$dir list=\"$list\"
337 $CHMOD $FILEMODE $dir/$f
341 $CHOWN $OWNER $GROUP $dir/$f
344 $MANIFEST f
$FILEMODE $OWNER $GROUP $HERE/$f ${dir#$DIST_ROOT}/$f
346 [ $status -ne 0 ] && break