gst-plugins-nuvdemux/install-sh
author rosfran
Tue Oct 24 22:48:15 2006 +0100 (2006-10-24)
branchtrunk
changeset 50 c04c69f80f33
permissions -rwxr-xr-x
[svn r51] Check for the GST interfaces library (gst_x_overlay* functions).
melunko@47
     1
#!/bin/sh
melunko@47
     2
# install - install a program, script, or datafile
melunko@47
     3
melunko@47
     4
scriptversion=2004-04-01.17
melunko@47
     5
melunko@47
     6
# This originates from X11R5 (mit/util/scripts/install.sh), which was
melunko@47
     7
# later released in X11R6 (xc/config/util/install.sh) with the
melunko@47
     8
# following copyright and license.
melunko@47
     9
#
melunko@47
    10
# Copyright (C) 1994 X Consortium
melunko@47
    11
#
melunko@47
    12
# Permission is hereby granted, free of charge, to any person obtaining a copy
melunko@47
    13
# of this software and associated documentation files (the "Software"), to
melunko@47
    14
# deal in the Software without restriction, including without limitation the
melunko@47
    15
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
melunko@47
    16
# sell copies of the Software, and to permit persons to whom the Software is
melunko@47
    17
# furnished to do so, subject to the following conditions:
melunko@47
    18
#
melunko@47
    19
# The above copyright notice and this permission notice shall be included in
melunko@47
    20
# all copies or substantial portions of the Software.
melunko@47
    21
#
melunko@47
    22
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
melunko@47
    23
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
melunko@47
    24
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
melunko@47
    25
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
melunko@47
    26
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
melunko@47
    27
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
melunko@47
    28
#
melunko@47
    29
# Except as contained in this notice, the name of the X Consortium shall not
melunko@47
    30
# be used in advertising or otherwise to promote the sale, use or other deal-
melunko@47
    31
# ings in this Software without prior written authorization from the X Consor-
melunko@47
    32
# tium.
melunko@47
    33
#
melunko@47
    34
#
melunko@47
    35
# FSF changes to this file are in the public domain.
melunko@47
    36
#
melunko@47
    37
# Calling this script install-sh is preferred over install.sh, to prevent
melunko@47
    38
# `make' implicit rules from creating a file called install from it
melunko@47
    39
# when there is no Makefile.
melunko@47
    40
#
melunko@47
    41
# This script is compatible with the BSD install script, but was written
melunko@47
    42
# from scratch.  It can only install one file at a time, a restriction
melunko@47
    43
# shared with many OS's install programs.
melunko@47
    44
melunko@47
    45
# set DOITPROG to echo to test this script
melunko@47
    46
melunko@47
    47
# Don't use :- since 4.3BSD and earlier shells don't like it.
melunko@47
    48
doit="${DOITPROG-}"
melunko@47
    49
melunko@47
    50
# put in absolute paths if you don't have them in your path; or use env. vars.
melunko@47
    51
melunko@47
    52
mvprog="${MVPROG-mv}"
melunko@47
    53
cpprog="${CPPROG-cp}"
melunko@47
    54
chmodprog="${CHMODPROG-chmod}"
melunko@47
    55
chownprog="${CHOWNPROG-chown}"
melunko@47
    56
chgrpprog="${CHGRPPROG-chgrp}"
melunko@47
    57
stripprog="${STRIPPROG-strip}"
melunko@47
    58
rmprog="${RMPROG-rm}"
melunko@47
    59
mkdirprog="${MKDIRPROG-mkdir}"
melunko@47
    60
melunko@47
    61
transformbasename=
melunko@47
    62
transform_arg=
melunko@47
    63
instcmd="$mvprog"
melunko@47
    64
chmodcmd="$chmodprog 0755"
melunko@47
    65
chowncmd=
melunko@47
    66
chgrpcmd=
melunko@47
    67
stripcmd=
melunko@47
    68
rmcmd="$rmprog -f"
melunko@47
    69
mvcmd="$mvprog"
melunko@47
    70
src=
melunko@47
    71
dst=
melunko@47
    72
dir_arg=
melunko@47
    73
melunko@47
    74
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
melunko@47
    75
   or: $0 [OPTION]... SRCFILES... DIRECTORY
melunko@47
    76
   or: $0 -d DIRECTORIES...
melunko@47
    77
melunko@47
    78
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
melunko@47
    79
In the second, create the directory path DIR.
melunko@47
    80
melunko@47
    81
Options:
melunko@47
    82
-b=TRANSFORMBASENAME
melunko@47
    83
-c         copy source (using $cpprog) instead of moving (using $mvprog).
melunko@47
    84
-d         create directories instead of installing files.
melunko@47
    85
-g GROUP   $chgrp installed files to GROUP.
melunko@47
    86
-m MODE    $chmod installed files to MODE.
melunko@47
    87
-o USER    $chown installed files to USER.
melunko@47
    88
-s         strip installed files (using $stripprog).
melunko@47
    89
-t=TRANSFORM
melunko@47
    90
--help     display this help and exit.
melunko@47
    91
--version  display version info and exit.
melunko@47
    92
melunko@47
    93
Environment variables override the default commands:
melunko@47
    94
  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
melunko@47
    95
"
melunko@47
    96
melunko@47
    97
while test -n "$1"; do
melunko@47
    98
  case $1 in
melunko@47
    99
    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
melunko@47
   100
        shift
melunko@47
   101
        continue;;
melunko@47
   102
melunko@47
   103
    -c) instcmd=$cpprog
melunko@47
   104
        shift
melunko@47
   105
        continue;;
melunko@47
   106
melunko@47
   107
    -d) dir_arg=true
melunko@47
   108
        shift
melunko@47
   109
        continue;;
melunko@47
   110
melunko@47
   111
    -g) chgrpcmd="$chgrpprog $2"
melunko@47
   112
        shift
melunko@47
   113
        shift
melunko@47
   114
        continue;;
melunko@47
   115
melunko@47
   116
    --help) echo "$usage"; exit 0;;
melunko@47
   117
melunko@47
   118
    -m) chmodcmd="$chmodprog $2"
melunko@47
   119
        shift
melunko@47
   120
        shift
melunko@47
   121
        continue;;
melunko@47
   122
melunko@47
   123
    -o) chowncmd="$chownprog $2"
melunko@47
   124
        shift
melunko@47
   125
        shift
melunko@47
   126
        continue;;
melunko@47
   127
melunko@47
   128
    -s) stripcmd=$stripprog
melunko@47
   129
        shift
melunko@47
   130
        continue;;
melunko@47
   131
melunko@47
   132
    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
melunko@47
   133
        shift
melunko@47
   134
        continue;;
melunko@47
   135
melunko@47
   136
    --version) echo "$0 $scriptversion"; exit 0;;
melunko@47
   137
melunko@47
   138
    *)  # When -d is used, all remaining arguments are directories to create.
melunko@47
   139
	test -n "$dir_arg" && break
melunko@47
   140
        # Otherwise, the last argument is the destination.  Remove it from $@.
melunko@47
   141
	for arg
melunko@47
   142
	do
melunko@47
   143
          if test -n "$dstarg"; then
melunko@47
   144
	    # $@ is not empty: it contains at least $arg.
melunko@47
   145
	    set fnord "$@" "$dstarg"
melunko@47
   146
	    shift # fnord
melunko@47
   147
	  fi
melunko@47
   148
	  shift # arg
melunko@47
   149
	  dstarg=$arg
melunko@47
   150
	done
melunko@47
   151
	break;;
melunko@47
   152
  esac
melunko@47
   153
done
melunko@47
   154
melunko@47
   155
if test -z "$1"; then
melunko@47
   156
  if test -z "$dir_arg"; then
melunko@47
   157
    echo "$0: no input file specified." >&2
melunko@47
   158
    exit 1
melunko@47
   159
  fi
melunko@47
   160
  # It's OK to call `install-sh -d' without argument.
melunko@47
   161
  # This can happen when creating conditional directories.
melunko@47
   162
  exit 0
melunko@47
   163
fi
melunko@47
   164
melunko@47
   165
for src
melunko@47
   166
do
melunko@47
   167
  # Protect names starting with `-'.
melunko@47
   168
  case $src in
melunko@47
   169
    -*) src=./$src ;;
melunko@47
   170
  esac
melunko@47
   171
melunko@47
   172
  if test -n "$dir_arg"; then
melunko@47
   173
    dst=$src
melunko@47
   174
    src=
melunko@47
   175
melunko@47
   176
    if test -d "$dst"; then
melunko@47
   177
      instcmd=:
melunko@47
   178
      chmodcmd=
melunko@47
   179
    else
melunko@47
   180
      instcmd=$mkdirprog
melunko@47
   181
    fi
melunko@47
   182
  else
melunko@47
   183
    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
melunko@47
   184
    # might cause directories to be created, which would be especially bad
melunko@47
   185
    # if $src (and thus $dsttmp) contains '*'.
melunko@47
   186
    if test ! -f "$src" && test ! -d "$src"; then
melunko@47
   187
      echo "$0: $src does not exist." >&2
melunko@47
   188
      exit 1
melunko@47
   189
    fi
melunko@47
   190
melunko@47
   191
    if test -z "$dstarg"; then
melunko@47
   192
      echo "$0: no destination specified." >&2
melunko@47
   193
      exit 1
melunko@47
   194
    fi
melunko@47
   195
melunko@47
   196
    dst=$dstarg
melunko@47
   197
    # Protect names starting with `-'.
melunko@47
   198
    case $dst in
melunko@47
   199
      -*) dst=./$dst ;;
melunko@47
   200
    esac
melunko@47
   201
melunko@47
   202
    # If destination is a directory, append the input filename; won't work
melunko@47
   203
    # if double slashes aren't ignored.
melunko@47
   204
    if test -d "$dst"; then
melunko@47
   205
      dst=$dst/`basename "$src"`
melunko@47
   206
    fi
melunko@47
   207
  fi
melunko@47
   208
melunko@47
   209
  # This sed command emulates the dirname command.
melunko@47
   210
  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
melunko@47
   211
melunko@47
   212
  # Make sure that the destination directory exists.
melunko@47
   213
melunko@47
   214
  # Skip lots of stat calls in the usual case.
melunko@47
   215
  if test ! -d "$dstdir"; then
melunko@47
   216
    defaultIFS='
melunko@47
   217
	 '
melunko@47
   218
    IFS="${IFS-$defaultIFS}"
melunko@47
   219
melunko@47
   220
    oIFS=$IFS
melunko@47
   221
    # Some sh's can't handle IFS=/ for some reason.
melunko@47
   222
    IFS='%'
melunko@47
   223
    set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
melunko@47
   224
    IFS=$oIFS
melunko@47
   225
melunko@47
   226
    pathcomp=
melunko@47
   227
melunko@47
   228
    while test $# -ne 0 ; do
melunko@47
   229
      pathcomp=$pathcomp$1
melunko@47
   230
      shift
melunko@47
   231
      if test ! -d "$pathcomp"; then
melunko@47
   232
        $mkdirprog "$pathcomp" || lasterr=$?
melunko@47
   233
	# mkdir can fail with a `File exist' error in case several
melunko@47
   234
	# install-sh are creating the directory concurrently.  This
melunko@47
   235
	# is OK.
melunko@47
   236
	test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
melunko@47
   237
      fi
melunko@47
   238
      pathcomp=$pathcomp/
melunko@47
   239
    done
melunko@47
   240
  fi
melunko@47
   241
melunko@47
   242
  if test -n "$dir_arg"; then
melunko@47
   243
    $doit $instcmd "$dst" \
melunko@47
   244
      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
melunko@47
   245
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
melunko@47
   246
      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
melunko@47
   247
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
melunko@47
   248
melunko@47
   249
  else
melunko@47
   250
    # If we're going to rename the final executable, determine the name now.
melunko@47
   251
    if test -z "$transformarg"; then
melunko@47
   252
      dstfile=`basename "$dst"`
melunko@47
   253
    else
melunko@47
   254
      dstfile=`basename "$dst" $transformbasename \
melunko@47
   255
               | sed $transformarg`$transformbasename
melunko@47
   256
    fi
melunko@47
   257
melunko@47
   258
    # don't allow the sed command to completely eliminate the filename.
melunko@47
   259
    test -z "$dstfile" && dstfile=`basename "$dst"`
melunko@47
   260
melunko@47
   261
    # Make a couple of temp file names in the proper directory.
melunko@47
   262
    dsttmp=$dstdir/_inst.$$_
melunko@47
   263
    rmtmp=$dstdir/_rm.$$_
melunko@47
   264
melunko@47
   265
    # Trap to clean up those temp files at exit.
melunko@47
   266
    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
melunko@47
   267
    trap '(exit $?); exit' 1 2 13 15
melunko@47
   268
melunko@47
   269
    # Move or copy the file name to the temp name
melunko@47
   270
    $doit $instcmd "$src" "$dsttmp" &&
melunko@47
   271
melunko@47
   272
    # and set any options; do chmod last to preserve setuid bits.
melunko@47
   273
    #
melunko@47
   274
    # If any of these fail, we abort the whole thing.  If we want to
melunko@47
   275
    # ignore errors from any of these, just make sure not to ignore
melunko@47
   276
    # errors from the above "$doit $instcmd $src $dsttmp" command.
melunko@47
   277
    #
melunko@47
   278
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
melunko@47
   279
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
melunko@47
   280
      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
melunko@47
   281
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
melunko@47
   282
melunko@47
   283
    # Now rename the file to the real destination.
melunko@47
   284
    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
melunko@47
   285
      || {
melunko@47
   286
	   # The rename failed, perhaps because mv can't rename something else
melunko@47
   287
	   # to itself, or perhaps because mv is so ancient that it does not
melunko@47
   288
	   # support -f.
melunko@47
   289
melunko@47
   290
	   # Now remove or move aside any old file at destination location.
melunko@47
   291
	   # We try this two ways since rm can't unlink itself on some
melunko@47
   292
	   # systems and the destination file might be busy for other
melunko@47
   293
	   # reasons.  In this case, the final cleanup might fail but the new
melunko@47
   294
	   # file should still install successfully.
melunko@47
   295
	   {
melunko@47
   296
	     if test -f "$dstdir/$dstfile"; then
melunko@47
   297
	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
melunko@47
   298
	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
melunko@47
   299
	       || {
melunko@47
   300
		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
melunko@47
   301
		 (exit 1); exit
melunko@47
   302
	       }
melunko@47
   303
	     else
melunko@47
   304
	       :
melunko@47
   305
	     fi
melunko@47
   306
	   } &&
melunko@47
   307
melunko@47
   308
	   # Now rename the file to the real destination.
melunko@47
   309
	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
melunko@47
   310
	 }
melunko@47
   311
    }
melunko@47
   312
  fi || { (exit 1); exit; }
melunko@47
   313
done
melunko@47
   314
melunko@47
   315
# The final little trick to "correctly" pass the exit status to the exit trap.
melunko@47
   316
{
melunko@47
   317
  (exit 0); exit
melunko@47
   318
}
melunko@47
   319
melunko@47
   320
# Local variables:
melunko@47
   321
# eval: (add-hook 'write-file-hooks 'time-stamp)
melunko@47
   322
# time-stamp-start: "scriptversion="
melunko@47
   323
# time-stamp-format: "%:y-%02m-%02d.%02H"
melunko@47
   324
# time-stamp-end: "$"
melunko@47
   325
# End: