From 9d08d181f0b996a055c18a2b49bac6c2ed6158af Mon Sep 17 00:00:00 2001 From: Samuel Tyler Date: Sat, 4 Oct 2025 11:45:06 +1000 Subject: [PATCH] Support new sources format within the lb environment --- .../checksum-transcriber-1.0.amd64.checksums | 2 +- ...checksum-transcriber-1.0.riscv64.checksums | 2 +- .../checksum-transcriber-1.0.x86.checksums | 2 +- .../src/checksum-transcriber.c | 13 ++++--- steps/helpers.sh | 39 +++++++++++-------- steps/improve/clean_sources.sh | 5 +-- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.amd64.checksums b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.amd64.checksums index f3e910c0..e319b374 100644 --- a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.amd64.checksums +++ b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.amd64.checksums @@ -1 +1 @@ -80145a20564648b3a84cf9233e0da7f0a8ac4e5853512a1552de2931de09d5c0 /usr/bin/checksum-transcriber +64978b2b50c5ba1dfb384d2d76fd7c0ddfcf330d75704881f174a3c81e7cc153 /usr/bin/checksum-transcriber diff --git a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.riscv64.checksums b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.riscv64.checksums index 83bc9499..71e2d4e6 100644 --- a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.riscv64.checksums +++ b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.riscv64.checksums @@ -1 +1 @@ -ef770a377283258d72595fff9900dc093d8be9d3a1052ddb3eaca0759c29b140 /usr/bin/checksum-transcriber +1c3021d8051fefd615edb50907e3015d810f974b5b9461f8f9aa383478620a0d /usr/bin/checksum-transcriber diff --git a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.x86.checksums b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.x86.checksums index b68a127b..269f907b 100644 --- a/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.x86.checksums +++ b/steps/checksum-transcriber-1.0/checksum-transcriber-1.0.x86.checksums @@ -1 +1 @@ -f161bdb859c2ef76138fa20d2503ae70600b426d770e447cbb55e1a292319252 /usr/bin/checksum-transcriber +3b43fcfe665d48c7041292bc78b3de0c5e7fe17fab425837bc5c596856d20bf8 /usr/bin/checksum-transcriber diff --git a/steps/checksum-transcriber-1.0/src/checksum-transcriber.c b/steps/checksum-transcriber-1.0/src/checksum-transcriber.c index b335fb5f..4a2c1f7c 100644 --- a/steps/checksum-transcriber-1.0/src/checksum-transcriber.c +++ b/steps/checksum-transcriber-1.0/src/checksum-transcriber.c @@ -11,7 +11,7 @@ #include #define MAX_STRING 4096 -#define MAX_TOKENS 3 +#define MAX_TOKENS 8 char *get_distfiles(char **envp) { char *envvar = "DISTFILES="; @@ -60,12 +60,15 @@ int main(int argc, char **argv, char **envp) { } line = strchr(line, '\n'); line[0] = '\0'; + // Only "file" type of distfile supported at this point + require(strcmp(tokens[0], "f") == 0 || strcmp(tokens[0], "file") == 0, + "Only support file distfile type at this point"); // Get checksum and filename - checksum = tokens[1]; - if (tokens[2] != NULL) { - filename = tokens[2]; + checksum = tokens[2]; + if (tokens[3] != NULL) { + filename = tokens[3]; } else { - filename = strrchr(tokens[0], '/'); + filename = strrchr(tokens[1], '/'); filename += 1; } // Put it all together diff --git a/steps/helpers.sh b/steps/helpers.sh index 1ad05641..c4836d6d 100755 --- a/steps/helpers.sh +++ b/steps/helpers.sh @@ -273,14 +273,9 @@ randomize() { } download_source_line() { - if [[ "${1}" == git://* ]]; then - shift - fi upstream_url="${1}" checksum="${2}" fname="${3}" - # Default to basename of url if not given - fname="${fname:-$(basename "${upstream_url}")}" if ! [ -e "${fname}" ]; then for mirror in $(randomize "${MIRRORS}"); do # In qemu SimpleMirror is not running on the guest os, use qemu IP @@ -298,14 +293,9 @@ download_source_line() { } check_source_line() { - if [[ "${1}" == git://* ]]; then - shift - fi url="${1}" checksum="${2}" fname="${3}" - # Default to basename of url if not given - fname="${fname:-$(basename "${url}")}" if ! [ -e "${fname}" ]; then echo "${fname} does not exist!" false @@ -315,6 +305,24 @@ check_source_line() { rm "${fname}.sum" } +source_line_action() { + action="$1" + shift + type="$1" + shift + case $type in + "g" | "git") + shift + ;; + esac + url="${1}" + checksum="${2}" + fname="${3}" + # Default to basename of url if not given + fname="${fname:-$(basename "${url}")}" + $action "$url" "$checksum" "$fname" +} + # Default get function that downloads source tarballs. default_src_get() { # shellcheck disable=SC2153 @@ -323,22 +331,19 @@ default_src_get() { while read line; do # This is intentional - we want to split out ${line} into separate arguments. # shellcheck disable=SC2086 - download_source_line ${line} + source_line_action download_source_line ${line} done < "${base_dir}/sources" # shellcheck disable=SC2162 while read line; do # This is intentional - we want to split out ${line} into separate arguments. # shellcheck disable=SC2086 - check_source_line ${line} + source_line_action check_source_line ${line} done < "${base_dir}/sources" cd - } # Intelligently extracts a file based upon its filetype. extract_file() { - if [[ "${1}" == git://* ]]; then - shift - fi f="${3:-$(basename "${1}")}" # shellcheck disable=SC2154 case "${noextract}" in @@ -384,7 +389,7 @@ default_src_unpack() { first_line=$(head -n 1 ../sources) # Again, we want to split out into words. # shellcheck disable=SC2086 - extract_file ${first_line} + source_line_action extract_file ${first_line} # This assumes there is only one directory in the tarball # Get the dirname "smartly" if ! [ -e "${dirname}" ]; then @@ -398,7 +403,7 @@ default_src_unpack() { # shellcheck disable=SC2162 tail -n +2 ../sources | while read line; do # shellcheck disable=SC2086 - extract_file ${line} + source_line_action extract_file ${line} done } diff --git a/steps/improve/clean_sources.sh b/steps/improve/clean_sources.sh index 6a9adaa5..697427fc 100755 --- a/steps/improve/clean_sources.sh +++ b/steps/improve/clean_sources.sh @@ -6,9 +6,6 @@ # Delete sources of packages before linux kernel get_source_filename() { - if [[ "${1}" == git://* ]]; then - shift - fi local url="${1}" local fname="${3}" # Default to basename of url if not given @@ -24,7 +21,7 @@ pkgs="$(awk '/^build:/ { print $2 }' "${SRCDIR}/manifest" | awk '/^linux-[0-9]/, keep_sources="" for pkg in ${pkgs}; do while read line; do - keep_sources="${keep_sources} $(get_source_filename ${line})" + keep_sources="${keep_sources} $(source_line_action get_source_filename ${line})" done < "${SRCDIR}/${pkg}/sources" done