Skip to content

Commit b3e6c14

Browse files
committed
Make download-distfiles.sh read from steps/manifest
This brings the shell script closer to what get_packages() at lib/generator.py does. It allows for downloading only what is specified in the manifest.
1 parent 2057d55 commit b3e6c14

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
target/
77
kernel
88
distfiles/
9+
mirrorstate/
910
__pycache__
1011
steps/bootstrap.cfg

download-distfiles.sh

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ download_source() {
1010
local distfiles=${1}
1111
local url=${2}
1212
shift 2
13-
if [[ ${url} == git://* ]]; then
14-
url=${1}
15-
shift
16-
fi
13+
case $url in
14+
'git://'*)
15+
url=${1}
16+
shift
17+
;;
18+
esac
1719
local checksum=${1}
1820
local fname=${2}
1921
# Default to basename of url if not given
@@ -28,7 +30,7 @@ download_source() {
2830
echo "Downloading ${fname}"
2931
if [ "${mirrors_len}" -ne 0 ]; then
3032
local mirror_ix=$((RANDOM % mirrors_len))
31-
url=${mirrors[${mirror_ix}]}/${fname}
33+
eval "url=\${mirror_$mirror_ix}"
3234
fi
3335
curl --fail --location "${url}" --output "${dest_path}" || true
3436
fi
@@ -38,10 +40,12 @@ check_source() {
3840
local distfiles=${1}
3941
local url=${2}
4042
shift 2
41-
if [[ ${url} == git://* ]]; then
42-
url=${1}
43-
shift
44-
fi
43+
case $url in
44+
'git://'*)
45+
url=${1}
46+
shift
47+
;;
48+
esac
4549
local checksum=${1}
4650
local fname=${2}
4751
# Default to basename of url if not given
@@ -51,34 +55,40 @@ check_source() {
5155
echo "${checksum} ${dest_path}" | sha256sum -c
5256
}
5357

58+
walk_manifest_sources () {
59+
local action=$1
60+
local manifest_entry=
61+
local entry=
62+
63+
while read -r manifest_entry || test -n "$manifest_entry"; do
64+
case $manifest_entry in
65+
'build:'*)
66+
entry="${manifest_entry#'build: '}"
67+
[ -e "./steps/${entry}/sources" ] || continue
68+
while read -r line; do
69+
# This is intentional - we want to split out ${line} into separate arguments.
70+
# shellcheck disable=SC2086
71+
$action distfiles ${line}
72+
done < "./steps/${entry}/sources"
73+
;;
74+
esac
75+
done < "./steps/manifest"
76+
}
77+
5478
set -e
5579

56-
mirrors=( "$@" )
5780
mirrors_len=$#
81+
while test $# -gt 0;
82+
do
83+
eval "mirror_$#=$1"
84+
shift
85+
done
5886

5987
cd "$(dirname "$(readlink -f "$0")")"
6088
mkdir -p distfiles
6189

6290
# First, try to download anything missing - ignore failing mirrors
63-
for entry in steps/*; do
64-
[ -e "${entry}/sources" ] || continue
65-
66-
# shellcheck disable=SC2162
67-
while read line; do
68-
# This is intentional - we want to split out ${line} into separate arguments.
69-
# shellcheck disable=SC2086
70-
download_source distfiles ${line}
71-
done < "${entry}/sources"
72-
done
73-
91+
walk_manifest_sources download_source
7492
# Then, check if everything has been obtained at least once
75-
for entry in steps/*; do
76-
[ -e "${entry}/sources" ] || continue
93+
walk_manifest_sources check_source
7794

78-
# shellcheck disable=SC2162
79-
while read line; do
80-
# This is intentional - we want to split out ${line} into separate arguments.
81-
# shellcheck disable=SC2086
82-
check_source distfiles ${line}
83-
done < "${entry}/sources"
84-
done

steps/libatomic_ops-7.6.10/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ivmai/libatomic_ops/releases/download/v7.6.10/libatomic_ops-7.6.10.tar.gz 587edf60817f56daf1e1ab38a4b3c729b8e846ff67b4f62a6157183708f099af
1+
https://samuelt.me/pub/live-bootstrap/libatomic_ops-7.6.10.tar.gz 587edf60817f56daf1e1ab38a4b3c729b8e846ff67b4f62a6157183708f099af

0 commit comments

Comments
 (0)