From b76dba93996c97a97548ebc96e99fe75c99ed3ba Mon Sep 17 00:00:00 2001 From: bill-auger Date: Mon, 16 Oct 2017 21:44:34 -0400 Subject: add sanity checks --- configs/profile/build.sh | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/configs/profile/build.sh b/configs/profile/build.sh index b882d39..bffb518 100755 --- a/configs/profile/build.sh +++ b/configs/profile/build.sh @@ -231,15 +231,10 @@ make_iso() { mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} -L ${iso_label} -o ${out_dir} iso ${iso_filename} } -if [[ ${EUID} -ne 0 ]]; then - echo "This script must be run as root." - _usage 1 -fi -if [[ ${arch} != x86_64 ]]; then - echo "This script needs to be run on x86_64" - _usage 1 -fi +## prepare state ## + +# set CLI options while getopts 'V:L:D:w:o:vh' arg; do case "${arg}" in @@ -258,6 +253,24 @@ while getopts 'V:L:D:w:o:vh' arg; do done +## sanity checks ## + +# validate build environment +if [[ "$(uname -m)" != 'x86_64' ]] || ! grep 'ID_LIKE=.*archlinux' /usr/lib/os-release > /dev/null; then + echo "This script needs to be run on an x86_64 ArchLinux derrivative." + exit 1 +elif [[ ${EUID} -ne 0 ]]; then + echo "This script needs to be run with root privileges." + exit 1 +elif ! pacman --version | grep libalpm > /dev/null; then + echo "This script needs the 'pacman' package manager to be installed." + exit 1 +elif ! pacman -Qi parabolaiso-data > /dev/null; then + echo "This script needs the 'parabolaiso-data' package to be installed." + exit 1 +fi + +# sanitize paths iso_label=${iso_label// /} iso_dirname=${iso_dirname// /} work_dir=${work_dir// /} @@ -267,6 +280,8 @@ iso_title="${iso_title} ${iso_version}" iso_filename="parabola-${iso_edition}-${iso_type}-${iso_version}.iso" +## build ISO ## + chown -R 0:0 "${releng_dir}/root-image/" mkdir -p ${work_dir} -- cgit v1.2.2