blob: 12a4999025b6754256c65021e309c504bd5e6472 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
|