Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release-src > by-pkgid > 04ff9ed59b61c1ef8cfc3b0a05672f8a > files > 7

mailman-2.1.20-2.mga5.src.rpm

%define uid     mail
%define gid     mail
%define email_version   2.5.8

Name:       mailman
Version:    2.1.20
Release:    %mkrel 2
Summary:    The GNU Mailing List Management System
Group:      System/Servers
License:    GPL
URL:        http://www.list.org/
Source0:    http://ftp.gnu.org/gnu/mailman/%{name}-%{version}.tgz
Source2:    %{name}.service
Patch0:     %{name}-buildroot-check.patch
Patch1:     mailman-2.1.12-rename-arch.patch
Patch6:     %{name}-2.1.2-postfix-aliases.patch
Patch9:     %{name}-2.1.11-change-default-icons-url.patch
Requires:   mail-server
Requires:   apache
# for /bin/crontab:
Requires(post):  cronie
Requires(post):  rpm-helper
Requires(preun): rpm-helper
BuildRequires:	python
BuildRequires:	python-devel
BuildRequires:	python-dnspython
Requires:	python-GnuPG-Interface
Requires:	gnupg
Requires:	openssl

%description
Mailman -- The GNU Mailing List Management System --
is a mailing list management system written mostly in
Python. Features:

  o Most standard mailing list features, including:
     moderation, mail based commands, digests, etc...
  o An extensive Web interface, customizable on a per-list basis.
  o Web based list administration interface for *all* admin-type tasks
  o Automatic Web based hypermail-style archives (using pipermail or
    other external archiver), including provisions for private archives
  o Integrated mail list to newsgroup gatewaying
  o Integrated newsgroup to mail list gatewaying (polling-based... if you
     have access to the nntp server, you should be able to easily do
     non-polling based news->mail list gatewaying; email viega@list.org,
     I'd like to help get that going and come up
     with instructions)
  o Smart bounce detection and correction
  o Integrated fast bulk mailing
  o Smart spam protection
  o Extensible logging
  o Multiple list owners and moderators are possible
  o Optional MIME-compliant digests

%prep
%setup -q
%patch0 -p1 -b .buildroot
%patch1 -p1 -b .rename-arch
%patch6 -p1 -b .chmod
%patch9 -p1 -b .default


%build
%serverbuild
# As a normal user, we don't have permissions to do this.  %patch0 changes
#   configure so that the directory check will never fail.
autoreconf
./configure \
    --prefix=%{_libdir}/%{name} \
    --with-var-prefix=%{_var}/lib/%{name} \
    --with-mail-gid=%{gid} \
    --with-cgi-gid=apache \
    --with-username=%{uid} \
    --with-groupname=%{gid} \
    --without-permcheck \
    --with-cgi-ext=.cgi \
    --libdir=%{_libdir}

make
# fix encoding typo
perl -pi -e 's/gb2132/gb2312/' misc/email-2.5.6/email/Charset.py

%install
%makeinstall_std

# apache conf
install -d -m 755 %{buildroot}%{_webappconfdir}
cat > %{buildroot}%{_webappconfdir}/%{name}.conf <<EOF
# Mailman Apache configuration file
Alias /%{name}/icons %{_libdir}/%{name}/icons

<IfModule alias_module>
    ScriptAlias /%{name}       %{_libdir}/%{name}/cgi-bin
</IfModule>

Alias /pipermail     %{_var}/lib/%{name}/archives/public


<Directory %{_libdir}/%{name}/cgi-bin>
    Require all granted
    Options ExecCGI
    DirectoryIndex listinfo.cgi
</Directory>

<Directory %{_libdir}/%{name}/icons>
    Require all granted
</Directory>

<Directory %{_var}/lib/mailman/archives/public>
    Require all granted
    Options FollowSymlinks
</Directory>
EOF

# systemd service
install -d -m 755 %{buildroot}%{_unitdir}
install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/mailman.service
sed -i "s|/usr/lib|%{_libdir}|g" %{buildroot}%{_unitdir}/mailman.service

# move logs directory into /var/log
install -d -m 755 %{buildroot}%{_var}/log
mv %{buildroot}%{_var}/lib/%{name}/logs %{buildroot}%{_var}/log/%{name}
(cd %{buildroot}%{_var}/lib/%{name} && ln -s ../../log/%{name} logs)

# move config file into /etc
install -d -m 755 %{buildroot}%{_sysconfdir}
mv %{buildroot}%{_libdir}/%{name}/Mailman/mm_cfg.py %{buildroot}%{_sysconfdir}/%{name}
(cd %{buildroot}%{_libdir}/%{name}/Mailman && ln -s ../../../..%{_sysconfdir}/%{name} mm_cfg.py)
rm -f %{buildroot}%{_libdir}/%{name}/Mailman/mm_cfg.py.dist

# fix permissions mess
chmod -R go=u-ws %{buildroot}%{_libdir}/%{name}
chmod 750 %{buildroot}%{_var}/lib/%{name}/archives/private

# logrotate
install -d m 755 %{buildroot}%{_sysconfdir}/logrotate.d
cat > %{buildroot}%{_sysconfdir}/logrotate.d/%{name} <<EOF
# daily rotated log files
%{_var}/log/mailman/smtp-failure %{_var}/log/mailman/smtp %{_var}/log/mailman/locks %{_var}/log/mailman/fromusenet %{_var}/log/mailman/qrunner {
    daily
    missingok
    rotate 7
    sharedscripts
    postrotate
    [ -f '/var/run/mailman/mailman.pid' ] && %{_libdir}/mailman/bin/mailmanctl -q reopen || exit 0
    endscript
}

# weekly rotated log files
%{_var}/log/mailman/bounce %{_var}/log/mailman/error %{_var}/log/mailman/vette %{_var}/log/mailman/mischief {
    weekly
    missingok
    rotate 4
    sharedscripts
    postrotate
    [ -f '/var/run/mailman/mailman.pid' ] && %{_libdir}/mailman/bin/mailmanctl -q reopen || exit 0
    endscript
}

# monthly rotated log files
%{_var}/log/mailman/digest %{_var}/log/mailman/subscribe %{_var}/log/mailman/post {
    monthly
    missingok
    rotate 12
    sharedscripts
    postrotate
    [ -f '/var/run/mailman/mailman.pid' ] && %{_libdir}/mailman/bin/mailmanctl -q reopen || exit 0
    endscript
}
EOF

# binaries symlinks from /usr/sbin
install -d -m 755 %{buildroot}%{_sbindir}
pushd %{buildroot}%{_sbindir}
for bin in ../..%{_libdir}/%{name}/bin/*; do
    ln -s $bin .
done
popd

cat > README.mga <<EOF
Mageia RPM specific notes

setup
-----
The setup used here differs from default one, to achieve better FHS compliance.
- the configuration file is /etc/mailman
- the log files are in /var/log/mailman
- the constant files are in %{_libdir}/mailman
- the variable files are in /var/lib/mailman
Moreover, the perms used are most standard and secures. check_perms will
scream, but mailman runs fine.

post-installation
-----------------
Post-installation script attempts first to integrate mailman aliases file with
existing mail aliases. Then the server-wide 'mailman' list is automatically
created, with root@hostname as admin, and a randomly generated password. This
list is configured with generic default values, but its configuration should be
reviewed before usage.
The password is available in the notification message sent by mailman upon list
creation, and is also used as the site password. The mailman service has to be
started, and the SMTP server has to be running for the message to be correctly
delivered.

The httpd.conf file in %{_webconfdir} needs a few changes:
(This may prevent other script in /var/www/cgi-bin/ not to work anymore)
comment out:
 <IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 
 </IfModule>

and

 <Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
 </Directory>


upgrade
-------
The alias db (/var/lib/mailman/data/aliases.db) should be owned by the same uid
and gid as the one used by mailman, mail.mail here. You may experience troubles
when upgrading from old releases of the packages.
EOF

%pre
if [ $1 = "2" ]; then
  if [ ! -L %{_libdir}/%{name}/Mailman/mm_cfg.py ]; then
    mv %{_libdir}/%{name}/Mailman/mm_cfg.py %{_sysconfdir}/%{name}.tmp
  fi
  if [ ! -L %{_var}/lib/%{name}/logs ]; then
    mv %{_var}/lib/%{name}/logs %{_var}/log/%{name}
  fi
fi

%post
%_post_service %{name}

cd %{_libdir}/%{name}

if [ $1 = 1 ] && [ -z "$DURING_INSTALL" ]; then
    # installation

    # generic tasks
    hostname=`hostname`
    domainname=`dnsdomainname`

    if [ -z "$domainname" ]; then
        domainname=localdomain
    fi

    # mailman basic configuration
    cat >>Mailman/mm_cfg.py <<EOF
DEFAULT_EMAIL_HOST = '$domainname'
DEFAULT_URL_HOST = '$hostname'
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
EOF

    # make sure mail user is allowed to use cron
    if [ -f %{_sysconfdir}/cron.allow ]; then
        if ! grep -q %{uid} %{_sysconfdir}/cron.allow; then
            echo "%{uid}" >> %{_sysconfdir}/cron.allow
        fi
    fi

    # add cron task
    crontab -u %{uid} %{_libdir}/%{name}/cron/crontab.in

    # add aliases
    %create_ghostfile %{_var}/lib/%{name}/data/aliases %{uid} %{gid} 660
    mta="`readlink /etc/alternatives/sendmail-command 2>/dev/null | cut -d . -f 2`"
    if [ "$mta" == "postfix" ]; then
        cat >>Mailman/mm_cfg.py <<EOF
MTA = 'Postfix'
EOF
        maps=`/usr/sbin/postconf -h alias_maps`
        postconf -e \
            "recipient_delimiter = +" \
            "unknown_local_recipient_reject_code = 550" \
            "alias_maps = $maps, hash:%{_var}/lib/%{name}/data/aliases"
        /usr/sbin/postalias %{_var}/lib/%{name}/data/aliases
    else
        cat >> %{_sysconfdir}/aliases <<EOF
:include:   %{_var}/lib/%{name}/data/aliases
EOF
        /usr/bin/newaliases
    fi

    # generate random password
    passwd=%_get_password 8

    # site password
    %{_sbindir}/mmsitepass $passwd > /dev/null

    if [ ! -f /var/lib/mailman/lists/mailman/config.pck ]; then
        # initial list creation and configuration
        su %{uid} \
            -c "%{_sbindir}/newlist mailman root@$hostname $passwd" > /dev/null
        su %{uid} \
            -c "%{_sbindir}/config_list -i /var/lib/mailman/data/sitelist.cfg mailman"
    fi

else
    # upgrade
    if [ -f %{_sysconfdir}/%{name}.tmp ]; then
        mv -f %{_sysconfdir}/%{name}.tmp %{_sysconfdir}/%{name}
    fi
fi

%preun
%_preun_service %{name}

%postun
if [ $1 = 0 ]; then
    # generic tasks

    # remove cron task
    crontab -u %{uid} -r

    # remove aliases
    mta="`readlink /etc/alternatives/sendmail-command 2>/dev/null | cut -d . -f 2`"
    if [ "$mta" == "postfix" ]; then
        database=`/usr/sbin/postconf -h alias_database | \
            sed -e 's|, hash:%{_var}/lib/%{name}/data/aliases||'`
        maps=`/usr/sbin/postconf -h alias_maps | \
            sed -e 's|, hash:%{_var}/lib/%{name}/data/aliases||'`
        postconf -e \
            "alias_database = $database" \
            "alias_maps = $maps"
    else
        sed -i -e '/:include:   %{_var}/lib/%{name}/data/aliases/d' \
            %{_sysconfdir}/aliases
    fi
    /usr/bin/newaliases
fi

%files
%doc ACKNOWLEDGMENTS BUGS FAQ INSTALL NEWS* README* TODO* UPGRADING
%doc gnu-COPYING-GPL contrib/README.check_perms_grsecurity
%doc doc/*
# constant files
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/cron
%{_libdir}/%{name}/pythonlib
%{_libdir}/%{name}/scripts
%{_libdir}/%{name}/tests
%{_libdir}/%{name}/messages
%{_libdir}/%{name}/templates
%{_libdir}/%{name}/bin
%{_libdir}/%{name}/Mailman
%{_libdir}/%{name}/icons
%dir %{_libdir}/%{name}/mail
%attr(2755,root,%{gid}) %{_libdir}/%{name}/mail/*
%dir %{_libdir}/%{name}/cgi-bin
%attr(2755,root,%{gid}) %{_libdir}/%{name}/cgi-bin/*
# variable files
%attr(-,%{uid},%{gid}) %{_var}/lib/%{name}
%attr(-,%{uid},apache) %{_var}/lib/%{name}/archives/private
%attr(-,%{uid},%{gid}) %{_var}/log/%{name}
# configuration files
%{_unitdir}/%{name}.service
%config(noreplace) %{_webappconfdir}/%{name}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/%{name}
%{_sbindir}/*


%changelog
* Sat May 09 2015 spuhler <spuhler> 2.1.20-2.mga5
+ Revision: 821563
- changed Alias /%%{name}  to ScriptAlias /%%{name}
- added comments in the README.mga file
  * This will allow for the cgi-bin scripts to run and provide the WEB interface.

* Tue May 05 2015 spuhler <spuhler> 2.1.20-1.mga5
+ Revision: 821276
- upgrade to version 2.1.20
- removed mailman-2.1.15-CVE-2015-2775.patch
  * it's included in 2.1.20
- removed mailman-2.1.5-build.patch
  * it's done differently in 2.1.20

* Thu Apr 09 2015 luigiwalser <luigiwalser> 2.1.15-8.mga5
+ Revision: 820026
- add patch from debian to fix CVE-2015-2775

* Wed Oct 15 2014 umeabot <umeabot> 2.1.15-7.mga5
+ Revision: 740131
- Second Mageia 5 Mass Rebuild

* Tue Sep 16 2014 umeabot <umeabot> 2.1.15-6.mga5
+ Revision: 682136
- Mageia 5 Mass Rebuild

  + guillomovitch <guillomovitch>
    - do not run %%post during installation (fix #9267)

* Fri Oct 18 2013 umeabot <umeabot> 2.1.15-4.mga4
+ Revision: 507710
- Mageia 4 Mass Rebuild

  + tv <tv>
    - requires(post) cronie for /bin/crontab

* Sat Jan 12 2013 umeabot <umeabot> 2.1.15-3.mga3
+ Revision: 359315
- Mass Rebuild - https://wiki.mageia.org/en/Feature:Mageia3MassRebuild

* Sun Dec 23 2012 remmy <remmy> 2.1.15-2.mga3
+ Revision: 334261
- The systemd unit file as shipped would not work for several reasons:
- mailman-update-cfg was called which is not shipped by us;
- ownership of logfiles was set to mailman instead of mail;
- on x86_64 it referred to /usr/lib instead of /usr/lib64
  This should close mga#8067

* Sat Sep 08 2012 guillomovitch <guillomovitch> 2.1.15-1.mga3
+ Revision: 290472
- new version
- drop s/mime patch, too much invasive
- drop sysinit support

* Tue May 08 2012 pterjan <pterjan> 2.1.13-9.mga2
+ Revision: 234919
- Fix initscript's LSB header

* Sat Apr 28 2012 tmb <tmb> 2.1.13-8.mga2
+ Revision: 233774
- Require rpm-helper >= 0.24.8-1 for systemd support

* Tue Mar 13 2012 guillomovitch <guillomovitch> 2.1.13-7.mga2
+ Revision: 223243
- systemd support

* Sun Mar 06 2011 ennael <ennael> 2.1.13-6.mga1
+ Revision: 65702
- clean spec file
- imported package mailman