1#! @SCRIPT_SH@ 2# $Id$ 3# 4# @WARNING@ 5# 6# HylaFAX Facsimile Software 7# 8# Copyright (c) 1990-1996 Sam Leffler 9# Copyright (c) 1991-1996 Silicon Graphics, Inc. 10# HylaFAX is a trademark of Silicon Graphics 11# 12# Permission to use, copy, modify, distribute, and sell this software and 13# its documentation for any purpose is hereby granted without fee, provided 14# that (i) the above copyright notices and this permission notice appear in 15# all copies of the software and related documentation, and (ii) the names of 16# Sam Leffler and Silicon Graphics may not be used in any advertising or 17# publicity relating to the software without the specific, prior written 18# permission of Sam Leffler and Silicon Graphics. 19# 20# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 21# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 22# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 23# 24# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 25# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 26# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 27# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 28# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 29# OF THIS SOFTWARE. 30# 31 32# 33# Warning, this file was automatically created by the HylaFAX configure script 34# 35# VERSION: @VERSION@ 36# DATE: @DATE@ 37# TARGET: @TARGET@ 38# 39 40# 41# Shell script to emulate Silicon Graphics install program. 42# We emulate the non-standard interface used by install so 43# that we can build SGI inst packages on SGI systems. Note 44# that we cannot emulate everything because we don't maintain 45# a history of installed software; thus we cannot tell when 46# configuration files have been modified and save old copies. 47# 48# NB: we don't do chown/chmod/chgrp by default; it must be 49# explicitly set on the command line. 50# 51 52# 53# install [options] files ... 54# 55# Options are: 56# 57# -o save existing target foo as OLDfoo 58# -O remove existing target foo, if it fails save as OLDfoo 59# -m mode set mode of installed target 60# -u uid set uid of installed target 61# -g gid set gid of installed target 62# -root path set ROOT directory for target pathnames 63# -dir create directories 64# -fifo create FIFO special files 65# -ln path create hard link 66# -lns path create symbolic link 67# -src path source pathname different from target 68# -f dir install files in the target directory ROOT/dir 69# -F dir like -f, but create directories that do not exist 70# -v echo actions 71# -idb stuff specify package and, optionally, do special work 72# 73preopts= 74postopts= 75SaveFirst=no 76HasSource=yes 77RemoveFirst=no 78NoUpdate=no 79Suggested=no 80Updated=no 81 82CMD="@CP@" 83SRC= 84FILES= 85DESTDIR= 86CHMOD=": @CHMOD@" 87CHOWN=": @CHOWN@ @SYSUID@:@SYSGID@" 88CHGRP=":" 89RM="@RM@ -f" 90MV="@MV@ @MV_F@" 91ECHO=@ECHO@ 92VERBOSE=":" 93STRIP="@STRIP@" 94CMP=@CMP@ 95objectExists() 96{ 97 return 1 98} 99 100TARGETS= 101while [ x"$1" != x ] 102do 103 arg=$1 104 case $arg in 105 -m) shift; CHMOD="@CHMOD@ $1";; 106 -u) shift; CHOWN="@CHOWN@ $1";; 107 -g) shift; CHGRP="@CHGRP@ $1";; 108 -o) SaveFirst=yes;; 109 -O) RemoveFirst=yes; SaveFirst=yes;; 110 -root) shift; ROOT=$1;; 111 -dir) CMD="@MKDIR@"; HasSource=no; 112 RM=":"; STRIP=":" 113 objectExists() 114 { 115 test -d $1 116 } 117 ;; 118 -fifo) CMD=@MKFIFO@; HasSource=no; 119 case $CMD in 120 *mknod) postopts="p";; 121 esac 122 STRIP=":" 123 objectExists() 124 { 125 # 126 # If -p is not supported then the right thing 127 # should still happen... 128 # 129 test -p $1 >/dev/null 2>&1 130 } 131 ;; 132 -ln) shift; CMD=@LN@; SRC="${ROOT}$1" 133 STRIP=":" 134 ;; 135 -lns) shift; CMD=@LN@; preopts="@LN_S@"; SRC="$1" 136 STRIP=":" 137 objectExists() 138 { 139 # 140 # Some systems support -h to check for a 141 # symbolic link and others -l; one should 142 # do the right thing or both should fail. 143 # 144 (test -h $1 || test -l $1) >/dev/null 2>&1 145 } 146 ;; 147 -src) shift; SRC="$1";; 148 -[fF]) shift; DESTDIR="$1/";; 149 -idb) shift; opt="$1" 150 case "$opt" in 151 *config\(update\)*) Updated=yes;; 152 *config\(suggest\)*) Suggested=yes;; 153 *config\(noupdate\)*) NoUpdate=yes;; 154 *nostrip*) STRIP=":";; 155 esac 156 ;; 157 # these are skipped/not handled 158 -new|-rawidb|-blk|-chr) shift;; 159 -v) VERBOSE=$ECHO;; 160 -*) ;; 161 *) TARGETS="$TARGETS $arg";; 162 esac 163 shift 164done 165 166# I'll assume install.sh is only used from within HylaFAX Makefiles 167ROOT_SH=`echo $0 | sed 's;/port/install.sh;;'`/root.sh 168# If we are not root we write commands to root.sh 169do_chXXX() 170{ 171# Check the user id. 172 eval `id | sed 's/[^a-z0-9=].*//'` 173 if [ "${uid:=0}" -ne 0 ] 174 then 175 echo "$*" >> ${ROOT_SH} 176 else 177 eval $* 178 fi 179} 180 181# 182# Install the specified target. 183# 184install() 185{ 186 src=$1 target=$2 187 if [ $RemoveFirst = yes ] && [ -f $target ]; then 188 $VERBOSE "$RM $target" 189 $RM $target 190 fi 191 if [ $SaveFirst = yes ] && [ -f $target ]; then 192 bf=`echo $src | @SED@ 's;.*/;;'` 193 $VERBOSE "$MV $target $ROOT/$DESTDIR/OLD$bf" 194 $MV $target $ROOT/$DESTDIR/OLD$bf 195 fi 196 if [ -z "$SRC" ] && [ $HasSource = yes ]; then 197 $VERBOSE "$CMD $preopts $src $target $postopts" 198 $CMD $preopts $f $target $postopts 199 elif [ $SaveFirst = no ] && objectExists $target; then 200 $VERBOSE "$target exists; not remade" 201 else 202 $VERBOSE "$CMD $preopts $SRC $target $postopts" 203 $CMD $preopts $SRC $target $postopts 204 fi 205 if [ $? -eq 0 ]; then 206 $VERBOSE "$CHOWN $target" 207 do_chXXX $CHOWN $target 208 if [ "$CHGRP" != ":" ]; then 209 $VERBOSE "$CHGRP $target" 210 do_chXXX $CHGRP $target 211 fi 212 $VERBOSE "$CHMOD $target" 213 do_chXXX $CHMOD $target 214 if [ $STRIP != ":" ] && [ -x $ROOT$DESTDIR$f ]; then 215 $STRIP $target >/dev/null 2>&1 || true 216 $VERBOSE "$STRIP $target" 217 fi 218 fi 219} 220 221if [ $Suggested = yes ]; then 222 # 223 # A suggested file. If an existing target does 224 # not exist, then install it. Otherwise, install 225 # it as target.N if it's different from the current 226 # installed target. 227 # 228 # NB: cannot be used with a special file 'cuz we 229 # use test -f to see if the file exists. 230 # 231 for f in $TARGETS; do 232 t=$ROOT$DESTDIR$f 233 if [ -f $t ]; then 234 if [ -z "$SRC" ] && [ $HasSource = yes ]; then 235 $CMP -s $f $t || { 236 $ECHO "*** Warning, target has local changes, installing $f as $t.N" 237 install $f $t.N; 238 } 239 else 240 $CMP -s $SRC $t || { 241 $ECHO "*** Warning, target has local changes, installing $f as $t.N" 242 install $f $t.N 243 } 244 fi 245 else 246 install $f $t 247 fi 248 done 249elif [ $Updated = yes ]; then 250 # 251 # A file to be updated. If an existing target does 252 # not exist, then install it. Otherwise, install 253 # it as target and save the old version as target.O 254 # if the old version is different from the current 255 # installed target. 256 # 257 # NB: cannot be used with a special file 'cuz we 258 # use test -f to see if the file exists. 259 # 260 for f in $TARGETS; do 261 t=$ROOT$DESTDIR$f 262 if [ -f $t ]; then 263 if [ -z "$SRC" ] && [ $HasSource = yes ]; then 264 $CMP -s $f $t || $MV $t $t.O 265 else 266 $CMP -s $SRC $t || $MV $t $t.O 267 fi 268 fi 269 install $f $t 270 done 271elif [ $NoUpdate = yes ]; then 272 # 273 # A file that is never to be updated; the target 274 # is created only if it does not exist. 275 # 276 # NB: cannot be used with a special file 'cuz we 277 # use test -f to see if the file exists. 278 # 279 for f in $TARGETS; do 280 t=$ROOT$DESTDIR$f 281 test -f $t || install $f $t 282 done 283else 284 # 285 # Normal case, a target that should be installed 286 # with the existing copy, optionally, saved first. 287 # 288 for f in $TARGETS; do 289 install $f $ROOT$DESTDIR$f 290 done 291fi 292