diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | debian/changelog | 72 | ||||
| -rw-r--r-- | debian/control | 17 | ||||
| -rw-r--r-- | debian/python-django-ishtar.install | 2 | ||||
| -rw-r--r-- | debian/python-django-ishtar.postinst | 70 | ||||
| -rwxr-xr-x | debian/rules | 20 | ||||
| -rw-r--r-- | django-simple-history/debian/changelog | 5 | ||||
| -rw-r--r-- | django-simple-history/debian/compat | 1 | ||||
| -rw-r--r-- | django-simple-history/debian/control | 17 | ||||
| -rw-r--r-- | django-simple-history/debian/copyright | 42 | ||||
| -rwxr-xr-x | django-simple-history/debian/rules | 4 | ||||
| -rw-r--r-- | install/local_settings.py.sample | 2 | ||||
| -rw-r--r-- | install/nginx.conf.template | 6 | ||||
| -rw-r--r-- | install/uwsgi.ini.template | 2 | ||||
| -rwxr-xr-x | ishtar-prepare-instance | 197 | 
15 files changed, 448 insertions, 10 deletions
| diff --git a/.gitignore b/.gitignore index d04cb7f2f..ebbb01d07 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@  *.pyc  *.mo  *~ -django-simple-history/*  django-formwizard/*  ishtar-docs  ishtar-logo diff --git a/debian/changelog b/debian/changelog index 385a7355c..f1c4dac99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,75 @@ +python-django-ishtar (0.97-0) UNRELEASED; urgency=low + +  * Upstream: cf CHANGES.md. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Tue, 23 Aug 2016 11:56:42 +0200 + +python-django-ishtar (0.96-3) UNRELEASED; urgency=low + +  * Upstream: cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Tue, 19 July 2016 11:50:00 +0200 + +python-django-ishtar (0.96-2) UNRELEASED; urgency=low + +  * Upstream: cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Sun, 17 July 2016 23:23:00 +0200 + +python-django-ishtar (0.96-1) UNRELEASED; urgency=low + +  * Add media/upload, media/imported directory with corrected permissions +  * Symbolic link of settings.py to example_project +  * Upstream: cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Sat, 15 July 2016 19:27:00 +0200 + +python-django-ishtar (0.96-0) UNRELEASED; urgency=low + +  * Debian installer: fix DB_PORT +  * Debian installer: fix fixtures installation +  * Upstream: cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Thu, 14 July 2016 19:22:00 +0200 + +python-django-ishtar (0.95-2) UNRELEASED; urgency=low + +  * Upstream improvements - cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Fri, 09 Jun 2016 12:12:00 +0200 + +python-django-ishtar (0.95-1) UNRELEASED; urgency=low + +  * Upstream improvements - cf CHANGES.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Fri, 08 Jun 2016 18:43:29 +0200 + +python-django-ishtar (0.94-2) UNRELEASED; urgency=low + +  * Fix a bad migration script. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Fri, 03 Jun 2016 22:59:29 +0200 + +python-django-ishtar (0.94-1) UNRELEASED; urgency=low + +  * Upstream improvments - cf CHANGELOG.txt. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Fri, 03 Jun 2016 22:27:29 +0200 + +python-django-ishtar (0.93-1) UNRELEASED; urgency=low + +  [ Étienne Loks ] +  * Upstream improvments. + +  [ Cyril Brulebois ] +  * Keep track of created instances in the INSTANCES file under +    /var/lib/python-django-ishtar and make postinst script loop over +    it to update instances, and restart uwsgi/nginx if appropriate. +  * Fix ishtar-prepare-instance: compilemessages wasn't called in +    ishtar_common/, only in archaeological_*/. + + -- Étienne Loks <etienne.loks@iggdrasil.net>  Tue, 19 Apr 2016 22:39:29 +0200 +  python-django-ishtar (0.9-1) UNRELEASED; urgency=low    * Initial release. diff --git a/debian/control b/debian/control index eaa0d9fc8..fb4ce26e5 100644 --- a/debian/control +++ b/debian/control @@ -24,7 +24,22 @@ Depends: ${misc:Depends},   python-tidylib,   python-lxml,   python-html5lib, - python-memcache + python-memcache, + python-oook-replace, + python-django-extra-views, + python-django-simple-history, + python-unicodecsv, + python-markdown, +# DB + postgresql-9.1, + postgresql-9.1-postgis, +# Web: + nginx, + uwsgi, + uwsgi-plugin-python, +# Extra: + apg, + gettext,  Recommends: javascript-common,   libjs-jquery,   libjs-jquery-ui, diff --git a/debian/python-django-ishtar.install b/debian/python-django-ishtar.install new file mode 100644 index 000000000..14d90d1e6 --- /dev/null +++ b/debian/python-django-ishtar.install @@ -0,0 +1,2 @@ +/var/lib/python-django-ishtar +ishtar-prepare-instance  usr/sbin diff --git a/debian/python-django-ishtar.postinst b/debian/python-django-ishtar.postinst new file mode 100644 index 000000000..5efd25548 --- /dev/null +++ b/debian/python-django-ishtar.postinst @@ -0,0 +1,70 @@ +#!/bin/sh + +set -e +set -x + +DATA_DIR=/var/lib/python-django-ishtar +INSTANCES_FILE=$DATA_DIR/INSTANCES + +case "$1" in +    configure) +        instances="$( (cat $INSTANCES_FILE 2>/dev/null || true) | xargs )" +        if [ -n "$instances" ]; then +            echo "updading instances found in $INSTANCES_FILE: $instances" +            for instance in $instances; do +                # The upgrade procedure below was built from the "update" +                # target and its dependencies in the upstream Makefile: +                echo "updating $instance" +                cd $DATA_DIR/$instance + +                # from "syncdb" target: +                python manage.py syncdb --noinput +                python manage.py migrate + +                # from "compilemessages" target: +                # +                # NOTE: Instead of hardcoding an "apps" variable here, let's +                # look at candidates with find, and check whether each of +                # them indeed contains PO files as a second check: +                maybe_localized=$(cd $DATA_DIR; find -maxdepth 2 -name 'locale') +                for candidate in $maybe_localized; do +                    if find $DATA_DIR/$candidate -name '*.po' >/dev/null 2>&1; then +                        # Really looks like a valid app, let's strip the last +                        # directory, cd into it, and compile messages using +                        # the instance's manage.py script: +                        app=${candidate%%/locale} +                        (cd $DATA_DIR/$app; python $DATA_DIR/$instance/manage.py compilemessages) +                    fi +                done +                # XXX: Doing this only once is likely sufficient, so +                # we could remember having performed that update while +                # taking care of the first instance, to avoid +                # extraneous reruns? + +                # from "collectstatic" target: +                python manage.py collectstatic --noinput + +                echo "updating $instance: OK" +            done +            echo "updating all instances: OK" + +            # the assumption is that nginx and uwsgi were configured +            # through ishtar-prepare-instance, so let's restart them +            # unconditionally: +            invoke-rc.d uwsgi restart +            invoke-rc.d nginx restart +            echo "restarting uwsgi and nginx: OK" +        else +            echo "found no instances to upgrade in $INSTANCES_FILE" +        fi +    ;; + +    abort-upgrade|abort-remove|abort-deconfigure) + +    ;; + +    *) +        echo "postinst called with unknown argument \`$1'" >&2 +        exit 1 +    ;; +esac diff --git a/debian/rules b/debian/rules index dd12cc51f..903fa0919 100755 --- a/debian/rules +++ b/debian/rules @@ -10,9 +10,23 @@ PYTHON2=$(shell pyversions -vr)  export http_proxy = http://127.0.9.1:9  %: -	dh $@ --with python2 +	dh $@ + +override_dh_auto_build: +	echo "Building does nothing" + +override_dh_auto_configure: +	echo "Configuring does nothing" + +override_dh_auto_install: +	git ls-files \ +		| grep -v ^debian \ +		| grep -v ^django-simple-history \ +		| grep -v ^doc \ +	> install.list +	mkdir -p debian/tmp/var/lib/python-django-ishtar +	rsync -av --files-from install.list . debian/tmp/var/lib/python-django-ishtar  override_dh_auto_clean:  	dh_auto_clean -	rm -rf build -	rm -rf *.egg-info +	rm -f install.list diff --git a/django-simple-history/debian/changelog b/django-simple-history/debian/changelog new file mode 100644 index 000000000..719616a5f --- /dev/null +++ b/django-simple-history/debian/changelog @@ -0,0 +1,5 @@ +python-django-simple-history (0~0) wheezy; urgency=medium + +  * Initial release. + + -- Cyril Brulebois <cyril@debamax.com>  Wed, 06 Apr 2016 22:44:50 +0200 diff --git a/django-simple-history/debian/compat b/django-simple-history/debian/compat new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/django-simple-history/debian/compat @@ -0,0 +1 @@ +8 diff --git a/django-simple-history/debian/control b/django-simple-history/debian/control new file mode 100644 index 000000000..44608d14a --- /dev/null +++ b/django-simple-history/debian/control @@ -0,0 +1,17 @@ +Source: python-django-simple-history +Section: python +Priority: optional +Maintainer: Cyril Brulebois <cyril@debamax.com> +Build-Depends: debhelper (>= 9.0.0), + python | python-all | python-dev | python-all-dev, + python-setuptools +Standards-Version: 3.9.3 +Homepage: http://pypi.python.org/pypi/ishtar + +Package: python-django-simple-history +Architecture: all +Depends: ${misc:Depends}, + ${python:Depends}, + python-django (>= 1.4), + python-django (<< 1.5), +Description: TBD diff --git a/django-simple-history/debian/copyright b/django-simple-history/debian/copyright new file mode 100644 index 000000000..f5ec3b221 --- /dev/null +++ b/django-simple-history/debian/copyright @@ -0,0 +1,42 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ishtar +Source: XXX + +Files: * +Copyright: 2013 Étienne Loks <etienne.loks@peacefrogs.net> +License: AGPL-3.0+ + +Files: debian/* +Copyright: 2016 Cyril Brulebois <cyril@debamax.com> +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +License: AGPL-3.0 + This program is free software: you can use, redistribute, and/or modify + this code under the terms of the GNU Affero General Public License + version 3. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + diff --git a/django-simple-history/debian/rules b/django-simple-history/debian/rules new file mode 100755 index 000000000..2d33f6ac8 --- /dev/null +++ b/django-simple-history/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: +	dh $@ diff --git a/install/local_settings.py.sample b/install/local_settings.py.sample index 459828c00..857249613 100644 --- a/install/local_settings.py.sample +++ b/install/local_settings.py.sample @@ -15,7 +15,7 @@ LOGFILE = "/var/log/django/ishtar-#APP_NAME#.log"  MEDIA_ROOT = "#APP_DIR#/media/" -ODT_TEMPLATE = "#INSTALL_PATH#/ishtar/ishtar_common/static/template.odt" +ODT_TEMPLATE = "#INSTALL_PATH#/ishtar_common/static/template.odt"  ADMINS = (      # ('Your Name', 'your_email@domain.com'), diff --git a/install/nginx.conf.template b/install/nginx.conf.template index 8df09e859..a65ce652c 100644 --- a/install/nginx.conf.template +++ b/install/nginx.conf.template @@ -1,18 +1,18 @@  server {      listen #NGINX_PORT#;      server_name #URL#; -    root #INSTALL_PREFIX#/#DB_NAME#/ishtar/; +    root #INSTALL_PREFIX#/#APP_NAME#/;      access_log /var/log/django/#APP_NAME#-access.log;      error_log /var/log/django/#APP_NAME#-error.log;      client_max_body_size 20M;      location /static-#DATE#/ { # STATIC_URL -        alias #INSTALL_PREFIX#/#DB_NAME#/ishtar/#APP_NAME#/static/; # STATIC_ROOT +        alias #INSTALL_PREFIX#/#APP_NAME#/static/; # STATIC_ROOT          expires 30d;      }      location /media/ { # MEDIA_URL -        alias #INSTALL_PREFIX#/#DB_NAME#/ishtar/#APP_NAME#/media/; # MEDIA_ROOT +        alias #INSTALL_PREFIX#/#APP_NAME#/media/; # MEDIA_ROOT          expires 30d;      } diff --git a/install/uwsgi.ini.template b/install/uwsgi.ini.template index dd8f00480..51a4c5b7f 100644 --- a/install/uwsgi.ini.template +++ b/install/uwsgi.ini.template @@ -2,7 +2,7 @@  # variables  projectname = #APP_NAME#  projectdomain = #URL# -base = #INSTALL_PREFIX#/#DB_NAME#/ishtar/ +base = #INSTALL_PREFIX#  # config  plugins = python diff --git a/ishtar-prepare-instance b/ishtar-prepare-instance new file mode 100755 index 000000000..7820db4be --- /dev/null +++ b/ishtar-prepare-instance @@ -0,0 +1,197 @@ +#!/bin/sh +# +# Stripped-down version of the install.sh script, only dealing with +# customizing files shipped through a Debian package which also pulls +# a bunch of dependencies. +set -e +set -u + +# Instance then project names: +INSTANCE=${INSTANCE-iggdrasil} +PROJECT=${PROJECT-$INSTANCE} +URL=${URL-localhost} +DEST=/var/lib/python-django-ishtar +INSTANCES_FILE=$DEST/INSTANCES + +echo "*** Preparing ishtar (instance: $INSTANCE, project: $PROJECT) under $DEST ***" + +export LANG=fr_FR.UTF-8 +if [ "$(locale 2>&1 >/dev/null|wc -l)" != 0 ]; then +    echo "Unable to set LANG=$LANG properly" +    echo "Try: 'dpkg-reconfigure locales' or install the 'locales-all' package" +    exit 1 +fi + +# XXX: Should probably ship those from the package, and make them +#      either ishtar or python-django-ishtar, or django/ishtar +#      alternatively: +mkdir -p            /var/log/django +chown root:www-data /var/log/django +touch               "/var/log/django/ishtar-$INSTANCE.log" +chown root:www-data "/var/log/django/ishtar-$INSTANCE.log" +chmod g+w           "/var/log/django/ishtar-$INSTANCE.log" + + +# Duplicate example_project into our instance: +cd $DEST +if [ -d "$INSTANCE" ]; then +    echo "Sorry, $INSTANCE already exists, not going further" +    exit 1 +fi +cp -ra example_project $INSTANCE + +echo "Debug...." +rm $INSTANCE/settings.py +ln -s $DEST/example_project/settings.py $DEST/$INSTANCE/settings.py +ls $DEST/ +ls $DEST/example_project +ls -la $DEST/$INSTANCE +echo "Debug done" + +# Collect static data: +cd $INSTANCE +./manage.py collectstatic --noinput +cd - + +# Only language available: +LOCALE=fr +for d in archaeological_* ishtar_common; do +    cd $d +    ../$INSTANCE/manage.py compilemessages -l $LOCALE +    cd - +done + +# Preparing DB: +PG_VERSION=9.1 +DB_HOST=${DB_HOST-127.0.0.1} +DB_PORT=${DB_PORT-5432} +DB_PASSWORD=${DB_PASSWORD-''} +DB_NAME="ishtar-$INSTANCE" + +# Generate a password on the fly if none was specified: +if [ -z "$DB_PASSWORD" ]; then +    DB_PASSWORD=$(apg -a 0 -M ncl -n 1 -x 10 -m 10) +fi + +export PG_VERSION DB_HOST DB_PORT DB_PASSWORD DB_NAME PROJECT +su postgres <<'EOF' +  echo "Checking template_postgis" +  if ! psql -l | grep -qs template_postgis; then +    echo " - not present, creating" +    createdb template_postgis +    psql -q -d template_postgis -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/postgis.sql +    psql -q -d template_postgis -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/spatial_ref_sys.sql +  else +    echo " - already present" +  fi + +  echo "Checking $DB_NAME" +  if ! psql -l | grep -qs "$DB_NAME"; then +    echo " - not present, creating" +    createuser --echo --adduser --createdb --encrypted $DB_NAME +    psql --command "ALTER USER \""$DB_NAME"\" with password '"$DB_PASSWORD"';" +    createdb -T template_postgis --echo --owner $DB_NAME --encoding UNICODE $DB_NAME "$PROJECT" +  else +    echo " - already present" +  fi +EOF + + +# Permissions: +mkdir -p -m 775     "$INSTANCE/media/imported" +mkdir -p -m 775     "$INSTANCE/media/upload" +chown -R root:www-data "$INSTANCE/media" + +### LOCAL SETTINGS + +# Set some variables to avoid changing sed calls too much compared to +# the initial install/install.sh script: +INSTALL_PATH=$DEST +INSTALL_PREFIX=$DEST +APP_DIR="$DEST/$INSTANCE" +DATE=`date +%F` +SECRET_KEY=$(apg -a 0 -M ncl -n 1 -x 10 -m 40) + +# Declare these in advance, at least the port is needed: +UWSGI_PORT=${UWSGI_PORT-8891} +UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available' +UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled' + +sed -s "s|#APP_NAME#|$INSTANCE|g;\ +        s|#INSTALL_PATH#|$INSTALL_PATH|g;\ +        s|#DATE#|$DATE|g;\ +        s|#PROJECT_NAME#|$PROJECT|g;\ +        s|#DB_HOST#|$DB_HOST|g;\ +        s|#DB_NAME#|$DB_NAME|g;\ +        s|#DB_PORT#|$DB_PORT|g;\ +        s|#APP_DIR#|$APP_DIR|g;\ +        s|#SECRET_KEY#|$SECRET_KEY|g;\ +        s|#DB_PASSWORD#|$DB_PASSWORD|g;\ +        s|#UWSGI_PORT#|$UWSGI_PORT|g;" \ +    "install/local_settings.py.sample" > \ +    "$INSTANCE/local_settings.py" + +### DB feeding +cd $INSTANCE +./manage.py syncdb --noinput +./manage.py migrate +./manage.py flush --noinput + +FIXTURES="$DEST/fixtures/initial_data-auth-fr.json $DEST/ishtar_common/fixtures/initial_data-fr.json $DEST/ishtar_common/fixtures/initial_importtypes-fr.json $DEST/archaeological_operations/fixtures/initial_data-fr.json $DEST/archaeological_context_records/fixtures/initial_data-fr.json $DEST/archaeological_files/fixtures/initial_data-fr.json $DEST/archaeological_finds/fixtures/initial_data-fr.json $DEST/archaeological_warehouse/fixtures/initial_data-fr.json" +for data in $FIXTURES; do +    echo $data; +    ./manage.py loaddata $data; +done + +./manage.py createsuperuser +./manage.py migrate --fake +cd - + +echo "*** DB all done ***" + + +### UWSGI + +sed -s "s|#APP_NAME#|$INSTANCE|g;\ +        s|#DB_NAME#|$DB_NAME|g;\ +        s|#INSTALL_PREFIX#|$INSTALL_PREFIX|g;\ +        s|#URL#|$URL|g;\ +        s|#UWSGI_PORT#|$UWSGI_PORT|g;" \ +    "install/uwsgi.ini.template" > \ +    "$INSTANCE/uwsgi.ini" + +# XXX: Generation of django.wsgi was entirely dropped. + +# XXX: Using -f might be a bit too aggressive +ln -sf "$DEST/$INSTANCE/uwsgi.ini" \ +       "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini" +ln -sf "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini" \ +       "$UWSGI_ENABLE_PATH/ishtar-$INSTANCE.ini" + + +### NGINX + +NGINX_PORT=${NGINX_PORT-80} +NGINX_AVAILABLE_PATH='/etc/nginx/sites-available' +NGINX_ENABLE_PATH='/etc/nginx/sites-enabled' + +sed -s "s|#APP_NAME#|$INSTANCE|g;\ +        s|#UWSGI_PORT#|$UWSGI_PORT|g;\ +        s|#DB_NAME#|$DB_NAME|g;\ +        s|#DATE#|$DATE|g;\ +        s|#NGINX_PORT#|$NGINX_PORT|g;\ +        s|#INSTALL_PREFIX#|$INSTALL_PREFIX|g;\ +        s|#URL#|$URL|g;" \ +    "install/nginx.conf.template" > \ +    "$INSTANCE/nginx.conf" + +ln -sf "$DEST/$INSTANCE/nginx.conf" \ +       "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf" +ln -sf "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf" \ +       "$NGINX_ENABLE_PATH/ishtar-$INSTANCE.conf" + +echo "*** uwsgi and nginx configured, restart them and you're done ***" +printf "\n    /etc/init.d/uwsgi restart\n    /etc/init.d/nginx restart\n\n Enjoy ishtar!\n" + +# Register instance: +echo "$INSTANCE" >> $INSTANCES_FILE | 
