1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gst-plugins-nuvdemux/install-sh Tue Oct 24 15:02:26 2006 +0100
1.3 @@ -0,0 +1,325 @@
1.4 +#!/bin/sh
1.5 +# install - install a program, script, or datafile
1.6 +
1.7 +scriptversion=2004-04-01.17
1.8 +
1.9 +# This originates from X11R5 (mit/util/scripts/install.sh), which was
1.10 +# later released in X11R6 (xc/config/util/install.sh) with the
1.11 +# following copyright and license.
1.12 +#
1.13 +# Copyright (C) 1994 X Consortium
1.14 +#
1.15 +# Permission is hereby granted, free of charge, to any person obtaining a copy
1.16 +# of this software and associated documentation files (the "Software"), to
1.17 +# deal in the Software without restriction, including without limitation the
1.18 +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1.19 +# sell copies of the Software, and to permit persons to whom the Software is
1.20 +# furnished to do so, subject to the following conditions:
1.21 +#
1.22 +# The above copyright notice and this permission notice shall be included in
1.23 +# all copies or substantial portions of the Software.
1.24 +#
1.25 +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1.26 +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1.27 +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1.28 +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1.29 +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
1.30 +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1.31 +#
1.32 +# Except as contained in this notice, the name of the X Consortium shall not
1.33 +# be used in advertising or otherwise to promote the sale, use or other deal-
1.34 +# ings in this Software without prior written authorization from the X Consor-
1.35 +# tium.
1.36 +#
1.37 +#
1.38 +# FSF changes to this file are in the public domain.
1.39 +#
1.40 +# Calling this script install-sh is preferred over install.sh, to prevent
1.41 +# `make' implicit rules from creating a file called install from it
1.42 +# when there is no Makefile.
1.43 +#
1.44 +# This script is compatible with the BSD install script, but was written
1.45 +# from scratch. It can only install one file at a time, a restriction
1.46 +# shared with many OS's install programs.
1.47 +
1.48 +# set DOITPROG to echo to test this script
1.49 +
1.50 +# Don't use :- since 4.3BSD and earlier shells don't like it.
1.51 +doit="${DOITPROG-}"
1.52 +
1.53 +# put in absolute paths if you don't have them in your path; or use env. vars.
1.54 +
1.55 +mvprog="${MVPROG-mv}"
1.56 +cpprog="${CPPROG-cp}"
1.57 +chmodprog="${CHMODPROG-chmod}"
1.58 +chownprog="${CHOWNPROG-chown}"
1.59 +chgrpprog="${CHGRPPROG-chgrp}"
1.60 +stripprog="${STRIPPROG-strip}"
1.61 +rmprog="${RMPROG-rm}"
1.62 +mkdirprog="${MKDIRPROG-mkdir}"
1.63 +
1.64 +transformbasename=
1.65 +transform_arg=
1.66 +instcmd="$mvprog"
1.67 +chmodcmd="$chmodprog 0755"
1.68 +chowncmd=
1.69 +chgrpcmd=
1.70 +stripcmd=
1.71 +rmcmd="$rmprog -f"
1.72 +mvcmd="$mvprog"
1.73 +src=
1.74 +dst=
1.75 +dir_arg=
1.76 +
1.77 +usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
1.78 + or: $0 [OPTION]... SRCFILES... DIRECTORY
1.79 + or: $0 -d DIRECTORIES...
1.80 +
1.81 +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
1.82 +In the second, create the directory path DIR.
1.83 +
1.84 +Options:
1.85 +-b=TRANSFORMBASENAME
1.86 +-c copy source (using $cpprog) instead of moving (using $mvprog).
1.87 +-d create directories instead of installing files.
1.88 +-g GROUP $chgrp installed files to GROUP.
1.89 +-m MODE $chmod installed files to MODE.
1.90 +-o USER $chown installed files to USER.
1.91 +-s strip installed files (using $stripprog).
1.92 +-t=TRANSFORM
1.93 +--help display this help and exit.
1.94 +--version display version info and exit.
1.95 +
1.96 +Environment variables override the default commands:
1.97 + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
1.98 +"
1.99 +
1.100 +while test -n "$1"; do
1.101 + case $1 in
1.102 + -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
1.103 + shift
1.104 + continue;;
1.105 +
1.106 + -c) instcmd=$cpprog
1.107 + shift
1.108 + continue;;
1.109 +
1.110 + -d) dir_arg=true
1.111 + shift
1.112 + continue;;
1.113 +
1.114 + -g) chgrpcmd="$chgrpprog $2"
1.115 + shift
1.116 + shift
1.117 + continue;;
1.118 +
1.119 + --help) echo "$usage"; exit 0;;
1.120 +
1.121 + -m) chmodcmd="$chmodprog $2"
1.122 + shift
1.123 + shift
1.124 + continue;;
1.125 +
1.126 + -o) chowncmd="$chownprog $2"
1.127 + shift
1.128 + shift
1.129 + continue;;
1.130 +
1.131 + -s) stripcmd=$stripprog
1.132 + shift
1.133 + continue;;
1.134 +
1.135 + -t=*) transformarg=`echo $1 | sed 's/-t=//'`
1.136 + shift
1.137 + continue;;
1.138 +
1.139 + --version) echo "$0 $scriptversion"; exit 0;;
1.140 +
1.141 + *) # When -d is used, all remaining arguments are directories to create.
1.142 + test -n "$dir_arg" && break
1.143 + # Otherwise, the last argument is the destination. Remove it from $@.
1.144 + for arg
1.145 + do
1.146 + if test -n "$dstarg"; then
1.147 + # $@ is not empty: it contains at least $arg.
1.148 + set fnord "$@" "$dstarg"
1.149 + shift # fnord
1.150 + fi
1.151 + shift # arg
1.152 + dstarg=$arg
1.153 + done
1.154 + break;;
1.155 + esac
1.156 +done
1.157 +
1.158 +if test -z "$1"; then
1.159 + if test -z "$dir_arg"; then
1.160 + echo "$0: no input file specified." >&2
1.161 + exit 1
1.162 + fi
1.163 + # It's OK to call `install-sh -d' without argument.
1.164 + # This can happen when creating conditional directories.
1.165 + exit 0
1.166 +fi
1.167 +
1.168 +for src
1.169 +do
1.170 + # Protect names starting with `-'.
1.171 + case $src in
1.172 + -*) src=./$src ;;
1.173 + esac
1.174 +
1.175 + if test -n "$dir_arg"; then
1.176 + dst=$src
1.177 + src=
1.178 +
1.179 + if test -d "$dst"; then
1.180 + instcmd=:
1.181 + chmodcmd=
1.182 + else
1.183 + instcmd=$mkdirprog
1.184 + fi
1.185 + else
1.186 + # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
1.187 + # might cause directories to be created, which would be especially bad
1.188 + # if $src (and thus $dsttmp) contains '*'.
1.189 + if test ! -f "$src" && test ! -d "$src"; then
1.190 + echo "$0: $src does not exist." >&2
1.191 + exit 1
1.192 + fi
1.193 +
1.194 + if test -z "$dstarg"; then
1.195 + echo "$0: no destination specified." >&2
1.196 + exit 1
1.197 + fi
1.198 +
1.199 + dst=$dstarg
1.200 + # Protect names starting with `-'.
1.201 + case $dst in
1.202 + -*) dst=./$dst ;;
1.203 + esac
1.204 +
1.205 + # If destination is a directory, append the input filename; won't work
1.206 + # if double slashes aren't ignored.
1.207 + if test -d "$dst"; then
1.208 + dst=$dst/`basename "$src"`
1.209 + fi
1.210 + fi
1.211 +
1.212 + # This sed command emulates the dirname command.
1.213 + dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
1.214 +
1.215 + # Make sure that the destination directory exists.
1.216 +
1.217 + # Skip lots of stat calls in the usual case.
1.218 + if test ! -d "$dstdir"; then
1.219 + defaultIFS='
1.220 + '
1.221 + IFS="${IFS-$defaultIFS}"
1.222 +
1.223 + oIFS=$IFS
1.224 + # Some sh's can't handle IFS=/ for some reason.
1.225 + IFS='%'
1.226 + set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
1.227 + IFS=$oIFS
1.228 +
1.229 + pathcomp=
1.230 +
1.231 + while test $# -ne 0 ; do
1.232 + pathcomp=$pathcomp$1
1.233 + shift
1.234 + if test ! -d "$pathcomp"; then
1.235 + $mkdirprog "$pathcomp" || lasterr=$?
1.236 + # mkdir can fail with a `File exist' error in case several
1.237 + # install-sh are creating the directory concurrently. This
1.238 + # is OK.
1.239 + test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
1.240 + fi
1.241 + pathcomp=$pathcomp/
1.242 + done
1.243 + fi
1.244 +
1.245 + if test -n "$dir_arg"; then
1.246 + $doit $instcmd "$dst" \
1.247 + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
1.248 + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
1.249 + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
1.250 + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
1.251 +
1.252 + else
1.253 + # If we're going to rename the final executable, determine the name now.
1.254 + if test -z "$transformarg"; then
1.255 + dstfile=`basename "$dst"`
1.256 + else
1.257 + dstfile=`basename "$dst" $transformbasename \
1.258 + | sed $transformarg`$transformbasename
1.259 + fi
1.260 +
1.261 + # don't allow the sed command to completely eliminate the filename.
1.262 + test -z "$dstfile" && dstfile=`basename "$dst"`
1.263 +
1.264 + # Make a couple of temp file names in the proper directory.
1.265 + dsttmp=$dstdir/_inst.$$_
1.266 + rmtmp=$dstdir/_rm.$$_
1.267 +
1.268 + # Trap to clean up those temp files at exit.
1.269 + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
1.270 + trap '(exit $?); exit' 1 2 13 15
1.271 +
1.272 + # Move or copy the file name to the temp name
1.273 + $doit $instcmd "$src" "$dsttmp" &&
1.274 +
1.275 + # and set any options; do chmod last to preserve setuid bits.
1.276 + #
1.277 + # If any of these fail, we abort the whole thing. If we want to
1.278 + # ignore errors from any of these, just make sure not to ignore
1.279 + # errors from the above "$doit $instcmd $src $dsttmp" command.
1.280 + #
1.281 + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
1.282 + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
1.283 + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
1.284 + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
1.285 +
1.286 + # Now rename the file to the real destination.
1.287 + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
1.288 + || {
1.289 + # The rename failed, perhaps because mv can't rename something else
1.290 + # to itself, or perhaps because mv is so ancient that it does not
1.291 + # support -f.
1.292 +
1.293 + # Now remove or move aside any old file at destination location.
1.294 + # We try this two ways since rm can't unlink itself on some
1.295 + # systems and the destination file might be busy for other
1.296 + # reasons. In this case, the final cleanup might fail but the new
1.297 + # file should still install successfully.
1.298 + {
1.299 + if test -f "$dstdir/$dstfile"; then
1.300 + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
1.301 + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
1.302 + || {
1.303 + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
1.304 + (exit 1); exit
1.305 + }
1.306 + else
1.307 + :
1.308 + fi
1.309 + } &&
1.310 +
1.311 + # Now rename the file to the real destination.
1.312 + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
1.313 + }
1.314 + }
1.315 + fi || { (exit 1); exit; }
1.316 +done
1.317 +
1.318 +# The final little trick to "correctly" pass the exit status to the exit trap.
1.319 +{
1.320 + (exit 0); exit
1.321 +}
1.322 +
1.323 +# Local variables:
1.324 +# eval: (add-hook 'write-file-hooks 'time-stamp)
1.325 +# time-stamp-start: "scriptversion="
1.326 +# time-stamp-format: "%:y-%02m-%02d.%02H"
1.327 +# time-stamp-end: "$"
1.328 +# End: