Koha/debian/koha-common.postinst
Tomas Cohen Arazi 2a7e71554b Bug 10942: (QA followup) make warnings to to STDERR
As noted by Robin, STDOUT is used by the script to communicate with
debconf and, hence, the warning messages should be directed to STDERR.

This patch does that. To test:

- Set AUTOMATIC_TRANSLATIONS_UPDATE="no" so the warning normally shows
- Redirect STDOUT to /dev/null:
  dpkg -i koha-common...deb > /dev/null
=> Warning message doesn't show (i.e. it is sent to STDOUT)
- Apply the patch, rebuild package
- Redirect STDOUT to /dev/null:
  dpkg -i koha-common...deb > /dev/null
=> Warning message shows (i.e. is correctly sent to STDERR)
- Redirect STDERR to /dev/null:
  dpkg -i koha-common...deb 2> /dev/null
=> Warning message doesn't show
- Verify that previous tests pass

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2014-04-24 12:50:54 +00:00

83 lines
2.2 KiB
Bash

#!/bin/sh
set -e
# Default to "yes"
AUTOMATIC_TRANSLATIONS_UPDATE="yes"
. /usr/share/debconf/confmodule
# Read configuration variable file if it is present
CONFIG=/etc/koha/koha-common.conf
if [ -r $CONFIG ]; then
. $CONFIG
fi
conf=/etc/mysql/koha-common.cnf
if [ ! -e "$conf" ] && [ ! -L "$conf" ]
then
ln -s debian.cnf "$conf"
fi
#DEBHELPER#
koha-upgrade-schema $(koha-list)
# Generate a config file if one doesn't exist already
if [ ! -e $CONFIG ]; then
cat <<EOF > $CONFIG
## Automatic template translation update
#
# This variable controls whether template translations should
# be updated automatically on koha-common package upgrades.
# Options: 'yes' (default)
# 'no'
# Note: if you choose 'no' then you will have to issue
# $ koha-translate --update <lang_code>
#
AUTOMATIC_TRANSLATIONS_UPDATE="yes"
EOF
fi
# Substitute the values from debconf into the file.
db_get koha-common/automatically-update-translations
UPDATE="$RET"
if [ "$UPDATE" = "false" ]; then
UPDATE="no"
else
UPDATE="yes"
fi
# In case they were removed/commented out, we add it in.
grep -Eq '^ *AUTOMATIC_TRANSLATIONS_UPDATE=' $CONFIG || \
echo "AUTOMATIC_TRANSLATIONS_UPDATE=" >> $CONFIG
sed -e "s/^ *AUTOMATIC_TRANSLATIONS_UPDATE=.*/AUTOMATIC_TRANSLATIONS_UPDATE=\"$UPDATE\"/" < $CONFIG > $CONFIG.tmp
mv -f $CONFIG.tmp $CONFIG
if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then
for lang in $(koha-translate --list | grep -v -x "en"); do
if koha-translate --update $lang; then
echo "Updated the $lang translations."
else
cat <<EOF >&2
ERROR: an error was found when updating '$lang' translations. Please manually
run 'koha-translate --update $lang'. Run man koha-translate for more options.
EOF
fi
done
else
# no auto-update, check update needed and warn if needed
if koha-translate --list | grep -v -q -x "en"; then
# translations installed, update needed
cat <<EOF >&2
Warning: template translations are not set to be automatically updated.
Please manually run 'koha-translate --update lang_code' to update them.
You can run 'koha-translate --list' to get a list of the installed translations codes.
EOF
fi
fi
db_stop
exit 0