From a0afdfbd47d99900273173d7a6598c8bb0f79934 Mon Sep 17 00:00:00 2001 From: bryan Date: Thu, 24 Oct 2024 14:53:10 -0400 Subject: [PATCH] Fix image verification --- openwrtbuilder | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/openwrtbuilder b/openwrtbuilder index a68fbb8..4ff39d9 100755 --- a/openwrtbuilder +++ b/openwrtbuilder @@ -313,20 +313,20 @@ install_dependencies() { get_imagebuilder() { debug "${FUNCNAME[0]}" "$*" - local -a ib_url_file=("$1" "$2") - local -a sha256_url_file=("$3" "$4") - local -a url_file_pairs=( - "${ib_url_file[@]}" - "${sha256_url_file[@]}") + + local -a url_file_pairs=("$@") for ((i=0; i<${#url_file_pairs[@]}; i+=2)); do local url="${url_file_pairs[i]}" local file="${url_file_pairs[i+1]}" - if [[ -f $file ]] && ask_ok "$file exists. Re-download?"; then + # Check if file exists and ask user to remove and redownload + if [[ -f $file ]] && ! ask_ok "Use existing $file?"; then execute rm -f "$file" fi - if ! [[ -f "$file" ]]; then + + # Download the file if it doesn't exist + if [[ ! -f "$file" ]]; then echo "Downloading $url to $file using $DL_TOOL" execute "$DL_TOOL" "-o" "$file" "$url" fi @@ -402,11 +402,12 @@ make_images() { } verify_images() { - debug "${FUNCNAME[0]}" + debug "${FUNCNAME[0]}" "$*" + local sha256_file="$1" local outfile for outfile in "$BINDIR"/*.img.gz; do - verify "$outfile" "$IB_OUT_SHA256_FILE" || return 1 + verify "$outfile" "$sha256_file" || return 1 done } @@ -778,7 +779,7 @@ main() { extract "$ib_file" "$BUILDDIR" || return $? add_repos make_images && - verify_images + verify_images "$ib_sha256_file" #copyFiles fi