use less ancient versions of autofoo scripts
authorOzkan Sezer <sezeroz@gmail.com>
Thu, 18 Oct 2018 11:58:00 +0300
changeset 123362f4ebd8f5693
parent 12334 0789a425e8d7
child 12338 a02aa66a76d8
use less ancient versions of autofoo scripts
build-scripts/install-sh
build-scripts/mkinstalldirs
     1.1 --- a/build-scripts/install-sh	Tue Oct 16 15:00:43 2018 -0700
     1.2 +++ b/build-scripts/install-sh	Thu Oct 18 11:58:00 2018 +0300
     1.3 @@ -1,7 +1,7 @@
     1.4  #!/bin/sh
     1.5  # install - install a program, script, or datafile
     1.6  
     1.7 -scriptversion=2005-02-02.21
     1.8 +scriptversion=2011-11-20.07; # UTC
     1.9  
    1.10  # This originates from X11R5 (mit/util/scripts/install.sh), which was
    1.11  # later released in X11R6 (xc/config/util/install.sh) with the
    1.12 @@ -35,42 +35,72 @@
    1.13  # FSF changes to this file are in the public domain.
    1.14  #
    1.15  # Calling this script install-sh is preferred over install.sh, to prevent
    1.16 -# `make' implicit rules from creating a file called install from it
    1.17 +# 'make' implicit rules from creating a file called install from it
    1.18  # when there is no Makefile.
    1.19  #
    1.20  # This script is compatible with the BSD install script, but was written
    1.21 -# from scratch.  It can only install one file at a time, a restriction
    1.22 -# shared with many OS's install programs.
    1.23 +# from scratch.
    1.24 +
    1.25 +nl='
    1.26 +'
    1.27 +IFS=" ""	$nl"
    1.28  
    1.29  # set DOITPROG to echo to test this script
    1.30  
    1.31  # Don't use :- since 4.3BSD and earlier shells don't like it.
    1.32 -doit="${DOITPROG-}"
    1.33 +doit=${DOITPROG-}
    1.34 +if test -z "$doit"; then
    1.35 +  doit_exec=exec
    1.36 +else
    1.37 +  doit_exec=$doit
    1.38 +fi
    1.39  
    1.40 -# put in absolute paths if you don't have them in your path; or use env. vars.
    1.41 +# Put in absolute file names if you don't have them in your path;
    1.42 +# or use environment vars.
    1.43  
    1.44 -mvprog="${MVPROG-mv}"
    1.45 -cpprog="${CPPROG-cp}"
    1.46 -chmodprog="${CHMODPROG-chmod}"
    1.47 -chownprog="${CHOWNPROG-chown}"
    1.48 -chgrpprog="${CHGRPPROG-chgrp}"
    1.49 -stripprog="${STRIPPROG-strip}"
    1.50 -rmprog="${RMPROG-rm}"
    1.51 -mkdirprog="${MKDIRPROG-mkdir}"
    1.52 +chgrpprog=${CHGRPPROG-chgrp}
    1.53 +chmodprog=${CHMODPROG-chmod}
    1.54 +chownprog=${CHOWNPROG-chown}
    1.55 +cmpprog=${CMPPROG-cmp}
    1.56 +cpprog=${CPPROG-cp}
    1.57 +mkdirprog=${MKDIRPROG-mkdir}
    1.58 +mvprog=${MVPROG-mv}
    1.59 +rmprog=${RMPROG-rm}
    1.60 +stripprog=${STRIPPROG-strip}
    1.61  
    1.62 -chmodcmd="$chmodprog 0755"
    1.63 +posix_glob='?'
    1.64 +initialize_posix_glob='
    1.65 +  test "$posix_glob" != "?" || {
    1.66 +    if (set -f) 2>/dev/null; then
    1.67 +      posix_glob=
    1.68 +    else
    1.69 +      posix_glob=:
    1.70 +    fi
    1.71 +  }
    1.72 +'
    1.73 +
    1.74 +posix_mkdir=
    1.75 +
    1.76 +# Desired mode of installed file.
    1.77 +mode=0755
    1.78 +
    1.79 +chgrpcmd=
    1.80 +chmodcmd=$chmodprog
    1.81  chowncmd=
    1.82 -chgrpcmd=
    1.83 +mvcmd=$mvprog
    1.84 +rmcmd="$rmprog -f"
    1.85  stripcmd=
    1.86 -rmcmd="$rmprog -f"
    1.87 -mvcmd="$mvprog"
    1.88 +
    1.89  src=
    1.90  dst=
    1.91  dir_arg=
    1.92 -dstarg=
    1.93 +dst_arg=
    1.94 +
    1.95 +copy_on_change=false
    1.96  no_target_directory=
    1.97  
    1.98 -usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
    1.99 +usage="\
   1.100 +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
   1.101     or: $0 [OPTION]... SRCFILES... DIRECTORY
   1.102     or: $0 [OPTION]... -t DIRECTORY SRCFILES...
   1.103     or: $0 [OPTION]... -d DIRECTORIES...
   1.104 @@ -80,108 +110,148 @@
   1.105  In the 4th, create DIRECTORIES.
   1.106  
   1.107  Options:
   1.108 --c         (ignored)
   1.109 --d         create directories instead of installing files.
   1.110 --g GROUP   $chgrpprog installed files to GROUP.
   1.111 --m MODE    $chmodprog installed files to MODE.
   1.112 --o USER    $chownprog installed files to USER.
   1.113 --s         $stripprog installed files.
   1.114 --t DIRECTORY  install into DIRECTORY.
   1.115 --T         report an error if DSTFILE is a directory.
   1.116 ---help     display this help and exit.
   1.117 ---version  display version info and exit.
   1.118 +     --help     display this help and exit.
   1.119 +     --version  display version info and exit.
   1.120 +
   1.121 +  -c            (ignored)
   1.122 +  -C            install only if different (preserve the last data modification time)
   1.123 +  -d            create directories instead of installing files.
   1.124 +  -g GROUP      $chgrpprog installed files to GROUP.
   1.125 +  -m MODE       $chmodprog installed files to MODE.
   1.126 +  -o USER       $chownprog installed files to USER.
   1.127 +  -s            $stripprog installed files.
   1.128 +  -t DIRECTORY  install into DIRECTORY.
   1.129 +  -T            report an error if DSTFILE is a directory.
   1.130  
   1.131  Environment variables override the default commands:
   1.132 -  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
   1.133 +  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
   1.134 +  RMPROG STRIPPROG
   1.135  "
   1.136  
   1.137 -while test -n "$1"; do
   1.138 +while test $# -ne 0; do
   1.139    case $1 in
   1.140 -    -c) shift
   1.141 -        continue;;
   1.142 +    -c) ;;
   1.143  
   1.144 -    -d) dir_arg=true
   1.145 -        shift
   1.146 -        continue;;
   1.147 +    -C) copy_on_change=true;;
   1.148 +
   1.149 +    -d) dir_arg=true;;
   1.150  
   1.151      -g) chgrpcmd="$chgrpprog $2"
   1.152 -        shift
   1.153 -        shift
   1.154 -        continue;;
   1.155 +	shift;;
   1.156  
   1.157      --help) echo "$usage"; exit $?;;
   1.158  
   1.159 -    -m) chmodcmd="$chmodprog $2"
   1.160 -        shift
   1.161 -        shift
   1.162 -        continue;;
   1.163 +    -m) mode=$2
   1.164 +	case $mode in
   1.165 +	  *' '* | *'	'* | *'
   1.166 +'*	  | *'*'* | *'?'* | *'['*)
   1.167 +	    echo "$0: invalid mode: $mode" >&2
   1.168 +	    exit 1;;
   1.169 +	esac
   1.170 +	shift;;
   1.171  
   1.172      -o) chowncmd="$chownprog $2"
   1.173 -        shift
   1.174 -        shift
   1.175 -        continue;;
   1.176 +	shift;;
   1.177  
   1.178 -    -s) stripcmd=$stripprog
   1.179 -        shift
   1.180 -        continue;;
   1.181 +    -s) stripcmd=$stripprog;;
   1.182  
   1.183 -    -t) dstarg=$2
   1.184 -	shift
   1.185 -	shift
   1.186 -	continue;;
   1.187 +    -t) dst_arg=$2
   1.188 +	# Protect names problematic for 'test' and other utilities.
   1.189 +	case $dst_arg in
   1.190 +	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
   1.191 +	esac
   1.192 +	shift;;
   1.193  
   1.194 -    -T) no_target_directory=true
   1.195 -	shift
   1.196 -	continue;;
   1.197 +    -T) no_target_directory=true;;
   1.198  
   1.199      --version) echo "$0 $scriptversion"; exit $?;;
   1.200  
   1.201 -    *)  # When -d is used, all remaining arguments are directories to create.
   1.202 -	# When -t is used, the destination is already specified.
   1.203 -	test -n "$dir_arg$dstarg" && break
   1.204 -        # Otherwise, the last argument is the destination.  Remove it from $@.
   1.205 -	for arg
   1.206 -	do
   1.207 -          if test -n "$dstarg"; then
   1.208 -	    # $@ is not empty: it contains at least $arg.
   1.209 -	    set fnord "$@" "$dstarg"
   1.210 -	    shift # fnord
   1.211 -	  fi
   1.212 -	  shift # arg
   1.213 -	  dstarg=$arg
   1.214 -	done
   1.215 +    --)	shift
   1.216  	break;;
   1.217 +
   1.218 +    -*)	echo "$0: invalid option: $1" >&2
   1.219 +	exit 1;;
   1.220 +
   1.221 +    *)  break;;
   1.222    esac
   1.223 +  shift
   1.224  done
   1.225  
   1.226 -if test -z "$1"; then
   1.227 +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   1.228 +  # When -d is used, all remaining arguments are directories to create.
   1.229 +  # When -t is used, the destination is already specified.
   1.230 +  # Otherwise, the last argument is the destination.  Remove it from $@.
   1.231 +  for arg
   1.232 +  do
   1.233 +    if test -n "$dst_arg"; then
   1.234 +      # $@ is not empty: it contains at least $arg.
   1.235 +      set fnord "$@" "$dst_arg"
   1.236 +      shift # fnord
   1.237 +    fi
   1.238 +    shift # arg
   1.239 +    dst_arg=$arg
   1.240 +    # Protect names problematic for 'test' and other utilities.
   1.241 +    case $dst_arg in
   1.242 +      -* | [=\(\)!]) dst_arg=./$dst_arg;;
   1.243 +    esac
   1.244 +  done
   1.245 +fi
   1.246 +
   1.247 +if test $# -eq 0; then
   1.248    if test -z "$dir_arg"; then
   1.249      echo "$0: no input file specified." >&2
   1.250      exit 1
   1.251    fi
   1.252 -  # It's OK to call `install-sh -d' without argument.
   1.253 +  # It's OK to call 'install-sh -d' without argument.
   1.254    # This can happen when creating conditional directories.
   1.255    exit 0
   1.256  fi
   1.257  
   1.258 +if test -z "$dir_arg"; then
   1.259 +  do_exit='(exit $ret); exit $ret'
   1.260 +  trap "ret=129; $do_exit" 1
   1.261 +  trap "ret=130; $do_exit" 2
   1.262 +  trap "ret=141; $do_exit" 13
   1.263 +  trap "ret=143; $do_exit" 15
   1.264 +
   1.265 +  # Set umask so as not to create temps with too-generous modes.
   1.266 +  # However, 'strip' requires both read and write access to temps.
   1.267 +  case $mode in
   1.268 +    # Optimize common cases.
   1.269 +    *644) cp_umask=133;;
   1.270 +    *755) cp_umask=22;;
   1.271 +
   1.272 +    *[0-7])
   1.273 +      if test -z "$stripcmd"; then
   1.274 +	u_plus_rw=
   1.275 +      else
   1.276 +	u_plus_rw='% 200'
   1.277 +      fi
   1.278 +      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
   1.279 +    *)
   1.280 +      if test -z "$stripcmd"; then
   1.281 +	u_plus_rw=
   1.282 +      else
   1.283 +	u_plus_rw=,u+rw
   1.284 +      fi
   1.285 +      cp_umask=$mode$u_plus_rw;;
   1.286 +  esac
   1.287 +fi
   1.288 +
   1.289  for src
   1.290  do
   1.291 -  # Protect names starting with `-'.
   1.292 +  # Protect names problematic for 'test' and other utilities.
   1.293    case $src in
   1.294 -    -*) src=./$src ;;
   1.295 +    -* | [=\(\)!]) src=./$src;;
   1.296    esac
   1.297  
   1.298    if test -n "$dir_arg"; then
   1.299      dst=$src
   1.300 -    src=
   1.301 +    dstdir=$dst
   1.302 +    test -d "$dstdir"
   1.303 +    dstdir_status=$?
   1.304 +  else
   1.305  
   1.306 -    if test -d "$dst"; then
   1.307 -      mkdircmd=:
   1.308 -      chmodcmd=
   1.309 -    else
   1.310 -      mkdircmd=$mkdirprog
   1.311 -    fi
   1.312 -  else
   1.313      # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
   1.314      # might cause directories to be created, which would be especially bad
   1.315      # if $src (and thus $dsttmp) contains '*'.
   1.316 @@ -190,71 +260,194 @@
   1.317        exit 1
   1.318      fi
   1.319  
   1.320 -    if test -z "$dstarg"; then
   1.321 +    if test -z "$dst_arg"; then
   1.322        echo "$0: no destination specified." >&2
   1.323        exit 1
   1.324      fi
   1.325 -
   1.326 -    dst=$dstarg
   1.327 -    # Protect names starting with `-'.
   1.328 -    case $dst in
   1.329 -      -*) dst=./$dst ;;
   1.330 -    esac
   1.331 +    dst=$dst_arg
   1.332  
   1.333      # If destination is a directory, append the input filename; won't work
   1.334      # if double slashes aren't ignored.
   1.335      if test -d "$dst"; then
   1.336        if test -n "$no_target_directory"; then
   1.337 -	echo "$0: $dstarg: Is a directory" >&2
   1.338 +	echo "$0: $dst_arg: Is a directory" >&2
   1.339  	exit 1
   1.340        fi
   1.341 -      dst=$dst/`basename "$src"`
   1.342 +      dstdir=$dst
   1.343 +      dst=$dstdir/`basename "$src"`
   1.344 +      dstdir_status=0
   1.345 +    else
   1.346 +      # Prefer dirname, but fall back on a substitute if dirname fails.
   1.347 +      dstdir=`
   1.348 +	(dirname "$dst") 2>/dev/null ||
   1.349 +	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
   1.350 +	     X"$dst" : 'X\(//\)[^/]' \| \
   1.351 +	     X"$dst" : 'X\(//\)$' \| \
   1.352 +	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
   1.353 +	echo X"$dst" |
   1.354 +	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
   1.355 +		   s//\1/
   1.356 +		   q
   1.357 +		 }
   1.358 +		 /^X\(\/\/\)[^/].*/{
   1.359 +		   s//\1/
   1.360 +		   q
   1.361 +		 }
   1.362 +		 /^X\(\/\/\)$/{
   1.363 +		   s//\1/
   1.364 +		   q
   1.365 +		 }
   1.366 +		 /^X\(\/\).*/{
   1.367 +		   s//\1/
   1.368 +		   q
   1.369 +		 }
   1.370 +		 s/.*/./; q'
   1.371 +      `
   1.372 +
   1.373 +      test -d "$dstdir"
   1.374 +      dstdir_status=$?
   1.375      fi
   1.376    fi
   1.377  
   1.378 -  # This sed command emulates the dirname command.
   1.379 -  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
   1.380 +  obsolete_mkdir_used=false
   1.381  
   1.382 -  # Make sure that the destination directory exists.
   1.383 +  if test $dstdir_status != 0; then
   1.384 +    case $posix_mkdir in
   1.385 +      '')
   1.386 +	# Create intermediate dirs using mode 755 as modified by the umask.
   1.387 +	# This is like FreeBSD 'install' as of 1997-10-28.
   1.388 +	umask=`umask`
   1.389 +	case $stripcmd.$umask in
   1.390 +	  # Optimize common cases.
   1.391 +	  *[2367][2367]) mkdir_umask=$umask;;
   1.392 +	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
   1.393  
   1.394 -  # Skip lots of stat calls in the usual case.
   1.395 -  if test ! -d "$dstdir"; then
   1.396 -    defaultIFS='
   1.397 -	 '
   1.398 -    IFS="${IFS-$defaultIFS}"
   1.399 +	  *[0-7])
   1.400 +	    mkdir_umask=`expr $umask + 22 \
   1.401 +	      - $umask % 100 % 40 + $umask % 20 \
   1.402 +	      - $umask % 10 % 4 + $umask % 2
   1.403 +	    `;;
   1.404 +	  *) mkdir_umask=$umask,go-w;;
   1.405 +	esac
   1.406  
   1.407 -    oIFS=$IFS
   1.408 -    # Some sh's can't handle IFS=/ for some reason.
   1.409 -    IFS='%'
   1.410 -    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
   1.411 -    shift
   1.412 -    IFS=$oIFS
   1.413 +	# With -d, create the new directory with the user-specified mode.
   1.414 +	# Otherwise, rely on $mkdir_umask.
   1.415 +	if test -n "$dir_arg"; then
   1.416 +	  mkdir_mode=-m$mode
   1.417 +	else
   1.418 +	  mkdir_mode=
   1.419 +	fi
   1.420  
   1.421 -    pathcomp=
   1.422 +	posix_mkdir=false
   1.423 +	case $umask in
   1.424 +	  *[123567][0-7][0-7])
   1.425 +	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
   1.426 +	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
   1.427 +	    ;;
   1.428 +	  *)
   1.429 +	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
   1.430 +	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
   1.431  
   1.432 -    while test $# -ne 0 ; do
   1.433 -      pathcomp=$pathcomp$1
   1.434 +	    if (umask $mkdir_umask &&
   1.435 +		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
   1.436 +	    then
   1.437 +	      if test -z "$dir_arg" || {
   1.438 +		   # Check for POSIX incompatibilities with -m.
   1.439 +		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
   1.440 +		   # other-writable bit of parent directory when it shouldn't.
   1.441 +		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
   1.442 +		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
   1.443 +		   case $ls_ld_tmpdir in
   1.444 +		     d????-?r-*) different_mode=700;;
   1.445 +		     d????-?--*) different_mode=755;;
   1.446 +		     *) false;;
   1.447 +		   esac &&
   1.448 +		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
   1.449 +		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
   1.450 +		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
   1.451 +		   }
   1.452 +		 }
   1.453 +	      then posix_mkdir=:
   1.454 +	      fi
   1.455 +	      rmdir "$tmpdir/d" "$tmpdir"
   1.456 +	    else
   1.457 +	      # Remove any dirs left behind by ancient mkdir implementations.
   1.458 +	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
   1.459 +	    fi
   1.460 +	    trap '' 0;;
   1.461 +	esac;;
   1.462 +    esac
   1.463 +
   1.464 +    if
   1.465 +      $posix_mkdir && (
   1.466 +	umask $mkdir_umask &&
   1.467 +	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
   1.468 +      )
   1.469 +    then :
   1.470 +    else
   1.471 +
   1.472 +      # The umask is ridiculous, or mkdir does not conform to POSIX,
   1.473 +      # or it failed possibly due to a race condition.  Create the
   1.474 +      # directory the slow way, step by step, checking for races as we go.
   1.475 +
   1.476 +      case $dstdir in
   1.477 +	/*) prefix='/';;
   1.478 +	[-=\(\)!]*) prefix='./';;
   1.479 +	*)  prefix='';;
   1.480 +      esac
   1.481 +
   1.482 +      eval "$initialize_posix_glob"
   1.483 +
   1.484 +      oIFS=$IFS
   1.485 +      IFS=/
   1.486 +      $posix_glob set -f
   1.487 +      set fnord $dstdir
   1.488        shift
   1.489 -      if test ! -d "$pathcomp"; then
   1.490 -        $mkdirprog "$pathcomp"
   1.491 -	# mkdir can fail with a `File exist' error in case several
   1.492 -	# install-sh are creating the directory concurrently.  This
   1.493 -	# is OK.
   1.494 -	test -d "$pathcomp" || exit
   1.495 +      $posix_glob set +f
   1.496 +      IFS=$oIFS
   1.497 +
   1.498 +      prefixes=
   1.499 +
   1.500 +      for d
   1.501 +      do
   1.502 +	test X"$d" = X && continue
   1.503 +
   1.504 +	prefix=$prefix$d
   1.505 +	if test -d "$prefix"; then
   1.506 +	  prefixes=
   1.507 +	else
   1.508 +	  if $posix_mkdir; then
   1.509 +	    (umask=$mkdir_umask &&
   1.510 +	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
   1.511 +	    # Don't fail if two instances are running concurrently.
   1.512 +	    test -d "$prefix" || exit 1
   1.513 +	  else
   1.514 +	    case $prefix in
   1.515 +	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
   1.516 +	      *) qprefix=$prefix;;
   1.517 +	    esac
   1.518 +	    prefixes="$prefixes '$qprefix'"
   1.519 +	  fi
   1.520 +	fi
   1.521 +	prefix=$prefix/
   1.522 +      done
   1.523 +
   1.524 +      if test -n "$prefixes"; then
   1.525 +	# Don't fail if two instances are running concurrently.
   1.526 +	(umask $mkdir_umask &&
   1.527 +	 eval "\$doit_exec \$mkdirprog $prefixes") ||
   1.528 +	  test -d "$dstdir" || exit 1
   1.529 +	obsolete_mkdir_used=true
   1.530        fi
   1.531 -      pathcomp=$pathcomp/
   1.532 -    done
   1.533 +    fi
   1.534    fi
   1.535  
   1.536    if test -n "$dir_arg"; then
   1.537 -    $doit $mkdircmd "$dst" \
   1.538 -      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
   1.539 -      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
   1.540 -      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
   1.541 -      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
   1.542 -
   1.543 +    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
   1.544 +    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
   1.545 +    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
   1.546 +      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
   1.547    else
   1.548 -    dstfile=`basename "$dst"`
   1.549  
   1.550      # Make a couple of temp file names in the proper directory.
   1.551      dsttmp=$dstdir/_inst.$$_
   1.552 @@ -262,10 +455,9 @@
   1.553  
   1.554      # Trap to clean up those temp files at exit.
   1.555      trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
   1.556 -    trap '(exit $?); exit' 1 2 13 15
   1.557  
   1.558      # Copy the file name to the temp name.
   1.559 -    $doit $cpprog "$src" "$dsttmp" &&
   1.560 +    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
   1.561  
   1.562      # and set any options; do chmod last to preserve setuid bits.
   1.563      #
   1.564 @@ -273,51 +465,63 @@
   1.565      # ignore errors from any of these, just make sure not to ignore
   1.566      # errors from the above "$doit $cpprog $src $dsttmp" command.
   1.567      #
   1.568 -    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
   1.569 -      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
   1.570 -      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
   1.571 -      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
   1.572 +    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
   1.573 +    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
   1.574 +    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
   1.575 +    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
   1.576  
   1.577 -    # Now rename the file to the real destination.
   1.578 -    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
   1.579 -      || {
   1.580 -	   # The rename failed, perhaps because mv can't rename something else
   1.581 -	   # to itself, or perhaps because mv is so ancient that it does not
   1.582 -	   # support -f.
   1.583 +    # If -C, don't bother to copy if it wouldn't change the file.
   1.584 +    if $copy_on_change &&
   1.585 +       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
   1.586 +       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
   1.587  
   1.588 -	   # Now remove or move aside any old file at destination location.
   1.589 -	   # We try this two ways since rm can't unlink itself on some
   1.590 -	   # systems and the destination file might be busy for other
   1.591 -	   # reasons.  In this case, the final cleanup might fail but the new
   1.592 -	   # file should still install successfully.
   1.593 -	   {
   1.594 -	     if test -f "$dstdir/$dstfile"; then
   1.595 -	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
   1.596 -	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
   1.597 -	       || {
   1.598 -		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
   1.599 -		 (exit 1); exit 1
   1.600 -	       }
   1.601 -	     else
   1.602 -	       :
   1.603 -	     fi
   1.604 -	   } &&
   1.605 +       eval "$initialize_posix_glob" &&
   1.606 +       $posix_glob set -f &&
   1.607 +       set X $old && old=:$2:$4:$5:$6 &&
   1.608 +       set X $new && new=:$2:$4:$5:$6 &&
   1.609 +       $posix_glob set +f &&
   1.610  
   1.611 -	   # Now rename the file to the real destination.
   1.612 -	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
   1.613 -	 }
   1.614 -    }
   1.615 -  fi || { (exit 1); exit 1; }
   1.616 +       test "$old" = "$new" &&
   1.617 +       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
   1.618 +    then
   1.619 +      rm -f "$dsttmp"
   1.620 +    else
   1.621 +      # Rename the file to the real destination.
   1.622 +      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
   1.623 +
   1.624 +      # The rename failed, perhaps because mv can't rename something else
   1.625 +      # to itself, or perhaps because mv is so ancient that it does not
   1.626 +      # support -f.
   1.627 +      {
   1.628 +	# Now remove or move aside any old file at destination location.
   1.629 +	# We try this two ways since rm can't unlink itself on some
   1.630 +	# systems and the destination file might be busy for other
   1.631 +	# reasons.  In this case, the final cleanup might fail but the new
   1.632 +	# file should still install successfully.
   1.633 +	{
   1.634 +	  test ! -f "$dst" ||
   1.635 +	  $doit $rmcmd -f "$dst" 2>/dev/null ||
   1.636 +	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
   1.637 +	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
   1.638 +	  } ||
   1.639 +	  { echo "$0: cannot unlink or rename $dst" >&2
   1.640 +	    (exit 1); exit 1
   1.641 +	  }
   1.642 +	} &&
   1.643 +
   1.644 +	# Now rename the file to the real destination.
   1.645 +	$doit $mvcmd "$dsttmp" "$dst"
   1.646 +      }
   1.647 +    fi || exit 1
   1.648 +
   1.649 +    trap '' 0
   1.650 +  fi
   1.651  done
   1.652  
   1.653 -# The final little trick to "correctly" pass the exit status to the exit trap.
   1.654 -{
   1.655 -  (exit 0); exit 0
   1.656 -}
   1.657 -
   1.658  # Local variables:
   1.659  # eval: (add-hook 'write-file-hooks 'time-stamp)
   1.660  # time-stamp-start: "scriptversion="
   1.661  # time-stamp-format: "%:y-%02m-%02d.%02H"
   1.662 -# time-stamp-end: "$"
   1.663 +# time-stamp-time-zone: "UTC"
   1.664 +# time-stamp-end: "; # UTC"
   1.665  # End:
     2.1 --- a/build-scripts/mkinstalldirs	Tue Oct 16 15:00:43 2018 -0700
     2.2 +++ b/build-scripts/mkinstalldirs	Thu Oct 18 11:58:00 2018 +0300
     2.3 @@ -1,29 +1,59 @@
     2.4  #! /bin/sh
     2.5  # mkinstalldirs --- make directory hierarchy
     2.6 -# Author: Noah Friedman <friedman@prep.ai.mit.edu>
     2.7 +
     2.8 +scriptversion=2009-04-28.21; # UTC
     2.9 +
    2.10 +# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
    2.11  # Created: 1993-05-16
    2.12 -# Public domain
    2.13 +# Public domain.
    2.14 +#
    2.15 +# This file is maintained in Automake, please report
    2.16 +# bugs to <bug-automake@gnu.org> or send patches to
    2.17 +# <automake-patches@gnu.org>.
    2.18  
    2.19 +nl='
    2.20 +'
    2.21 +IFS=" ""	$nl"
    2.22  errstatus=0
    2.23 -dirmode=""
    2.24 +dirmode=
    2.25  
    2.26  usage="\
    2.27 -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
    2.28 +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
    2.29 +
    2.30 +Create each directory DIR (with mode MODE, if specified), including all
    2.31 +leading file name components.
    2.32 +
    2.33 +Report bugs to <bug-automake@gnu.org>."
    2.34  
    2.35  # process command line arguments
    2.36  while test $# -gt 0 ; do
    2.37 -   case "${1}" in
    2.38 -     -h | --help | --h* )			# -h for help
    2.39 -	echo "${usage}" 1>&2; exit 0 ;;
    2.40 -     -m )					# -m PERM arg
    2.41 -	shift
    2.42 -	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
    2.43 -	dirmode="${1}"
    2.44 -	shift ;;
    2.45 -     -- ) shift; break ;;			# stop option processing
    2.46 -     -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
    2.47 -     * )  break ;;				# first non-opt arg
    2.48 -   esac
    2.49 +  case $1 in
    2.50 +    -h | --help | --h*)         # -h for help
    2.51 +      echo "$usage"
    2.52 +      exit $?
    2.53 +      ;;
    2.54 +    -m)                         # -m PERM arg
    2.55 +      shift
    2.56 +      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
    2.57 +      dirmode=$1
    2.58 +      shift
    2.59 +      ;;
    2.60 +    --version)
    2.61 +      echo "$0 $scriptversion"
    2.62 +      exit $?
    2.63 +      ;;
    2.64 +    --)                         # stop option processing
    2.65 +      shift
    2.66 +      break
    2.67 +      ;;
    2.68 +    -*)                         # unknown option
    2.69 +      echo "$usage" 1>&2
    2.70 +      exit 1
    2.71 +      ;;
    2.72 +    *)                          # first non-opt arg
    2.73 +      break
    2.74 +      ;;
    2.75 +  esac
    2.76  done
    2.77  
    2.78  for file
    2.79 @@ -36,64 +66,97 @@
    2.80  done
    2.81  
    2.82  case $# in
    2.83 -0) exit 0 ;;
    2.84 +  0) exit 0 ;;
    2.85  esac
    2.86  
    2.87 +# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
    2.88 +# mkdir -p a/c at the same time, both will detect that a is missing,
    2.89 +# one will create a, then the other will try to create a and die with
    2.90 +# a "File exists" error.  This is a problem when calling mkinstalldirs
    2.91 +# from a parallel make.  We use --version in the probe to restrict
    2.92 +# ourselves to GNU mkdir, which is thread-safe.
    2.93  case $dirmode in
    2.94 -'')
    2.95 -  if mkdir -p -- . 2>/dev/null; then
    2.96 -    echo "mkdir -p -- $*"
    2.97 -    exec mkdir -p -- "$@"
    2.98 -  fi ;;
    2.99 -*)
   2.100 -  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
   2.101 -    echo "mkdir -m $dirmode -p -- $*"
   2.102 -    exec mkdir -m "$dirmode" -p -- "$@"
   2.103 -  fi ;;
   2.104 +  '')
   2.105 +    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
   2.106 +      echo "mkdir -p -- $*"
   2.107 +      exec mkdir -p -- "$@"
   2.108 +    else
   2.109 +      # On NextStep and OpenStep, the 'mkdir' command does not
   2.110 +      # recognize any option.  It will interpret all options as
   2.111 +      # directories to create, and then abort because '.' already
   2.112 +      # exists.
   2.113 +      test -d ./-p && rmdir ./-p
   2.114 +      test -d ./--version && rmdir ./--version
   2.115 +    fi
   2.116 +    ;;
   2.117 +  *)
   2.118 +    if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
   2.119 +       test ! -d ./--version; then
   2.120 +      echo "mkdir -m $dirmode -p -- $*"
   2.121 +      exec mkdir -m "$dirmode" -p -- "$@"
   2.122 +    else
   2.123 +      # Clean up after NextStep and OpenStep mkdir.
   2.124 +      for d in ./-m ./-p ./--version "./$dirmode";
   2.125 +      do
   2.126 +        test -d $d && rmdir $d
   2.127 +      done
   2.128 +    fi
   2.129 +    ;;
   2.130  esac
   2.131  
   2.132  for file
   2.133  do
   2.134 -   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
   2.135 -   shift
   2.136 +  case $file in
   2.137 +    /*) pathcomp=/ ;;
   2.138 +    *)  pathcomp= ;;
   2.139 +  esac
   2.140 +  oIFS=$IFS
   2.141 +  IFS=/
   2.142 +  set fnord $file
   2.143 +  shift
   2.144 +  IFS=$oIFS
   2.145  
   2.146 -   pathcomp=
   2.147 -   for d
   2.148 -   do
   2.149 -     pathcomp="$pathcomp$d"
   2.150 -     case "$pathcomp" in
   2.151 -       -* ) pathcomp=./$pathcomp ;;
   2.152 -     esac
   2.153 +  for d
   2.154 +  do
   2.155 +    test "x$d" = x && continue
   2.156  
   2.157 -     if test ! -d "$pathcomp"; then
   2.158 -	echo "mkdir $pathcomp"
   2.159 +    pathcomp=$pathcomp$d
   2.160 +    case $pathcomp in
   2.161 +      -*) pathcomp=./$pathcomp ;;
   2.162 +    esac
   2.163  
   2.164 -	mkdir "$pathcomp" || lasterr=$?
   2.165 +    if test ! -d "$pathcomp"; then
   2.166 +      echo "mkdir $pathcomp"
   2.167  
   2.168 -	if test ! -d "$pathcomp"; then
   2.169 -	  errstatus=$lasterr
   2.170 -	else
   2.171 -	  if test ! -z "$dirmode"; then
   2.172 -	     echo "chmod $dirmode $pathcomp"
   2.173 +      mkdir "$pathcomp" || lasterr=$?
   2.174  
   2.175 -	     lasterr=""
   2.176 -	     chmod "$dirmode" "$pathcomp" || lasterr=$?
   2.177 +      if test ! -d "$pathcomp"; then
   2.178 +	errstatus=$lasterr
   2.179 +      else
   2.180 +	if test ! -z "$dirmode"; then
   2.181 +	  echo "chmod $dirmode $pathcomp"
   2.182 +	  lasterr=
   2.183 +	  chmod "$dirmode" "$pathcomp" || lasterr=$?
   2.184  
   2.185 -	     if test ! -z "$lasterr"; then
   2.186 -	       errstatus=$lasterr
   2.187 -	     fi
   2.188 +	  if test ! -z "$lasterr"; then
   2.189 +	    errstatus=$lasterr
   2.190  	  fi
   2.191  	fi
   2.192 -     fi
   2.193 +      fi
   2.194 +    fi
   2.195  
   2.196 -     pathcomp="$pathcomp/"
   2.197 -   done
   2.198 +    pathcomp=$pathcomp/
   2.199 +  done
   2.200  done
   2.201  
   2.202  exit $errstatus
   2.203  
   2.204  # Local Variables:
   2.205  # mode: shell-script
   2.206 -# sh-indentation: 3
   2.207 +# sh-indentation: 2
   2.208 +# eval: (add-hook 'write-file-hooks 'time-stamp)
   2.209 +# time-stamp-start: "scriptversion="
   2.210 +# time-stamp-format: "%:y-%02m-%02d.%02H"
   2.211 +# time-stamp-time-zone: "UTC"
   2.212 +# time-stamp-end: "; # UTC"
   2.213  # End:
   2.214 -# mkinstalldirs ends here