asterisk/build_tools/install_subst
Tzafrir Cohen 199c7de764 install_subst: helper script for installing with path substitution
A helper script to copy a source file substituting any
__ASTERISK_<foo>_DIR__ with the content of $AST<foo>DIR.

Review: https://reviewboard.asterisk.org/r/3202/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408059 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-14 08:52:07 +00:00

44 lines
979 B
Bash
Executable file

#!/bin/sh
# install_subst: install a script while doing path substitution
# install_subst [-d] source destination
#
# -d: file is data (rather than script)
install_args=
if [ "$1" = '-d' ]; then
install_args="-m 644"
shift
fi
set -e
tmp=`mktemp install_subst_XXXXXX`
cleanup_tmp() {
rm -f "$tmp"
}
# Delete it on exit
trap cleanup_tmp 0
src="$1"
dst="$2"
sed <"$src" \
-e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \
-e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \
-e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \
-e "s|__ASTERISK_HEADER_DIR__|$ASTHEADERDIR|g" \
-e "s|__ASTERISK_LIB_DIR__|$ASTLIBDIR|g" \
-e "s|__ASTERISK_LOG_DIR__|$ASTLOGDIR|g" \
-e "s|__ASTERISK_MOD_DIR__|$ASTMODDIR|g" \
-e "s|__ASTERISK_MAN_DIR__|$ASTMANDIR|g" \
-e "s|__ASTERISK_SBIN_DIR__|$ASTSBINDIR|g" \
-e "s|__ASTERISK_SPOOL_DIR__|$ASTSPOOLDIR|g" \
-e "s|__ASTERISK_VARLIB_DIR__|$ASTVARLIBDIR|g" \
-e "s|__ASTERISK_VARRUN_DIR__|$ASTVARRUNDIR|g" \
> "$tmp"
install $install_args "$tmp" "$dst"