Blame install-sh

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