From cfd492cf7cf089a540073d60d025ed1d3c84ecf9 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 31 Dec 2020 13:55:39 +0300 Subject: [PATCH] Pull request: scripts: fix build-release Merge in DNS/adguard-home from 2276-fix-release-3 to master Updates #2276. Updates #2507. Squashed commit of the following: commit 1f756975922b403e06dca3e9d44d9ed2edccb97c Author: Ainar Garipov Date: Thu Dec 31 13:45:25 2020 +0300 scripts: fix build-release --- scripts/make/build-release.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index bad82e89..36dae35b 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -157,6 +157,7 @@ build() { GOMIPS="${build_mips#0}"\ GOOS="$os"\ VERBOSE="$(( verbose - 1 ))"\ + VERSION="$version"\ OUT="$build_output"\ sh ./scripts/make/go-build.sh\ ; @@ -287,7 +288,7 @@ log "calculating checksums" cd "./${dist}" # Don't use quotes to get word splitting. - sha256sum $(ls *.tar.gz *.zip) > ./checksums.txt + sha256sum $(ls -1 -A -q *.tar.gz *.zip) > ./checksums.txt ) log "writing versions" @@ -295,6 +296,9 @@ log "writing versions" echo "$version" > "./${dist}/version.txt" # Create the verison.json file. +# +# TODO(a.garipov): Perhaps rewrite this as a go run program. Dealing +# with structured documents is really not a Shell's job. readonly version_download_url="https://static.adguard.com/adguardhome/${channel}" readonly version_json="./${dist}/version.json" @@ -319,8 +323,12 @@ echo "{ # Use +f here so that ls works and we don't need to use find. set +f + readonly ar_files="$(ls -1 -A -q "./${dist}/"*.tar.gz "./${dist}/"*.zip)" + readonly ar_files_len="$(echo "$ar_files" | wc -l)" + + i='1' # Don't use quotes to get word splitting. - for f in $(ls "./${dist}/"*.tar.gz "./${dist}/"*.zip) + for f in $ar_files do platform="$f" @@ -334,7 +342,14 @@ echo "{ # Use the filename's base path. filename="${f#./${dist}/}" - echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >> "$version_json" + if [ "$i" = "$ar_files_len" ] + then + echo " \"download_${platform}\": \"${version_download_url}/${filename}\"" >> "$version_json" + else + echo " \"download_${platform}\": \"${version_download_url}/${filename}\"," >> "$version_json" + fi + + : "$(( i++ ))" done )