-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshlib-wrapper
executable file
·42 lines (35 loc) · 1.48 KB
/
shlib-wrapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
# shlib-wrapper - execute shlib utilities from dev environments
#
# This wrapper allows the execution of shlib based applications from within the
# source-code environment. I.e. the application is not installed
#
# The wrapper requires that the following exist as a minimum.
# <project>/shlib.config
# <project>/<command> -> libexec/shlib/shlib-wrapper
# <project>/libexec/<project>/<command>
# <project>/libexec/shlib/shlib
set -e
die() { echo "error: $*" >&2; exit 1; }
test -f "${0%/*}/shlib.config" || die "missing 'shlib.config'"
. "${0%/*}/shlib.config" > /dev/null 2>&1 || die "bad config 'shlib.config'"
! test -z "${project}" || die "no project defined in 'shlib.config'"
# Assign any variables after sourcing the 'shlib.config'
PROJECT_DIR="${0%/*}"
if test "${PROJECT_DIR}" = '.'; then
PROJECT_DIR="${PWD}"
fi
LIBEXEC_DIR="${PROJECT_DIR}/libexec"
progname="${0##*/}"
test -d "${LIBEXEC_DIR}/${project}" || die "missing '${LIBEXEC_DIR}/${project}'"
test -f "${LIBEXEC_DIR}/${project}/${progname}" || die "invalid script '${progname}'"
test -f "${LIBEXEC_DIR}/shlib/shlib" || die "invalid shlib @ '${LIBEXEC_DIR}/shlib'"
PATH="${LIBEXEC_DIR}/shlib:${PATH}"
export PATH
# Normal use-case in which we set the SHLIB_PATH and execute everthing in
# developer mode
# note: we destroy the old SHLIB_PATH on purpose
SHLIB_PATH="${LIBEXEC_DIR}/shlib:${LIBEXEC_DIR}/${project}"
export SHLIB_PATH
exec "${LIBEXEC_DIR}/shlib/shlib" "${LIBEXEC_DIR}/${project}/${progname}" "$@"
# vim: filetype=sh