Changeset 1237

Show
Ignore:
Timestamp:
03/11/06 16:09:50 (2 years ago)
Author:
lunar
Message:

r88@sud: lunar | 2006-03-11 15:14:54 +0100
Major cleanup on a debian packaging POV


  • Adapt package to 0.9.4 configuration files (for alternc.install and
    menufile.txt) and bump dependency accordingly.
  • Add mysql-client to Depends field (used in debian scripts)
  • Now store Mailman configuration file template in /etc/alternc/templates/mailman/mm_cfg.py
  • Remove unneeded use of debconf:

alternc is in pre-depends, and its configuration file is sourced in
postinst script. This script use a '-e' shell, and will then fail if
it is unable to read the configuration file.

  • Add a warning about modifying /etc/mailman/mm_cfg.py directly.
  • Major overhaul of postinst script:

o Fix apache configuration template condition. o Uses alternc.install to update apache configuration files against

modified templates.

o Generated Mailman configuration is now backuped in /var/backups/alternc

in order to prevent overwrite of user modification (despite the
warning).
The postinst script will fail in this case, displaying a message telling
the user how to correct the situation.

o Automatically creates the "mailman" list (a.k.a site list) if it

doesn't exist. (Closes: #157, #365, #560)

  • Overhaul of postrm script too:

o Adapt to 0.9.4 configuration style.
o Drop mailman table on purge. (Closes: #224)

  • Cleanup of debian/rules
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/debian/control

    r1232 r1237  
    1010Section: admin 
    1111Architecture: any 
    12 Pre-Depends: alternc (>=0.9.3
    13 Depends: mailman (>=2.1), debconf (>= 0.5.00) 
     12Pre-Depends: alternc (>= 0.9.4
     13Depends: mailman (>= 2.1), mysql-client 
    1414Description: Mailman module for AlternC 
    1515 AlternC is a hosting software suite based on Valentin 
  • trunk/debian/dirs

    r1196 r1237  
     1/etc/alternc/templates/mailman 
     2/usr/lib/alternc 
     3/usr/share/alternc/install 
     4/usr/share/doc/alternc-mailman 
     5/var/alternc/bureau/admin 
    16/var/alternc/bureau/class 
    2 /var/alternc/bureau/admin 
     7/var/alternc/bureau/locales/en_US/LC_MESSAGES 
    38/var/alternc/bureau/locales/fr_FR/LC_MESSAGES 
    4 /var/alternc/bureau/locales/en_US/LC_MESSAGES 
    59/var/alternc/cgi-bin 
    6 /usr/lib/alternc 
    7 /usr/share/doc/alternc-mailman 
    8 /usr/share/alternc/install/etc/mailman 
     10/var/backups/alternc 
  • trunk/debian/postinst

    r1219 r1237  
    1 #!/bin/sh -e 
     1#!/bin/sh 
    22 
    3 # Cette fonction regarde si un fichier de config ($1) a déjà reçu une modif 
    4 # de config, et sinon, lui ajoute la ligne voulue là où la balise le demande. 
     3set -e 
     4 
     5CONFIGFILE="/etc/alternc/local.sh" 
     6MENUFILE="/etc/alternc/menulist.txt" 
     7MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman" 
     8MAILMAN_CONFIG="/etc/mailman/mm_cfg.py" 
     9MAILMAN_CONFIG_TEMPLATE="/etc/alternc/templates/mailman/mm_cfg.py" 
     10MAILMAN_CONFIG_BACKUP="/var/backups/alternc/etc-mailman-mm_cfg.py" 
     11MAILMAN_SCRIPT="/var/lib/mailman/mail/mailman" 
     12 
     13# Add mailman aliases to the apache configuration file given as argument 
    514function configure { 
    6     if grep -vqs "\*\*\*MAILMAN\*\*\*" $1 
    7         then 
    8     # 1. on déplace le fichier 
    9         rm -f $1.alternc_mailman 
     15    if ! grep -Eq "\*\*\*MAILMAN\*\*\*" $1; then 
     16        cp -a -f $1.tmp 
    1017        sed -e "s/\*\*\*ALTERNC_ALIASES\*\*\*/&\\ 
    1118            # ***MAILMAN*** \\ 
    1219        Alias \/marchives\/ \/var\/lib\/mailman\/archives\/public\/ \\ 
    13         Alias \/mimages\/ \/usr\/share\/images\/mailman\//" <$1 >$1.alternc_mailman 
    14         mv -f $1.alternc_mailman $1 
     20        Alias \/mimages\/ \/usr\/share\/images\/mailman\//" < $1 > $1.tmp 
     21        mv -f $1.tmp $1 
    1522    fi 
    1623} 
    1724 
    1825 
     26case "$1" in 
     27  configure) 
     28    . "$CONFIGFILE" 
    1929 
    20 if [ "$1" = "configure" ] 
    21     then 
    22     QUIT=0 
    23     # is "AlternC" package properly installed ? 
    24     if [ -f /etc/alternc/alternc.conf ] 
    25     then 
    26         # is Alternc package properly CONFIGURED by the user ? 
    27         (grep "^exit" /etc/alternc/alternc.conf) || (QUIT=1) 
    28     else  
    29        QUIT=1 
     30    echo "Installing mysql table" 
     31    mysql -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" "$MYSQL_DATABASE" \ 
     32        < /usr/share/alternc/install/mailman.sql 
     33     
     34    # Install generated mailman configuration if it has not been modified since 
     35    # last package configuration 
     36    if [ -f "$MAILMAN_CONFIG_BACKUP" ]; then 
     37        if ! diff -q "$MAILMAN_CONFIG" "$MAILMAN_CONFIG_BACKUP"; then 
     38            echo "$MAILMAN_CONFIG has been modified since last alternc-mailman" 
     39            echo "configuration.  You should merge your changes to" 
     40            echo "$MAILMAN_CONFIG_TEMPLATE and delete $MAILMAN_CONFIG_BACKUP" 
     41            exit 1 
     42        fi 
    3043    fi 
    31     if [ ! -f /etc/alternc/local.sh ] 
    32     then 
    33        QUIT=1 
     44    sed -e "s/%%fqdn%%/$FQDN/" < "$MAILMAN_CONFIG_TEMPLATE" > "$MAILMAN_CONFIG" 
     45    cp -a -f "$MAILMAN_CONFIG" "$MAILMAN_CONFIG_BACKUP" 
     46 
     47    # Create the "mailman" list if it does not exist yet 
     48    if [ ! -d /var/lib/mailman/lists/mailman ]; then 
     49        /var/lib/mailman/bin/newlist -q mailman "root@$FQDN" "$MYSQL_PASS" 
     50        ( echo "INSERT INTO mailman 
     51                VALUES (NULL, 2000, 'mailman', '${FQDN}', 'mailman');" 
     52          echo "INSERT INTO mail_domain 
     53                VALUES ('${user}@${FQDN}', '${user}_${FQDN}', 2000, 0, 1);" 
     54          echo "INSERT INTO mail_alias 
     55                VALUES ('${user}_${FQDN}', 
     56                        '\"| $MAILMAN_SCRIPT post mailman\"');" 
     57          for kind in request owner admin bounces confirm join \ 
     58                      leave subscribe unsubscribe; do 
     59              echo "INSERT INTO mail_domain 
     60                         VALUES ('mailman-${kind}@${FQDN}', 
     61                                 'mailman-${kind}_${FQDN}', 2000, 0, 1);" 
     62              echo "INSERT INTO mail_alias 
     63                         VALUES ('mailman-${kind}_${FQDN}', 
     64                                 '\"| $MAILMAN_SCRIPT ${kind} mailman\"');"  
     65          done 
     66        ) | mysql -f -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" \ 
     67              "$MYSQL_DATABASE" || true 
    3468    fi 
    3569 
     70    # Refresh apache configuration 
     71    configure /etc/alternc/templates/apache/httpd.conf 
     72    configure /etc/alternc/templates/apache-ssl/httpd.conf 
     73    ln -sf /usr/lib/cgi-bin/mailman /var/alternc/cgi-bin/mailman 
     74    alternc.install 
    3675 
    37     if [ $QUIT -eq 0 ] 
    38         then 
    39         # Oui : on peut créer la table mailman tout de suite 
    40         . /etc/alternc/local.sh 
    41         echo "Installing mysql table" 
    42         mysql -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" "$MYSQL_DATABASE" </usr/share/alternc/install/mailman.sql || true 
    43         # on modifie le httpd.conf d'apache et d'apache-ssl (déjà installés) 
    44         echo "Configuring apache" 
    45         configure /etc/apache/httpd.conf 
    46         echo "Configuring apache-ssl" 
    47         configure /etc/apache-ssl/httpd.conf 
    48         echo "Configuration AlternC" 
    49         # On modifie /usr/share/alternc/install/etc/apache et apache-ssl 
    50         # uniquement si besoin. 
    51         configure /usr/share/alternc/install/etc/apache/httpd.conf 
    52         configure /usr/share/alternc/install/etc/apache-ssl/httpd.conf 
    53         # On crée le fichier mm_cfg.py dans /etc/mailman :  
    54         echo "Création du fichier de config mailman" 
    55         sed -e "s/%%fqdn%%/$FQDN/" </usr/share/alternc/install/etc/mailman/mm_cfg.py >/etc/mailman/mm_cfg.py 
    56         # Process the language compilation. 
    57         /usr/share/alternc/install/dopo.sh 
    58         ln -sf /usr/lib/cgi-bin/mailman /var/alternc/cgi-bin/mailman 
    59         # ADD Mailman menu item :  
    60         MENUFILE=/var/alternc/bureau/admin/menulist.txt 
    61         if grep -vqs "menu_mailman" $MENUFILE 
    62         then 
    63             rm -f $MENUFILE.alternc_mailman 
    64             sed -e "s/menu_ftp.php/&\\ 
     76    # Process the language compilation. 
     77    /usr/share/alternc/install/dopo.sh 
     78 
     79    # ADD Mailman menu item :  
     80    if ! grep -q "^menu_mailman.php$" "$MENUFILE"; then 
     81        rm -f $MENUFILE.alternc_mailman 
     82        sed -e "s/menu_ftp.php/&\\ 
    6583menu_mailman.php/" <$MENUFILE >$MENUFILE.alternc_mailman 
    66             mv -f $MENUFILE.alternc_mailman $MENUFILE 
    67         fi 
    68         # Set nonexec on list creation / deletion via cgi-bin 
    69         chmod 0 /usr/lib/cgi-bin/mailman/create  /usr/lib/cgi-bin/mailman/rmlist || true 
    70         /etc/init.d/apache restart 
    71         /etc/init.d/apache-ssl restart 
    72     else  
    73         # Source debconf library. 
    74         . /usr/share/debconf/confmodule 
    75         db_version 2.0 
    76         db_title AlternC-Mailman 
    77         db_fset alternc-mailman/errorinstall seen false 
    78         db_input medium alternc-mailman/errorinstall 
    79         db_go 
    80         # il FAUT qu'AlternC soit proprement configuré pour installer mailman 
    81         exit 1 
     84        mv -f $MENUFILE.alternc_mailman $MENUFILE 
    8285    fi 
    83 fi   
     86    ;; 
     87 
     88  abort-upgrade|abort-remove|abort-deconfigure) 
     89    ;; 
     90 
     91  *) 
     92    echo "postinst called with unknown argument \`$1'" >&2 
     93    exit 1 
     94    ;; 
     95esac 
    8496 
    8597# dh_installdeb will replace this with shell code automatically 
    8698# generated by other debhelper scripts. 
    8799#DEBHELPER# 
     100 
     101# vim: et sw=4 
  • trunk/debian/postrm

    r1227 r1237  
    11#!/bin/sh -e 
    22 
    3 # Cette fonction regarde si un fichier de config ($1) a déjà reçu une modif 
    4 # de config, et si oui, lui enleve les lignes voulues 
     3CONFIGFILE="/etc/alternc/local.sh" 
     4MENUFILE="/etc/alternc/menulist.txt" 
     5 
     6# Remove mailman aliases to the apache configuration file given as argument 
    57function unconfigure { 
    6     if grep -qs "\*\*\*MAILMAN\*\*\*" $1 
    7         then 
    8         # 1. on déplace le fichier 
    9         rm -f $1.alternc_mailman 
    10         cat $1 | grep -v "\*\*\*MAILMAN\*\*\*" | grep -v "      Alias /marchives/ /var/lib/mailman/archives/public/" | grep -v "Alias /mimages/ /usr/share/images/mailman/" >$1.alternc_mailman 
     8    if grep -Eqs "\*\*\*MAILMAN\*\*\*" $1; then 
     9        cp -a -f $1.alternc_mailman 
     10        cat $1 | grep -v "\*\*\*MAILMAN\*\*\*" | 
     11            grep -v "   Alias /marchives/ /var/lib/mailman/archives/public/" | 
     12            grep -v "Alias /mimages/ /usr/share/images/mailman/" \ 
     13            > $1.alternc_mailman 
    1114        mv -f $1.alternc_mailman $1  
    1215    fi 
     
    1518case "$1" in 
    1619  remove) 
    17     unconfigure /etc/apache/httpd.conf 
    18     unconfigure /etc/apache-ssl/httpd.conf 
    19     unconfigure /usr/share/alternc/install/etc/apache/httpd.conf 
    20     unconfigure /usr/share/alternc/install/etc/apache-ssl/httpd.conf 
     20    # Remove Mailman references from Apache configuration 
     21    unconfigure /etc/alternc/templates/apache/httpd.conf 
     22    unconfigure /etc/alternc/templates/apache-ssl/httpd.conf 
     23    alternc.install 
     24 
    2125    rm -f /var/alternc/cgi-bin/mailman 
    22     MENUFILE=/var/alternc/bureau/admin/menulist.txt 
    23     if grep -qs "menu_mailman.php" $MENUFILE 
    24     then 
     26 
     27    if grep -qs "menu_mailman.php" $MENUFILE; then 
    2528        rm -f $MENUFILE.alternc_mailman 
    2629        cat $MENUFILE | grep -v "menu_mailman.php" >$MENUFILE.alternc_mailman 
     
    2932    ;; 
    3033  purge) 
    31     . /etc/alternc/local.sh 
    32     mysql -f -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" "$MYSQL_DATABASE" -e "DROP TABLE IF EXISTS mailman" 
     34    if [ -e "$CONFIGFILE" -a -x "/usr/bin/mysql" ]; then 
     35        . "$CONFIGFILE" 
     36        mysql -f -u"$MYSQL_USER" -p"$MYSQL_PASS" -h"$MYSQL_HOST" \ 
     37              "$MYSQL_DATABASE" -e "DROP TABLE IF EXISTS mailman" 
     38    fi 
    3339    ;; 
    3440esac 
    35 # purge 
    3641 
    3742# dh_installdeb will replace this with shell code automatically 
  • trunk/debian/rules

    r1226 r1237  
    11#!/usr/bin/make -f 
    2 # Sample debian/rules that uses debhelper. 
    3 # This file is public domain software, originally written by Joey Hess. 
    4 # 
    5 # This version is for a multibinary package. It also allows you to build any 
    6 # of the binary packages independantly, via binary-<package> targets. 
    72 
    83# Uncomment this to turn on verbose mode.  
    9 export DH_VERBOSE=1 
    10  
    11 ######################################## 
    12 ## TODO 
    13 ## Virer les lignes # inutiles ou historiques (marquées ##) 
    14  
     4#export DH_VERBOSE=1 
    155 
    166# This has to be exported to make some magic below work. 
     
    2010build-stamp: 
    2111        dh_testdir 
    22  
    23 # compilation et installation des binaires 
    24         pushd src; make; popd 
    25  
     12        make -C src 
    2613        touch build-stamp 
    2714 
     
    3017        dh_testroot 
    3118        rm -f build-stamp 
    32  
    33         # Add here commands to clean up after the build process. 
    34         #-$(MAKE) clean 
    35         #-$(MAKE) distclean 
    36         pushd src; make clean; popd 
    37  
     19        make -C src clean 
    3820        dh_clean 
    3921 
    40 install: DH_OPTIONS= 
    4122install: build 
    4223        dh_testdir 
     
    4425        dh_clean -k 
    4526        dh_installdirs 
    46  
    47  
    48         # Add here commands to install the package into debian/tmp. 
    49         #$(MAKE) prefix=`pwd`/debian/tmp/usr install 
    50  
    5127        cp -r bureau debian/tmp/var/alternc/ 
    5228        chown root:www-data -R debian/tmp/var/alternc 
    5329        chmod -R 0640 debian/tmp/var/alternc 
    5430        chmod -R a+X debian/tmp/var/alternc 
    55  
    5631        # Install the binaries : -r-sr-sr-x 
    57         install -m 06555 -o list -g list src/mailman.create src/mailman.delete src/mailman.list debian/tmp/usr/lib/alternc/ 
    58  
    59         install -m 0644 mm_cfg.py debian/tmp/usr/share/alternc/install/etc/mailman
     32        install -m 06555 -o list -g list \ 
     33                src/mailman.create src/mailman.delete src/mailman.list \ 
     34               debian/tmp/usr/lib/alternc
    6035        install -m 0644 mailman.sql debian/tmp/usr/share/alternc/install/ 
    61  
    6236        # Remove any remaining CVS dir ;) 
    6337        find debian/tmp/ -depth -name "CVS" -exec rm -rf {} \; 
    64 #       dh_install --prefix=install/alternc 
    65  
    66 # This single target is used to build all the packages, all at once, or 
    67 # one at a time. So keep in mind: any options passed to commands here will 
    68 # affect _all_ packages. Anything you want to only affect one package 
    69 # should be put in another target, such as the install target. 
    7038 
    7139binary-common: build install 
     
    7442        dh_installchangelogs 
    7543        dh_installdocs 
    76 #       dh_installexamples 
    77 #       dh_installmenu 
    78         dh_installdebconf 
    79 #       dh_installlogrotate 
    80 #       dh_installemacsen 
    81 #       dh_installpam 
    82 #       dh_installmime 
    83 #       dh_installinit 
    84 #       dh_installman 
    85         dh_installcron 
    86 #       dh_installinfo 
    87 #       dh_undocumented 
    88 #       dh_installman 
    8944        dh_strip 
    9045        dh_link 
    9146        dh_compress 
    92         dh_fixperms --exclude mailman.delete --exclude mailman.create --exclude mailman.list 
    93  
    94  
    95 #       dh_makeshlibs 
     47        dh_fixperms --exclude mailman.delete \ 
     48                --exclude mailman.create --exclude mailman.list 
    9649        dh_installdeb 
    9750        dh_perl 
    98 #       dh_shlibdeps 
    9951        dh_gencontrol -- -cdebian/control 
    10052        dh_md5sums 
    10153        dh_builddeb 
    10254 
    103 # Build architecture independant packages using the common target. 
    10455binary-indep: build install binary-common 
    105 # (Uncomment this next line if you have such packages.) 
    106 #        $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common 
    10756 
    108 # Build architecture dependant packages using the common target. 
    10957binary-arch: build install binary-common 
    110 #       $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common 
    111  
    112 # Any other binary targets build just one binary package at a time. 
    113 # binary-%: build install 
    114 #       make -f debian/rules binary-common DH_OPTIONS=-p$* 
    115  
    116 # binary: binary-indep binary-arch 
    117 # .PHONY: build clean binary-indep binary-arch binary install 
    11858 
    11959binary: binary-common 
    12060 
    121 .PHONY: build clean binary install 
     61.PHONY: build clean binary binary-common binary-arch binary-indep install  
  • trunk/mm_cfg.py

    r1218 r1237  
    11# -*- python -*- 
     2 
     3# WARNING!  DO NOT EDIT THIS FILE! 
     4#  
     5# This file has been generated by alternc-mailman configuration. 
     6# 
     7# If you want to change anything, you should modify 
     8#   /etc/alternc/templates/mailman/mm_cfg.py 
     9# and use 
     10#   dpkg-reconfigure alternc-mailman 
     11# to update this file. 
    212 
    313# Copyright (C) 1998,1999,2000 by the Free Software Foundation, Inc.