aboutsummaryrefslogtreecommitdiffstats
path: root/download.sh
blob: 6d09ad1833e7b802eb5a7c083140f859060c0b2c (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
#!/bin/bash

cat packages.csv | while read 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


        echo -ne "${PRP}Downloading ${YLW}${URL}${RST}... "
        wget -nc -q -O "${LFS_SRC}/${CACHEFILE}" "${URL}" & pid=$!
        spinner "$pid"
        if ! echo "${MD5SUM} ${LFS_SRC}/${CACHEFILE}" | md5sum -c >/dev/null; then
            rm -f "${LFS_SRC}/${CACHEFILE}"
            echo -e "${GRN}Verification of ${YLW}${CACHEFILE} ${RED}failed! MD5 mismatch!${RST}"
            exit 1
        fi

        echo -e "${GRN}OK${RST}"
    fi
done