From 50b67be7e409161f5c6f4847ca2beb23e81b51ae Mon Sep 17 00:00:00 2001 From: William Harrington Date: Fri, 26 Mar 2021 15:03:25 -0500 Subject: Create a script exporting separate functions and remove download function from downloads script. Reformat MD5 mismatch failed message. --- download.sh | 18 +----------------- functions.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 functions.sh diff --git a/download.sh b/download.sh index 4e3c794..2cec438 100644 --- a/download.sh +++ b/download.sh @@ -2,22 +2,6 @@ # Downlod Packages and Patches -download() -{ - tput civis - local url=$1 - echo -n " " - wget -nc -q --show-progress --progress=dot "$url" 2>&1 | grep --line-buffered "%" | \ - sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' - local retval="${PIPESTATUS[0]}" - if [ "${retval}" -ne 0 ]; then - printf "%b" "${RED}FAILED! WGET EXIT (${retval})\n${RST}" - exit "${retval}" - fi - printf "%b" "\b\b\b\b\n" - tput cnorm -} - cat packages.csv patches.csv | while read -r line; do #NAME="$(echo "$line" | cut -d\, -f1)" VERSION="$(echo "$line" | cut -d\, -f2)" @@ -32,7 +16,7 @@ cat packages.csv patches.csv | while read -r line; do download "${URL}" if ! echo "${MD5SUM} ${LFS}/sources/${CACHEFILE}" | md5sum -c > /dev/null 2>&1; then rm -f "${LFS}/sources/${CACHEFILE}" - printf "%b" "\n${GRN}Verification of ${YLW}${CACHEFILE} ${RED}FAILED! MD5 MISMATCH!${RST}\n" + printf "%b" "${GRN}Verification of ${YLW}${CACHEFILE} ${RED}FAILED! MD5 MISMATCH!${RST}\n" exit 1 fi fi diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..d2ff5be --- /dev/null +++ b/functions.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +download() +{ + tput civis + local url=$1 + echo -n " " + wget -nc -q --show-progress --progress=dot "$url" 2>&1 | grep --line-buffered "%" | \ + sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}' + local retval="${PIPESTATUS[0]}" + if [ "${retval}" -ne 0 ]; then + printf "%b" "${RED}FAILED! WGET EXIT (${retval})\n${RST}" + exit "${retval}" + fi + printf "%b" "\b\b\b\b\n" + tput cnorm +} + +export -f download -- cgit v1.2.3-54-g00ecf