head	1.6;
access;
symbols
	groff-1_20_1_real:1.6
	groff-1_20_1:1.6
	groff-1_20:1.6
	groff-1_19_2:1.4
	FDL:1.2
	groff-1_19_1:1.2
	groff-1_19:1.1.1.1
	groff-1_18_1:1.1.1.1
	groff-1_18:1.1.1.1
	groff-1_17_2:1.1.1.1
	groff-1_17_1:1.1.1.1
	groff-1_17a:1.1.1.1
	groff-1_17:1.1.1.1
	groff-1_16_1b:1.1.1.1
	groff-1_16_1a:1.1.1.1
	groff-1_16_1:1.1.1.1
	groff-1_16:1.1.1.1
	groff-20000311:1.1.1.1
	groff-20000310-1:1.1.1.1
	groff-20000310:1.1.1.1
	pre-1_16:1.1.1.1
	start:1.1.1.1
	wlemb:1.1.1;
locks; strict;
comment	@# @;


1.6
date	2007.06.12.06.58.46;	author wl;	state Exp;
branches;
next	1.5;
commitid	eJ3ohC4cqaSxIAls;

1.5
date	2006.01.23.07.29.50;	author wl;	state Exp;
branches;
next	1.4;

1.4
date	2005.09.04.10.02.23;	author wl;	state Exp;
branches;
next	1.3;

1.3
date	2004.12.21.05.56.53;	author wl;	state Exp;
branches;
next	1.2;

1.2
date	2004.05.04.16.54.38;	author wlemb;	state Exp;
branches;
next	1.1;

1.1
date	2000.02.06.09.34.43;	author wlemb;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.02.06.09.34.43;	author wlemb;	state Exp;
branches;
next	;


desc
@@


1.6
log
@

* src/devices/xditview/TODO, NEWS: Updated.
* src/devices/xditview/Makefile.sub (install_data, uninstall_sub):
Handle `GXditview-color'.
* src/devices/xditview/gxditview.man: Updated.

* m4/groff.m4 (GROFF_APPRESDIR_CHECK): Updated.
* m4/codeset.m4, m4/glibc21.m4, m4/iconv.m4, m4/lib-link.m4: Updated
from `gnulib' git repository.

* configure.ac: Updated.
* configure: Regenerated (using autoconf 2.61).

* config.guess, config.sub: Updated from `config' CVS repository.
* config.rpath, install-sh, mkinstalldirs: Updated from `gnulib' git
repository.
@
text
@#!/bin/sh
# install - install a program, script, or datafile

scriptversion=2006-12-25.00

# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.

nl='
'
IFS=" ""	$nl"

# set DOITPROG to echo to test this script

# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
  doit_exec=exec
else
  doit_exec=$doit
fi

# Put in absolute file names if you don't have them in your path;
# or use environment vars.

chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}

posix_glob='?'
initialize_posix_glob='
  test "$posix_glob" != "?" || {
    if (set -f) 2>/dev/null; then
      posix_glob=
    else
      posix_glob=:
    fi
  }
'

posix_mkdir=

# Desired mode of installed file.
mode=0755

chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=

src=
dst=
dir_arg=
dst_arg=

copy_on_change=false
no_target_directory=

usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
   or: $0 [OPTION]... SRCFILES... DIRECTORY
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
   or: $0 [OPTION]... -d DIRECTORIES...

In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.

Options:
     --help     display this help and exit.
     --version  display version info and exit.

  -c            (ignored)
  -C            install only if different (preserve the last data modification time)
  -d            create directories instead of installing files.
  -g GROUP      $chgrpprog installed files to GROUP.
  -m MODE       $chmodprog installed files to MODE.
  -o USER       $chownprog installed files to USER.
  -s            $stripprog installed files.
  -t DIRECTORY  install into DIRECTORY.
  -T            report an error if DSTFILE is a directory.

Environment variables override the default commands:
  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
  RMPROG STRIPPROG
"

while test $# -ne 0; do
  case $1 in
    -c) ;;

    -C) copy_on_change=true;;

    -d) dir_arg=true;;

    -g) chgrpcmd="$chgrpprog $2"
	shift;;

    --help) echo "$usage"; exit $?;;

    -m) mode=$2
	case $mode in
	  *' '* | *'	'* | *'
'*	  | *'*'* | *'?'* | *'['*)
	    echo "$0: invalid mode: $mode" >&2
	    exit 1;;
	esac
	shift;;

    -o) chowncmd="$chownprog $2"
	shift;;

    -s) stripcmd=$stripprog;;

    -t) dst_arg=$2
	shift;;

    -T) no_target_directory=true;;

    --version) echo "$0 $scriptversion"; exit $?;;

    --)	shift
	break;;

    -*)	echo "$0: invalid option: $1" >&2
	exit 1;;

    *)  break;;
  esac
  shift
done

if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
  # When -d is used, all remaining arguments are directories to create.
  # When -t is used, the destination is already specified.
  # Otherwise, the last argument is the destination.  Remove it from $@@.
  for arg
  do
    if test -n "$dst_arg"; then
      # $@@ is not empty: it contains at least $arg.
      set fnord "$@@" "$dst_arg"
      shift # fnord
    fi
    shift # arg
    dst_arg=$arg
  done
fi

if test $# -eq 0; then
  if test -z "$dir_arg"; then
    echo "$0: no input file specified." >&2
    exit 1
  fi
  # It's OK to call `install-sh -d' without argument.
  # This can happen when creating conditional directories.
  exit 0
fi

if test -z "$dir_arg"; then
  trap '(exit $?); exit' 1 2 13 15

  # Set umask so as not to create temps with too-generous modes.
  # However, 'strip' requires both read and write access to temps.
  case $mode in
    # Optimize common cases.
    *644) cp_umask=133;;
    *755) cp_umask=22;;

    *[0-7])
      if test -z "$stripcmd"; then
	u_plus_rw=
      else
	u_plus_rw='% 200'
      fi
      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
    *)
      if test -z "$stripcmd"; then
	u_plus_rw=
      else
	u_plus_rw=,u+rw
      fi
      cp_umask=$mode$u_plus_rw;;
  esac
fi

for src
do
  # Protect names starting with `-'.
  case $src in
    -*) src=./$src;;
  esac

  if test -n "$dir_arg"; then
    dst=$src
    dstdir=$dst
    test -d "$dstdir"
    dstdir_status=$?
  else

    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
    # might cause directories to be created, which would be especially bad
    # if $src (and thus $dsttmp) contains '*'.
    if test ! -f "$src" && test ! -d "$src"; then
      echo "$0: $src does not exist." >&2
      exit 1
    fi

    if test -z "$dst_arg"; then
      echo "$0: no destination specified." >&2
      exit 1
    fi

    dst=$dst_arg
    # Protect names starting with `-'.
    case $dst in
      -*) dst=./$dst;;
    esac

    # If destination is a directory, append the input filename; won't work
    # if double slashes aren't ignored.
    if test -d "$dst"; then
      if test -n "$no_target_directory"; then
	echo "$0: $dst_arg: Is a directory" >&2
	exit 1
      fi
      dstdir=$dst
      dst=$dstdir/`basename "$src"`
      dstdir_status=0
    else
      # Prefer dirname, but fall back on a substitute if dirname fails.
      dstdir=`
	(dirname "$dst") 2>/dev/null ||
	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	     X"$dst" : 'X\(//\)[^/]' \| \
	     X"$dst" : 'X\(//\)$' \| \
	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
	echo X"$dst" |
	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
		   s//\1/
		   q
		 }
		 /^X\(\/\/\)[^/].*/{
		   s//\1/
		   q
		 }
		 /^X\(\/\/\)$/{
		   s//\1/
		   q
		 }
		 /^X\(\/\).*/{
		   s//\1/
		   q
		 }
		 s/.*/./; q'
      `

      test -d "$dstdir"
      dstdir_status=$?
    fi
  fi

  obsolete_mkdir_used=false

  if test $dstdir_status != 0; then
    case $posix_mkdir in
      '')
	# Create intermediate dirs using mode 755 as modified by the umask.
	# This is like FreeBSD 'install' as of 1997-10-28.
	umask=`umask`
	case $stripcmd.$umask in
	  # Optimize common cases.
	  *[2367][2367]) mkdir_umask=$umask;;
	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;

	  *[0-7])
	    mkdir_umask=`expr $umask + 22 \
	      - $umask % 100 % 40 + $umask % 20 \
	      - $umask % 10 % 4 + $umask % 2
	    `;;
	  *) mkdir_umask=$umask,go-w;;
	esac

	# With -d, create the new directory with the user-specified mode.
	# Otherwise, rely on $mkdir_umask.
	if test -n "$dir_arg"; then
	  mkdir_mode=-m$mode
	else
	  mkdir_mode=
	fi

	posix_mkdir=false
	case $umask in
	  *[123567][0-7][0-7])
	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
	    ;;
	  *)
	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0

	    if (umask $mkdir_umask &&
		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
	    then
	      if test -z "$dir_arg" || {
		   # Check for POSIX incompatibilities with -m.
		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
		   # other-writeable bit of parent directory when it shouldn't.
		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
		   case $ls_ld_tmpdir in
		     d????-?r-*) different_mode=700;;
		     d????-?--*) different_mode=755;;
		     *) false;;
		   esac &&
		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
		   }
		 }
	      then posix_mkdir=:
	      fi
	      rmdir "$tmpdir/d" "$tmpdir"
	    else
	      # Remove any dirs left behind by ancient mkdir implementations.
	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
	    fi
	    trap '' 0;;
	esac;;
    esac

    if
      $posix_mkdir && (
	umask $mkdir_umask &&
	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
      )
    then :
    else

      # The umask is ridiculous, or mkdir does not conform to POSIX,
      # or it failed possibly due to a race condition.  Create the
      # directory the slow way, step by step, checking for races as we go.

      case $dstdir in
	/*) prefix='/';;
	-*) prefix='./';;
	*)  prefix='';;
      esac

      eval "$initialize_posix_glob"

      oIFS=$IFS
      IFS=/
      $posix_glob set -f
      set fnord $dstdir
      shift
      $posix_glob set +f
      IFS=$oIFS

      prefixes=

      for d
      do
	test -z "$d" && continue

	prefix=$prefix$d
	if test -d "$prefix"; then
	  prefixes=
	else
	  if $posix_mkdir; then
	    (umask=$mkdir_umask &&
	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
	    # Don't fail if two instances are running concurrently.
	    test -d "$prefix" || exit 1
	  else
	    case $prefix in
	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
	      *) qprefix=$prefix;;
	    esac
	    prefixes="$prefixes '$qprefix'"
	  fi
	fi
	prefix=$prefix/
      done

      if test -n "$prefixes"; then
	# Don't fail if two instances are running concurrently.
	(umask $mkdir_umask &&
	 eval "\$doit_exec \$mkdirprog $prefixes") ||
	  test -d "$dstdir" || exit 1
	obsolete_mkdir_used=true
      fi
    fi
  fi

  if test -n "$dir_arg"; then
    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
  else

    # Make a couple of temp file names in the proper directory.
    dsttmp=$dstdir/_inst.$$_
    rmtmp=$dstdir/_rm.$$_

    # Trap to clean up those temp files at exit.
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0

    # Copy the file name to the temp name.
    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&

    # and set any options; do chmod last to preserve setuid bits.
    #
    # If any of these fail, we abort the whole thing.  If we want to
    # ignore errors from any of these, just make sure not to ignore
    # errors from the above "$doit $cpprog $src $dsttmp" command.
    #
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&

    # If -C, don't bother to copy if it wouldn't change the file.
    if $copy_on_change &&
       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&

       eval "$initialize_posix_glob" &&
       $posix_glob set -f &&
       set X $old && old=:$2:$4:$5:$6 &&
       set X $new && new=:$2:$4:$5:$6 &&
       $posix_glob set +f &&

       test "$old" = "$new" &&
       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
    then
      rm -f "$dsttmp"
    else
      # Rename the file to the real destination.
      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||

      # The rename failed, perhaps because mv can't rename something else
      # to itself, or perhaps because mv is so ancient that it does not
      # support -f.
      {
	# Now remove or move aside any old file at destination location.
	# We try this two ways since rm can't unlink itself on some
	# systems and the destination file might be busy for other
	# reasons.  In this case, the final cleanup might fail but the new
	# file should still install successfully.
	{
	  test ! -f "$dst" ||
	  $doit $rmcmd -f "$dst" 2>/dev/null ||
	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
	  } ||
	  { echo "$0: cannot unlink or rename $dst" >&2
	    (exit 1); exit 1
	  }
	} &&

	# Now rename the file to the real destination.
	$doit $mvcmd "$dsttmp" "$dst"
      }
    fi || exit 1

    trap '' 0
  fi
done

# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:
@


1.5
log
@

* install-sh: New version; taken from texinfo CVS.
@
text
@d4 1
a4 1
scriptversion=2006-01-12.21
d42 5
a46 2
# from scratch.  It can only install one file at a time, a restriction
# shared with many OS's install programs.
d51 6
a56 1
doit="${DOITPROG-}"
d58 2
a59 1
# put in absolute paths if you don't have them in your path; or use env. vars.
d61 20
a80 8
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
a81 1
posix_glob=
a83 4
# Symbolic mode for testing mkdir with directories.
# It is the same as 755, but also tests that "u+" works.
test_mode=u=rwx,g=rx,o=rx,u+wx

d87 1
a87 4
# Desired mode of newly created intermediate directories.
# It is empty if not known yet.
intermediate_mode=

d90 2
a91 1
chgrpcmd=
d93 1
a93 2
rmcmd="$rmprog -f"
mvcmd="$mvprog"
d97 3
a99 1
dstarg=
d102 2
a103 1
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
d113 12
a124 10
-c         (ignored)
-d         create directories instead of installing files.
-g GROUP   $chgrpprog installed files to GROUP.
-m MODE    $chmodprog installed files to MODE.
-o USER    $chownprog installed files to USER.
-s         $stripprog installed files.
-t DIRECTORY  install into DIRECTORY.
-T         report an error if DSTFILE is a directory.
--help     display this help and exit.
--version  display version info and exit.
d127 2
a128 1
  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
d131 1
a131 1
while test -n "$1"; do
d133 1
a133 2
    -c) shift
        continue;;
d135 3
a137 3
    -d) dir_arg=true
        shift
        continue;;
d140 1
a140 3
        shift
        shift
        continue;;
d145 7
a151 3
        shift
        shift
        continue;;
d154 8
a161 16
        shift
        shift
        continue;;

    -s) stripcmd=$stripprog
        shift
        continue;;

    -t) dstarg=$2
	shift
	shift
	continue;;

    -T) no_target_directory=true
	shift
	continue;;
d165 1
a165 14
    *)  # When -d is used, all remaining arguments are directories to create.
	# When -t is used, the destination is already specified.
	test -n "$dir_arg$dstarg" && break
        # Otherwise, the last argument is the destination.  Remove it from $@@.
	for arg
	do
          if test -n "$dstarg"; then
	    # $@@ is not empty: it contains at least $arg.
	    set fnord "$@@" "$dstarg"
	    shift # fnord
	  fi
	  shift # arg
	  dstarg=$arg
	done
d167 5
d173 1
d176 17
a192 1
if test -z "$1"; then
d202 26
a227 1
test -n "$dir_arg" || trap '(exit $?); exit' 1 2 13 15
d233 1
a233 1
    -*) src=./$src ;;
d251 1
a251 1
    if test -z "$dstarg"; then
d256 1
a256 1
    dst=$dstarg
d259 1
a259 1
      -*) dst=./$dst ;;
d266 1
a266 1
	echo "$0: $dstarg: Is a directory" >&2
d279 1
a279 2
	     X"$dst" : 'X\(/\)' \| \
	     .       : '\(.\)' 2>/dev/null ||
d310 15
a324 11
	posix_mkdir=false
	if $mkdirprog -m $test_mode -p -- / >/dev/null 2>&1; then
	  posix_mkdir=true
	else
	  # Remove any dirs left behind by ancient mkdir implementations.
	  rmdir ./-m "$test_mode" ./-p ./-- 2>/dev/null
	fi ;;
    esac

    if
      $posix_mkdir && {
d327 1
a327 5
	# Otherwise, create it using the same intermediate mode that
	# mkdir -p would use when creating intermediate directories.
	# POSIX says that this mode is "$(umask -S),u+wx", so use that
	# if umask -S works.

d329 1
a329 1
	  mkdir_mode=$mode
d331 1
a331 9
	  case $intermediate_mode in
	    '')
	      if umask_S=`(umask -S) 2>/dev/null`; then
		intermediate_mode=$umask_S,u+wx
	      else
		intermediate_mode=$test_mode
	      fi ;;
	  esac
	  mkdir_mode=$intermediate_mode
d334 45
a378 2
	$mkdirprog -m "$mkdir_mode" -p -- "$dstdir"
      }
d382 3
a384 3
      # mkdir does not conform to POSIX, or it failed possibly due to
      # a race condition.  Create the directory the slow way, step by
      # step, checking for races as we go.
d387 3
a389 3
	/*) pathcomp=/ ;;
	-*) pathcomp=./ ;;
	*)  pathcomp= ;;
d392 1
a392 8
      case $posix_glob in
        '')
	  if (set -f) 2>/dev/null; then
	    posix_glob=true
	  else
	    posix_glob=false
	  fi ;;
      esac
d396 1
a396 1
      $posix_glob && set -f
d399 1
a399 1
      $posix_glob && set +f
d402 2
d406 1
a406 1
	test "x$d" = x && continue
d408 16
a423 5
	pathcomp=$pathcomp$d
	if test ! -d "$pathcomp"; then
	  $mkdirprog "$pathcomp"
	  # Don't fail if two instances are running concurrently.
	  test -d "$pathcomp" || exit 1
d425 1
a425 1
	pathcomp=$pathcomp/
d427 8
a434 1
      obsolete_mkdir_used=true
d442 1
a442 1
      test -z "$chmodcmd" || $doit $chmodcmd "$mode" "$dst"; } || exit 1
d453 1
a453 1
    $doit $cpprog "$src" "$dsttmp" &&
d461 48
a508 35
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
      && { test -z "$chmodcmd" || $doit $chmodcmd "$mode" "$dsttmp"; } &&

    # Now rename the file to the real destination.
    { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
      || {
	   # The rename failed, perhaps because mv can't rename something else
	   # to itself, or perhaps because mv is so ancient that it does not
	   # support -f.

	   # Now remove or move aside any old file at destination location.
	   # We try this two ways since rm can't unlink itself on some
	   # systems and the destination file might be busy for other
	   # reasons.  In this case, the final cleanup might fail but the new
	   # file should still install successfully.
	   {
	     if test -f "$dst"; then
	       $doit $rmcmd -f "$dst" 2>/dev/null \
	       || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
		     && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
	       || {
		 echo "$0: cannot unlink or rename $dst" >&2
		 (exit 1); exit 1
	       }
	     else
	       :
	     fi
	   } &&

	   # Now rename the file to the real destination.
	   $doit $mvcmd "$dsttmp" "$dst"
	 }
    } || exit 1
@


1.4
log
@

* install-sh, mkinstalldirs: New versions; taken from texinfo CVS.
@
text
@d4 1
a4 1
scriptversion=2005-07-09.12
d61 15
a75 1
chmodcmd="$chmodprog 0755"
d128 1
a128 1
    -m) chmodcmd="$chmodprog $2"
d181 2
d192 4
a195 1
    src=
a196 7
    if test -d "$dst"; then
      mkdircmd=:
      chmodcmd=
    else
      mkdircmd=$mkdirprog
    fi
  else
d223 34
a256 1
      dst=$dst/`basename "$src"`
d260 1
a260 2
  # This sed command emulates the dirname command.
  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
d262 39
a300 1
  # Make sure that the destination directory exists.
d302 41
a342 27
  # Skip lots of stat calls in the usual case.
  if test ! -d "$dstdir"; then
    case $dstdir in
      /*) pathcomp=/ ;;
      -*) pathcomp=./ ;;
      *)  pathcomp= ;;
    esac
    oIFS=$IFS
    IFS=/
    set fnord $dstdir
    shift
    IFS=$oIFS

    for d
    do
      test "x$d" = x && continue

      pathcomp=$pathcomp$d
      if test ! -d "$pathcomp"; then
        $mkdirprog "$pathcomp"
	# mkdir can fail with a `File exist' error in case several
	# install-sh are creating the directory concurrently.  This
	# is OK.
	test -d "$pathcomp" || exit 1
      fi
      pathcomp=$pathcomp/
    done
d346 4
a349 6
    $doit $mkdircmd "$dst" \
      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }

a350 1
    dstfile=`basename "$dst"`
a357 1
    trap '(exit $?); exit' 1 2 13 15
d371 1
a371 1
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
d374 1
a374 1
    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
d386 4
a389 3
	     if test -f "$dstdir/$dstfile"; then
	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
d391 1
a391 1
		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
d400 1
a400 1
	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
d402 4
a405 2
    }
  fi || { (exit 1); exit 1; }
a407 5
# The final little trick to "correctly" pass the exit status to the exit trap.
{
  (exit 0); exit 0
}

@


1.3
log
@

* install-sh: New version; taken from texinfo CVS.
@
text
@d4 1
a4 1
scriptversion=2004-12-17.09
d112 1
a112 1
    --help) echo "$usage"; exit 0;;
d137 1
a137 1
    --version) echo "$0 $scriptversion"; exit 0;;
d222 5
a226 4
    defaultIFS='
	 '
    IFS="${IFS-$defaultIFS}"

d228 2
a229 3
    # Some sh's can't handle IFS=/ for some reason.
    IFS='%'
    set x `echo "$dstdir" | sed -e 's@@/@@%@@g' -e 's@@^%@@/@@'`
d233 3
a235 1
    pathcomp=
d237 1
a237 3
    while test $# -ne 0 ; do
      pathcomp=$pathcomp$1
      shift
d243 1
a243 1
	test -d "$pathcomp" || exit
@


1.2
log
@

* install-sh, mkinstalldirs: New versions; taken from texinfo CVS.
@
text
@d4 1
a4 1
scriptversion=2004-04-01.17
a60 3
transformbasename=
transform_arg=
instcmd="$mvprog"
d70 2
d73 1
a73 1
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
d75 2
a76 1
   or: $0 -d DIRECTORIES...
d78 3
a80 2
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
In the second, create the directory path DIR.
d83 1
a83 2
-b=TRANSFORMBASENAME
-c         copy source (using $cpprog) instead of moving (using $mvprog).
d85 6
a90 5
-g GROUP   $chgrp installed files to GROUP.
-m MODE    $chmod installed files to MODE.
-o USER    $chown installed files to USER.
-s         strip installed files (using $stripprog).
-t=TRANSFORM
d100 1
a100 6
    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
        shift
        continue;;

    -c) instcmd=$cpprog
        shift
d128 8
a135 3
    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
        shift
        continue;;
d140 2
a141 1
	test -n "$dir_arg" && break
d179 1
a179 1
      instcmd=:
d182 1
a182 1
      instcmd=$mkdirprog
d185 1
a185 1
    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
d207 4
d216 1
a216 1
  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
d229 2
a230 1
    set - `echo "$dstdir" | sed -e 's@@/@@%@@g' -e 's@@^%@@/@@'`
d239 1
a239 1
        $mkdirprog "$pathcomp" || lasterr=$?
d243 1
a243 1
	test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
d250 1
a250 1
    $doit $instcmd "$dst" \
d257 1
a257 10
    # If we're going to rename the final executable, determine the name now.
    if test -z "$transformarg"; then
      dstfile=`basename "$dst"`
    else
      dstfile=`basename "$dst" $transformbasename \
               | sed $transformarg`$transformbasename
    fi

    # don't allow the sed command to completely eliminate the filename.
    test -z "$dstfile" && dstfile=`basename "$dst"`
d264 1
a264 1
    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
d267 2
a268 2
    # Move or copy the file name to the temp name
    $doit $instcmd "$src" "$dsttmp" &&
d274 1
a274 1
    # errors from the above "$doit $instcmd $src $dsttmp" command.
d299 1
a299 1
		 (exit 1); exit
d310 1
a310 1
  fi || { (exit 1); exit; }
d315 1
a315 1
  (exit 0); exit
@


1.1
log
@Initial revision
@
text
@d1 17
a17 1
#! /bin/sh
d19 17
a35 2
# install - install a program, script, or datafile
# This comes from X11R5.
d42 2
a43 3
# from scratch.
#

a49 1

d61 2
a62 2
tranformbasename=""
transform_arg=""
d65 3
a67 3
chowncmd=""
chgrpcmd=""
stripcmd=""
d70 83
a152 52
src=""
dst=""
dir_arg=""

while [ x"$1" != x ]; do
    case $1 in
	-c) instcmd="$cpprog"
	    shift
	    continue;;

	-d) dir_arg=true
	    shift
	    continue;;

	-m) chmodcmd="$chmodprog $2"
	    shift
	    shift
	    continue;;

	-o) chowncmd="$chownprog $2"
	    shift
	    shift
	    continue;;

	-g) chgrpcmd="$chgrpprog $2"
	    shift
	    shift
	    continue;;

	-s) stripcmd="$stripprog"
	    shift
	    continue;;

	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
	    shift
	    continue;;

	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
	    shift
	    continue;;

	*)  if [ x"$src" = x ]
	    then
		src=$1
	    else
		# this colon is to work around a 386BSD /bin/sh bug
		:
		dst=$1
	    fi
	    shift
	    continue;;
    esac
d155 8
a162 6
if [ x"$src" = x ]
then
	echo "install:	no input file specified"
	exit 1
else
	true
d165 36
a200 72
if [ x"$dir_arg" != x ]; then
	dst=$src
	src=""
	
	if [ -d $dst ]; then
		instcmd=:
	else
		instcmd=mkdir
	fi
else

# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad 
# if $src (and thus $dsttmp) contains '*'.

	if [ -f $src -o -d $src ]
	then
		true
	else
		echo "install:  $src does not exist"
		exit 1
	fi
	
	if [ x"$dst" = x ]
	then
		echo "install:	no destination specified"
		exit 1
	else
		true
	fi

# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic

	if [ -d $dst ]
	then
		dst="$dst"/`basename $src`
	else
		true
	fi
fi

## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`

# Make sure that the destination directory exists.
#  this part is taken from Noah Friedman's mkinstalldirs script

# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='	
'
IFS="${IFS-${defaultIFS}}"

oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@@/@@%@@g' -e 's@@^%@@/@@'`
IFS="${oIFS}"

pathcomp=''

while [ $# -ne 0 ] ; do
	pathcomp="${pathcomp}${1}"
	shift

	if [ ! -d "${pathcomp}" ] ;
        then
		$mkdirprog "${pathcomp}"
	else
		true
	fi
d202 111
a312 1
	pathcomp="${pathcomp}/"
a313 59
fi

if [ x"$dir_arg" != x ]
then
	$doit $instcmd $dst &&

	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else

# If we're going to rename the final executable, determine the name now.

	if [ x"$transformarg" = x ] 
	then
		dstfile=`basename $dst`
	else
		dstfile=`basename $dst $transformbasename | 
			sed $transformarg`$transformbasename
	fi

# don't allow the sed command to completely eliminate the filename

	if [ x"$dstfile" = x ] 
	then
		dstfile=`basename $dst`
	else
		true
	fi

# Make a temp file name in the proper directory.

	dsttmp=$dstdir/#inst.$$#

# Move or copy the file name to the temp name

	$doit $instcmd $src $dsttmp &&

	trap "rm -f ${dsttmp}" 0 &&

# and set any options; do chmod last to preserve setuid bits

# If any of these fail, we abort the whole thing.  If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.

	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&

# Now rename the file to the real destination.

	$doit $rmcmd -f $dstdir/$dstfile &&
	$doit $mvcmd $dsttmp $dstdir/$dstfile 

fi &&

d315 11
a325 1
exit 0
@


1.1.1.1
log
@groff pre-1.16 with new directory structure
@
text
@@
