summaryrefslogtreecommitdiff
path: root/build_tools
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2014-02-14 08:52:07 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2014-02-14 08:52:07 +0000
commit199c7de764d0d6b9acb3b6f3e990f8923c14ca02 (patch)
tree447bddd48ef41cabfdd4ea2cc3d05ce8ce486744 /build_tools
parent584f9bafa0bddef3862cbe08412082a2f0d3db4f (diff)
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
Diffstat (limited to 'build_tools')
-rwxr-xr-xbuild_tools/install_subst43
1 files changed, 43 insertions, 0 deletions
diff --git a/build_tools/install_subst b/build_tools/install_subst
new file mode 100755
index 000000000..5b5407aa8
--- /dev/null
+++ b/build_tools/install_subst
@@ -0,0 +1,43 @@
+#!/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"