1#!/bin/sh 2# 3# Licensed to the Apache Software Foundation (ASF) under one or more 4# contributor license agreements. See the NOTICE file distributed with 5# this work for additional information regarding copyright ownership. 6# The ASF licenses this file to You under the Apache License, Version 2.0 7# (the "License"); you may not use this file except in compliance with 8# the License. You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18## 19## install.sh -- install a program, script or datafile 20## 21## Based on `install-sh' from the X Consortium's X11R5 distribution 22## as of 89/12/18 which is freely available. 23## Cleaned up for Apache's Autoconf-style Interface (APACI) 24## by Ralf S. Engelschall <rse@apache.org> 25## 26# 27# This script falls under the Apache License. 28# See http://www.apache.org/docs/LICENSE 29 30 31# 32# put in absolute paths if you don't have them in your path; 33# or use env. vars. 34# 35mvprog="${MVPROG-mv}" 36cpprog="${CPPROG-cp}" 37chmodprog="${CHMODPROG-chmod}" 38chownprog="${CHOWNPROG-chown}" 39chgrpprog="${CHGRPPROG-chgrp}" 40stripprog="${STRIPPROG-strip}" 41rmprog="${RMPROG-rm}" 42 43# 44# parse argument line 45# 46instcmd="$mvprog" 47chmodcmd="" 48chowncmd="" 49chgrpcmd="" 50stripcmd="" 51rmcmd="$rmprog -f" 52mvcmd="$mvprog" 53ext="" 54src="" 55dst="" 56while [ "x$1" != "x" ]; do 57 case $1 in 58 -c) instcmd="$cpprog" 59 shift; continue 60 ;; 61 -m) chmodcmd="$chmodprog $2" 62 shift; shift; continue 63 ;; 64 -o) chowncmd="$chownprog $2" 65 shift; shift; continue 66 ;; 67 -g) chgrpcmd="$chgrpprog $2" 68 shift; shift; continue 69 ;; 70 -s) stripcmd="$stripprog" 71 shift; continue 72 ;; 73 -S) stripcmd="$stripprog $2" 74 shift; shift; continue 75 ;; 76 -e) ext="$2" 77 shift; shift; continue 78 ;; 79 *) if [ "x$src" = "x" ]; then 80 src=$1 81 else 82 dst=$1 83 fi 84 shift; continue 85 ;; 86 esac 87done 88if [ "x$src" = "x" ]; then 89 echo "install.sh: no input file specified" 90 exit 1 91fi 92if [ "x$dst" = "x" ]; then 93 echo "install.sh: no destination specified" 94 exit 1 95fi 96 97# 98# If destination is a directory, append the input filename; if 99# your system does not like double slashes in filenames, you may 100# need to add some logic 101# 102if [ -d $dst ]; then 103 dst="$dst/`basename $src`" 104fi 105 106# Add a possible extension (such as ".exe") to src and dst 107src="$src$ext" 108dst="$dst$ext" 109 110# Make a temp file name in the proper directory. 111dstdir=`dirname $dst` 112dsttmp=$dstdir/#inst.$$# 113 114# Move or copy the file name to the temp name 115$instcmd $src $dsttmp 116 117# And set any options; do chmod last to preserve setuid bits 118if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi 119if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi 120if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi 121if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi 122 123# Now rename the file to the real destination. 124$rmcmd $dst 125$mvcmd $dsttmp $dst 126 127exit 0 128 129