Skip to content
Snippets Groups Projects
Commit 13f8f060 authored by Jörg Sachse's avatar Jörg Sachse
Browse files

add error handling, color coded messages and shellchecked style

parent 626a97ec
No related branches found
No related tags found
No related merge requests found
build_all.sh 100644 → 100755
...@@ -19,19 +19,30 @@ ...@@ -19,19 +19,30 @@
set -o nounset # Treat unset variables as an error set -o nounset # Treat unset variables as an error
BUILD=./build RED="\\e[31m"
if [ -e ${BUILD} ]; WHITE="\\e[0m"
then ERROR="${RED}[ERROR]\t${WHITE}"
echo BUILD-dir ${BUILD} already exist, Aborting... INFO="[INFO]\t"
else
TEMP_FILE=$(mktemp) BUILD="./build"
COMBINED_FILE=${BUILD}/SLUB_mediaconch_policy_all.xml REQUIREMENTS="mktemp xsltproc" # list external required binaries here (space separated)
mkdir $BUILD
for REQUIREMENT in ${REQUIREMENTS}; do
command -v "${REQUIREMENT}" >/dev/null 2>&1 || { echo >&2 "${ERROR}${REQUIREMENT} required but not installed. Aborting."; exit 1; }
done
if [ -d ${BUILD} ]; then
echo "${INFO}BUILD-dir '${BUILD}' already exists. It will be removed and recreated for a fresh build."
rm -rf "${BUILD}" || { echo >&2 "${ERROR}Could not remove pre-existing build directory at '${BUILD}'. Aborting."; exit 1; }
fi
TEMP_FILE="$(mktemp)"
COMBINED_FILE="${BUILD}/SLUB_mediaconch_policy_all.xml"
mkdir -p "${BUILD}" || { echo >&2 "${ERROR}Could not create build directory at '${BUILD}'. Aborting."; exit 1; }
echo '<?xml version="1.0" encoding="UTF-8"?>' > "${TEMP_FILE}" echo '<?xml version="1.0" encoding="UTF-8"?>' > "${TEMP_FILE}"
echo '<policy />' >> "${TEMP_FILE}" echo '<policy />' >> "${TEMP_FILE}"
xsltproc SLUB_mediaconch_policy_all.xsl "${TEMP_FILE}" > "${COMBINED_FILE}" xsltproc "SLUB_mediaconch_policy_all.xsl" "${TEMP_FILE}" > "${COMBINED_FILE}"
rm -f "${TEMP_FILE}" rm -f "${TEMP_FILE}"
ls -lh "${COMBINED_FILE}" ls -lh "${COMBINED_FILE}"
echo "finished." echo "${INFO}finished."
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment