diff --git a/bin/polynum-build-virtualenv b/bin/polynum-build-virtualenv new file mode 100755 index 0000000..c3d1ef1 --- /dev/null +++ b/bin/polynum-build-virtualenv @@ -0,0 +1,28 @@ +#!/bin/bash + +VEDIR=${VIRTUAL_ENV-/opt/polynum/virtualenv} + +PIPOPT=$PIPOPT"-v --log=$VEDIR/install.log" +if [ x"$PROXY" != "x" ]; then + PIPOPT=$PIPOPT" --proxy=$PROXY" +fi + +function abort() { + echo $1 1>&2 + exit 1 +} + +test -e ${VEDIR} && abort "$VEDIR already exists" + +DIR=`dirname $VEDIR` +VE=`basename $VEDIR` +test -d $DIR || "$DIR does not exist (or is not a directory)" + +cd $DIR || abort "cannot cd to $DIR" +virtualenv --system-site-packages $VE || abort "cannot create virtualenv $VE in $DIR" + +cd $VE +. bin/activate || abort "cannot activate virtualenv (???)" +pip $PIPOPT install -U pip +pip $PIPOPT install --requirement=/usr/share/doc/polynum/requirements + diff --git a/bin/polynum-manage.py b/bin/polynum-manage.py new file mode 100755 index 0000000..f11c190 --- /dev/null +++ b/bin/polynum-manage.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +import os +import sys +import site + +POLYNUM_DIR = os.environ.get('POLYNUM_DIR', '/opt/polynum') +VIRTUAL_ENV = os.environ.get('VIRTUAL_ENV', os.path.join(POLYNUM_DIR, 'virtualenv')) + +if not os.path.isdir(POLYNUM_DIR): + print >> sys.stderr, POLYNUM_DIR + ' does not exist' + sys.exit(1) + +sys.path.append(POLYNUM_DIR) + +if os.path.isdir(VIRTUAL_ENV): + site_packages = os.path.join(VIRTUAL_ENV, + 'lib', + 'python%d.%d' % sys.version_info[:2], + 'site-packages') + site.addsitedir(site_packages) + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polynum.settings") + from django.core.management import execute_from_command_line + execute_from_command_line(sys.argv) + diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..74a5044 --- /dev/null +++ b/debian/README @@ -0,0 +1,8 @@ +The Debian Package polynum +---------------------------- + +All files goes to /opt/polynum/ + +'coz everybody loves /opt ! + + -- Thomas NOEL Tue, 17 Jul 2012 12:57:01 +0200 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..243dd8b --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +polynum (0.20120717.01) unstable; urgency=low + + * Premier paquet + + -- Thomas NOEL Tue, 17 Jul 2012 12:57:01 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d5d0265 --- /dev/null +++ b/debian/control @@ -0,0 +1,18 @@ +Source: polynum +Section: web +Priority: extra +Maintainer: Thomas NOEL +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.3 +Homepage: https://sourcesup.cru.fr/projects/polynum/ +Vcs-Browser: https://sourcesup.renater.fr/scm/?group_id=859 + +Package: polynum +Architecture: all +Depends: ${misc:Depends}, python, python-psycopg2, python-ldap +Recommends: python-virtualenv +Suggests: postgresql +Description: Polycopiés numériques + Polynum (polycopiés numériques) est une application web pour demander + l'impression de polycopiés via l'ENT. Elle propose des options de diffusion + afin de mettre à disposition en ligne les polycopiés pour les étudiants. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..deece50 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,10 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: polynum +Source: https://sourcesup.cru.fr/projects/polynum/ + +Files: * +Copyright: 2012 Université Dauphine +License: AGPL-3.0+ + +# http://aloha-editor.org +# diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..511d134 --- /dev/null +++ b/debian/docs @@ -0,0 +1,3 @@ +README +requirements +local_settings.py.example diff --git a/debian/init.d b/debian/init.d new file mode 100644 index 0000000..e6694d8 --- /dev/null +++ b/debian/init.d @@ -0,0 +1,154 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: polynum +# Required-Start: $network $local_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: +# Description: +# <...> +# <...> +### END INIT INFO + +# Author: Thomas NOEL + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=polynum # Introduce a short description here +NAME=polynum # Introduce the short server's name here +DAEMON=/usr/sbin/polynum # Introduce the server's location here +DAEMON_ARGS="" # Arguments to run the daemon with +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/menu.ex b/debian/menu.ex new file mode 100644 index 0000000..ab426a8 --- /dev/null +++ b/debian/menu.ex @@ -0,0 +1,2 @@ +?package(polynum):needs="X11|text|vc|wm" section="Applications/see-menu-manual"\ + title="polynum" command="/usr/bin/polynum" diff --git a/debian/polynum.cron.d.ex b/debian/polynum.cron.d.ex new file mode 100644 index 0000000..0727303 --- /dev/null +++ b/debian/polynum.cron.d.ex @@ -0,0 +1,4 @@ +# +# Regular cron jobs for the polynum package +# +0 4 * * * root [ -x /usr/bin/polynum_maintenance ] && /usr/bin/polynum_maintenance diff --git a/debian/polynum.default.ex b/debian/polynum.default.ex new file mode 100644 index 0000000..6ed498e --- /dev/null +++ b/debian/polynum.default.ex @@ -0,0 +1,10 @@ +# Defaults for polynum initscript +# sourced by /etc/init.d/polynum +# installed at /etc/default/polynum by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Additional options that are passed to the Daemon. +DAEMON_OPTS="" diff --git a/debian/postinst.ex b/debian/postinst.ex new file mode 100644 index 0000000..b3edc0d --- /dev/null +++ b/debian/postinst.ex @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for polynum +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/postrm.ex b/debian/postrm.ex new file mode 100644 index 0000000..209b3d0 --- /dev/null +++ b/debian/postrm.ex @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for polynum +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/preinst.ex b/debian/preinst.ex new file mode 100644 index 0000000..1f37f77 --- /dev/null +++ b/debian/preinst.ex @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for polynum +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm.ex b/debian/prerm.ex new file mode 100644 index 0000000..a85a9fd --- /dev/null +++ b/debian/prerm.ex @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for polynum +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..b760bee --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native)