aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-04-01 01:06:37 +0200
committerEinhard Leichtfuß <alguien@respiranto.de>2018-04-01 01:06:37 +0200
commitfa22a06bad529fccd4083f9a355902e4e5cb09c9 (patch)
tree991298cb764b89eaae4c37e159d9a36005e46cb4
parent82c373e3e69d4cf028dbad4896129991c8e963c4 (diff)
Set up update.sh for vcs packages
Therefore, use $vcs_langs instead of $langs, due to fra-deu and deu-fra missing in the vcs tree. Furthermore, in - svn/sample.PKGBUILD, `- change the default pkgrel to 2, since any update is forced, i.e. there is no version change asking for update; - update.sh, `- add a usage note, `- require a specific type (e.g. src) to be supplied, `- remove the need to specify $ext for -u, `- set up a handle_all_vcs() function specifically for VCS sources, i.e. svn, `- move the download of freedict-database.json to handle_all().
-rw-r--r--basic.sh7
-rw-r--r--svn/sample.PKGBUILD2
-rwxr-xr-xupdate.sh80
3 files changed, 78 insertions, 11 deletions
diff --git a/basic.sh b/basic.sh
index 6e90dbc..2220e27 100644
--- a/basic.sh
+++ b/basic.sh
@@ -8,6 +8,13 @@ langs=(
spa-eng eng-spa
)
+typeset -a vcs_langs
+vcs_langs=(
+ deu-eng eng-deu
+ fra-eng eng-fra
+ spa-eng eng-spa
+ )
+
function init
{
tmp_d="$(mktemp -d)"
diff --git a/svn/sample.PKGBUILD b/svn/sample.PKGBUILD
index 8f1f690..aa502b4 100644
--- a/svn/sample.PKGBUILD
+++ b/svn/sample.PKGBUILD
@@ -5,7 +5,7 @@ _pkgname=dict-freedict-${_lang}
pkgname=${_pkgname}-svn
pkgver=%VER%
_pkgver=${pkgver//_/-}
-pkgrel=1
+pkgrel=2
pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from Freedict.org"
arch=('any')
url="http://www.freedict.org/"
diff --git a/update.sh b/update.sh
index 6cf91e2..baa8998 100755
--- a/update.sh
+++ b/update.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# usage: $0 dir [-u xyz-uvw|-ua|-uaf]
+# usage: $0 dir type [-u xyz-uvw|-ua|-uaf]
typeset -A long
long[fra]=French
@@ -39,24 +39,50 @@ prepare[deu-fra-bin]=\
function main
{
- [ "$#" -gt 0 ] && cd "$1" || exit 1
- shift
+ if [ "$#" -lt 2 ]
+ then
+ echo "Usage: $0 <base_dir> <type> [-u <xy>-<zw>|-ua|-uaf]" >&2
+ exit 1
+ else
+ cd "$1" || exit 1
+ fi
+
+ type="$2"
+
+ shift 2
+
- curl -sO http://freedict.org/freedict-database.json
init
- handle_all src '' src "$@"
- handle_all bin -bin dictd "$@"
+ if [[ "$type" == src ]]
+ then
+ handle_all src '' src "$@"
+ elif [[ "$type" == bin ]]
+ then
+ handle_all bin -bin dictd "$@"
+ elif [[ "$type" == svn ]]
+ then
+ handle_all_vcs svn -svn "$@"
+ else
+ echo "Type $type not supported." >&2
+ exit 1
+ fi
}
+# $1 source type: (normal|vcs)
function update
{
+ src_type=$1
+
echo "Updating ${lang}${ext} (${pkgver} -> ${convver})..."
lang_a="${long[${lang%-*}]}"
lang_b="${long[${lang#*-}]}"
- checksum="$(wget -qO - "$url" | sha512sum | sed -E 's/\s*-$//')"
+ if [[ $src_type != vcs ]]
+ then
+ checksum="$(wget -qO - "$url" | sha512sum | sed -E 's/\s*-$//')"
+ fi
cp ../sample.PKGBUILD "$tmp"
@@ -91,11 +117,13 @@ function handle_all
platform="$3"
shift 3
- cd "$type"
+ curl -sO http://freedict.org/freedict-database.json
+
+ cd "$type" || exit 1
for lang in ${langs[@]}
do
- cd dict-freedict-${lang}${ext}
+ cd dict-freedict-${lang}${ext} || exit 1
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)"
@@ -115,7 +143,7 @@ function handle_all
then
echo "${lang}${ext} URL changed (${url})."
else
- if [[ "$1" == "-u" && "$2" == "$lang${ext}" ]] \
+ if [[ "$1" == "-u" && "$2" == "$lang" ]] \
|| ([[ "$1" == "-ua" ]] && $ureq) \
|| [[ "$1" == "-uaf" ]]
then
@@ -129,5 +157,37 @@ function handle_all
cd ..
}
+# $1 type: (svn)
+# $2 suffix: (-svn)
+# ${@:3} args: $@
+function handle_all_vcs
+{
+ type="$1"
+ ext="$2"
+ shift 2
+
+ cd "$type" || exit 1
+
+ for lang in ${vcs_langs[@]}
+ do
+ cd dict-freedict-${lang}${ext} || exit 1
+ 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 \
+ | sed -E 's/\s*pkgver\s*=\s*(.+)\s*/\1/')"
+ convver="$ver"
+
+ if [[ "$1" == "-u" && "$2" == "$lang" ]] || [[ "$1" == "-uaf" ]]
+ then
+ update
+ fi
+
+ cd ..
+ done
+
+ cd ..
+}
+
main "$@"