Commit 0fb051b2 authored by intrigeri's avatar intrigeri

auto/config: consistently use fatal() to error out.

We're using fatal() in many places in this script already, but not everywhere.
As a result, some error messages were printed to STDOUT while some others went
to STDERR. Let's be consistent.
parent 211f15af
......@@ -9,8 +9,7 @@ set -x
# we require building from git
if ! git rev-parse --is-inside-work-tree; then
echo "${PWD} is not a Git tree. Exiting."
exit 1
fatal "${PWD} is not a Git tree. Exiting."
fi
. config/amnesia
......@@ -21,12 +20,10 @@ fi
if [ -n "${SOURCE_DATE_EPOCH}" ]; then
CURRENT_EPOCH="$(date --utc +%s)"
if [ "${SOURCE_DATE_EPOCH}" -gt "${CURRENT_EPOCH}" ]; then
echo "SOURCE_DATE_EPOCH is set before the current time. Exiting."
exit 1
fatal "SOURCE_DATE_EPOCH is set before the current time. Exiting."
fi
else
echo "SOURCE_DATE_EPOCH is not set. Exiting."
exit 1
fatal "SOURCE_DATE_EPOCH is not set. Exiting."
fi
# get git branch or tag so we can set the basename appropriately, i.e.:
......@@ -78,19 +75,16 @@ echo "BUILD_BASENAME='${BUILD_BASENAME}'" > tmp/build_environment
# sanity checks
if grep -qs -E '^Pin:\s+release\s+.*a=' config/chroot_apt/preferences ; then
echo "Found unsupported a= syntax in config/chroot_apt/preferences,"
echo "use n= instead. Exiting."
exit 1
fatal "Found unsupported a= syntax in config/chroot_apt/preferences," \
"use n= instead. Exiting."
fi
if grep -qs -E '^Pin:\s+release\s+.*o=Debian Backports' \
config/chroot_apt/preferences ; then
echo "Found unsupported 'o=Debian Backports' syntax,"
echo "in config/chroot_apt/preferences. Use o=Debian instead. Exiting."
exit 1
fatal "Found unsupported 'o=Debian Backports' syntax," \
"in config/chroot_apt/preferences. Use o=Debian instead. Exiting."
fi
if [ $(dpkg --print-architecture) != amd64 ] ; then
echo "Only amd64 build systems are supported"
exit 1
fatal "Only amd64 build systems are supported"
fi
# init variables
......@@ -118,16 +112,16 @@ DEBIAN_MIRROR="$(apt-mirror debian)"
DEBIAN_SECURITY_MIRROR="$(apt-mirror debian-security)"
TORPROJECT_MIRROR="$(apt-mirror torproject)"
[ -n "$DEBIAN_MIRROR" ] || exit 1
[ -n "$DEBIAN_SECURITY_MIRROR" ] || exit 1
[ -n "$TORPROJECT_MIRROR" ] || exit 1
[ -n "$DEBIAN_MIRROR" ] || fatal "\$DEBIAN_MIRROR is empty"
[ -n "$DEBIAN_SECURITY_MIRROR" ] || fatal "\$DEBIAN_SECURITY_MIRROR is empty"
[ -n "$TORPROJECT_MIRROR" ] || fatal "\$TORPROJECT_MIRROR is empty"
perl -pi \
-E \
"s|^(deb(?:-src)?\s+)https?://ftp[.]us[.]debian[.]org/debian/?(\s+)|\$1$DEBIAN_MIRROR\$2| ; \
s|^(deb(?:-src)?\s+)https?://deb[.]torproject[.]org/torproject[.]org/?(\s+)|\$1$TORPROJECT_MIRROR\$2|" \
config/chroot_sources/*.chroot \
|| exit 1
|| fatal "APT mirror substitution failed with exit code $?"
# set Amnesia's general options
$RUN_LB_CONFIG \
......@@ -170,7 +164,8 @@ install -d config/chroot_local-includes/etc/amnesia/
# environment
TAILS_WIKI_SUPPORTED_LANGUAGES="$(ikiwiki-supported-languages ikiwiki.setup)"
[ -n "$TAILS_WIKI_SUPPORTED_LANGUAGES" ] || exit 16
[ -n "$TAILS_WIKI_SUPPORTED_LANGUAGES" ] \
|| fatal "\$TAILS_WIKI_SUPPORTED_LANGUAGES is empty"
echo "TAILS_WIKI_SUPPORTED_LANGUAGES='${TAILS_WIKI_SUPPORTED_LANGUAGES}'" \
>> config/chroot_local-includes/etc/amnesia/environment
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment