1386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari#!/bin/sh 2386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# 3386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# install - install a program, script, or datafile 4386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# This comes from X11R5 (mit/util/scripts/install.sh). 5386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# 6386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Copyright 1991 by the Massachusetts Institute of Technology 7386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# 8386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Permission to use, copy, modify, distribute, and sell this software and its 9386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# documentation for any purpose is hereby granted without fee, provided that 10386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# the above copyright notice appear in all copies and that both that 11386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# copyright notice and this permission notice appear in supporting 12386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# documentation, and that the name of M.I.T. not be used in advertising or 13386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# publicity pertaining to distribution of the software without specific, 14386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# written prior permission. M.I.T. makes no representations about the 15386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# suitability of this software for any purpose. It is provided "as is" 16386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# without express or implied warranty. 17386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# 18386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Calling this script install-sh is preferred over install.sh, to prevent 19386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# `make' implicit rules from creating a file called install from it 20386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# when there is no Makefile. 21386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# 22386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# This script is compatible with the BSD install script, but was written 23386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# from scratch. It can only install one file at a time, a restriction 24386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# shared with many OS's install programs. 25386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 26386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 27386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# set DOITPROG to echo to test this script 28386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 29386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Don't use :- since 4.3BSD and earlier shells don't like it. 30386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridoit="${DOITPROG-}" 31386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 32386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 33386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# put in absolute paths if you don't have them in your path; or use env. vars. 34386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 35386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarimvprog="${MVPROG-mv}" 36386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaricpprog="${CPPROG-cp}" 37386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichmodprog="${CHMODPROG-chmod}" 38386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichownprog="${CHOWNPROG-chown}" 39386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichgrpprog="${CHGRPPROG-chgrp}" 40386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaristripprog="${STRIPPROG-strip}" 41386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarirmprog="${RMPROG-rm}" 42386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarimkdirprog="${MKDIRPROG-mkdir}" 43386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 44386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaritransformbasename="" 45386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaritransform_arg="" 46386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariinstcmd="$mvprog" 47386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichmodcmd="$chmodprog 0755" 48386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichowncmd="" 49386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarichgrpcmd="" 50386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaristripcmd="" 51386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarirmcmd="$rmprog -f" 52386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarimvcmd="$mvprog" 53386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarisrc="" 54386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridst="" 55386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridir_arg="" 56386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 57386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariwhile [ x"$1" != x ]; do 58386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari case $1 in 59386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -c) instcmd="$cpprog" 60386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 61386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 62386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 63386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -d) dir_arg=true 64386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 65386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 66386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 67386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -m) chmodcmd="$chmodprog $2" 68386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 69386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 70386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 71386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 72386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -o) chowncmd="$chownprog $2" 73386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 74386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 75386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 76386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 77386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -g) chgrpcmd="$chgrpprog $2" 78386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 79386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 80386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 81386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 82386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -s) stripcmd="$stripprog" 83386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 84386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 85386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 86386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 88386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 89386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 90386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 92386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 93386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 94386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari *) if [ x"$src" = x ] 95386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 96386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari src=$1 97386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 98386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari # this colon is to work around a 386BSD /bin/sh bug 99386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari : 100386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dst=$1 101386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 102386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 103386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari continue;; 104386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari esac 105386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridone 106386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 107386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariif [ x"$src" = x ] 108386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarithen 109386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari echo "install: no input file specified" 110386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari exit 1 111386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarielse 112386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 113386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarifi 114386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 115386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariif [ x"$dir_arg" != x ]; then 116386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dst=$src 117386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari src="" 118386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 119386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ -d $dst ]; then 120386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari instcmd=: 121386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari chmodcmd="" 122386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 123386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari instcmd=mkdir 124386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 125386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarielse 126386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 127386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# might cause directories to be created, which would be especially bad 129386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# if $src (and thus $dsttmp) contains '*'. 130386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 131386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ -f $src -o -d $src ] 132386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 133386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 134386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 135386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari echo "install: $src does not exist" 136386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari exit 1 137386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 138386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 139386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$dst" = x ] 140386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 141386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari echo "install: no destination specified" 142386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari exit 1 143386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 144386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 145386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 146386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 147386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# If destination is a directory, append the input filename; if your system 148386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# does not like double slashes in filenames, you may need to add some logic 149386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 150386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ -d $dst ] 151386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 152386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dst="$dst"/`basename $src` 153386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 154386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 155386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 156386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarifi 157386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 158386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari## this sed command emulates the dirname command 159386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 161386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Make sure that the destination directory exists. 162386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# this part is taken from Noah Friedman's mkinstalldirs script 163386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 164386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Skip lots of stat calls in the usual case. 165386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariif [ ! -d "$dstdir" ]; then 166386ce4d9144fc190797f4e43a31aeaf76ca2e373Param ReddappagaridefaultIFS=' 167386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari' 168386ce4d9144fc190797f4e43a31aeaf76ca2e373Param ReddappagariIFS="${IFS-${defaultIFS}}" 169386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 170386ce4d9144fc190797f4e43a31aeaf76ca2e373Param ReddappagarioIFS="${IFS}" 171386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Some sh's can't handle IFS=/ for some reason. 172386ce4d9144fc190797f4e43a31aeaf76ca2e373Param ReddappagariIFS='%' 173386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariset - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174386ce4d9144fc190797f4e43a31aeaf76ca2e373Param ReddappagariIFS="${oIFS}" 175386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 176386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaripathcomp='' 177386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 178386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariwhile [ $# -ne 0 ] ; do 179386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari pathcomp="${pathcomp}${1}" 180386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari shift 181386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 182386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ ! -d "${pathcomp}" ] ; 183386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 184386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari $mkdirprog "${pathcomp}" 185386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 186386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 187386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 188386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 189386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari pathcomp="${pathcomp}/" 190386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagaridone 191386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarifi 192386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 193386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariif [ x"$dir_arg" != x ] 194386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarithen 195386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari $doit $instcmd $dst && 196386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 197386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarielse 202386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 203386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# If we're going to rename the final executable, determine the name now. 204386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 205386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$transformarg" = x ] 206386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 207386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dstfile=`basename $dst` 208386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 209386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dstfile=`basename $dst $transformbasename | 210386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari sed $transformarg`$transformbasename 211386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 212386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 213386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# don't allow the sed command to completely eliminate the filename 214386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 215386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$dstfile" = x ] 216386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari then 217386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dstfile=`basename $dst` 218386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari else 219386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari true 220386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari fi 221386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 222386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Make a temp file name in the proper directory. 223386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 224386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari dsttmp=$dstdir/#inst.$$# 225386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 226386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Move or copy the file name to the temp name 227386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 228386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari $doit $instcmd $src $dsttmp && 229386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 230386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari trap "rm -f ${dsttmp}" 0 && 231386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 232386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# and set any options; do chmod last to preserve setuid bits 233386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 234386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# If any of these fail, we abort the whole thing. If we want to 235386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# ignore errors from any of these, just make sure not to ignore 236386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# errors from the above "$doit $instcmd $src $dsttmp" command. 237386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 238386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 243386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari# Now rename the file to the real destination. 244386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 245386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari $doit $rmcmd -f $dstdir/$dstfile && 246386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari $doit $mvcmd $dsttmp $dstdir/$dstfile 247386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 248386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagarifi && 249386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 250386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagari 251386ce4d9144fc190797f4e43a31aeaf76ca2e373Param Reddappagariexit 0 252