summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaja2019-03-19 01:05:09 +0100
committerJaja2019-03-19 01:05:09 +0100
commit0048f5876cb57f4c518a12a60906947d6beee7d0 (patch)
treecdebddb0c68a4f0c298fe78483229d29b3f93f2f
parent13054c794060adff37dac6fba9570296ea2c2408 (diff)
downloadaur-0048f5876cb57f4c518a12a60906947d6beee7d0.tar.gz
config file script; bsdtar unpack
-rw-r--r--.SRCINFO2
-rw-r--r--PKGBUILD5
-rw-r--r--languagetool-ngrams-it.install56
3 files changed, 55 insertions, 8 deletions
diff --git a/.SRCINFO b/.SRCINFO
index cc32bd04b9c5..c20bbab194a2 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -6,11 +6,9 @@ pkgbase = languagetool-ngrams-it
install = languagetool-ngrams-it.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-ngrams-it-20150915.zip
options = !strip
source = languagetool-ngrams-it-20150915.zip::https://languagetool.org/download/ngram-data/untested/ngram-it-20150915.zip
md5sums = b6402b56d77ce55b205073f6df761309
diff --git a/PKGBUILD b/PKGBUILD
index 681daecaa39e..e85154618a5a 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -11,10 +11,8 @@ 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/ngram-data/untested/ngram-it-${pkgver}.zip")
-noextract=(${pkgname}-${pkgver}.zip)
md5sums=('b6402b56d77ce55b205073f6df761309')
PKGEXT='.pkg.tar'
options=(!strip)
@@ -30,5 +28,6 @@ prepare() {
package() {
install -d "${pkgdir}"/usr/share/ngrams
- unzip -q "${srcdir}"/${pkgname}-${pkgver}.zip -d "${pkgdir}"/usr/share/ngrams
+ unlink "${srcdir}"/${pkgname}-${pkgver}.zip
+ mv "${srcdir}"/* "${pkgdir}"/usr/share/ngrams/
}
diff --git a/languagetool-ngrams-it.install b/languagetool-ngrams-it.install
index 1840d39d81d0..a01b606e2081 100644
--- a/languagetool-ngrams-it.install
+++ b/languagetool-ngrams-it.install
@@ -1,5 +1,55 @@
post_install() {
- echo ''
- echo 'Do not forget to add "ngramDir=/usr/share/ngrams" in ~/.languagetool[-ooo].cfg or use LanguageTool GUI config to point to "/usr/share/ngrams"!'
- 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="ngramDir"
+ _VALUE="/usr/share/ngrams"
+
+ _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
}