#!/bin/ksh # $Id: install.sh.in,v 1.6 2003/09/23 18:09:33 jmmv Exp $ # Install files and directories (internal script). # # Copyright (c) 2003 Julio M. Merino Vidal. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of the author nor the names of contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # TYPE, GRP and OWN are always handled by configure. : ${BIN_MODE:=555} : ${DATA_MODE:=644} : ${DIR_MODE:=755} install_files() { msg="$1"; shift mode="$1"; shift if [ $# -eq 2 ]; then if [ -d $2 ]; then target="$2/`basename $1`" # NOLINT else target="$2" fi echo "installing ${msg} file ${target}..." [ -f ${target} ] && rm -f ${target} cp $1 ${target} chmod ${mode} ${target} [ -n "${OWN}" ] && chown ${OWN} ${target} [ -n "${GRP}" ] && chgrp ${GRP} ${target} return fi files= while [ $# -gt 1 ]; do files="${files} $1" shift done dir="$1" for f in ${files}; do target="${dir}/`basename ${f}`" # NOLINT echo "installing ${msg} file ${target}..." if [ -f ${target} ]; then rm -f ${target} fi cp ${f} ${target} chmod ${mode} ${target} [ -n "${OWN}" ] && chown ${OWN} ${target} [ -n "${GRP}" ] && chgrp ${GRP} ${target} done } case "${TYPE}" in bin) install_files binary ${BIN_MODE} $* ;; data) install_files data ${DATA_MODE} $* ;; dir) if [ ! -d $1 ]; then echo "creating directory $1..." mkdir -p $1 chmod ${DIR_MODE} $1 [ -n "${OWN}" ] && chown ${OWN} $1 [ -n "${GRP}" ] && chgrp ${GRP} $1 fi ;; esac exit 0 # Local Variables: *** # mode: shell-script *** # End: *** # vim: syntax=sh