Skip to Content.
Sympa Menu

devel - Re: [sympa-dev] hello

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Mathieu Kretchner <address@concealed>
  • To: address@concealed, Jason Giangrande <address@concealed>
  • Subject: Re: [sympa-dev] hello
  • Date: Fri, 11 Apr 2008 15:03:42 +0200

hello Jason,

We have work on your spec version in order to fusion / improve your spec with our spec !
And here you'll find the last (I hope) version of the spec file. There is still some weird code but it's working well.
Now we try to debug possibles mistakes.

Regards


Guillaume Rousse a écrit :
David Verdin a écrit :
Hi Jason,

Thanks for sharing this code!
We are currently working on the improvement of the autotools usage in
Sympa, thanks to the work of G. Rousse.
Your work will take place in this wider context.
Building rpm (or distributions packages, more generally) is outside
intended autotools purpose, probably because it's too specific and it's
outside software maintainer role. Packages are usually maintained
separatly by third party, from distributed tarballs, and don't require
any specific support (excepted standard GNU build system features, such
as 'make install DESTDIR=' style support).

Of course, software authors may be interested either in distributing rpm
themselves (bad idea, IMHO, unless you're willing to deal with X
distributions, Y versions and Z architectures), or to distribute
software ready to be transformed into rpm for their users (far more
generic solution). But you don't need any 'make_rpm' target in your
makefile for this: just having a spec file in your top-level directory
of your archive allow anyone to run 'rpmbuild -ta sympa-x.y.z.tar.gz'.

sympa currently has make targets for generating mandriva and redhat
packages. I don't see much use for the mandriva target, as I already
maintain sympa inside mandriva. Just moving the spec file Jason
submitted at the top-level of sympa archive, and dropping anything
related to rpm building in Makefile.am would remove a lot of cruft,
while retaining needed functionality.

Note however there is a chicken-and-egg issue currently, as this spec
file is actually not a spec file, but a spec file template, with
intended substitution target for sympa installation process. A spec file
is not supposed to be a result of a first ./configure script execution,
embedding values passed by the user, to call the same script with the
same parameters, but drive the configuration process itself (see
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/sympa/current/SPECS/
for an example). This is over-complex, fragile, and counter-intuitive.
You'd rather replace this ugly mess with a static spec file, and if
you're really worried about the potential mismatch between its version
and tarball version, make the related substitution part of the sympa
release process, not of the final user configuration process.


# $Id: sympa.spec,v 1.56 2008/04/11 13:00:06 mkretchn Exp $
%define name sympa
%define version 5.4.1
%define release inria_semir_1.5
%define home_s /var/sympa
%define data_s /usr/share/sympa
%define conf_s /etc/sympa
%define etc_s /etc/sympa
%define spoo_s /var/sympa/spool

Summary:  Sympa is a powerful multilingual List Manager - LDAP and SQL features.
Name:  %{name}
Version:  %{version}
Release:  %{release}
License:  GPL
Group: System Environment/Daemons
Source:  http://www.sympa.org/distribution/%{name}-%{version}.tar.gz
URL: http://www.sympa.org
Requires: smtpdaemon
Requires: bash
Requires: shadow-utils
Requires: glibc >= 2.0
Requires: MHonArc >= 2.4.6
Requires: mod_fcgid
Requires: mod_ssl
Requires: mysql-server
Requires: openssl >= 0.9.5a
Requires: perl >= 0:5.005
Requires: perl-Archive-Zip
Requires: perl-CGI-Simple
Requires: perl-Crypt-CipherSaber
Requires: perl-DBD-MySQL
Requires: perl-DBI >= 1.06
Requires: perl-FCGI >= 0.48
Requires: perl-HTML-StripScripts-Parser
Requires: perl-IO-stringy >= 1.0
Requires: perl-LDAP >= 0.10
Requires: perl-libintl
Requires: perl-libwww-perl
Requires: perl-MailTools >= 1.14
Requires: perl-MIME-Charset 
Requires: perl-MIME-EncWords
Requires: perl-MIME-tools >= 5.209
Requires: perl-Net-SSLeay >= 1.21
Requires: perl-SOAP-Lite
Requires: perl-suidperl
Requires: perl-Template-Toolkit
Requires: perl-URI
Requires: perl-XML-LibXML
Requires: webserver
Prereq: /usr/sbin/useradd
Prereq: /usr/sbin/groupadd
Provides: perl(SympaTransport)
Provides: perl(parser.pl)
Provides: perl(tools.pl)
Provides: perl(tt2.pl)
BuildRoot: %{_tmppath}/%{name}-%{version}
BuildRequires: openssl-devel >= 0.9.5a
Prefix: %{_prefix}

%description

Sympa is scalable and highly customizable mailing list manager. 
It can cope with big lists (200,000 subscribers) and comes with
a complete (user and admin) Web interface. It is internationalized,
and supports the us, fr, de, es, it, fi, and chinese locales. 
A scripting language allows you to extend the behavior of commands.
Sympa can be linked to an LDAP directory or an RDBMS to create dynamic mailing lists.
Sympa provides S/MIME-based authentication and encryption.

%prep

rm -rf $RPM_BUILD_ROOT
%setup -q

%build

./configure \
--prefix=/var/sympa \
--enable-secure \
--with-confdir=/etc/sympa \
--with-etcdir=/etc/sympa \
--with-cgidir=/var/www/cgi-bin \
--with-bindir=/var/sympa/bin \
--with-sbindir=/var/sympa/sbin \
--with-mandir=%{_mandir} \
--with-libexecdir=/var/sympa/bin \
--with-libdir=/usr/lib/sympa/bin \
--with-datadir=/usr/share/sympa \
--with-expldir=/var/sympa/expl \
--with-piddir=/var/run/sympa \
--with-localedir=/usr/lib/sympa/locale \
--with-scriptdir=/var/sympa/bin \
--with-sampledir=/usr/share/sympa/examples \
--with-spooldir=/var/sympa/spool \
--with-openssl=/usr/bin/openssl \
;make sources soap_wrapper wrapper man locale


%install

rm -rf $RPM_BUILD_ROOT

# Create icons directory
mkdir -p /var/sympa/static_content/icons

make HOST=MYHOST DESTDIR=$RPM_BUILD_ROOT install

# Create bounce and archive directories
for dir in bounce wwsarchives wwsbounce ; do
  if [ ! -d $RPM_BUILD_ROOT%{spoo_s}/$dir ] ; then
    mkdir -p $RPM_BUILD_ROOT%{spoo_s}/$dir
    chown sympa $RPM_BUILD_ROOT%{spoo_s}/$dir
    chgrp sympa $RPM_BUILD_ROOT%{spoo_s}/$dir
    chmod 770 $RPM_BUILD_ROOT%{spoo_s}/$dir
  fi
done


%pre

# Create "sympa" group if it is not already there
if ! grep -q "^sympa:" /etc/group; then
    echo "Adding system group: sympa."
    /usr/sbin/groupadd sympa
else
    echo "Group already exists"
fi

# Add "apache" in group "sympa" so that it could access
# /etc/sympa/wwsympa.conf and therefore a working wwsympa ;-)
if ! grep -q "^sympa:.*\<apache\>" /etc/group; then
    echo "Adding apache in group sympa."
    comma="";
    [ -n "$(grep '^sympa:' /etc/group | sed -e 's/^sympa:.*:.*://')" ] && comma=",";
    perl -pi -e "s/^(sympa:.*)/\1${comma}apache/" /etc/group
fi

# Create "sympa" user if it is not already there
home_s_pw=`sed -n -e "/^sympa:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/s//\1/p" /etc/passwd`
if [ -z "$home_s_pw" ]; then
    echo "Adding system user: sympa."
    /usr/sbin/useradd -M -g sympa -d %{home_s} sympa -c "Sympa mailing-list manager" -s "/bin/false"
elif [ "$home_s_pw" != "%{home_s}" ]; then
    echo "Problem: user \"sympa\" already exists with a home different from %{home_s}"
    exit 0
fi


%post

## Setting Runlevels
for I in 0 1 2 6; do
    mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc$I.d
    ln -s $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name} $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/K25%{name}
done
for I in 3 5; do
    mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc$I.d
    ln -s $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name} $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/S95%{name}
done

if [ -e "/var/log/sympa" ] && [ ! -f "/var/log/sympa" ]; then
    echo "Problem: /var/log/sympa already exists but it is not a file!"
fi
touch /var/log/sympa || /bin/true
chown sympa.sympa /var/log/sympa
chmod 0640 /var/log/sympa

# Setup log facility for Sympa
if [ -f /etc/syslog.conf ] ;then
    if [ `grep -c sympa /etc/syslog.conf` -eq 0 ] ;then
	typeset -i cntlog
	cntlog=0
#	while [ `grep -c local${cntlog} /etc/syslog.conf` -gt 0 ];do cntlog=${cntlog}+1;done	
	if [ ${cntlog} -le 9 ];then
	    echo "# added by %{name}-%{version} rpm $(date)" >> /etc/syslog.conf
	    echo "local${cntlog}.*       -/var/log/%{name}" >> /etc/syslog.conf
	fi
	perl -pi -e "s|^\*\.info;|\*\.info;local${cntlog}.none;|" /etc/syslog.conf
	for conffile in %{conf_s}/sympa.conf; do
	    perl -pi -e "s|syslog(\s+)LOCAL[0-9]+|syslog\1LOCAL${cntlog}|" $conffile
	done
    fi
fi

# rotate log for sympa
if [ -d /etc/logrotate.d ] ;then
    if [ ! -f /etc/logrotate.d/sympa ] ;then
	echo "/var/log/sympa {" > /etc/logrotate.d/sympa
	echo "    missingok" >> /etc/logrotate.d/sympa
	echo "    notifempty" >> /etc/logrotate.d/sympa
	echo "    copytruncate" >> /etc/logrotate.d/sympa
	echo "    rotate 10" >> /etc/logrotate.d/sympa
	echo "}" >> /etc/logrotate.d/sympa
    fi
fi

#the directory where sendmail can call queue and bouncequeue
bin_queue=/var/sympa/bin

# eventually, add queue and bouncequeue to sendmail security shell
if [ -d /etc/smrsh ]; then
  bin_queue=/etc/smrsh
  if [ ! -e /etc/smrsh/queue ]; then
    ln -s /var/sympa/bin/queue /etc/smrsh/queue
  fi
 
  if [ ! -e /etc/smrsh/bouncequeue ]; then
    ln -s /var/sympa/bin/bouncequeue /etc/smrsh/bouncequeue
  fi
fi

# config httpd for sympa /etc/httpd/conf.d/sympa.conf
install -d -m 755 /etc/httpd/conf.d
cat > /etc/httpd/conf.d/sympa.conf <<EOF
# added by %{name}-%{version} rpm $(date)
Alias /static-sympa %{_var}/sympa/static_content
ScriptAlias /sympa %{_var}/www/cgi-bin/wwsympa-wrapper.fcgi
#
# redirect en https
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://%{SERVER_NAME}/ [R=permanent,L]
#
# redirect vers /sympa
<LocationMatch "^/+$">
RewriteEngine On
  RewriteRule ^(.*)$ /sympa [R=permanent,L]
</LocationMatch>
EOF


# Try to add some sample entries in /etc/aliases for sympa
for a_file in /etc/aliases /etc/postfix/aliases; do
    if [ -f ${a_file} ]; then
	if [ `grep -c sympa ${a_file}` -eq 0 ]; then
	    cp -f ${a_file} ${a_file}.rpmorig
	    echo >> ${a_file}
	    echo "# added by %{name}-%{version} rpm " $(date) >> ${a_file}
	    if [ `grep -c listmaster ${a_file}` -eq 0 ]; then
		echo "listmaster: \"|${bin_queue}/queue listmaster\"" >> ${a_file}
	    fi
	    echo "sympa: \"|${bin_queue}/queue sympa\"" >> ${a_file}
	    echo "bounce+*: \"|${bin_queue}/bouncequeue sympa\"" >> ${a_file}
	    echo "abuse-feedback-report: \"| /var/sympa/bin/bouncequeue sympa@${HOSTNAME}\"" >> ${a_file}
	    echo "sympa-request:  listmaster@${HOSTNAME}" >> ${a_file}
	    echo "sympa-owner:    listmaster@${HOSTNAME}" >> ${a_file}
	    echo "" >> ${a_file}
      # The user have to manually comment out the new aliases
      # and then invoke: /usr/bin/newaliases
	    echo "Your new aliases have been set up in ${a_file}. Please check them out before running /usr/bin/newaliases"
	    echo "You must configure your MTA (sendmail, postfix,...) for using a second aliases file, the one modified by sympa for his lists : /etc/mail/sympa_aliases"
	    echo "Refer to INSTALL file for more setup information..."
	fi
    fi
done

# create the alias file used by sympa for his lists
if [ ! -f "/etc/mail/sympa_aliases" ]; then
  if [ ! -d "/etc/mail" ]; then
      mkdir -p /etc/mail
  fi
  touch /etc/mail/sympa_aliases || /bin/true
  chown root.sympa /etc/mail/sympa_aliases
  chmod 0660 /etc/mail/sympa_aliases
fi

# aliases inclusion in postfix
mta="`readlink /etc/alternatives/mta 2>/dev/null | cut -d . -f 2`"
if [ "$mta" == "postfix" ]; then
    database=`/usr/sbin/postconf -h alias_database`
    maps=`/usr/sbin/postconf -h alias_maps`
    postconf -e \
        "alias_database = $database, hash:/etc/mail/sympa_aliases" \
        "alias_maps = $maps, hash:/etc/mail/sympa_aliases"
fi
/usr/bin/newaliases

# reset the default cookie
typeset -x secret
secret=`perl -e "print int(rand(time))"`
perl -pi -e "s|'cookie',\n|'cookie',|" /var/sympa/sbin/sympa_wizard.pl
perl -pi -e "s|'cookie',.*\n|'cookie', 'default' => '${secret}',\n|" /var/sympa/sbin/sympa_wizard.pl

# set Apache and MySQL runlevels
chkconfig httpd on
chkconfig mysqld on


%preun

# clean syslog
sed -i /sympa/d /etc/syslog.conf 

# clean logrotate
if [ ! -f /etc/logrotate.d/sympa ] ;then
    rm -f /etc/logrotate.d/sympa 
fi

# remove apache config
rm -f /etc/httpd/conf.d/sympa.conf

# remove aliases
mta="`readlink /etc/alternatives/mta 2>/dev/null | cut -d . -f 2`"
  if [ "$mta" == "postfix" ]; then
    database=`/usr/sbin/postconf -h alias_database | \
	sed -e 's|, hash:/etc/mail/sympa_aliases||'`
    maps=`/usr/sbin/postconf -h alias_maps | \
	sed -e 's|, hash:/etc/mail/sympa_aliases||'`
    postconf -e \
	"alias_database = $database" \
	"alias_maps = $maps"
    /usr/bin/newaliases
  fi
  
  rm -f /etc/mail/sympa_aliases*

# clean sympa dirs
rm -rf /var/sympa
rm -rf /usr/lib/sympa

# clean log
rm -f /var/log/sympa

  
%postun

# Remove sympa user and group
if [ ! -d %{home_s} ]; then
    /usr/sbin/userdel sympa
    /usr/sbin/groupdel sympa  
fi

# remove links in /etc/smrsh
if [ $1 = 0 -a -d /etc/smrsh ]; then
  if [ -L /etc/smrsh/queue ]; then
    rm -f /etc/smrsh/queue
  fi
  if [ -L /etc/smrsh/bouncequeue ]; then
    rm -f /etc/smrsh/bouncequeue
  fi

fi

# remove links in runlevels
for I in 0 1 2 6; do
    if [ -L $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/K25%{name} ]; then
    rm -f $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/K25%{name}
    fi
done
for I in 3 5; do
    if [ -L $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/S95%{name} ]; then
	rm -f $RPM_BUILD_ROOT/etc/rc.d/rc$I.d/S95%{name}
    fi
done

# clean sympa dirs
rm -rf /var/sympa
rm -rf /usr/lib/sympa

# clean log
rm -f /var/log/sympa


%files

# par default les fichiers sont a sympa:sympa
%defattr(-,sympa,sympa)

# Where to store the data & config files of the lists
%dir /var/sympa/expl

# Documentation
%doc %attr(-,root,root) INSTALL README AUTHORS COPYING NEWS ChangeLog
%doc %attr(-,root,root) doc/sympa.pdf
%doc %attr(-,root,root) /var/sympa/doc/*
%attr(-,root,root) %{_mandir}/man8/*
%{etc_s}/README

# Spools
%dir %{spoo_s}
%dir %{spoo_s}/msg
%dir %{spoo_s}/bounce
%dir %{spoo_s}/wwsarchives
%dir %{spoo_s}/wwsbounce
%dir %{spoo_s}/digest
%dir %{spoo_s}/moderation
%dir %{spoo_s}/expire
%dir %{spoo_s}/auth
%dir %{spoo_s}/outgoing
%dir %{spoo_s}/tmp
%dir %{spoo_s}/task

# Configuration files
%config(noreplace) %{conf_s}/sympa.conf
%config(noreplace) %{conf_s}/wwsympa.conf


# Config directories populated by the user
%dir %{etc_s}/create_list_templates
%dir %{etc_s}/scenari
%dir %{etc_s}/mail_tt2
%dir %{etc_s}/web_tt2
%dir %{etc_s}/general_task_models
%dir %{etc_s}/task_models

# Binaries
%attr(-,-,-) /usr/lib/sympa/bin
%attr(-,-,-) /var/sympa/sbin
%attr(-,-,-) /var/sympa/bin

# Variable directories
/usr/lib/sympa/locale
/usr/share/sympa
/var/sympa/arc

# Icons
/var/sympa/static_content

# Binaries for Apache
/var/www/cgi-bin/sympa_soap_server-wrapper.fcgi
/var/www/cgi-bin/sympa_soap_server.fcgi
/var/www/cgi-bin/wwsympa-wrapper.fcgi
/var/www/cgi-bin/wwsympa_sudo_wrapper.pl
/var/www/cgi-bin/wwsympa.fcgi

# Init scripts
%config(noreplace) %attr(0755,root,root) /etc/rc.d/init.d/sympa


%clean

rm -rf $RPM_BUILD_ROOT

%changelog

* Fri Apr 11 2008 Mathieu Kretchner <address@concealed> , Olivier Dijoux <address@concealed>
- Initial Release RPM sympa 5.4.1

begin:vcard
fn:Mathieu Kretchner
n:Kretchner;Mathieu
org:INRIA;Syslog
adr;dom:;;2007 route des lucioles - BP93;Sophia Antipolis;;06902 CEDEX
email;internet:address@concealed
tel;work:04 92 38 76 67
x-mozilla-html:FALSE
version:2.1
end:vcard




Archive powered by MHonArc 2.6.19+.

Top of Page