/usr/bin/ui-auto-env is in ui-auto 1.1.17-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | #!/bin/bash -e
SUPPORTED_EXPORTS="PATH LD_LIBRARY_PATH CFLAGS CXXFLAGS LDFLAGS ACLOCAL"
SUPPORTED_SHELLS="posix"
PATH="${PATH}:$(dirname $0):/usr/local/share/ui-auto:/usr/share/ui-auto"
. ui-libopt.sh
ui_opt_init "Produce shell code to taint the environment to use
ui-auto enabled projects."
ui_opt_add "d" "Also run for the project's dependencies."
ui_opt_add "p" "Also set the path of the project as cwd."
ui_opt_add "D" "Only run for the project's dependencies."
ui_opt_add "I" "Information on a project's configuration in '~/.ui-auto.conf'."
ui_opt_add "E:" "Exports to produce, given as space-separated list." "${SUPPORTED_EXPORTS}" "" "\
Supported='${SUPPORTED_EXPORTS}'."
ui_opt_add "S:" "Shell syntax to use. Supported: ${SUPPORTED_SHELLS}." "posix"
ui_opt_addPos "ID" "A project id as configured in '~/.ui-auto.conf'."
ui_opt_parse "$@"
checkCall()
{
for e in ${EXPORTS}; do
local ok=false
for s in ${SUPPORTED_EXPORTS}; do
if test "${e}" = "${s}"; then
ok=true
break;
fi
done
if ! ${ok}; then
ui_opt_error "Unsupported export: ${e}" HELP
fi
done
if test ! -e "${PROJECT_CONF}"; then
ui_opt_error "${PROJECT_CONF} not found"
fi
}
iset()
{
eval $1="\${2}"
}
addItem()
{
local var="${1}"
local item="${2}"
local sep=$(test -z "${!var}" -o -z "${item}" || echo -n "${3}")
local append="${4}"
local eregex="(^|[${sep}])${item}($|[${sep}])"
if echo -n "${!var}" | egrep --quiet -e "${eregex}"; then
echo "NOTE: \"${item}\" already included in $var, skipping." >&2
else
if test "${append}" = "append"; then
iset $var "${!var}${sep}${item}"
else
iset $var "${item}${sep}${!var}"
fi
fi
}
calcEnv()
{
for f in ${ui_env_library_paths}; do
addItem LD_LIBRARY_PATH "${PROJECT_PATH}/${f}" ":"
addItem LDFLAGS "-L${PROJECT_PATH}/${f}" " "
done
for f in ${ui_env_include_paths}; do
addItem CFLAGS "-I${PROJECT_PATH}/${f}" " "
addItem CXXFLAGS "-I${PROJECT_PATH}/${f}" " "
done
for f in ${ui_env_program_paths}; do
addItem PATH "${PROJECT_PATH}/${f}" ":"
done
if test "${ui_env_m4_macro_paths}" -a "x$ACLOCAL" = "x"; then
iset ACLOCAL "aclocal"
fi
for f in ${ui_env_m4_macro_paths}; do
addItem ACLOCAL "-I${PROJECT_PATH}/${f}" " " append
done
}
serialCall()
{
local list="${1}"
tmp=$(mktemp /tmp/ui-auto-env.XXXXXX)
trap "rm -f ${tmp}" EXIT
for p in ${list}; do
${0} "${p}" >"${tmp}"
eval $(cat ${tmp})
done
cat "${tmp}"
}
# Processing starts here
if ! . ~/.ui-auto.conf; then
ui_opt_error " Syntax wrong (or no) ~/.ui-auto.conf file; please configure first"
fi
ID=$(ui_opt_getPos 0 | tr "-" "_")
ID_LOC="${ID}_loc"
if [ -z "${!ID_LOC}" ]; then
echo -e "ID $ID not configured in ~/.ui-auto.conf.\n" >&2
exit 1
fi
ID_DEPS="${ID}_deps"
if ui_opt_given p; then
echo "cd \"${!ID_LOC}\";"
fi
if ui_opt_given C; then
# Check project only
echo "Project : ${ID}"
echo "Location : ${!ID_LOC}"
echo "Dependencies: ${!ID_DEPS}"
exit 0
elif ui_opt_given d; then
serialCall "${!ID_DEPS} ${ID}"
exit 0
elif ui_opt_given D; then
serialCall "${!ID_DEPS}"
exit 0
fi
# Single run
cd "${!ID_LOC}"
PROJECT_PATH="$(pwd)"
PROJECT_CONF="${PROJECT_PATH}/.ui-auto.conf"
EXPORTS=$(ui_opt_get E)
SHELL=$(ui_opt_get S)
checkCall
. "${PROJECT_CONF}"
calcEnv
for e in ${EXPORTS}; do
case ${SHELL} in
posix)
if test "${!e}"; then
echo "${e}=\"${!e}\"; export ${e};"
fi
;;
*)
ui_opt_error "Unsupported shell: ${SHELL}" HELP
esac
done
exit 0
|