From 6de12d402f698309f729302fd03e66c18d6b35ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Sun, 27 Nov 2022 20:51:52 +0100 Subject: [PATCH 1/4] Add script to download sysa and sysc distfiles without Python --- README.rst | 1 + download-distfiles.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 download-distfiles.sh diff --git a/README.rst b/README.rst index 36c47d4..39cf501 100644 --- 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 new file mode 100755 index 0000000..dcf4d11 --- /dev/null +++ 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 From 71f67c7fbcdbb491bdb4ccb44f8ac45e9b80e943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Mon, 28 Nov 2022 20:00:18 +0100 Subject: [PATCH 2/4] Add download-distfiles.sh to shellcheck and include reuse information --- .cirrus.yml | 2 +- download-distfiles.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 45c1098..67b85e6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -24,7 +24,7 @@ shell_lint_task: - apt-get -y install shellcheck - apt-get -y clean check_script: - - shellcheck sysa/run.sh sysb/init sysb/run.sh sysc/init sysc/run.sh sysc/run2.sh sysa/helpers.sh + - shellcheck sysa/run.sh sysb/init sysb/run.sh sysc/init sysc/run.sh sysc/run2.sh sysa/helpers.sh download-distfiles.sh reuse_lint_task: container: diff --git a/download-distfiles.sh b/download-distfiles.sh index dcf4d11..aec142c 100755 --- a/download-distfiles.sh +++ b/download-distfiles.sh @@ -1,5 +1,9 @@ #!/bin/sh +# SPDX-FileCopyrightText: 2022 fosslinux +# +# SPDX-License-Identifier: GPL-3.0-or-later + download_source() { local distfiles="${1}" local url="${2}" From d91e31e6a225f2017eed88952ecff4407508055f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Mon, 28 Nov 2022 20:03:42 +0100 Subject: [PATCH 3/4] Use bash as interpreter in download-distfiles.sh --- download-distfiles.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download-distfiles.sh b/download-distfiles.sh index aec142c..efe9eb0 100755 --- a/download-distfiles.sh +++ b/download-distfiles.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-FileCopyrightText: 2022 fosslinux # From 6f4afb4e3fb9dcbc96ebaf678719f152ac0c3f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Mon, 28 Nov 2022 20:10:30 +0100 Subject: [PATCH 4/4] Make shellcheck happy --- download-distfiles.sh | 2 ++ sysa/helpers.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/download-distfiles.sh b/download-distfiles.sh index efe9eb0..2877cfd 100755 --- a/download-distfiles.sh +++ b/download-distfiles.sh @@ -31,8 +31,10 @@ download_for_sys() { [ -e "${entry}/sources" ] || continue local line + # shellcheck disable=SC2162 while read line; do # This is intentional - we want to split out ${line} into separate arguments. + # shellcheck disable=SC2086 download_source "${distfiles}" ${line} done < "${entry}/sources" done diff --git a/sysa/helpers.sh b/sysa/helpers.sh index a012129..150dd7d 100755 --- a/sysa/helpers.sh +++ b/sysa/helpers.sh @@ -131,7 +131,7 @@ build() { script_name=${2:-${pkg}.sh} dirname=${4:-${pkg}} - # shellcheck ignore=SC2015 + # shellcheck disable=SC2015 bin_preseed && return || true # Normal build if preseed fails cd "${SOURCES}/${pkg}" || (echo "Cannot cd into ${pkg}!"; kill $$)