[Debian-l10n-commits] r2764 - in /pootle/trunk/debian: dbconfig.template patches/debian_extra_config.patch patches/series pootle.config pootle.postinst pootle.postrm pootle.templates
themill-guest at users.alioth.debian.org
themill-guest at users.alioth.debian.org
Wed Nov 16 16:08:00 UTC 2011
Author: themill-guest
Date: Wed Nov 16 16:07:59 2011
New Revision: 2764
URL: http://svn.debian.org/wsvn/?sc=1&rev=2764
Log:
Handle existing sqlite installations on upgrade
Added:
pootle/trunk/debian/patches/debian_extra_config.patch
pootle/trunk/debian/pootle.templates
Modified:
pootle/trunk/debian/dbconfig.template
pootle/trunk/debian/patches/series
pootle/trunk/debian/pootle.config
pootle/trunk/debian/pootle.postinst
pootle/trunk/debian/pootle.postrm
Modified: pootle/trunk/debian/dbconfig.template
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/dbconfig.template?rev=2764&op=diff
==============================================================================
--- pootle/trunk/debian/dbconfig.template (original)
+++ pootle/trunk/debian/dbconfig.template Wed Nov 16 16:07:59 2011
@@ -6,4 +6,7 @@
DATABASE_PORT = '_DBC_DBPORT_' # Set to empty string for default. Not used with sqlite3.
if DATABASE_ENGINE == 'pgsql':
- DATABASE_ENGINE = 'postgresql_psycopg2'
+ DATABASE_ENGINE = 'postgresql_psycopg2'
+
+if DATABASE_ENGINE == 'sqlite3':
+ DATABASE_NAME = working_path('dbs/pootle.db')
Added: pootle/trunk/debian/patches/debian_extra_config.patch
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/patches/debian_extra_config.patch?rev=2764&op=file
==============================================================================
--- pootle/trunk/debian/patches/debian_extra_config.patch (added)
+++ pootle/trunk/debian/patches/debian_extra_config.patch Wed Nov 16 16:07:59 2011
@@ -1,0 +1,20 @@
+--- a/localsettings.py
++++ b/localsettings.py
+@@ -5,6 +5,8 @@
+ # Import some helper functions:
+ from pootle.install_dirs import *
+
++execfile(config_path("debian_config.py"))
++
+ # Mail settings
+
+ # Address used for messages sent by Pootle.
+@@ -65,7 +67,7 @@
+ # By default we use Django's in memory cache which is only suitable
+ # for small deployments. memcached is preferred. For more info, check
+ # http://docs.djangoproject.com/en/dev/topics/cache/#setting-up-the-cache
+-CACHE_BACKEND = 'db://pootlecache?max_entries=65536&cull_frequency=16'
++#CACHE_BACKEND = 'db://pootlecache?max_entries=65536&cull_frequency=16'
+
+ # Uncomment to use memcached for caching
+ #CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
Modified: pootle/trunk/debian/patches/series
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/patches/series?rev=2764&op=diff
==============================================================================
--- pootle/trunk/debian/patches/series (original)
+++ pootle/trunk/debian/patches/series Wed Nov 16 16:07:59 2011
@@ -3,4 +3,5 @@
#pootle_continue_after_po_failure.patch
#import_old_config.patch
debian_remove_external
-debian_use_dbconfig.patch
+debian_use_dbconfig.patch
+debian_extra_config.patch
Modified: pootle/trunk/debian/pootle.config
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/pootle.config?rev=2764&op=diff
==============================================================================
--- pootle/trunk/debian/pootle.config (original)
+++ pootle/trunk/debian/pootle.config Wed Nov 16 16:07:59 2011
@@ -4,10 +4,27 @@
. /usr/share/debconf/confmodule
+POOTLE_HOME=/var/lib/pootle
+
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
- dbc_dbtypes="mysql, pgsql"
+ dbc_dbtypes="mysql, pgsql, sqlite3"
dbc_authmethod_user="password"
- #dbc_first_version="2.0.5-2"
- . /usr/share/dbconfig-common/dpkg/config
+ dbc_first_version="2.0.5-2"
+ dbc_basepath=$POOTLE_HOME/dbs
+ . /usr/share/dbconfig-common/dpkg/config
dbc_go pootle $@
fi
+
+if [ -d "$POOTLE_HOME" ]; then
+ POOTLE_USER=$(stat -c"%U" "$POOTLE_HOME")
+ POOTLE_GROUP=$(stat -c"%G" "$POOTLE_HOME")
+ if [ "$POOTLE_USER" != "root" -a "$POOTLE_GROUP" != "root" ]; then
+ db_set pootle/server-username $POOTLE_USER
+ db_set pootle/server-groupname $POOTLE_GROUP
+ fi
+fi
+
+db_input medium pootle/server-username || true
+db_input medium pootle/server-groupname || true
+
+db_go || true
Modified: pootle/trunk/debian/pootle.postinst
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/pootle.postinst?rev=2764&op=diff
==============================================================================
--- pootle/trunk/debian/pootle.postinst (original)
+++ pootle/trunk/debian/pootle.postinst Wed Nov 16 16:07:59 2011
@@ -5,7 +5,7 @@
set -e
-#dbc_first_version="2.0.5-2"
+dbc_first_version="2.0.5-2"
dbc_generate_include='template:/etc/pootle/dbconfig.py'
dbc_generate_include_args=' -o template_infile=/usr/share/doc/pootle/dbconfig.template'
dbc_generate_include_owner='root:pootle'
@@ -17,39 +17,97 @@
. /usr/share/dbconfig-common/dpkg/postinst
dbc_go pootle $@
-POOTLE_USER=pootle
-POOTLE_GROUP=pootle
POOTLE_HOME=/var/lib/pootle
+
+db_get pootle/server-username || true
+POOTLE_USER=${RET-www-data}
+db_get pootle/server-username || true
+POOTLE_GROUP=${RET-www-data}
+
+set_permissions() {
+ if ! getent group $POOTLE_GROUP > /dev/null 2>&1; then
+ echo -n "Adding group $POOTLE_GROUP.."
+ addgroup --quiet --system $POOTLE_GROUP
+ echo "..done"
+ fi
+ if ! getent passwd $POOTLE_USER > /dev/null 2>&1; then
+ echo -n "Adding user $POOTLE_USER.."
+ adduser --quiet --system --gecos "Pootle daemon" \
+ --ingroup $POOTLE_GROUP \
+ --no-create-home --home $POOTLE_HOME \
+ $POOTLE_USER
+ echo "..done"
+ fi
+
+ mkdir -p $POOTLE_HOME
+ chmod 755 $POOTLE_HOME
+ chown $POOTLE_USER:$POOTLE_GROUP $POOTLE_HOME
+ chmod -R 755 $POOTLE_HOME/po
+ chown -R $POOTLE_USER:$POOTLE_GROUP $POOTLE_HOME/po
+ chmod -R 755 $POOTLE_HOME/dbs
+ chown -R $POOTLE_USER:$POOTLE_GROUP $POOTLE_HOME/dbs
+
+ # Also protect config files
+ chmod 750 /etc/pootle
+ chown -R root:$POOTLE_GROUP /etc/pootle
+}
+
+configure_memcached() {
+ (
+ echo "# This file is automatically generated."
+ echo "# Edit localsettings.py to override these settings."
+
+ [ -e /etc/default/memcached ] && . /etc/default/memcached
+ if [ -f /usr/bin/memcached -a "$ENABLE_MEMCACHED" = "yes" ]; then
+ echo "CACHE_BACKEND = 'memcached://127.0.0.1:11211/'"
+ echo "SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'"
+ else
+ echo "CACHE_BACKEND = 'db://pootlecache?max_entries=65536&cull_frequency=16'"
+ fi
+ ) > /etc/pootle/debian_config.py
+}
+
+move_po_files() {
+ cd $POOTLE_HOME
+ for d in *; do
+ case "$d" in
+ dbs|po|pootle|terminology|tutorial)
+ ;;
+ *)
+ echo "Moving $POOTLE_HOME/$d to $POOTLE_HOME/po/$d"
+ mv "$d" po/
+ ;;
+ esac
+ done
+}
case "$1" in
configure)
- if ! getent group $POOTLE_GROUP > /dev/null 2>&1; then
- echo -n "Adding group $POOTLE_GROUP.."
- addgroup --quiet --system $POOTLE_GROUP
- echo "..done"
+ set_permissions
+ configure_memcached
+ if [ -z "$2" ]; then
+ # new installation
+ su $POOTLE_USER -p -c "
+ django-admin syncdb --settings pootle.settings --noinput
+ django-admin initdb --settings pootle.settings
+ django-admin refresh_stats --settings pootle.settings
+ "
+# createsuperuser ? => use debconf for this
+ elif dpkg --compare-versions "$2" lt 1.3.0~beta3-1; then
+ # lenny -> squeeze upgrade
+ move_po_files
+ su $POOTLE_USER -p -c "
+ django-admin syncdb --settings pootle.settings --noinput
+ django-admin initdb --settings pootle.settings
+ python /usr/share/pyshared/pootle/tools/import_old_prefs.py /etc/pootle/pootle.prefs /etc/pootle/users.prefs
+ django-admin refresh_stats --settings pootle.settings
+ "
+ elif dpkg --compare-versions "$2" lt 2.0.6; then
+ # squeeze -> wheezy upgrade
+ :
fi
- if ! getent passwd $POOTLE_USER > /dev/null 2>&1; then
- echo -n "Adding user $POOTLE_USER.."
- adduser --quiet --system --gecos "Pootle daemon" \
- --ingroup $POOTLE_GROUP \
- --no-create-home --home $POOTLE_HOME \
- $POOTLE_USER
- echo "..done"
- fi
-
- mkdir -p /var/lib/pootle
- chmod 755 /var/lib/pootle
- chown $POOTLE_USER:$POOTLE_GROUP /var/lib/pootle
- chmod -R 755 /var/lib/pootle/po
- chown -R $POOTLE_USER:$POOTLE_GROUP /var/lib/pootle/po
- chmod -R 755 /var/lib/pootle/dbs
- chown -R $POOTLE_USER:$POOTLE_GROUP /var/lib/pootle/dbs
-
- # Ensure the configuration files will be only readable by 'pootle'
- chmod 770 /etc/pootle
-# chmod 660 /etc/pootle/pootle.prefs
-# chmod 660 /etc/pootle/users.prefs
- chown -R $POOTLE_USER:root /etc/pootle
+ # all upgrades
+ su $POOTLE_USER -p -c "django-admin updatedb --settings=pootle.settings"
;;
abort-upgrade|abort-remove|abort-deconfigure)
@@ -61,35 +119,6 @@
;;
esac
-case "$1" in
- configure)
- if [ -z "$2" ]; then
- update-python-modules -p
- su pootle -p -c "django-admin syncdb --settings pootle.settings --noinput"
- su pootle -p -c "django-admin initdb --settings pootle.settings"
- su pootle -p -c "django-admin refresh_stats --settings pootle.settings"
-# createsuperuser ? => use debconf for this
- elif dpkg --compare-versions "$2" lt 1.3.0~beta3-1; then
- cd /var/lib/pootle
- for d in *; do
- case "$d" in
- dbs|po|pootle|terminology|tutorial)
- ;;
- *)
- echo "Moving /var/lib/pootle/$d to /var/lib/pootle/po/$d"
- mv "$d" po/
- ;;
- esac
- done
- update-python-modules -p
- su pootle -p -c "django-admin syncdb --settings pootle.settings --noinput"
- su pootle -p -c "django-admin initdb --settings pootle.settings"
- su pootle -p -c "python /usr/share/pyshared/pootle/tools/import_old_prefs.py /etc/pootle/pootle.prefs /etc/pootle/users.prefs"
- su pootle -p -c "django-admin refresh_stats --settings pootle.settings"
- fi
- ;;
-esac
-
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
Modified: pootle/trunk/debian/pootle.postrm
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/pootle.postrm?rev=2764&op=diff
==============================================================================
--- pootle/trunk/debian/pootle.postrm (original)
+++ pootle/trunk/debian/pootle.postrm Wed Nov 16 16:07:59 2011
@@ -7,12 +7,12 @@
. /usr/share/debconf/confmodule
fi
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
- . /usr/share/dbconfig-common/dpkg/postrm
- dbc_go db-test-multidbtype $@
+ . /usr/share/dbconfig-common/dpkg/postrm
+ dbc_go pootle $@
fi
if [ "$1" = "purge" ]; then
- rm -f /etc/pootle/dbconfig.py
+ rm -f /etc/pootle/dbconfig.py /etc/pootle/debian_config.py
if which ucf >/dev/null 2>&1; then
ucf --purge /etc/pootle/dbconfig.py
ucfr --purge pootle /etc/pootle/dbconfig.py
Added: pootle/trunk/debian/pootle.templates
URL: http://svn.debian.org/wsvn/pootle/trunk/debian/pootle.templates?rev=2764&op=file
==============================================================================
--- pootle/trunk/debian/pootle.templates (added)
+++ pootle/trunk/debian/pootle.templates Wed Nov 16 16:07:59 2011
@@ -1,0 +1,17 @@
+Template: pootle/server-username
+Type: string
+Default: www-data
+Description: Username for po file ownership:
+ The translation files that pootle is managing need to be writeable
+ by the web server process.
+ .
+ If you leave this field empty, the default username ('www-data') will be used.
+
+Template: pootle/server-groupname
+Type: string
+Default: www-data
+Description: Group name for po file ownership:
+ The translation files that pootle is managing need to be writeable
+ by the web server process.
+ .
+ If you leave this field empty, the default group ('www-data') will be used.
More information about the Debian-l10n-commits
mailing list