diff options
author | Jaja | 2019-03-19 01:06:04 +0100 |
---|---|---|
committer | Jaja | 2019-03-19 01:06:04 +0100 |
commit | 4e1f2001c65175462f52392da467299ecee219a7 (patch) | |
tree | 11ccc21626b8793cf1cf5836e53b6094e4beaa3e | |
parent | f38b4b0dbb36024b682293cd632413efb06de153 (diff) | |
download | aur-4e1f2001c65175462f52392da467299ecee219a7.tar.gz |
config file script; bsdtar unpack; fix locale
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 11 | ||||
-rw-r--r-- | languagetool-word2vec-de.install | 56 |
3 files changed, 59 insertions, 12 deletions
@@ -1,16 +1,14 @@ pkgbase = languagetool-word2vec-de pkgdesc = Finding errors using neural network rules, german text pkgver = 20180211 - pkgrel = 1 + pkgrel = 2 url = https://forum.languagetool.org/t/neural-network-rules/2225 install = languagetool-word2vec-de.install arch = any license = CCPL - makedepends = unzip optdepends = languagetool: system wide installation of LT optdepends = libreoffice-extension-languagetool: standalone LT for LibreOffice optdepends = openoffice-extension-languagetool: standalone LT for OpenOffice - noextract = languagetool-word2vec-de-20180211.zip options = !strip source = languagetool-word2vec-de-20180211.zip::https://languagetool.org/download/word2vec/de.zip md5sums = 46bf12792ae3a8095e9e215a47a8cf02 @@ -3,7 +3,7 @@ pkgname=languagetool-word2vec-de pkgver=20180211 -pkgrel=1 +pkgrel=2 pkgdesc="Finding errors using neural network rules, german text" arch=('any') url="https://forum.languagetool.org/t/neural-network-rules/2225" @@ -11,16 +11,15 @@ license=('CCPL') optdepends=('languagetool: system wide installation of LT' 'libreoffice-extension-languagetool: standalone LT for LibreOffice' 'openoffice-extension-languagetool: standalone LT for OpenOffice') -makedepends=('unzip') install=${pkgname}.install source=(${pkgname}-${pkgver}.zip::"https://languagetool.org/download/word2vec/de.zip") -noextract=(${pkgname}-${pkgver}.zip) md5sums=('46bf12792ae3a8095e9e215a47a8cf02') -PKGEXT='.pkg.tar' -LANG='C' +#PKGEXT='.pkg.tar' +#LANG='C' options=(!strip) package() { install -d "${pkgdir}"/usr/share/word2vec - unzip -q "${srcdir}"/${pkgname}-${pkgver}.zip -d "${pkgdir}"/usr/share/word2vec + unlink "${srcdir}"/${pkgname}-${pkgver}.zip + mv "${srcdir}"/* "${pkgdir}"/usr/share/word2vec/ } diff --git a/languagetool-word2vec-de.install b/languagetool-word2vec-de.install index 1183d01084a0..0b6111f4e2b9 100644 --- a/languagetool-word2vec-de.install +++ b/languagetool-word2vec-de.install @@ -1,5 +1,55 @@ post_install() { - echo '' - echo 'Do not forget to add "word2vecDir=/usr/share/word2vec" in ~/.languagetool[-ooo].cfg or use LanguageTool GUI config to point to "/usr/share/word2vec"!' - echo '' + # This is a simple, but verbosely written script to change or add a "key=value" line + # in two configuration files in every users home directory and the skeleton directory. + + _CONFIGLT=".languagetool.cfg" + _CONFIGOO=".languagetool-ooo.cfg" + _KEY="word2vecDir" + _VALUE="/usr/share/word2vec" + + _update_file() { + if (grep -Fxq "$_KEY=$_VALUE" "$1/$2" 2> /dev/null); then + # Skip if "key=value" is in place, or + printf " \e[32mUp-to-date\e[0m\t| $1/$2\n" + else + if (grep -Fq "$_KEY=" "$1/$2" 2> /dev/null); then + # update to match the desired value if the key exists, or + (sed 's|^'$_KEY'=.*|'$_KEY'='$_VALUE'|' -i "$1/$2") + printf " \e[33mValue updated\e[0m\t| $1/$2\n" + else + # append the "key=value" to the, possibly just created, configuration file. + (printf "$_KEY=$_VALUE\n" >> "$1/$2") + printf " \e[95mLine added\e[0m\t| $1/$2\n" + fi + fi + # Fix the ownership of the configuration file. + (chown --reference="$1" "$1/$2") + } + + printf "\e[1mUpdating configuration files to match \"$_KEY=$_VALUE\"\e[0m.\n" + # For a user's home directory under /home, + for USERDIR in $(getent passwd | cut -d: -f6 | grep /home); do + # that actually exists, + if [ -d "$USERDIR" ]; then + # update the 1st configuration file and + _update_file "$USERDIR" "$_CONFIGLT" + if [ -e "$USERDIR/$_CONFIGOO" ]; then + # update the 2nd configuration file if it exists, or + _update_file "$USERDIR" "$_CONFIGOO" + else + # create symbolic link to the 1st if it doesn't. + (ln -s "$_CONFIGLT" "$USERDIR/$_CONFIGOO") + printf " \e[95mLink created\e[0m\t| $USERDIR/$_CONFIGOO\n" + fi + fi + done + + # For any later created user, provide skeleton files + _update_file "/etc/skel" "$_CONFIGLT" + if [ -e "/etc/skel/$_CONFIGOO" ]; then + _update_file "/etc/skel" "$_CONFIGOO" + else + (ln -s "$_CONFIGLT" "/etc/skel/$_CONFIGOO") + printf " \e[95mLink created\e[0m\t| /etc/skel/$_CONFIGOO\n" + fi } |