From aa90c0c5dd8236025f1b778391bac60779aa0614 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Mon, 5 Apr 2021 20:54:52 -0500 Subject: Add a block to exit if package does not exist in packages.csv. --- packageinstall.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packageinstall.sh b/packageinstall.sh index a277e6c..88876ac 100644 --- a/packageinstall.sh +++ b/packageinstall.sh @@ -3,16 +3,24 @@ CHAPTER="$1" PACKAGE="$2" +if ! grep "^${PACKAGE}" packages.csv; then + printf "%b" " ${IRED}PACKAGE ${IYLW}${PACKAGE} ${IRED}DOES NOT EXIST!${RST}\n" + exit 1 +fi + if [[ -f "${LFS}/sources/chapter${CHAPTER}/${PACKAGE}" ]]; then printf "%b" "${GRN}Package ${YLW}${PACKAGE} ${GRN}already built and installed${RST}\n" else grep -i "^${PACKAGE}" packages.csv | grep -i -v "\.patch;" | while read -r line; do - VERSION="$(echo "$line" | cut -d\, -f2)" - URL="$(echo "$line" | cut -d\, -f3 | sed "s/@/${VERSION}/g")" + VERSION="$(echo "${line}" | cut -d\, -f2)" + URL="$(echo "${line}" | cut -d\, -f3 | sed "s/@/${VERSION}/g")" CACHEFILE="$(basename "${URL}")" DIRNAME="$(tar -tf "${CACHEFILE}" | sed -e 's@/.*@@' | uniq)" + echo $NAME + exit 1 + # Remove existing if exists rm -rf "${DIRNAME}" @@ -48,4 +56,5 @@ else popd > /dev/null || return 1 done + fi -- cgit v1.2.3-54-g00ecf