Blame hwmixvolume/install-sh

Packit Service b98cfc
#!/bin/sh
Packit Service b98cfc
# install - install a program, script, or datafile
Packit Service b98cfc
Packit Service b98cfc
scriptversion=2011-11-20.07; # UTC
Packit Service b98cfc
Packit Service b98cfc
# This originates from X11R5 (mit/util/scripts/install.sh), which was
Packit Service b98cfc
# later released in X11R6 (xc/config/util/install.sh) with the
Packit Service b98cfc
# following copyright and license.
Packit Service b98cfc
#
Packit Service b98cfc
# Copyright (C) 1994 X Consortium
Packit Service b98cfc
#
Packit Service b98cfc
# Permission is hereby granted, free of charge, to any person obtaining a copy
Packit Service b98cfc
# of this software and associated documentation files (the "Software"), to
Packit Service b98cfc
# deal in the Software without restriction, including without limitation the
Packit Service b98cfc
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
Packit Service b98cfc
# sell copies of the Software, and to permit persons to whom the Software is
Packit Service b98cfc
# furnished to do so, subject to the following conditions:
Packit Service b98cfc
#
Packit Service b98cfc
# The above copyright notice and this permission notice shall be included in
Packit Service b98cfc
# all copies or substantial portions of the Software.
Packit Service b98cfc
#
Packit Service b98cfc
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit Service b98cfc
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit Service b98cfc
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
Packit Service b98cfc
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Packit Service b98cfc
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
Packit Service b98cfc
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit Service b98cfc
#
Packit Service b98cfc
# Except as contained in this notice, the name of the X Consortium shall not
Packit Service b98cfc
# be used in advertising or otherwise to promote the sale, use or other deal-
Packit Service b98cfc
# ings in this Software without prior written authorization from the X Consor-
Packit Service b98cfc
# tium.
Packit Service b98cfc
#
Packit Service b98cfc
#
Packit Service b98cfc
# FSF changes to this file are in the public domain.
Packit Service b98cfc
#
Packit Service b98cfc
# Calling this script install-sh is preferred over install.sh, to prevent
Packit Service b98cfc
# 'make' implicit rules from creating a file called install from it
Packit Service b98cfc
# when there is no Makefile.
Packit Service b98cfc
#
Packit Service b98cfc
# This script is compatible with the BSD install script, but was written
Packit Service b98cfc
# from scratch.
Packit Service b98cfc
Packit Service b98cfc
nl='
Packit Service b98cfc
'
Packit Service b98cfc
IFS=" ""	$nl"
Packit Service b98cfc
Packit Service b98cfc
# set DOITPROG to echo to test this script
Packit Service b98cfc
Packit Service b98cfc
# Don't use :- since 4.3BSD and earlier shells don't like it.
Packit Service b98cfc
doit=${DOITPROG-}
Packit Service b98cfc
if test -z "$doit"; then
Packit Service b98cfc
  doit_exec=exec
Packit Service b98cfc
else
Packit Service b98cfc
  doit_exec=$doit
Packit Service b98cfc
fi
Packit Service b98cfc
Packit Service b98cfc
# Put in absolute file names if you don't have them in your path;
Packit Service b98cfc
# or use environment vars.
Packit Service b98cfc
Packit Service b98cfc
chgrpprog=${CHGRPPROG-chgrp}
Packit Service b98cfc
chmodprog=${CHMODPROG-chmod}
Packit Service b98cfc
chownprog=${CHOWNPROG-chown}
Packit Service b98cfc
cmpprog=${CMPPROG-cmp}
Packit Service b98cfc
cpprog=${CPPROG-cp}
Packit Service b98cfc
mkdirprog=${MKDIRPROG-mkdir}
Packit Service b98cfc
mvprog=${MVPROG-mv}
Packit Service b98cfc
rmprog=${RMPROG-rm}
Packit Service b98cfc
stripprog=${STRIPPROG-strip}
Packit Service b98cfc
Packit Service b98cfc
posix_glob='?'
Packit Service b98cfc
initialize_posix_glob='
Packit Service b98cfc
  test "$posix_glob" != "?" || {
Packit Service b98cfc
    if (set -f) 2>/dev/null; then
Packit Service b98cfc
      posix_glob=
Packit Service b98cfc
    else
Packit Service b98cfc
      posix_glob=:
Packit Service b98cfc
    fi
Packit Service b98cfc
  }
Packit Service b98cfc
'
Packit Service b98cfc
Packit Service b98cfc
posix_mkdir=
Packit Service b98cfc
Packit Service b98cfc
# Desired mode of installed file.
Packit Service b98cfc
mode=0755
Packit Service b98cfc
Packit Service b98cfc
chgrpcmd=
Packit Service b98cfc
chmodcmd=$chmodprog
Packit Service b98cfc
chowncmd=
Packit Service b98cfc
mvcmd=$mvprog
Packit Service b98cfc
rmcmd="$rmprog -f"
Packit Service b98cfc
stripcmd=
Packit Service b98cfc
Packit Service b98cfc
src=
Packit Service b98cfc
dst=
Packit Service b98cfc
dir_arg=
Packit Service b98cfc
dst_arg=
Packit Service b98cfc
Packit Service b98cfc
copy_on_change=false
Packit Service b98cfc
no_target_directory=
Packit Service b98cfc
Packit Service b98cfc
usage="\
Packit Service b98cfc
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
Packit Service b98cfc
   or: $0 [OPTION]... SRCFILES... DIRECTORY
Packit Service b98cfc
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
Packit Service b98cfc
   or: $0 [OPTION]... -d DIRECTORIES...
Packit Service b98cfc
Packit Service b98cfc
In the 1st form, copy SRCFILE to DSTFILE.
Packit Service b98cfc
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
Packit Service b98cfc
In the 4th, create DIRECTORIES.
Packit Service b98cfc
Packit Service b98cfc
Options:
Packit Service b98cfc
     --help     display this help and exit.
Packit Service b98cfc
     --version  display version info and exit.
Packit Service b98cfc
Packit Service b98cfc
  -c            (ignored)
Packit Service b98cfc
  -C            install only if different (preserve the last data modification time)
Packit Service b98cfc
  -d            create directories instead of installing files.
Packit Service b98cfc
  -g GROUP      $chgrpprog installed files to GROUP.
Packit Service b98cfc
  -m MODE       $chmodprog installed files to MODE.
Packit Service b98cfc
  -o USER       $chownprog installed files to USER.
Packit Service b98cfc
  -s            $stripprog installed files.
Packit Service b98cfc
  -t DIRECTORY  install into DIRECTORY.
Packit Service b98cfc
  -T            report an error if DSTFILE is a directory.
Packit Service b98cfc
Packit Service b98cfc
Environment variables override the default commands:
Packit Service b98cfc
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
Packit Service b98cfc
  RMPROG STRIPPROG
Packit Service b98cfc
"
Packit Service b98cfc
Packit Service b98cfc
while test $# -ne 0; do
Packit Service b98cfc
  case $1 in
Packit Service b98cfc
    -c) ;;
Packit Service b98cfc
Packit Service b98cfc
    -C) copy_on_change=true;;
Packit Service b98cfc
Packit Service b98cfc
    -d) dir_arg=true;;
Packit Service b98cfc
Packit Service b98cfc
    -g) chgrpcmd="$chgrpprog $2"
Packit Service b98cfc
	shift;;
Packit Service b98cfc
Packit Service b98cfc
    --help) echo "$usage"; exit $?;;
Packit Service b98cfc
Packit Service b98cfc
    -m) mode=$2
Packit Service b98cfc
	case $mode in
Packit Service b98cfc
	  *' '* | *'	'* | *'
Packit Service b98cfc
'*	  | *'*'* | *'?'* | *'['*)
Packit Service b98cfc
	    echo "$0: invalid mode: $mode" >&2
Packit Service b98cfc
	    exit 1;;
Packit Service b98cfc
	esac
Packit Service b98cfc
	shift;;
Packit Service b98cfc
Packit Service b98cfc
    -o) chowncmd="$chownprog $2"
Packit Service b98cfc
	shift;;
Packit Service b98cfc
Packit Service b98cfc
    -s) stripcmd=$stripprog;;
Packit Service b98cfc
Packit Service b98cfc
    -t) dst_arg=$2
Packit Service b98cfc
	# Protect names problematic for 'test' and other utilities.
Packit Service b98cfc
	case $dst_arg in
Packit Service b98cfc
	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
Packit Service b98cfc
	esac
Packit Service b98cfc
	shift;;
Packit Service b98cfc
Packit Service b98cfc
    -T) no_target_directory=true;;
Packit Service b98cfc
Packit Service b98cfc
    --version) echo "$0 $scriptversion"; exit $?;;
Packit Service b98cfc
Packit Service b98cfc
    --)	shift
Packit Service b98cfc
	break;;
Packit Service b98cfc
Packit Service b98cfc
    -*)	echo "$0: invalid option: $1" >&2
Packit Service b98cfc
	exit 1;;
Packit Service b98cfc
Packit Service b98cfc
    *)  break;;
Packit Service b98cfc
  esac
Packit Service b98cfc
  shift
Packit Service b98cfc
done
Packit Service b98cfc
Packit Service b98cfc
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
Packit Service b98cfc
  # When -d is used, all remaining arguments are directories to create.
Packit Service b98cfc
  # When -t is used, the destination is already specified.
Packit Service b98cfc
  # Otherwise, the last argument is the destination.  Remove it from $@.
Packit Service b98cfc
  for arg
Packit Service b98cfc
  do
Packit Service b98cfc
    if test -n "$dst_arg"; then
Packit Service b98cfc
      # $@ is not empty: it contains at least $arg.
Packit Service b98cfc
      set fnord "$@" "$dst_arg"
Packit Service b98cfc
      shift # fnord
Packit Service b98cfc
    fi
Packit Service b98cfc
    shift # arg
Packit Service b98cfc
    dst_arg=$arg
Packit Service b98cfc
    # Protect names problematic for 'test' and other utilities.
Packit Service b98cfc
    case $dst_arg in
Packit Service b98cfc
      -* | [=\(\)!]) dst_arg=./$dst_arg;;
Packit Service b98cfc
    esac
Packit Service b98cfc
  done
Packit Service b98cfc
fi
Packit Service b98cfc
Packit Service b98cfc
if test $# -eq 0; then
Packit Service b98cfc
  if test -z "$dir_arg"; then
Packit Service b98cfc
    echo "$0: no input file specified." >&2
Packit Service b98cfc
    exit 1
Packit Service b98cfc
  fi
Packit Service b98cfc
  # It's OK to call 'install-sh -d' without argument.
Packit Service b98cfc
  # This can happen when creating conditional directories.
Packit Service b98cfc
  exit 0
Packit Service b98cfc
fi
Packit Service b98cfc
Packit Service b98cfc
if test -z "$dir_arg"; then
Packit Service b98cfc
  do_exit='(exit $ret); exit $ret'
Packit Service b98cfc
  trap "ret=129; $do_exit" 1
Packit Service b98cfc
  trap "ret=130; $do_exit" 2
Packit Service b98cfc
  trap "ret=141; $do_exit" 13
Packit Service b98cfc
  trap "ret=143; $do_exit" 15
Packit Service b98cfc
Packit Service b98cfc
  # Set umask so as not to create temps with too-generous modes.
Packit Service b98cfc
  # However, 'strip' requires both read and write access to temps.
Packit Service b98cfc
  case $mode in
Packit Service b98cfc
    # Optimize common cases.
Packit Service b98cfc
    *644) cp_umask=133;;
Packit Service b98cfc
    *755) cp_umask=22;;
Packit Service b98cfc
Packit Service b98cfc
    *[0-7])
Packit Service b98cfc
      if test -z "$stripcmd"; then
Packit Service b98cfc
	u_plus_rw=
Packit Service b98cfc
      else
Packit Service b98cfc
	u_plus_rw='% 200'
Packit Service b98cfc
      fi
Packit Service b98cfc
      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
Packit Service b98cfc
    *)
Packit Service b98cfc
      if test -z "$stripcmd"; then
Packit Service b98cfc
	u_plus_rw=
Packit Service b98cfc
      else
Packit Service b98cfc
	u_plus_rw=,u+rw
Packit Service b98cfc
      fi
Packit Service b98cfc
      cp_umask=$mode$u_plus_rw;;
Packit Service b98cfc
  esac
Packit Service b98cfc
fi
Packit Service b98cfc
Packit Service b98cfc
for src
Packit Service b98cfc
do
Packit Service b98cfc
  # Protect names problematic for 'test' and other utilities.
Packit Service b98cfc
  case $src in
Packit Service b98cfc
    -* | [=\(\)!]) src=./$src;;
Packit Service b98cfc
  esac
Packit Service b98cfc
Packit Service b98cfc
  if test -n "$dir_arg"; then
Packit Service b98cfc
    dst=$src
Packit Service b98cfc
    dstdir=$dst
Packit Service b98cfc
    test -d "$dstdir"
Packit Service b98cfc
    dstdir_status=$?
Packit Service b98cfc
  else
Packit Service b98cfc
Packit Service b98cfc
    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
Packit Service b98cfc
    # might cause directories to be created, which would be especially bad
Packit Service b98cfc
    # if $src (and thus $dsttmp) contains '*'.
Packit Service b98cfc
    if test ! -f "$src" && test ! -d "$src"; then
Packit Service b98cfc
      echo "$0: $src does not exist." >&2
Packit Service b98cfc
      exit 1
Packit Service b98cfc
    fi
Packit Service b98cfc
Packit Service b98cfc
    if test -z "$dst_arg"; then
Packit Service b98cfc
      echo "$0: no destination specified." >&2
Packit Service b98cfc
      exit 1
Packit Service b98cfc
    fi
Packit Service b98cfc
    dst=$dst_arg
Packit Service b98cfc
Packit Service b98cfc
    # If destination is a directory, append the input filename; won't work
Packit Service b98cfc
    # if double slashes aren't ignored.
Packit Service b98cfc
    if test -d "$dst"; then
Packit Service b98cfc
      if test -n "$no_target_directory"; then
Packit Service b98cfc
	echo "$0: $dst_arg: Is a directory" >&2
Packit Service b98cfc
	exit 1
Packit Service b98cfc
      fi
Packit Service b98cfc
      dstdir=$dst
Packit Service b98cfc
      dst=$dstdir/`basename "$src"`
Packit Service b98cfc
      dstdir_status=0
Packit Service b98cfc
    else
Packit Service b98cfc
      # Prefer dirname, but fall back on a substitute if dirname fails.
Packit Service b98cfc
      dstdir=`
Packit Service b98cfc
	(dirname "$dst") 2>/dev/null ||
Packit Service b98cfc
	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
Packit Service b98cfc
	     X"$dst" : 'X\(//\)[^/]' \| \
Packit Service b98cfc
	     X"$dst" : 'X\(//\)$' \| \
Packit Service b98cfc
	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
Packit Service b98cfc
	echo X"$dst" |
Packit Service b98cfc
	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
Packit Service b98cfc
		   s//\1/
Packit Service b98cfc
		   q
Packit Service b98cfc
		 }
Packit Service b98cfc
		 /^X\(\/\/\)[^/].*/{
Packit Service b98cfc
		   s//\1/
Packit Service b98cfc
		   q
Packit Service b98cfc
		 }
Packit Service b98cfc
		 /^X\(\/\/\)$/{
Packit Service b98cfc
		   s//\1/
Packit Service b98cfc
		   q
Packit Service b98cfc
		 }
Packit Service b98cfc
		 /^X\(\/\).*/{
Packit Service b98cfc
		   s//\1/
Packit Service b98cfc
		   q
Packit Service b98cfc
		 }
Packit Service b98cfc
		 s/.*/./; q'
Packit Service b98cfc
      `
Packit Service b98cfc
Packit Service b98cfc
      test -d "$dstdir"
Packit Service b98cfc
      dstdir_status=$?
Packit Service b98cfc
    fi
Packit Service b98cfc
  fi
Packit Service b98cfc
Packit Service b98cfc
  obsolete_mkdir_used=false
Packit Service b98cfc
Packit Service b98cfc
  if test $dstdir_status != 0; then
Packit Service b98cfc
    case $posix_mkdir in
Packit Service b98cfc
      '')
Packit Service b98cfc
	# Create intermediate dirs using mode 755 as modified by the umask.
Packit Service b98cfc
	# This is like FreeBSD 'install' as of 1997-10-28.
Packit Service b98cfc
	umask=`umask`
Packit Service b98cfc
	case $stripcmd.$umask in
Packit Service b98cfc
	  # Optimize common cases.
Packit Service b98cfc
	  *[2367][2367]) mkdir_umask=$umask;;
Packit Service b98cfc
	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
Packit Service b98cfc
Packit Service b98cfc
	  *[0-7])
Packit Service b98cfc
	    mkdir_umask=`expr $umask + 22 \
Packit Service b98cfc
	      - $umask % 100 % 40 + $umask % 20 \
Packit Service b98cfc
	      - $umask % 10 % 4 + $umask % 2
Packit Service b98cfc
	    `;;
Packit Service b98cfc
	  *) mkdir_umask=$umask,go-w;;
Packit Service b98cfc
	esac
Packit Service b98cfc
Packit Service b98cfc
	# With -d, create the new directory with the user-specified mode.
Packit Service b98cfc
	# Otherwise, rely on $mkdir_umask.
Packit Service b98cfc
	if test -n "$dir_arg"; then
Packit Service b98cfc
	  mkdir_mode=-m$mode
Packit Service b98cfc
	else
Packit Service b98cfc
	  mkdir_mode=
Packit Service b98cfc
	fi
Packit Service b98cfc
Packit Service b98cfc
	posix_mkdir=false
Packit Service b98cfc
	case $umask in
Packit Service b98cfc
	  *[123567][0-7][0-7])
Packit Service b98cfc
	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
Packit Service b98cfc
	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
Packit Service b98cfc
	    ;;
Packit Service b98cfc
	  *)
Packit Service b98cfc
	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
Packit Service b98cfc
	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
Packit Service b98cfc
Packit Service b98cfc
	    if (umask $mkdir_umask &&
Packit Service b98cfc
		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
Packit Service b98cfc
	    then
Packit Service b98cfc
	      if test -z "$dir_arg" || {
Packit Service b98cfc
		   # Check for POSIX incompatibilities with -m.
Packit Service b98cfc
		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
Packit Service b98cfc
		   # other-writable bit of parent directory when it shouldn't.
Packit Service b98cfc
		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
Packit Service b98cfc
		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
Packit Service b98cfc
		   case $ls_ld_tmpdir in
Packit Service b98cfc
		     d????-?r-*) different_mode=700;;
Packit Service b98cfc
		     d????-?--*) different_mode=755;;
Packit Service b98cfc
		     *) false;;
Packit Service b98cfc
		   esac &&
Packit Service b98cfc
		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
Packit Service b98cfc
		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
Packit Service b98cfc
		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
Packit Service b98cfc
		   }
Packit Service b98cfc
		 }
Packit Service b98cfc
	      then posix_mkdir=:
Packit Service b98cfc
	      fi
Packit Service b98cfc
	      rmdir "$tmpdir/d" "$tmpdir"
Packit Service b98cfc
	    else
Packit Service b98cfc
	      # Remove any dirs left behind by ancient mkdir implementations.
Packit Service b98cfc
	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
Packit Service b98cfc
	    fi
Packit Service b98cfc
	    trap '' 0;;
Packit Service b98cfc
	esac;;
Packit Service b98cfc
    esac
Packit Service b98cfc
Packit Service b98cfc
    if
Packit Service b98cfc
      $posix_mkdir && (
Packit Service b98cfc
	umask $mkdir_umask &&
Packit Service b98cfc
	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
Packit Service b98cfc
      )
Packit Service b98cfc
    then :
Packit Service b98cfc
    else
Packit Service b98cfc
Packit Service b98cfc
      # The umask is ridiculous, or mkdir does not conform to POSIX,
Packit Service b98cfc
      # or it failed possibly due to a race condition.  Create the
Packit Service b98cfc
      # directory the slow way, step by step, checking for races as we go.
Packit Service b98cfc
Packit Service b98cfc
      case $dstdir in
Packit Service b98cfc
	/*) prefix='/';;
Packit Service b98cfc
	[-=\(\)!]*) prefix='./';;
Packit Service b98cfc
	*)  prefix='';;
Packit Service b98cfc
      esac
Packit Service b98cfc
Packit Service b98cfc
      eval "$initialize_posix_glob"
Packit Service b98cfc
Packit Service b98cfc
      oIFS=$IFS
Packit Service b98cfc
      IFS=/
Packit Service b98cfc
      $posix_glob set -f
Packit Service b98cfc
      set fnord $dstdir
Packit Service b98cfc
      shift
Packit Service b98cfc
      $posix_glob set +f
Packit Service b98cfc
      IFS=$oIFS
Packit Service b98cfc
Packit Service b98cfc
      prefixes=
Packit Service b98cfc
Packit Service b98cfc
      for d
Packit Service b98cfc
      do
Packit Service b98cfc
	test X"$d" = X && continue
Packit Service b98cfc
Packit Service b98cfc
	prefix=$prefix$d
Packit Service b98cfc
	if test -d "$prefix"; then
Packit Service b98cfc
	  prefixes=
Packit Service b98cfc
	else
Packit Service b98cfc
	  if $posix_mkdir; then
Packit Service b98cfc
	    (umask=$mkdir_umask &&
Packit Service b98cfc
	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
Packit Service b98cfc
	    # Don't fail if two instances are running concurrently.
Packit Service b98cfc
	    test -d "$prefix" || exit 1
Packit Service b98cfc
	  else
Packit Service b98cfc
	    case $prefix in
Packit Service b98cfc
	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
Packit Service b98cfc
	      *) qprefix=$prefix;;
Packit Service b98cfc
	    esac
Packit Service b98cfc
	    prefixes="$prefixes '$qprefix'"
Packit Service b98cfc
	  fi
Packit Service b98cfc
	fi
Packit Service b98cfc
	prefix=$prefix/
Packit Service b98cfc
      done
Packit Service b98cfc
Packit Service b98cfc
      if test -n "$prefixes"; then
Packit Service b98cfc
	# Don't fail if two instances are running concurrently.
Packit Service b98cfc
	(umask $mkdir_umask &&
Packit Service b98cfc
	 eval "\$doit_exec \$mkdirprog $prefixes") ||
Packit Service b98cfc
	  test -d "$dstdir" || exit 1
Packit Service b98cfc
	obsolete_mkdir_used=true
Packit Service b98cfc
      fi
Packit Service b98cfc
    fi
Packit Service b98cfc
  fi
Packit Service b98cfc
Packit Service b98cfc
  if test -n "$dir_arg"; then
Packit Service b98cfc
    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
Packit Service b98cfc
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
Packit Service b98cfc
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
Packit Service b98cfc
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
Packit Service b98cfc
  else
Packit Service b98cfc
Packit Service b98cfc
    # Make a couple of temp file names in the proper directory.
Packit Service b98cfc
    dsttmp=$dstdir/_inst.$$_
Packit Service b98cfc
    rmtmp=$dstdir/_rm.$$_
Packit Service b98cfc
Packit Service b98cfc
    # Trap to clean up those temp files at exit.
Packit Service b98cfc
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
Packit Service b98cfc
Packit Service b98cfc
    # Copy the file name to the temp name.
Packit Service b98cfc
    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
Packit Service b98cfc
Packit Service b98cfc
    # and set any options; do chmod last to preserve setuid bits.
Packit Service b98cfc
    #
Packit Service b98cfc
    # If any of these fail, we abort the whole thing.  If we want to
Packit Service b98cfc
    # ignore errors from any of these, just make sure not to ignore
Packit Service b98cfc
    # errors from the above "$doit $cpprog $src $dsttmp" command.
Packit Service b98cfc
    #
Packit Service b98cfc
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
Packit Service b98cfc
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
Packit Service b98cfc
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
Packit Service b98cfc
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
Packit Service b98cfc
Packit Service b98cfc
    # If -C, don't bother to copy if it wouldn't change the file.
Packit Service b98cfc
    if $copy_on_change &&
Packit Service b98cfc
       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
Packit Service b98cfc
       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
Packit Service b98cfc
Packit Service b98cfc
       eval "$initialize_posix_glob" &&
Packit Service b98cfc
       $posix_glob set -f &&
Packit Service b98cfc
       set X $old && old=:$2:$4:$5:$6 &&
Packit Service b98cfc
       set X $new && new=:$2:$4:$5:$6 &&
Packit Service b98cfc
       $posix_glob set +f &&
Packit Service b98cfc
Packit Service b98cfc
       test "$old" = "$new" &&
Packit Service b98cfc
       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
Packit Service b98cfc
    then
Packit Service b98cfc
      rm -f "$dsttmp"
Packit Service b98cfc
    else
Packit Service b98cfc
      # Rename the file to the real destination.
Packit Service b98cfc
      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
Packit Service b98cfc
Packit Service b98cfc
      # The rename failed, perhaps because mv can't rename something else
Packit Service b98cfc
      # to itself, or perhaps because mv is so ancient that it does not
Packit Service b98cfc
      # support -f.
Packit Service b98cfc
      {
Packit Service b98cfc
	# Now remove or move aside any old file at destination location.
Packit Service b98cfc
	# We try this two ways since rm can't unlink itself on some
Packit Service b98cfc
	# systems and the destination file might be busy for other
Packit Service b98cfc
	# reasons.  In this case, the final cleanup might fail but the new
Packit Service b98cfc
	# file should still install successfully.
Packit Service b98cfc
	{
Packit Service b98cfc
	  test ! -f "$dst" ||
Packit Service b98cfc
	  $doit $rmcmd -f "$dst" 2>/dev/null ||
Packit Service b98cfc
	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
Packit Service b98cfc
	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
Packit Service b98cfc
	  } ||
Packit Service b98cfc
	  { echo "$0: cannot unlink or rename $dst" >&2
Packit Service b98cfc
	    (exit 1); exit 1
Packit Service b98cfc
	  }
Packit Service b98cfc
	} &&
Packit Service b98cfc
Packit Service b98cfc
	# Now rename the file to the real destination.
Packit Service b98cfc
	$doit $mvcmd "$dsttmp" "$dst"
Packit Service b98cfc
      }
Packit Service b98cfc
    fi || exit 1
Packit Service b98cfc
Packit Service b98cfc
    trap '' 0
Packit Service b98cfc
  fi
Packit Service b98cfc
done
Packit Service b98cfc
Packit Service b98cfc
# Local variables:
Packit Service b98cfc
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit Service b98cfc
# time-stamp-start: "scriptversion="
Packit Service b98cfc
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit Service b98cfc
# time-stamp-time-zone: "UTC"
Packit Service b98cfc
# time-stamp-end: "; # UTC"
Packit Service b98cfc
# End: