diff options
author | William Harrington <kb0iic@berzerkula.org> | 2021-03-18 11:16:10 -0500 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2021-03-18 11:16:10 -0500 |
commit | 5a0d563dfe209f2be5d2555fccd4613accbc1249 (patch) | |
tree | e208ff6df3b561c533af43cfeeef27ee14371317 | |
parent | 72c75bc163170e42ed98b958310c7b69bee6485b (diff) |
Add package install. If package has been built then continue. Extract package, then build and pass background proces pid to spinner then when done, based on return value, display fail message or say package is done and touch a file named the package to notify the package was sucessfully built and installed during a consecutive run.
-rw-r--r-- | packageinstall.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/packageinstall.sh b/packageinstall.sh new file mode 100644 index 0000000..4523d06 --- /dev/null +++ b/packageinstall.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +CHAPTER="$1" +PACKAGE="$2" + +if [ -f "${LFS_SRC}/chapter${CHAPTER}/${PACKAGE}" ]; then + echo -e "${GRN}Package ${YLW}${PACKAGE} ${GRN}already built and installed for ${YLW}Chapter ${CHAPTER}.${RST}" + continue; + +else + grep -i "^${PACKAGE}" packages.csv | grep -i -v "\.patch;" | while read line; do + VERSION="$(echo $line | cut -d\, -f2)" + URL="$(echo $line | cut -d\, -f3 | sed "s/@/${VERSION}/g")" + CACHEFILE="$(basename "${URL}")" + DIRNAME="$(echo "${CACHEFILE}" | sed 's/\(.*\)\.tar\..*/\1/')" + + if [ -d "${DIRNAME}" ]; then + rm -rf ${DIRNAME} + fi + mkdir -p "${DIRNAME}" + + echo -e "${BLU}Extracting ${YLW}${CACHEFILE}" + tar -xf "${CACHEFILE}" -C "${DIRNAME}" + #TOPLEVELDIR = "tar -tf ${CACHEFILE} | sed -e 's@/.*@@' | uniq" + + pushd "${DIRNAME}" > /dev/null + if [ "$(ls -1A | wc -l)" == "1" ]; then + mv $(ls -1A)/* ./ + fi + + echo -ne "${CYN}Compiling ${YLW}${PACKAGE}${RST}... " + sleep 5 + + mkdir -p "../log/chapter${CHAPTER}/" + source "../chapter${CHAPTER}/${PACKAGE}.sh" 2>&1 > "../log/chapter${CHAPTER}/${PACKAGE}.log" 2>&1 & pid=$! + spinner "$pid" + if [ "$retval" -ne 0 ]; then + echo -e "\n${GRN}Compiling ${YLW}${PACKAGE} ${RED}FAILED!${RST}" + popd + exit 1 + fi + + echo -e "\n${GRN}Done Compiling ${YLW}${PACKAGE}${RST}" + touch ${LFS}/sources/chapter${CHAPTER}/${PACKAGE} + rm -rf ${LFS}/sources/${DIRNAME} + + popd > /dev/null + + done +fi
\ No newline at end of file |