diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-12-11 00:52:08 -0600 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-12-11 00:52:08 -0600 |
commit | 2c8204d6325a1a6607392d5905227b9043da17cc (patch) | |
tree | 5a2d9047d0a3fb5664c17284b92c6e572507d062 /packageinstall.sh | |
parent | f699702e72de8200632cfb95350ad51bb68c4b6f (diff) |
Major updates.
Diffstat (limited to 'packageinstall.sh')
-rw-r--r-- | packageinstall.sh | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/packageinstall.sh b/packageinstall.sh index e0516db..12a4999 100644 --- a/packageinstall.sh +++ b/packageinstall.sh @@ -1,59 +1,59 @@ -#!/bin/bash - -CHAPTER="$1" -PACKAGE="$2" - -if ! grep -q "^${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")" - CACHEFILE="$(basename "${URL}")" - DIRNAME="$(tar -tf "${CACHEFILE}" | sed -e 's@/.*@@' | uniq)" - - # Remove existing if exists - rm -rf "${DIRNAME}" - - printf "%b" "${IBLU}Extracting ${YLW}${CACHEFILE}${RST}... " - tar xf "${CACHEFILE}" > /dev/null 2>&1 & pid=$! - spinner "$pid" "${SPINNER}" - retval=$? - if [[ "$retval" -ne 0 ]]; then - printf "%b" "${GRN}Extraction " - fail "FAILED!" - return $retval - else - success "OK" - fi - - pushd "${DIRNAME}" > /dev/null || return 1 - - printf "%b" " ${CYN}Compiling ${YLW}${PACKAGE}${RST}... " - - mkdir -p "${LFS}/sources/log/chapter${CHAPTER}/" - # shellcheck source=/dev/null - source "${LFS}/sources/chapter${CHAPTER}/${PACKAGE}.sh" 2>&1 > "${LFS}/sources/log/chapter${CHAPTER}/${PACKAGE}.log" 2>&1 & pid=$! - spinner "$pid" "${SPINNER}" - retval=$? - if [[ "$retval" -ne 0 ]]; then - fail "FAILED!" - popd > /dev/null || return 1 - return $retval - else - success "OK" - touch "${LFS}"/sources/chapter"${CHAPTER}"/"${PACKAGE}" - rm -rf "${LFS}"/sources/"${DIRNAME}" - fi - - popd > /dev/null || return 1 - - done - -fi +#!/bin/bash
+
+CHAPTER="$1"
+PACKAGE="$2"
+
+if ! grep -q "^${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")"
+ CACHEFILE="$(basename "${URL}")"
+ DIRNAME="$(tar -tf "${CACHEFILE}" | sed -e 's@/.*@@' | uniq)"
+
+ # Remove existing if exists
+ rm -rf "${DIRNAME}"
+
+ printf "%b" "${IBLU}Extracting ${YLW}${CACHEFILE}${RST}... "
+ tar xf "${CACHEFILE}" > /dev/null 2>&1 & pid=$!
+ spinner "$pid" "${SPINNER}"
+ retval=$?
+ if [[ "$retval" -ne 0 ]]; then
+ printf "%b" "${GRN}Extraction "
+ fail "FAILED!"
+ return $retval
+ else
+ success "OK"
+ fi
+
+ pushd "${DIRNAME}" > /dev/null || return 1
+
+ printf "%b" " ${CYN}Compiling ${YLW}${PACKAGE}${RST}... "
+
+ mkdir -p "${LFS}/sources/log/chapter${CHAPTER}/"
+ # shellcheck source=/dev/null
+ source "${LFS}/sources/chapter${CHAPTER}/${PACKAGE}.sh" 2>&1 > "${LFS}/sources/log/chapter${CHAPTER}/${PACKAGE}.log" 2>&1 & pid=$!
+ spinner "$pid" "${SPINNER}"
+ retval=$?
+ if [[ "$retval" -ne 0 ]]; then
+ fail "FAILED!"
+ popd > /dev/null || return 1
+ return $retval
+ else
+ success "OK"
+ touch "${LFS}"/sources/chapter"${CHAPTER}"/"${PACKAGE}"
+ rm -rf "${LFS}"/sources/"${DIRNAME}"
+ fi
+
+ popd > /dev/null || return 1
+
+ done
+
+fi
|