aboutsummaryrefslogtreecommitdiffstats
path: root/download.sh
blob: 4e3c7942f75d23946e0e11dcdf197d792042e75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

# 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)"
    URL="$(echo "$line" | cut -d\, -f3 | sed "s/@/${VERSION}/g")"
    MD5SUM="$(echo "$line" | cut -d\, -f4)"
    CACHEFILE="$(basename "${URL}")"

    if [ ! -f "${CACHEFILE}" ]; then


        printf "%b" "${PRP}Downloading ${YLW}${CACHEFILE}${RST}... "
		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"
            exit 1
        fi
    fi
done