commit: 6de12d402f698309f729302fd03e66c18d6b35ec
parent 44c35017e7903299e7e93da6b801909b2b21d107
Author: Eduardo Sánchez Muñoz <eduardosm-dev@e64.io>
Date: Sun, 27 Nov 2022 20:51:52 +0100
Add script to download sysa and sysc distfiles without Python
Diffstat:
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/README.rst b/README.rst
@@ -167,6 +167,7 @@ repository is almost completely in a form where it can be used as the
source of a build.
1. Download required tarballs into ``sysa/distfiles`` and ``sysc/distfiles``.
+ You can use the ``download-distfiles.sh`` script.
2. Copy sysa/stage0-posix/src/* to the root of the repository.
3. Copy sysa/stage0-posix/src/bootstrap-seeds/POSIX/x86/kaem-optional-seed
to init in the root of the repository.
diff --git a/download-distfiles.sh b/download-distfiles.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+download_source() {
+ local distfiles="${1}"
+ local url="${2}"
+ local checksum="${3}"
+ local fname="${4}"
+ # Default to basename of url if not given
+ fname="${fname:-$(basename "${url}")}"
+
+ local dest_path="${distfiles}/${fname}"
+ if ! [ -e "${dest_path}" ]; then
+ echo "Downloading ${fname}"
+ curl -L "${url}" --output "${dest_path}"
+ fi
+ echo "${checksum} ${dest_path}" | sha256sum -c
+}
+
+download_for_sys() {
+ local sysdir="${1}"
+ local distfiles="${sysdir}/distfiles"
+
+ mkdir -p "${distfiles}"
+
+ local entry
+ for entry in "${sysdir}"/*; do
+ [ -e "${entry}/sources" ] || continue
+
+ local line
+ while read line; do
+ # This is intentional - we want to split out ${line} into separate arguments.
+ download_source "${distfiles}" ${line}
+ done < "${entry}/sources"
+ done
+}
+
+set -e
+cd "$(dirname "$(readlink -f "$0")")"
+download_for_sys sysa
+download_for_sys sysc