From b300f3c047a606024db2098523c8fff70721c716 Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Sun, 23 Dec 2018 16:02:33 +0100 Subject: Use the provided sample.* files Do not longer rely on them being symlinked to the target directories. Also, fix small error in make_install.sh:main() ($1 -> $2). And add some comments. --- README | 10 ++++++++++ TODO | 3 +-- make_install.sh | 10 +++++++--- update.sh | 31 ++++++++++++++++++++++++------- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/README b/README index b01160f..40689e4 100644 --- a/README +++ b/README @@ -9,6 +9,16 @@ Usage: Just call ./update.sh or ./make_install.sh to see usage information. +Dependencies: +------------- + +pacman +bash +coreutils +sed +curl + + Author: ------- diff --git a/TODO b/TODO index 3f01a3c..6aaf7d1 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,7 @@ TODO file for aur-fd-scripts [GENERAL] * Move dictd make dependency to freedict-tools. * Use updpkgsums from pacman-contrib. -* Use the provided sample.* instead of relying them to be in the destination - directories. +* (Better) error handling. * [consider] Unify the different sample.PKGBUILDs. * [consider] Split off a (bash) configuration file. diff --git a/make_install.sh b/make_install.sh index 6a3468d..359989c 100755 --- a/make_install.sh +++ b/make_install.sh @@ -36,7 +36,7 @@ function main cd "${1}/${2}" || exit 1 fi - if [[ "$1" == src ]] + if [[ "$2" == src ]] then ext= else @@ -58,14 +58,18 @@ function main } +# Create the install file. +# +# requires: $PWD == +# function make_install { pkgname=dict-freedict-${lang}${ext} - input ../sample.install + input "${script_dir}/sample.install" replace "%LANG%" "$lang" replace "%SUFFIX%" "$ext" - write ${pkgname}/${pkgname}.install + write "${pkgname}/${pkgname}.install" } diff --git a/update.sh b/update.sh index 6e06e00..b78e062 100755 --- a/update.sh +++ b/update.sh @@ -29,10 +29,14 @@ # -ua: Update all that are out of date. # -uaf: Update all, even if they appear up to date. + script_path="$(realpath "$0")" script_dir="${script_path%/*}" + +## Some configuration. + # Long names table. typeset -A long long[fra]=French @@ -51,7 +55,7 @@ contrs[fra-eng-bin]=\ contrs[eng-fra-bin]=\ '# Contributor: Benjamin Vanderford '$'\n' -# prepare functions. +# prepare() functions. typeset -A prepare prepare[deu-fra]=\ 'prepare() @@ -65,9 +69,13 @@ prepare[deu-fra]=\ } ' +## End configuration + + . "${script_dir}/basic.sh" + function main { if [ "$#" -lt 2 ] @@ -107,18 +115,19 @@ function main } -# $1 source type: (normal|vcs) -# requires: $PWD == / +# Update PKGBUILD and .SRCINFO +# +# requires: $lang, $ext, $type, $ver, $convver to be set; +# $PWD == // +# function update { - src_type=$1 - echo "Updating ${lang}${ext} (${pkgver} -> ${convver})..." lang_a="${long[${lang%-*}]}" lang_b="${long[${lang#*-}]}" - input ../sample.PKGBUILD + input "${script_dir}/${type}/sample.PKGBUILD" replace '%LANG%' "$lang" replace '%LANG_A%' "$lang_a" @@ -141,11 +150,15 @@ function update } +# Check for updates for src / bin packages and optionally update them. +# # $1 type: (src|bin) # $2 suffix: (|-bin) # $3 platform: (src|dictd) # ${@:4} args: $@ +# # requires: $PWD == +# function handle_all { type="$1" @@ -153,7 +166,7 @@ function handle_all platform="$3" shift 3 - curl -sO https://freedict.org/freedict-database.json + curl -sO https://freedict.org/freedict-database.json || exit 1 cd "$type" || exit 1 @@ -195,10 +208,14 @@ function handle_all } +# Check for updates for VCS (svn) packages and optionally update them. +# # $1 type: (svn) # $2 suffix: (-svn) # ${@:3} args: $@ +# # requires: $PWD == +# function handle_all_vcs { type="$1" -- cgit v1.2.3