Bugzilla – Attachment 26223 Details for
Bug 10942
Provide a way for package upgrades to update template translations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10942 - debconfing the update option
Bug-10942---debconfing-the-update-option.patch (text/plain), 5.12 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-03-12 23:16:39 UTC
(
hide
)
Description:
Bug 10942 - debconfing the update option
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-03-12 23:16:39 UTC
Size:
5.12 KB
patch
obsolete
>From 634c2392e552c018a1682d4abb0aa881ef856a99 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Wed, 12 Mar 2014 17:24:36 +1300 >Subject: [PATCH] Bug 10942 - debconfing the update option > >This causes a question to be asked at installation time as to whether >translations should be updated or not. The answer is written to the >config file, and stored in debconf. Effort is taken to ensure that if >the admin changes the config file, the update will be picked up and >reflected in debconf (i.e. that the admin's decision is always the >correct one.) > >Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> >Fixed two typos that made it fail and it worked like a charm. > >Tested like this: > >- Install the package >=> no errors, the file is created, defaults to 'yes' >- Install a language (koha-translate --install es-ES) >- Re-install the package (simulating an upgrade) >=> es-ES gets updated >- Set preference to 'no' >- Re-install >=> es-ES doesn't get updated, the warning is printed correctly >- Installed a second language (koha-translate --install pt-BR) >- did all the tests again >=> Success > >Note: on master there are obvious template translation warnings. >A copy of the generated package can be grabbed from: >http://es.koha-community.org/koha-common_3.15+20140312172225.af7c0a23_all.deb >--- > debian/koha-common.config | 20 +++++++++++++++++++- > debian/koha-common.postinst | 36 ++++++++++++++++++++++++++++++++++-- > debian/koha-common.templates | 7 +++++++ > debian/templates/koha-common.conf | 2 +- > 4 files changed, 61 insertions(+), 4 deletions(-) > >diff --git a/debian/koha-common.config b/debian/koha-common.config >index 716119d..3f97df9 100755 >--- a/debian/koha-common.config >+++ b/debian/koha-common.config >@@ -21,8 +21,26 @@ set -e > > . /usr/share/debconf/confmodule > >+CONFIGFILE=/etc/koha/koha-common.conf >+ >+if [ -e $CONFIGFILE ]; then >+ . $CONFIGFILE || true >+ # Put the current values into debconf >+ UPDATE="true" >+ if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "no" ] ; then >+ UPDATE="false" >+ fi >+ db_set koha-common/automatically-update-translations "$UPDATE" >+else >+ # True is the default >+ db_set koha-common/automatically-update-translations true >+fi >+ > if dpkg --compare-versions "$2" lt-nl 3.4 ; then > db_input high koha-common/3.2-3.4-upgrade-notice || true > fi >-db_go >+ >+db_input medium koha-common/automatically-update-translations || true >+ >+db_go || true > >diff --git a/debian/koha-common.postinst b/debian/koha-common.postinst >index d061403..47acd42 100644 >--- a/debian/koha-common.postinst >+++ b/debian/koha-common.postinst >@@ -8,8 +8,9 @@ AUTOMATIC_TRANSLATIONS_UPDATE="yes" > . /usr/share/debconf/confmodule > > # Read configuration variable file if it is present >-if [ -r /etc/koha/koha-common.conf ]; then >- . /etc/koha/koha-common.conf >+CONFIG=/etc/koha/koha-common.conf >+if [ -r $CONFIG ]; then >+ . $CONFIG > fi > > conf=/etc/mysql/koha-common.cnf >@@ -22,6 +23,37 @@ fi > > 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 >diff --git a/debian/koha-common.templates b/debian/koha-common.templates >index f88449e..5576fe8 100644 >--- a/debian/koha-common.templates >+++ b/debian/koha-common.templates >@@ -8,3 +8,10 @@ Description: koha-common upgrade actions required > should be largely operational during the process, but some things, > particularly to do with items, may appear strange until the upgrade and > re-index is complete. >+ >+Template: koha-common/automatically-update-translations >+Type: boolean >+Default: true >+Description: automatically update translations >+ When Koha is upgraded, any existing translated templates can be regenerated >+ to keep everything in sync. Select "yes" if you want this. >diff --git a/debian/templates/koha-common.conf b/debian/templates/koha-common.conf >index 331a893..b4e3db6 100644 >--- a/debian/templates/koha-common.conf >+++ b/debian/templates/koha-common.conf >@@ -14,4 +14,4 @@ > # Note: if you choose 'no' then you will have to issue > # $ koha-translate --update <lang_code> > # >-#AUTOMATIC_TRANSLATIONS_UPDATE="yes" >+AUTOMATIC_TRANSLATIONS_UPDATE="yes" >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10942
:
21459
|
21461
|
24096
|
24972
|
26122
|
26132
|
26133
|
26134
|
26135
|
26136
|
26137
|
26138
|
26220
|
26221
|
26222
|
26223
|
26301
|
27454
|
27455
|
27456
|
27457
|
27458