summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO21
-rw-r--r--PKGBUILD32
-rw-r--r--dict-cedict-git.install80
3 files changed, 133 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..64a0a478b6a
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,21 @@
+pkgbase = dict-cedict-git
+ pkgdesc = A port of CC-CEDICT database for dictd et al.
+ pkgver = 20201117.r5.255bb57
+ pkgrel = 1
+ url = https://www.mdbg.net/chinese/dictionary?page=cc-cedict
+ install = dict-cedict-git.install
+ arch = any
+ license = CCPL
+ makedepends = dictd
+ makedepends = git
+ makedepends = python
+ makedepends = curl
+ makedepends = gzip
+ optdepends = dictd: dict client and server
+ provides = dict-cedict
+ conflicts = dict-cedict
+ source = git+https://github.com/tuberry/dict-cedict
+ sha512sums = SKIP
+
+pkgname = dict-cedict-git
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..7450be0c2ca
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,32 @@
+# Maintainer: tuberry
+
+_srcname=dict-cedict
+pkgname=dict-cedict-git
+pkgver=20201117.r5.255bb57
+pkgrel=1
+pkgdesc="A port of CC-CEDICT database for dictd et al."
+arch=('any')
+url="https://www.mdbg.net/chinese/dictionary?page=cc-cedict"
+license=('CCPL')
+optdepends=('dictd: dict client and server')
+makedepends=('dictd' 'git' 'python' 'curl' 'gzip')
+provides=('dict-cedict')
+conflicts=('dict-cedict')
+install=${pkgname}.install
+source=("git+https://github.com/tuberry/${_srcname}")
+sha512sums=('SKIP')
+
+pkgver()
+{
+ cd ${_srcname}
+ printf "%s.r%s.%s" \
+ "$( curl ${url} 2>&1 | grep Latest | grep -Eo '[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}' | tr -d '-' )" \
+ "$( git rev-list --count HEAD )" \
+ "$( git rev-parse --short HEAD )"
+}
+
+package()
+{
+ cd ${_srcname}
+ make DESTDIR=${pkgdir} install
+}
diff --git a/dict-cedict-git.install b/dict-cedict-git.install
new file mode 100644
index 00000000000..8e70001f855
--- /dev/null
+++ b/dict-cedict-git.install
@@ -0,0 +1,80 @@
+# steal from dict-freedict-*s
+
+basename=cedict
+pkgname=dict-$basename-git
+dictd_conf=/etc/dict/dictd.conf
+datadir=/usr/share/dictd
+conf="database $basename {
+data $datadir/$basename.dict.dz
+index $datadir/$basename.index
+}"
+
+post_install()
+{
+ echo
+ if pacman -Qq dictd > /dev/null 2>&1
+ then
+ if grep -q "^database *$basename" "$dictd_conf"
+ then
+ echo "$pkgname already configured in $dictd_conf"
+ else
+ echo "Adding configuration for $pkgname to $dictd_conf"
+ echo "$conf" >> "$dictd_conf"
+ fi
+
+ if systemctl -q is-active dictd.service
+ then
+ echo "Restarting dictd service in order to" \
+ "use the new dictionary database"
+ systemctl restart dictd.service
+ else
+ echo "Starting dictd service in order to" \
+ "use the new dictionary database"
+ systemctl start dictd.service
+ fi
+ else
+ echo "dictd does not appear to be installed."
+ echo "In order to use this database you should either" \
+ "install dictd or alternatively" \
+ "another dict server and configure it on your own."
+ fi
+ echo
+}
+
+post_upgrade()
+{
+ if pacman -Qq dictd > /dev/null 2>&1 && \
+ systemctl -q is-active dictd.service
+ then
+ echo -e "\nRestarting dictd service in order to" \
+ "use the updated dictionary database"
+ systemctl restart dictd.service
+ fi
+}
+
+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"
+ then
+ echo
+ if test "$current_conf" = "$conf"
+ then
+ 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."
+ fi
+ fi
+
+ if systemctl -q is-active dictd.service
+ then
+ echo "Restarting dictd service in order to" \
+ "stop using the removed dictionary database"
+ systemctl restart dictd.service
+ fi
+ fi
+}