Blame build/install.sh

Packit 90a5c9
#!/bin/sh
Packit 90a5c9
#
Packit 90a5c9
# Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
# contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
# this work for additional information regarding copyright ownership.
Packit 90a5c9
# The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
# (the "License"); you may not use this file except in compliance with
Packit 90a5c9
# the License.  You may obtain a copy of the License at
Packit 90a5c9
#
Packit 90a5c9
#     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
#
Packit 90a5c9
# Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
# distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
# See the License for the specific language governing permissions and
Packit 90a5c9
# limitations under the License.
Packit 90a5c9
#
Packit 90a5c9
#
Packit 90a5c9
# install.sh -- install a program, script or datafile
Packit 90a5c9
#
Packit 90a5c9
# Based on `install-sh' from the X Consortium's X11R5 distribution
Packit 90a5c9
# as of 89/12/18 which is freely available.
Packit 90a5c9
# Cleaned up for Apache's Autoconf-style Interface (APACI)
Packit 90a5c9
# by Ralf S. Engelschall <rse apache.org>
Packit 90a5c9
Packit 90a5c9
#
Packit 90a5c9
#   put in absolute paths if you don't have them in your path; 
Packit 90a5c9
#   or use env. vars.
Packit 90a5c9
#
Packit 90a5c9
mvprog="${MVPROG-mv}"
Packit 90a5c9
cpprog="${CPPROG-cp}"
Packit 90a5c9
chmodprog="${CHMODPROG-chmod}"
Packit 90a5c9
chownprog="${CHOWNPROG-chown}"
Packit 90a5c9
chgrpprog="${CHGRPPROG-chgrp}"
Packit 90a5c9
stripprog="${STRIPPROG-strip}"
Packit 90a5c9
rmprog="${RMPROG-rm}"
Packit 90a5c9
Packit 90a5c9
#
Packit 90a5c9
#   parse argument line
Packit 90a5c9
#
Packit 90a5c9
instcmd="$mvprog"
Packit 90a5c9
chmodcmd=""
Packit 90a5c9
chowncmd=""
Packit 90a5c9
chgrpcmd=""
Packit 90a5c9
stripcmd=""
Packit 90a5c9
rmcmd="$rmprog -f"
Packit 90a5c9
mvcmd="$mvprog"
Packit 90a5c9
ext=""
Packit 90a5c9
src=""
Packit 90a5c9
dst=""
Packit 90a5c9
while [ "x$1" != "x" ]; do
Packit 90a5c9
    case $1 in
Packit 90a5c9
        -c) instcmd="$cpprog"
Packit 90a5c9
            shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -m) chmodcmd="$chmodprog $2"
Packit 90a5c9
            shift; shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -o) chowncmd="$chownprog $2"
Packit 90a5c9
            shift; shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -g) chgrpcmd="$chgrpprog $2"
Packit 90a5c9
            shift; shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -s) stripcmd="$stripprog"
Packit 90a5c9
            shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -S) stripcmd="$stripprog $2"
Packit 90a5c9
            shift; shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        -e) ext="$2"
Packit 90a5c9
            shift; shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
        *)  if [ "x$src" = "x" ]; then
Packit 90a5c9
                src=$1
Packit 90a5c9
            else
Packit 90a5c9
                dst=$1
Packit 90a5c9
            fi
Packit 90a5c9
            shift; continue
Packit 90a5c9
            ;;
Packit 90a5c9
    esac
Packit 90a5c9
done
Packit 90a5c9
if [ "x$src" = "x" ]; then
Packit 90a5c9
     echo "install.sh: no input file specified"
Packit 90a5c9
     exit 1
Packit 90a5c9
fi
Packit 90a5c9
if [ "x$dst" = "x" ]; then
Packit 90a5c9
     echo "install.sh: no destination specified"
Packit 90a5c9
     exit 1
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
#
Packit 90a5c9
#  If destination is a directory, append the input filename; if
Packit 90a5c9
#  your system does not like double slashes in filenames, you may
Packit 90a5c9
#  need to add some logic
Packit 90a5c9
#
Packit 90a5c9
if [ -d $dst ]; then
Packit 90a5c9
    dst="$dst/`basename $src`"
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
#  Add a possible extension (such as ".exe") to src and dst
Packit 90a5c9
src="$src$ext"
Packit 90a5c9
dst="$dst$ext"
Packit 90a5c9
Packit 90a5c9
#  Make a temp file name in the proper directory.
Packit 90a5c9
dstdir=`dirname $dst`
Packit 90a5c9
dsttmp=$dstdir/#inst.$$#
Packit 90a5c9
Packit 90a5c9
#  Move or copy the file name to the temp name
Packit 90a5c9
$instcmd $src $dsttmp
Packit 90a5c9
Packit 90a5c9
#  And set any options; do chmod last to preserve setuid bits
Packit 90a5c9
if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
Packit 90a5c9
if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
Packit 90a5c9
if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
Packit 90a5c9
if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
Packit 90a5c9
Packit 90a5c9
#  Now rename the file to the real destination.
Packit 90a5c9
$rmcmd $dst
Packit 90a5c9
$mvcmd $dsttmp $dst
Packit 90a5c9
Packit 90a5c9
exit 0
Packit 90a5c9