Blame install-sh

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