aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README8
-rw-r--r--TODO11
-rw-r--r--basic.bash (renamed from basic.sh)16
-rw-r--r--bin/sample.PKGBUILD24
-rw-r--r--general-config.bash (renamed from general-config.sh)37
-rwxr-xr-xmake_install.bash (renamed from make_install.sh)12
-rw-r--r--sample.install28
-rw-r--r--src/sample.PKGBUILD22
-rw-r--r--svn/sample.PKGBUILD42
-rwxr-xr-xupdate.bash (renamed from update.sh)33
-rw-r--r--user-config.default.bash9
-rw-r--r--user-config.default.sh9
13 files changed, 130 insertions, 122 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0c9cbde
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/user-config.bash
diff --git a/README b/README
index 28f088a..1031184 100644
--- a/README
+++ b/README
@@ -6,17 +6,17 @@ Things are to be written here.
Configuration:
--------------
-Copy user-config.default.sh to user-config.sh and set any options to your
+Copy user-config.default.bash to user-config.bash and set any options to your
linking.
Usage:
------
-Make sure user-config.sh exists and has the correct $maintainer variable set.
+Make sure user-config.bash exists and has the correct $maintainer variable set.
-Then, just call ./update.sh or ./make_install.sh. Usage information will be
-displayed.
+Then, just call ./update.bash or ./make_install.bash. Usage information will
+be displayed.
Dependencies:
diff --git a/TODO b/TODO
index 712ff59..1485fa7 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,13 @@
TODO file for aur-fd-scripts
[GENERAL]
-* Move dictd make dependency to freedict-tools.
* Use updpkgsums from pacman-contrib.
* (Better) error handling.
* Avoid looping over all packages when only one is to be updated.
* [consider] Unify the different sample.PKGBUILDs.
+* Prohibit update of deu-eng, eng-deu src and svn versions.
+ - They are created manually.
+ - Alternatively, adapt the system to account for the differences.
[FEATURES]
* Check for update of freedict-tools.
@@ -14,7 +16,6 @@ TODO file for aur-fd-scripts
* Set up directory structure if not existing.
* [consider] Notify on checksum change (should not happen unless version
numbers change).
-* Add $basedir in user-config.default.sh
-
-[NON-FUNCTIONAL]
-* Be consistent in quoting.
+* Add $basedir in user-config.default.bash
+* check(): `make validation'
+ - The .dtd and .rng files would need to be included in the tools package.
diff --git a/basic.sh b/basic.bash
index 5dc475f..363df0b 100644
--- a/basic.sh
+++ b/basic.bash
@@ -2,10 +2,10 @@
#
# Copyright 2018 Einhard Leichtfuß
#
-# basic.sh - script containing the array of the to be generated dictionary's
-# names and some common functionality, mostly wrapping sed.
+# basic.bash - script containing the array of the to be generated dictionary's
+# names and some common functionality, mostly wrapping sed.
#
-# Copyright 2018 Einhard Leichtfuß
+# Copyright 2018,2022 Einhard Leichtfuß
#
# This file is part of aur-fd-scripts
#
@@ -29,15 +29,15 @@
script_path="$(realpath "$0")"
script_dir="${script_path%/*}"
-. "${script_dir}/general-config.sh" || exit 1
-. "${script_dir}/user-config.sh" || exit 1
+. "${script_dir}/general-config.bash" || exit 1
+. "${script_dir}/user-config.bash" || exit 1
function init
{
tmp_d="$(mktemp -d)"
- tmp="$tmp_d/a"
- tmp_="$tmp_d/b"
+ tmp="${tmp_d}/a"
+ tmp_="${tmp_d}/b"
}
# $1: file to treat as input: filename
@@ -81,7 +81,7 @@ function replace_line
sed -Ei "
/${1}/ {
- r $tmp_
+ r ${tmp_}
d
}
" "$tmp"
diff --git a/bin/sample.PKGBUILD b/bin/sample.PKGBUILD
index 01b6b3f..dbb985d 100644
--- a/bin/sample.PKGBUILD
+++ b/bin/sample.PKGBUILD
@@ -4,19 +4,19 @@
# Generated by aur-fd-scripts - https://git.respiranto.de/aur-fd-scripts.git/
_lang=%LANG%
-_pkgname=dict-freedict-${_lang}
-pkgname=${_pkgname}-bin
-pkgver=%VER%
-_pkgver=${pkgver//_/-}
+_pkgname="dict-freedict-${_lang}"
+pkgname="${_pkgname}-bin"
+_pkgver=%VER%
+pkgver="${_pkgver//-/_}"
pkgrel=1
-pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from Freedict.org"
+pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from FreeDict.org"
arch=('any')
url="https://freedict.org/"
license=(%LICENSES%)
optdepends=('dictd: dict client and server')
-provides=(${_pkgname})
-conflicts=(${_pkgname})
-install=${pkgname}.install
+provides=("${_pkgname}=${pkgver}")
+conflicts=("$_pkgname")
+install="${pkgname}.install"
source=("https://download.freedict.org/dictionaries/${_lang}/${_pkgver}/freedict-${_lang}-${_pkgver}.dictd.tar.xz")
sha512sums=('%CHECKSUM%')
@@ -26,13 +26,13 @@ package()
{
install -m 755 -d "${pkgdir}/usr/share/dictd"
install -m 644 -t "${pkgdir}/usr/share/dictd/" \
- ${_lang}/${_lang}.{dict.dz,index}
+ "${_lang}/${_lang}".{dict.dz,index}
- for file in ${_lang}/{AUTHORS,README,NEWS,ChangeLog}
+ for file in "$_lang"/{AUTHORS,README,NEWS,ChangeLog}
do
- if test -f ${file}
+ if test -f "$file"
then
- install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" ${file}
+ install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" "$file"
fi
done
}
diff --git a/general-config.sh b/general-config.bash
index 43b10b3..e342b03 100644
--- a/general-config.sh
+++ b/general-config.bash
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#
-# Copyright 2018 Einhard Leichtfuß
+# Copyright 2018,2022 Einhard Leichtfuß
#
-# general-config.sh - general configuration options
+# general-config.bash - general configuration options
#
# This file is part of aur-fd-scripts
#
@@ -37,7 +37,7 @@ wikdict_langs=(
)
typeset -a langs
-langs=( ${vcs_langs[@]} ${wikdict_langs[@]} )
+langs=( "${vcs_langs[@]}" "${wikdict_langs[@]}" )
# Long names table.
@@ -61,29 +61,28 @@ contrs[eng-fra-bin]=\
# Licenses (indexed by $lang)
typeset -A licenses
-for lang in ${vcs_langs[@]}
+for lang in "${vcs_langs[@]}"
do
- licenses[$lang]="'GPL'"
+ licenses["$lang"]="'GPL'"
done
-for lang in ${wikdict_langs[@]}
+for lang in "${wikdict_langs[@]}"
do
- licenses[$lang]="'CCPL:by-sa' 'FDL'"
+ licenses["$lang"]="'CCPL:by-sa' 'FDL'"
done
-# prepare() functions (indexed by $lang$ext).
+# Optional prepare() function contents (indexed by $lang$ext).
+# - Not necessarily the full function body, but possibly only a part of it.
+# - We cannot assume to be in ${srcdir}.
typeset -A prepare
# Does not work for deu-fra-bin, since the index file must stay in sync.
-prepare[deu-fra]=\
-'prepare()
-{
- cd $_lang
- sed -Ei \
- -e '"'"'s/(10)(10)(100\>)(\s+\(10)(Googol.*(1|Eins) mit einem Googol Nullen)/\1^(\2^\3)\4^\5/'"'"' \
- -e '"'"'s/(10)([1-9][0-9]*)(.*(1|Eins) mit \2 Nullen)/\1\^\2\3/'"'"' \
- -e '"'"'s/(die Zahl 10)(60)/\1^\2/'"'"' \
- ${_lang}.tei
-}
-'
+read -r -d '' prepare[deu-fra] << 'EOF' ||:
+cd "${srcdir}/${_lang}"
+sed -Ei \
+ -e 's/(10)(10)(100\>)(\s+\(10)(Googol.*(1|Eins) mit einem Googol Nullen)/\1^(\2^\3)\4^\5/' \
+ -e 's/(10)([1-9][0-9]*)(.*(1|Eins) mit \2 Nullen)/\1\^\2\3/' \
+ -e 's/(die Zahl 10)(60)/\1^\2/' \
+ "${_lang}.tei"
+EOF
diff --git a/make_install.sh b/make_install.bash
index 579586a..fac838f 100755
--- a/make_install.sh
+++ b/make_install.bash
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#
-# make_install.sh - script to create the .install files
+# make_install.bash - script to create the .install files
#
-# Copyright 2018 Einhard Leichtfuß
+# Copyright 2018,2022 Einhard Leichtfuß
#
# This file is part of aur-fd-scripts
#
@@ -22,14 +22,14 @@
script_path="$(realpath "$0")"
script_dir="${script_path%/*}"
-. "${script_dir}/basic.sh" || exit 1
+. "${script_dir}/basic.bash" || exit 1
function main
{
if [ "$#" -lt 2 ]
then
- echo "Usage: $0 <base_dir> <type> (<xy>-<zw>|-a)" >&2
+ echo "Usage: ${0} <base_dir> <type> (<xy>-<zw>|-a)" >&2
exit 1
elif [ "$#" -gt 2 ]
then
@@ -52,7 +52,7 @@ function main
make_install
done
else
- lang=$3
+ lang="$3"
make_install
fi
}
@@ -65,7 +65,7 @@ function main
#
function make_install
{
- pkgname=dict-freedict-${lang}${ext}
+ pkgname="dict-freedict-${lang}${ext}"
input "${script_dir}/sample.install"
replace "%LANG%" "$lang"
diff --git a/sample.install b/sample.install
index f405077..34f6919 100644
--- a/sample.install
+++ b/sample.install
@@ -1,12 +1,12 @@
# Generated by aur-fd-scripts - https://git.respiranto.de/aur-fd-scripts.git/
basename=%LANG%
-pkgname=dict-freedict-$basename%SUFFIX%
+pkgname="dict-freedict-${basename}%SUFFIX%"
dictd_conf=/etc/dict/dictd.conf
datadir=/usr/share/dictd
-conf="database $basename {
- data $datadir/$basename.dict.dz
- index $datadir/$basename.index
+conf="database ${basename} {
+ data ${datadir}/${basename}.dict.dz
+ index ${datadir}/${basename}.index
}"
post_install()
@@ -14,12 +14,12 @@ post_install()
echo
if pacman -Qq dictd > /dev/null 2>&1
then
- if grep -q "^database *$basename" "$dictd_conf"
+ if grep -q "^database *${basename}" "${dictd_conf}"
then
- echo "$pkgname already configured in $dictd_conf"
+ echo "${pkgname} already configured in ${dictd_conf}"
else
- echo "Adding configuration for $pkgname to $dictd_conf"
- echo "$conf" >> "$dictd_conf"
+ echo "Adding configuration for ${pkgname} to ${dictd_conf}"
+ echo "${conf}" >> "${dictd_conf}"
fi
if systemctl -q is-active dictd.service
@@ -56,17 +56,17 @@ post_remove()
{
if pacman -Qq dictd > /dev/null 2>&1
then
- current_conf="$(grep -A 3 "^database *$basename" "$dictd_conf")"
- if test -n "$current_conf"
+ current_conf="$(grep -A 3 "^database *${basename}" "${dictd_conf}")"
+ if test -n "${current_conf}"
then
echo
- if test "$current_conf" = "$conf"
+ if test "${current_conf}" = "${conf}"
then
- echo "Removing configuration for $pkgname from $dictd_conf"
- sed -i "/database $basename {/,/}/d" "$dictd_conf"
+ echo "Removing configuration for ${pkgname} from ${dictd_conf}"
+ sed -i "/database ${basename} {/,/}/d" "${dictd_conf}"
else
echo "User created / modified configuration" \
- "for $pkgname in $dictd_conf is left untouched."
+ "for ${pkgname} in ${dictd_conf} is left untouched."
fi
fi
diff --git a/src/sample.PKGBUILD b/src/sample.PKGBUILD
index ced78fd..f22a6f0 100644
--- a/src/sample.PKGBUILD
+++ b/src/sample.PKGBUILD
@@ -4,17 +4,17 @@
# Generated by aur-fd-scripts - https://git.respiranto.de/aur-fd-scripts.git/
_lang=%LANG%
-pkgname=dict-freedict-${_lang}
-pkgver=%VER%
-_pkgver=${pkgver//_/-}
+pkgname="dict-freedict-${_lang}"
+_pkgver=%VER%
+pkgver="${_pkgver//-/_}"
pkgrel=1
-pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from Freedict.org"
+pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from FreeDict.org"
arch=('any')
url="https://freedict.org/"
license=(%LICENSES%)
optdepends=('dictd: dict client and server')
-makedepends=('dictd' 'freedict-tools')
-install=${pkgname}.install
+makedepends=('freedict-tools')
+install="${pkgname}.install"
source=("https://download.freedict.org/dictionaries/${_lang}/${_pkgver}/freedict-${_lang}-${_pkgver}.src.tar.xz")
sha512sums=('%CHECKSUM%')
@@ -22,7 +22,7 @@ sha512sums=('%CHECKSUM%')
build()
{
- cd $_lang
+ cd "$_lang"
make FREEDICT_TOOLS=/usr/lib/freedict-tools build-dictd
}
@@ -30,13 +30,13 @@ package()
{
install -m 755 -d "${pkgdir}/usr/share/dictd"
install -m 644 -t "${pkgdir}/usr/share/dictd/" \
- ${_lang}/build/dictd/${_lang}.{dict.dz,index}
+ "${_lang}/build/dictd/${_lang}".{dict.dz,index}
- for file in ${_lang}/{AUTHORS,README,NEWS,ChangeLog}
+ for file in "$_lang"/{AUTHORS,README,NEWS,ChangeLog}
do
- if test -f ${file}
+ if test -f "$file"
then
- install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" ${file}
+ install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" "$file"
fi
done
}
diff --git a/svn/sample.PKGBUILD b/svn/sample.PKGBUILD
index 452640a..3f49e82 100644
--- a/svn/sample.PKGBUILD
+++ b/svn/sample.PKGBUILD
@@ -4,33 +4,41 @@
# Generated by aur-fd-scripts - https://git.respiranto.de/aur-fd-scripts.git/
_lang=%LANG%
-_pkgname=dict-freedict-${_lang}
-pkgname=${_pkgname}-svn
-pkgver=%VER%
-_pkgver=${pkgver//_/-}
+_pkgname="dict-freedict-${_lang}"
+pkgname="${_pkgname}-svn"
+_pkgver=%VER%
+pkgver="${_pkgver//-/_}"
pkgrel=2
-pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from Freedict.org"
+pkgdesc="%LANG_A% -> %LANG_B% dictionary for dictd et al. from FreeDict.org"
arch=('any')
url="https://freedict.org/"
license=(%LICENSES%)
optdepends=('dictd: dict client and server')
-makedepends=('subversion' 'dictd' 'freedict-tools')
-provides=(${_pkgname})
-conflicts=(${_pkgname})
-install=${pkgname}.install
-source=("svn+https://github.com/freedict/fd-dictionaries/trunk/${_lang}")
-md5sums=('SKIP')
+makedepends=('subversion' 'freedict-tools')
+provides=("$_pkgname")
+conflicts=("$_pkgname")
+install="${pkgname}.install"
+source=("${pkgname}::svn+https://github.com/freedict/fd-dictionaries/trunk/${_lang}")
+sha512sums=('SKIP')
+
+prepare()
+{
+ # The Makefile expects the TEI XML file to reside in a directory named
+ # ${_lang}.
+ mv "$pkgname" "$_lang"
+%PREPARE_CONTENT%
+}
pkgver()
{
- cd $_lang
+ cd "$_lang"
local _ver="$(svnversion)"
printf "r%s" "${_ver//[[:alpha:]]}"
}
build()
{
- cd $_lang
+ cd "$_lang"
make FREEDICT_TOOLS=/usr/lib/freedict-tools build-dictd
}
@@ -38,13 +46,13 @@ package()
{
install -m 755 -d "${pkgdir}/usr/share/dictd"
install -m 644 -t "${pkgdir}/usr/share/dictd/" \
- ${_lang}/build/dictd/${_lang}.{dict.dz,index}
+ "${_lang}/build/dictd/${_lang}".{dict.dz,index}
- for file in ${_lang}/{AUTHORS,README,NEWS,ChangeLog}
+ for file in "$_lang"/{AUTHORS,README,NEWS,ChangeLog}
do
- if test -f ${file}
+ if test -f "$file"
then
- install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" ${file}
+ install -m 644 -Dt "${pkgdir}/usr/share/doc/freedict/${_lang}/" "$file"
fi
done
}
diff --git a/update.sh b/update.bash
index a032671..5be3658 100755
--- a/update.sh
+++ b/update.bash
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#
-# update.sh - script to check for updates and perform them (on the PKGBUILDs)
+# update.bash - script to check for updates and perform them (on the PKGBUILDs)
#
-# Copyright 2018 Einhard Leichtfuß
+# Copyright 2018,2022 Einhard Leichtfuß
#
# This file is part of aur-fd-scripts
#
@@ -33,14 +33,14 @@
script_path="$(realpath "$0")"
script_dir="${script_path%/*}"
-. "${script_dir}/basic.sh" || exit 1
+. "${script_dir}/basic.bash" || exit 1
function main
{
if [ "$#" -lt 2 ]
then
- echo "Usage: $0 <base_dir> <type> [--nopull] [-u <xy>-<zw>|-ua|-uaf]" >&2
+ echo "Usage: ${0} <base_dir> <type> [--nopull] [-u <xy>-<zw>|-ua|-uaf]" >&2
exit 1
else
cd "$1" || exit 1
@@ -69,7 +69,7 @@ function main
then
handle_all_vcs svn -svn "$@"
else
- echo "Type $type not supported." >&2
+ echo "Type ${type} not supported." >&2
exit 1
fi
}
@@ -93,19 +93,18 @@ function update
replace '%LANG%' "$lang"
replace '%LANG_A%' "$lang_a"
replace '%LANG_B%' "$lang_b"
- replace '%VER%' "$convver"
+ replace '%VER%' "$ver"
replace '%LICENSES%' "${licenses[$lang]}"
replace '%CHECKSUM%' "$checksum"
replace_line '%CONTRS%' "${contrs[${lang}${ext}]}" normal
- if [[ "$ver" == "$convver" ]]
- then
- delete_line '^_pkgver=\$\{pkgver\/\/_\/-\}$'
- replace '_pkgver' 'pkgver'
- fi
-
- replace_line '%PREPARE%' "${prepare[${lang}${ext}]}" rm-plus-one
+ local rstring_base="${prepare[${lang}${ext}]}"
+ local rstring
+ rstring=$'\n'"$(sed -E 's/^/\t/' <<< "$rstring_base")"$'\n'
+ replace_line '%PREPARE_CONTENT%' "${rstring_base:+${rstring}}"
+ rstring=$'prepare()\n{'"$rstring"$'}\n'
+ replace_line '%PREPARE%' "${rstring_base:+${rstring}}" rm-plus-one
write PKGBUILD
makepkg --printsrcinfo > .SRCINFO
@@ -128,7 +127,7 @@ function handle_all
platform="$3"
shift 3
- curl -sO https://freedict.org/freedict-database.json || exit 1
+ curl -sSO https://freedict.org/freedict-database.json || exit 1
cd "$type" || exit 1
@@ -137,7 +136,7 @@ function handle_all
cd $lang || exit 1
$nopull || git pull -q
pkgver="$(sed -En 's/\s*pkgver\s*=\s*(.+)\s*/\1/p' .SRCINFO)"
- data="$(jq -r ".[] | select(.name == \"${lang}\") | .releases[] | select(.platform==\"$platform\")" ../../freedict-database.json)"
+ data="$(jq -r ".[] | select(.name == \"${lang}\") | .releases[] | select(.platform==\"${platform}\")" ../../freedict-database.json)"
ver="$(jq -r '.version' <<< "$data")"
url="$(jq -r '.URL' <<< "$data")"
checksum="$(jq -r '.checksum' <<< "$data")"
@@ -186,9 +185,9 @@ function handle_all_vcs
cd "$type" || exit 1
- for lang in ${vcs_langs[@]}
+ for lang in "${vcs_langs[@]}"
do
- cd $lang || exit 1
+ cd "$lang" || exit 1
$nopull || git pull -q
pkgver="$(sed -En 's/\s*pkgver\s*=\s*(.+)\s*/\1/p' .SRCINFO)"
makepkg --nobuild --nodeps > /dev/null 2>&1
diff --git a/user-config.default.bash b/user-config.default.bash
new file mode 100644
index 0000000..a2e0eca
--- /dev/null
+++ b/user-config.default.bash
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+#
+# user-config.default.bash - user configuration options;
+# copy this file to user-config.bash and modify to
+# your liking.
+#
+
+# The maintainer to be listed in the PKGBUILD.
+maintainer="Your Name <your@email-address.tld>"
diff --git a/user-config.default.sh b/user-config.default.sh
deleted file mode 100644
index 4675afb..0000000
--- a/user-config.default.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-#
-# user-config.default.sh - user configuration options;
-# copy this file to user-config.sh and modify to
-# your liking.
-#
-
-# The maintainer to be listed in the PKGBUILD.
-maintainer="Your Name <your@email-address.tld>"