diff options
author | Einhard Leichtfuß <alguien@respiranto.de> | 2018-05-13 20:30:44 +0200 |
---|---|---|
committer | Einhard Leichtfuß <alguien@respiranto.de> | 2018-05-13 20:30:44 +0200 |
commit | dd809801e3c7a87d70e2b64bd028d1d3e386fa96 (patch) | |
tree | 261b8e318e1e5d885756d5ea897804c8c7131529 | |
parent | 28d74df07ad810d5a1c91f251308b36a78b1d2db (diff) |
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.
-rwxr-xr-x | update.sh | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -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 == <base directory>/<type> 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 == <base directory> 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 == <base directory> 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 \ |