From dd809801e3c7a87d70e2b64bd028d1d3e386fa96 Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Sun, 13 May 2018 20:30:44 +0200 Subject: Get checksum from specific file Before, the source file was downloaded and the checksum calculated from it. Additionally, the code's documentation was marginally improved and a --nopull option added. --- update.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/update.sh b/update.sh index aa2a395..31e0265 100755 --- a/update.sh +++ b/update.sh @@ -1,5 +1,12 @@ #!/bin/bash -# usage: $0 dir type [-u xyz-uvw|-ua|-uaf] +# usage: $0 dir type [--nopull] [-u xyz-uvw|-ua|-uaf] +# $1 base directory: string +# $2 type: (src|bin|svn) +# $4 option: --nopull {can be omitted} +# ${4,5} update force mode: (-u lang1-lang2|-ua|-uaf) {can be omitted} +# -u x: Update x, even if it appears up to date. +# -ua: Update all that are out of date. +# -uaf: Update all, even if they appear up to date. typeset -A long long[fra]=French @@ -49,7 +56,14 @@ function main type="$2" - shift 2 + if [ "$3" = "--nopull" ] + then + nopull=true + shift 3 + else + nopull=false + shift 2 + fi @@ -70,6 +84,7 @@ function main } # $1 source type: (normal|vcs) +# requires: $PWD == / function update { src_type=$1 @@ -81,7 +96,8 @@ function update if [[ $src_type != vcs ]] then - checksum="$(wget -qO - "$url" | sha512sum | sed -E 's/\s*-$//')" + #checksum="$(wget -qO - "$url" | sha512sum | sed -E 's/\s*-$//')" + checksum="$(wget -qO - "${url}.sha512" | cut -d ' ' -f 1)" fi cp ../sample.PKGBUILD "$tmp" @@ -110,6 +126,7 @@ function update # $2 suffix: (|-bin) # $3 platform: (src|dictd) # ${@:4} args: $@ +# requires: $PWD == function handle_all { type="$1" @@ -124,7 +141,7 @@ function handle_all for lang in ${langs[@]} do cd dict-freedict-${lang}${ext} || exit 1 - git pull -q + $nopull || git pull -q pkgver="$(grep pkgver .SRCINFO | sed -E 's/\s*pkgver\s*=\s*(.+)\s*/\1/')" ver="$(jq -r ".[] | select(.name == \"${lang}\") | .releases[] | select(.platform==\"$platform\") | .version" ../../freedict-database.json)" url="$(jq -r ".[] | select(.name == \"${lang}\") | .releases[] | select(.platform==\"$platform\") | .URL" ../../freedict-database.json)" @@ -160,6 +177,7 @@ function handle_all # $1 type: (svn) # $2 suffix: (-svn) # ${@:3} args: $@ +# requires: $PWD == function handle_all_vcs { type="$1" @@ -171,7 +189,7 @@ function handle_all_vcs for lang in ${vcs_langs[@]} do cd dict-freedict-${lang}${ext} || exit 1 - git pull -q + $nopull || git pull -q pkgver="$(grep pkgver .SRCINFO | sed -E 's/\s*pkgver\s*=\s*(.+)\s*/\1/')" makepkg --nobuild --nodeps > /dev/null 2>&1 ver="$(makepkg --printsrcinfo | grep pkgver \ -- cgit v1.2.3