toolkit/crashreporter/google-breakpad/autotools/install-sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/crashreporter/google-breakpad/autotools/install-sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,507 @@
     1.4 +#!/bin/sh
     1.5 +# install - install a program, script, or datafile
     1.6 +
     1.7 +scriptversion=2006-10-14.15
     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.
    1.46 +
    1.47 +nl='
    1.48 +'
    1.49 +IFS=" ""	$nl"
    1.50 +
    1.51 +# set DOITPROG to echo to test this script
    1.52 +
    1.53 +# Don't use :- since 4.3BSD and earlier shells don't like it.
    1.54 +doit="${DOITPROG-}"
    1.55 +if test -z "$doit"; then
    1.56 +  doit_exec=exec
    1.57 +else
    1.58 +  doit_exec=$doit
    1.59 +fi
    1.60 +
    1.61 +# Put in absolute file names if you don't have them in your path;
    1.62 +# or use environment vars.
    1.63 +
    1.64 +mvprog="${MVPROG-mv}"
    1.65 +cpprog="${CPPROG-cp}"
    1.66 +chmodprog="${CHMODPROG-chmod}"
    1.67 +chownprog="${CHOWNPROG-chown}"
    1.68 +chgrpprog="${CHGRPPROG-chgrp}"
    1.69 +stripprog="${STRIPPROG-strip}"
    1.70 +rmprog="${RMPROG-rm}"
    1.71 +mkdirprog="${MKDIRPROG-mkdir}"
    1.72 +
    1.73 +posix_glob=
    1.74 +posix_mkdir=
    1.75 +
    1.76 +# Desired mode of installed file.
    1.77 +mode=0755
    1.78 +
    1.79 +chmodcmd=$chmodprog
    1.80 +chowncmd=
    1.81 +chgrpcmd=
    1.82 +stripcmd=
    1.83 +rmcmd="$rmprog -f"
    1.84 +mvcmd="$mvprog"
    1.85 +src=
    1.86 +dst=
    1.87 +dir_arg=
    1.88 +dstarg=
    1.89 +no_target_directory=
    1.90 +
    1.91 +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
    1.92 +   or: $0 [OPTION]... SRCFILES... DIRECTORY
    1.93 +   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
    1.94 +   or: $0 [OPTION]... -d DIRECTORIES...
    1.95 +
    1.96 +In the 1st form, copy SRCFILE to DSTFILE.
    1.97 +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
    1.98 +In the 4th, create DIRECTORIES.
    1.99 +
   1.100 +Options:
   1.101 +-c         (ignored)
   1.102 +-d         create directories instead of installing files.
   1.103 +-g GROUP   $chgrpprog installed files to GROUP.
   1.104 +-m MODE    $chmodprog installed files to MODE.
   1.105 +-o USER    $chownprog installed files to USER.
   1.106 +-s         $stripprog installed files.
   1.107 +-t DIRECTORY  install into DIRECTORY.
   1.108 +-T         report an error if DSTFILE is a directory.
   1.109 +--help     display this help and exit.
   1.110 +--version  display version info and exit.
   1.111 +
   1.112 +Environment variables override the default commands:
   1.113 +  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
   1.114 +"
   1.115 +
   1.116 +while test $# -ne 0; do
   1.117 +  case $1 in
   1.118 +    -c) shift
   1.119 +        continue;;
   1.120 +
   1.121 +    -d) dir_arg=true
   1.122 +        shift
   1.123 +        continue;;
   1.124 +
   1.125 +    -g) chgrpcmd="$chgrpprog $2"
   1.126 +        shift
   1.127 +        shift
   1.128 +        continue;;
   1.129 +
   1.130 +    --help) echo "$usage"; exit $?;;
   1.131 +
   1.132 +    -m) mode=$2
   1.133 +        shift
   1.134 +        shift
   1.135 +	case $mode in
   1.136 +	  *' '* | *'	'* | *'
   1.137 +'*	  | *'*'* | *'?'* | *'['*)
   1.138 +	    echo "$0: invalid mode: $mode" >&2
   1.139 +	    exit 1;;
   1.140 +	esac
   1.141 +        continue;;
   1.142 +
   1.143 +    -o) chowncmd="$chownprog $2"
   1.144 +        shift
   1.145 +        shift
   1.146 +        continue;;
   1.147 +
   1.148 +    -s) stripcmd=$stripprog
   1.149 +        shift
   1.150 +        continue;;
   1.151 +
   1.152 +    -t) dstarg=$2
   1.153 +	shift
   1.154 +	shift
   1.155 +	continue;;
   1.156 +
   1.157 +    -T) no_target_directory=true
   1.158 +	shift
   1.159 +	continue;;
   1.160 +
   1.161 +    --version) echo "$0 $scriptversion"; exit $?;;
   1.162 +
   1.163 +    --)	shift
   1.164 +	break;;
   1.165 +
   1.166 +    -*)	echo "$0: invalid option: $1" >&2
   1.167 +	exit 1;;
   1.168 +
   1.169 +    *)  break;;
   1.170 +  esac
   1.171 +done
   1.172 +
   1.173 +if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
   1.174 +  # When -d is used, all remaining arguments are directories to create.
   1.175 +  # When -t is used, the destination is already specified.
   1.176 +  # Otherwise, the last argument is the destination.  Remove it from $@.
   1.177 +  for arg
   1.178 +  do
   1.179 +    if test -n "$dstarg"; then
   1.180 +      # $@ is not empty: it contains at least $arg.
   1.181 +      set fnord "$@" "$dstarg"
   1.182 +      shift # fnord
   1.183 +    fi
   1.184 +    shift # arg
   1.185 +    dstarg=$arg
   1.186 +  done
   1.187 +fi
   1.188 +
   1.189 +if test $# -eq 0; then
   1.190 +  if test -z "$dir_arg"; then
   1.191 +    echo "$0: no input file specified." >&2
   1.192 +    exit 1
   1.193 +  fi
   1.194 +  # It's OK to call `install-sh -d' without argument.
   1.195 +  # This can happen when creating conditional directories.
   1.196 +  exit 0
   1.197 +fi
   1.198 +
   1.199 +if test -z "$dir_arg"; then
   1.200 +  trap '(exit $?); exit' 1 2 13 15
   1.201 +
   1.202 +  # Set umask so as not to create temps with too-generous modes.
   1.203 +  # However, 'strip' requires both read and write access to temps.
   1.204 +  case $mode in
   1.205 +    # Optimize common cases.
   1.206 +    *644) cp_umask=133;;
   1.207 +    *755) cp_umask=22;;
   1.208 +
   1.209 +    *[0-7])
   1.210 +      if test -z "$stripcmd"; then
   1.211 +	u_plus_rw=
   1.212 +      else
   1.213 +	u_plus_rw='% 200'
   1.214 +      fi
   1.215 +      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
   1.216 +    *)
   1.217 +      if test -z "$stripcmd"; then
   1.218 +	u_plus_rw=
   1.219 +      else
   1.220 +	u_plus_rw=,u+rw
   1.221 +      fi
   1.222 +      cp_umask=$mode$u_plus_rw;;
   1.223 +  esac
   1.224 +fi
   1.225 +
   1.226 +for src
   1.227 +do
   1.228 +  # Protect names starting with `-'.
   1.229 +  case $src in
   1.230 +    -*) src=./$src ;;
   1.231 +  esac
   1.232 +
   1.233 +  if test -n "$dir_arg"; then
   1.234 +    dst=$src
   1.235 +    dstdir=$dst
   1.236 +    test -d "$dstdir"
   1.237 +    dstdir_status=$?
   1.238 +  else
   1.239 +
   1.240 +    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
   1.241 +    # might cause directories to be created, which would be especially bad
   1.242 +    # if $src (and thus $dsttmp) contains '*'.
   1.243 +    if test ! -f "$src" && test ! -d "$src"; then
   1.244 +      echo "$0: $src does not exist." >&2
   1.245 +      exit 1
   1.246 +    fi
   1.247 +
   1.248 +    if test -z "$dstarg"; then
   1.249 +      echo "$0: no destination specified." >&2
   1.250 +      exit 1
   1.251 +    fi
   1.252 +
   1.253 +    dst=$dstarg
   1.254 +    # Protect names starting with `-'.
   1.255 +    case $dst in
   1.256 +      -*) dst=./$dst ;;
   1.257 +    esac
   1.258 +
   1.259 +    # If destination is a directory, append the input filename; won't work
   1.260 +    # if double slashes aren't ignored.
   1.261 +    if test -d "$dst"; then
   1.262 +      if test -n "$no_target_directory"; then
   1.263 +	echo "$0: $dstarg: Is a directory" >&2
   1.264 +	exit 1
   1.265 +      fi
   1.266 +      dstdir=$dst
   1.267 +      dst=$dstdir/`basename "$src"`
   1.268 +      dstdir_status=0
   1.269 +    else
   1.270 +      # Prefer dirname, but fall back on a substitute if dirname fails.
   1.271 +      dstdir=`
   1.272 +	(dirname "$dst") 2>/dev/null ||
   1.273 +	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   1.274 +	     X"$dst" : 'X\(//\)[^/]' \| \
   1.275 +	     X"$dst" : 'X\(//\)$' \| \
   1.276 +	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
   1.277 +	echo X"$dst" |
   1.278 +	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
   1.279 +		   s//\1/
   1.280 +		   q
   1.281 +		 }
   1.282 +		 /^X\(\/\/\)[^/].*/{
   1.283 +		   s//\1/
   1.284 +		   q
   1.285 +		 }
   1.286 +		 /^X\(\/\/\)$/{
   1.287 +		   s//\1/
   1.288 +		   q
   1.289 +		 }
   1.290 +		 /^X\(\/\).*/{
   1.291 +		   s//\1/
   1.292 +		   q
   1.293 +		 }
   1.294 +		 s/.*/./; q'
   1.295 +      `
   1.296 +
   1.297 +      test -d "$dstdir"
   1.298 +      dstdir_status=$?
   1.299 +    fi
   1.300 +  fi
   1.301 +
   1.302 +  obsolete_mkdir_used=false
   1.303 +
   1.304 +  if test $dstdir_status != 0; then
   1.305 +    case $posix_mkdir in
   1.306 +      '')
   1.307 +	# Create intermediate dirs using mode 755 as modified by the umask.
   1.308 +	# This is like FreeBSD 'install' as of 1997-10-28.
   1.309 +	umask=`umask`
   1.310 +	case $stripcmd.$umask in
   1.311 +	  # Optimize common cases.
   1.312 +	  *[2367][2367]) mkdir_umask=$umask;;
   1.313 +	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
   1.314 +
   1.315 +	  *[0-7])
   1.316 +	    mkdir_umask=`expr $umask + 22 \
   1.317 +	      - $umask % 100 % 40 + $umask % 20 \
   1.318 +	      - $umask % 10 % 4 + $umask % 2
   1.319 +	    `;;
   1.320 +	  *) mkdir_umask=$umask,go-w;;
   1.321 +	esac
   1.322 +
   1.323 +	# With -d, create the new directory with the user-specified mode.
   1.324 +	# Otherwise, rely on $mkdir_umask.
   1.325 +	if test -n "$dir_arg"; then
   1.326 +	  mkdir_mode=-m$mode
   1.327 +	else
   1.328 +	  mkdir_mode=
   1.329 +	fi
   1.330 +
   1.331 +	posix_mkdir=false
   1.332 +	case $umask in
   1.333 +	  *[123567][0-7][0-7])
   1.334 +	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
   1.335 +	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
   1.336 +	    ;;
   1.337 +	  *)
   1.338 +	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
   1.339 +	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
   1.340 +
   1.341 +	    if (umask $mkdir_umask &&
   1.342 +		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
   1.343 +	    then
   1.344 +	      if test -z "$dir_arg" || {
   1.345 +		   # Check for POSIX incompatibilities with -m.
   1.346 +		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
   1.347 +		   # other-writeable bit of parent directory when it shouldn't.
   1.348 +		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
   1.349 +		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
   1.350 +		   case $ls_ld_tmpdir in
   1.351 +		     d????-?r-*) different_mode=700;;
   1.352 +		     d????-?--*) different_mode=755;;
   1.353 +		     *) false;;
   1.354 +		   esac &&
   1.355 +		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
   1.356 +		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
   1.357 +		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
   1.358 +		   }
   1.359 +		 }
   1.360 +	      then posix_mkdir=:
   1.361 +	      fi
   1.362 +	      rmdir "$tmpdir/d" "$tmpdir"
   1.363 +	    else
   1.364 +	      # Remove any dirs left behind by ancient mkdir implementations.
   1.365 +	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
   1.366 +	    fi
   1.367 +	    trap '' 0;;
   1.368 +	esac;;
   1.369 +    esac
   1.370 +
   1.371 +    if
   1.372 +      $posix_mkdir && (
   1.373 +	umask $mkdir_umask &&
   1.374 +	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
   1.375 +      )
   1.376 +    then :
   1.377 +    else
   1.378 +
   1.379 +      # The umask is ridiculous, or mkdir does not conform to POSIX,
   1.380 +      # or it failed possibly due to a race condition.  Create the
   1.381 +      # directory the slow way, step by step, checking for races as we go.
   1.382 +
   1.383 +      case $dstdir in
   1.384 +	/*) prefix=/ ;;
   1.385 +	-*) prefix=./ ;;
   1.386 +	*)  prefix= ;;
   1.387 +      esac
   1.388 +
   1.389 +      case $posix_glob in
   1.390 +        '')
   1.391 +	  if (set -f) 2>/dev/null; then
   1.392 +	    posix_glob=true
   1.393 +	  else
   1.394 +	    posix_glob=false
   1.395 +	  fi ;;
   1.396 +      esac
   1.397 +
   1.398 +      oIFS=$IFS
   1.399 +      IFS=/
   1.400 +      $posix_glob && set -f
   1.401 +      set fnord $dstdir
   1.402 +      shift
   1.403 +      $posix_glob && set +f
   1.404 +      IFS=$oIFS
   1.405 +
   1.406 +      prefixes=
   1.407 +
   1.408 +      for d
   1.409 +      do
   1.410 +	test -z "$d" && continue
   1.411 +
   1.412 +	prefix=$prefix$d
   1.413 +	if test -d "$prefix"; then
   1.414 +	  prefixes=
   1.415 +	else
   1.416 +	  if $posix_mkdir; then
   1.417 +	    (umask=$mkdir_umask &&
   1.418 +	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
   1.419 +	    # Don't fail if two instances are running concurrently.
   1.420 +	    test -d "$prefix" || exit 1
   1.421 +	  else
   1.422 +	    case $prefix in
   1.423 +	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
   1.424 +	      *) qprefix=$prefix;;
   1.425 +	    esac
   1.426 +	    prefixes="$prefixes '$qprefix'"
   1.427 +	  fi
   1.428 +	fi
   1.429 +	prefix=$prefix/
   1.430 +      done
   1.431 +
   1.432 +      if test -n "$prefixes"; then
   1.433 +	# Don't fail if two instances are running concurrently.
   1.434 +	(umask $mkdir_umask &&
   1.435 +	 eval "\$doit_exec \$mkdirprog $prefixes") ||
   1.436 +	  test -d "$dstdir" || exit 1
   1.437 +	obsolete_mkdir_used=true
   1.438 +      fi
   1.439 +    fi
   1.440 +  fi
   1.441 +
   1.442 +  if test -n "$dir_arg"; then
   1.443 +    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
   1.444 +    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
   1.445 +    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
   1.446 +      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
   1.447 +  else
   1.448 +
   1.449 +    # Make a couple of temp file names in the proper directory.
   1.450 +    dsttmp=$dstdir/_inst.$$_
   1.451 +    rmtmp=$dstdir/_rm.$$_
   1.452 +
   1.453 +    # Trap to clean up those temp files at exit.
   1.454 +    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
   1.455 +
   1.456 +    # Copy the file name to the temp name.
   1.457 +    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
   1.458 +
   1.459 +    # and set any options; do chmod last to preserve setuid bits.
   1.460 +    #
   1.461 +    # If any of these fail, we abort the whole thing.  If we want to
   1.462 +    # ignore errors from any of these, just make sure not to ignore
   1.463 +    # errors from the above "$doit $cpprog $src $dsttmp" command.
   1.464 +    #
   1.465 +    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
   1.466 +      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
   1.467 +      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
   1.468 +      && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
   1.469 +
   1.470 +    # Now rename the file to the real destination.
   1.471 +    { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
   1.472 +      || {
   1.473 +	   # The rename failed, perhaps because mv can't rename something else
   1.474 +	   # to itself, or perhaps because mv is so ancient that it does not
   1.475 +	   # support -f.
   1.476 +
   1.477 +	   # Now remove or move aside any old file at destination location.
   1.478 +	   # We try this two ways since rm can't unlink itself on some
   1.479 +	   # systems and the destination file might be busy for other
   1.480 +	   # reasons.  In this case, the final cleanup might fail but the new
   1.481 +	   # file should still install successfully.
   1.482 +	   {
   1.483 +	     if test -f "$dst"; then
   1.484 +	       $doit $rmcmd -f "$dst" 2>/dev/null \
   1.485 +	       || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
   1.486 +		     && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
   1.487 +	       || {
   1.488 +		 echo "$0: cannot unlink or rename $dst" >&2
   1.489 +		 (exit 1); exit 1
   1.490 +	       }
   1.491 +	     else
   1.492 +	       :
   1.493 +	     fi
   1.494 +	   } &&
   1.495 +
   1.496 +	   # Now rename the file to the real destination.
   1.497 +	   $doit $mvcmd "$dsttmp" "$dst"
   1.498 +	 }
   1.499 +    } || exit 1
   1.500 +
   1.501 +    trap '' 0
   1.502 +  fi
   1.503 +done
   1.504 +
   1.505 +# Local variables:
   1.506 +# eval: (add-hook 'write-file-hooks 'time-stamp)
   1.507 +# time-stamp-start: "scriptversion="
   1.508 +# time-stamp-format: "%:y-%02m-%02d.%02H"
   1.509 +# time-stamp-end: "$"
   1.510 +# End:

mercurial