view install-sh @ 105994:009383a57ce8

* x-dnd.el (x-dnd-maybe-call-test-function): * window.el (split-window-vertically): * whitespace.el (whitespace-help-on): * vc-rcs.el (vc-rcs-consult-headers): * userlock.el (ask-user-about-lock-help) (ask-user-about-supersession-help): * type-break.el (type-break-force-mode-line-update): * time-stamp.el (time-stamp-conv-warn): * terminal.el (te-set-output-log, te-more-break, te-filter) (te-sentinel,terminal-emulator): * term.el (make-term, term-exec, term-sentinel, term-read-input-ring) (term-write-input-ring, term-check-source, term-start-output-log): (term-display-buffer-line, term-dynamic-list-completions): (term-ansi-make-term, serial-term): * subr.el (selective-display): * strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer) (strokes-encode-buffer, strokes-xpm-for-compressed-string): * speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info) (speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support) (speedbar-remove-localized-speedbar-support) (speedbar-set-mode-line-format, speedbar-create-tag-hierarchy) (speedbar-update-special-contents, speedbar-buffer-buttons-engine) (speedbar-buffers-line-directory): * simple.el (shell-command-on-region, append-to-buffer) (prepend-to-buffer): * shadowfile.el (shadow-save-todo-file): * scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1) (scroll-bar-maybe-set-window-start): * sb-image.el (speedbar-image-dump): * saveplace.el (save-place-alist-to-file, save-places-to-alist) (load-save-place-alist-from-file): * ps-samp.el (ps-print-message-from-summary): * ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox) (ps-background-image, ps-begin-job, ps-do-despool): * ps-bdf.el (bdf-find-file, bdf-read-font-info): * printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting) (pr-ps-message-from-summary, pr-lpr-message-from-summary): (pr-call-process, pr-file-list, pr-interface-save): * novice.el (disabled-command-function) (enable-command, disable-command): * mouse.el (mouse-buffer-menu-alist): * mouse-copy.el (mouse-kill-preserving-secondary): * macros.el (kbd-macro-query): * ledit.el (ledit-go-to-lisp, ledit-go-to-liszt): * informat.el (batch-info-validate): * ido.el (ido-copy-current-word, ido-initiate-auto-merge): * hippie-exp.el (try-expand-dabbrev-visible): * help-mode.el (help-make-xrefs): * help-fns.el (describe-variable): * generic-x.el (bat-generic-mode-run-as-comint): * finder.el (finder-mouse-select): * find-dired.el (find-dired-sentinel): * filesets.el (filesets-file-close): * files.el (list-directory): * faces.el (list-faces-display, describe-face): * facemenu.el (list-colors-display): * ezimage.el (ezimage-image-association-dump, ezimage-image-dump): * epg.el (epg--process-filter, epg-cancel): * epa.el (epa--marked-keys, epa--select-keys, epa-display-info) (epa--read-signature-type): * emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B) (emerge-file-names): * ehelp.el (electric-helpify): * ediff.el (ediff-regions-wordwise, ediff-regions-linewise): * ediff-vers.el (rcs-ediff-view-revision): * ediff-util.el (ediff-setup): * ediff-mult.el (ediff-append-custom-diff): * ediff-diff.el (ediff-exec-process, ediff-process-sentinel) (ediff-wordify): * echistory.el (Electric-command-history-redo-expression): * dos-w32.el (find-file-not-found-set-buffer-file-coding-system): * disp-table.el (describe-display-table): * dired.el (dired-find-buffer-nocreate): * dired-aux.el (dired-rename-subdir, dired-dwim-target-directory): * dabbrev.el (dabbrev--same-major-mode-p): * chistory.el (list-command-history): * apropos.el (apropos-documentation): * allout.el (allout-obtain-passphrase): (allout-copy-exposed-to-buffer): (allout-verify-passphrase): Use with-current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 13 Nov 2009 22:19:45 +0000
parents 23a1cea22d13
children
line wrap: on
line source

#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  M.I.T. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
# 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.  It can only install one file at a time, a restriction
# shared with many OS's install programs.


# set DOITPROG to echo to test this script

# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"


# put in absolute paths if you don't have them in your path; or use env. vars.

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

transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
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
done

if [ x"$src" = x ]
then
	echo "install:	no input file specified"
	exit 1
else
	true
fi

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

	pathcomp="${pathcomp}/"
done
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 &&


exit 0