Loop Over AWL Directory Candidates

Using this method we're able to loop over the candidate directories
until we find what should be suitable AWL location. Further, adding
additional locations is as simple as adding a new line to ${awldirs}.

It does have the limitation that if the path has a new line in it
(/some/ridic
ulous/path), it'll treat it as two different paths. However, if
somebody seriously has that, they deserve the pain.
This commit is contained in:
Aaron W. Swenson 2014-11-14 13:44:39 -05:00
parent ccfff62118
commit cfd5fd7555
2 changed files with 43 additions and 23 deletions

View File

@ -10,23 +10,30 @@ DBADIR="`dirname \"$0\"`"
INSTALL_NOTE_FN="`mktemp -t tmp.XXXXXXXXXX`" INSTALL_NOTE_FN="`mktemp -t tmp.XXXXXXXXXX`"
testawldir() {
[ -f "${1}/dba/awl-tables.sql" ]
}
# # Candidate locations of the AWL directory
# Attempt to locate the AWL directory awldirs="${DBADIR}/../../awl
AWLDIR="${DBADIR}/../../awl" /usr/share/awl
if ! testawldir "${AWLDIR}"; then /usr/share/php/awl
AWLDIR="/usr/share/awl" /usr/local/share/awl"
if ! testawldir "${AWLDIR}"; then
AWLDIR="/usr/local/share/awl" # Disable globbing and use newline as seperator
if ! testawldir "${AWLDIR}"; then set -f; IFS='
'
for d in $awldirs ; do
if [ -f "${d}/dba/awl-tables.sql" ] ; then
AWLDIR="${d}"
break
fi
done
# Renable file globbing and reset seperator
set +f; unset IFS
if [ -z "${AWLDIR}" ] ; then
echo "Unable to find AWL libraries" echo "Unable to find AWL libraries"
exit 1 exit 1
fi fi
fi
fi
export AWL_DBAUSER=davical_dba export AWL_DBAUSER=davical_dba
export AWL_APPUSER=davical_app export AWL_APPUSER=davical_app

View File

@ -10,18 +10,31 @@
PODIR="po" PODIR="po"
LOCALEDIR="locale" LOCALEDIR="locale"
APPLICATION="davical" APPLICATION="davical"
AWL_LOCATION="../awl"
if [ ! -d "${AWL_LOCATION}" ]; then awldirs="../awl
AWL_LOCATION="`find .. -type d -name 'awl-*.*'`" `find .. -type d -name 'awl-*.*'`
if [ ! -d "${AWL_LOCATION}" ]; then /usr/share/awl
AWL_LOCATION=/usr/share/awl /usr/share/php/awl
if [ ! -d "${AWL_LOCATION}" ]; then /usr/local/share/awl"
# Disable globbing and use newline as seperator
set -f; IFS='
'
for d in $awldirs ; do
if [ -d "${d}" ] ; then
AWL_LOCATION="${d}"
break
fi
done
# Renable file globbing and reset seperator
set +f; unset IFS
if [ -z "${AWL_LOCATION}" ] ; then
echo "I can't find a location for the AWL libraries and I need those strings too" echo "I can't find a location for the AWL libraries and I need those strings too"
exit 1 exit 1
fi fi
fi
fi
egrep -l '(i18n|translate)' htdocs/*.php inc/*.php inc/ui/*.php > ${PODIR}/pofilelist.tmp1 egrep -l '(i18n|translate)' htdocs/*.php inc/*.php inc/ui/*.php > ${PODIR}/pofilelist.tmp1
sed "s:../awl:${AWL_LOCATION}:" ${PODIR}/pofilelist.txt >> ${PODIR}/pofilelist.tmp1 sed "s:../awl:${AWL_LOCATION}:" ${PODIR}/pofilelist.txt >> ${PODIR}/pofilelist.tmp1