Blame build-aux/install-sh

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