summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorrespiranto2015-08-10 00:43:27 +0200
committerrespiranto2015-08-10 00:43:27 +0200
commitdfff46e2c37927028e2087e08badb703db315920 (patch)
tree42fbdaa2b15572640e2cf3c6db98730102f90171
parent5cb2ec8b0b972efe35d759db3580ea6c7d3e44f7 (diff)
downloadaur-dfff46e2c37927028e2087e08badb703db315920.tar.gz
Improved the .install file and made dictd optional
- automated dictd configuration - notification if dictd is not installed - (re-)start dictd upon first install - restart dictd after each upgrade if it was running
-rw-r--r--.SRCINFO5
-rw-r--r--PKGBUILD9
-rw-r--r--dict-freedict-eng-deu.install72
3 files changed, 76 insertions, 10 deletions
diff --git a/.SRCINFO b/.SRCINFO
index a9493468cc02..859cc34cf93b 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,12 +1,13 @@
pkgbase = dict-freedict-eng-deu
pkgdesc = English -> German dictionary for dictd from Freedict.org
pkgver = 0.3.6
- pkgrel = 1
+ pkgrel = 2
url = http://www.freedict.org/
install = dict-freedict-eng-deu.install
arch = any
license = GPL
- depends = dictd
+ makedepends = dictd
+ optdepends = dictd: dict client and server
source = http://sourceforge.net/projects/freedict/files/English%20-%20German/0.3.6/freedict-eng-deu-0.3.6.tar.bz2
md5sums = 6b832d207ab166d49bff5e22e21ef328
diff --git a/PKGBUILD b/PKGBUILD
index cec5b8b03f20..4e9779a4e93b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,14 +1,15 @@
-# Contributor: akane <grangerspit@gmail.com> <xmpp:heiß@neko.im>
# Maintainer: respiranto <respiranto@icloud.com>
+# Contributor: akane <grangerspit@gmail.com> <xmpp:heiß@neko.im>
pkgname=dict-freedict-eng-deu
pkgver=0.3.6
-pkgrel=1
+pkgrel=2
pkgdesc="English -> German dictionary for dictd from Freedict.org"
arch=('any')
url="http://www.freedict.org/"
license=('GPL')
-depends=(dictd)
-install=dict-freedict-eng-deu.install
+makedepends=('dictd')
+optdepends=('dictd: dict client and server')
+install=$pkgname.install
source=("http://sourceforge.net/projects/freedict/files/English%20-%20German/$pkgver/freedict-eng-deu-$pkgver.tar.bz2")
md5sums=('6b832d207ab166d49bff5e22e21ef328')
diff --git a/dict-freedict-eng-deu.install b/dict-freedict-eng-deu.install
index cf923dd12079..c4d9eaa6d9ba 100644
--- a/dict-freedict-eng-deu.install
+++ b/dict-freedict-eng-deu.install
@@ -1,7 +1,71 @@
+pkgname=dict-freedict-eng-deu
+basename=eng-deu
+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 -e "\nYou have to configure dictd to use the new dictionary" \
- "database located in /usr/share/dictd/ manually" \
- "and restart the dictd service afterwards.\n\n" \
- "See also dictd(8).\n"
+ 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 -e "$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
+ fi
}