##
##  ecartis.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_main    1.0.0
%define       V_snap    20060813
%define       V_here    %{V_main}.%{V_snap}

#   package information
Name:         ecartis
Summary:      Ecartis Mailing List Manager
URL:          http://www.ecartis.org/
Vendor:       Noderunner Computing
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Mail
License:      GPL
Version:      %{V_here}
Release:      20160323

#   list of sources
Source0:      ftp://ftp.ecartis.org/pub/ecartis/snapshots/tar/ecartis-%{V_main}-snap%{V_snap}.tar.gz
Source1:      ecartis.cfg
Source2:      ecartis.aliases
Source3:      banned
Patch0:       ecartis.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, make
PreReq:       OpenPKG, openpkg >= 20160101, MTA

%description
    Ecartis is a open-source software package that administers mailing
    lists similar to Majordomo and Listserv. Ecartis' feature list
    includes anti-spam hooks, ability to strip down MIME messages and
    remove their attachments, virtual hosts, just to name a few).
    Ecartis was formerly known as Listar.

%track
    prog ecartis = {
        disabled
        comment   = "site no longer accepts anonymous login"
        version   = %{V_main}-snap%{V_snap}
        url       = ftp://ftp.ecartis.org/pub/ecartis/snapshots/tar
        regex     = ecartis-((\d+\.)*\d+(-snap\d{8})?)\.tar\.gz
    }

%prep
    %setup -q -n ecartis-%{V_main}
    %patch -p0
    ( cd src
      %{l_shtool} install -c -m 644 Makefile.dist Makefile
      %{l_shtool} subst \
          -e 's;^\(DYNMOD=.*\)$;#\1;' \
          -e 's;^\(CC=\).*$;\1%{l_cc};' \
          -e 's;^\(	\{1,\}\)chmod \(.*\)$;\1-chmod \2;' \
          -e 's;^\(WFLAGS *=.*\)$;#\1;' \
          Makefile
      case "%{l_platform -t}" in
          *-sunos5* )
              %{l_shtool} subst \
                  -e 's;^\#\(SUNOS_5 *=\).*$;\1 1;' \
                  -e 's;^\#\(NEED_FLOCK *=.*\)$;\1;' \
                  -e 's;^\#\(NEED_STRERROR *=.*\)$;\1;' \
                  Makefile
              ;;
      esac
    ) || exit $?

%build
    ( cd src
      #   we call 'make' twice intentionally since the dependencies described
      #   in the Makefile are not sufficient and one could end up in a broken
      #   or incomplete build -- sigh
      %{l_make} %{l_mflags} make_modules
      %{l_make} %{l_mflags} ecartis
    ) || exit $?

%install

    #   create directory structure
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/ecartis
    %{l_shtool} mkdir -f -p -m 711 \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis
    %{l_shtool} mkdir -f -p -m 751 \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/lists
    %{l_shtool} mkdir -f -p -m 750 \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/modules \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/queue \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/scripts \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/templates \
        $RPM_BUILD_ROOT%{l_prefix}/var/ecartis/log

    #   install Ecartis executable
    %{l_shtool} install -c -s -m 755 \
        src/build/ecartis \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/

    #   install Ecartis configuration file
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE ecartis.cfg} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/ecartis/
    ln -s ../../etc/ecartis/ecartis.cfg \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/ecartis.cfg

    #   install alias configuration file
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE ecartis.aliases} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/ecartis/
    ln -s ../../etc/ecartis/ecartis.aliases \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/ecartis.aliases

    #   install global blacklist configuration file
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE banned} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/ecartis/
    ln -s ../../etc/ecartis/banned \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/banned

    #   install additional files
    %{l_shtool} install -c -m 644 \
        ecartis.hlp \
        spam-regexp.sample \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/
    %{l_shtool} install -c -m 644 \
        scripts/* \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/scripts/
    %{l_shtool} install -c -m 644 \
        templates/* \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/ecartis/templates/

    #   determine file list
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
        '%config %attr(0600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/ecartis/*' \
        '%attr(4711,%{l_rgrp},%{l_rgrp}) %{l_prefix}/libexec/ecartis/ecartis' \
        '%dir %attr(0750,%{l_rgrp},%{l_rgrp}) %{l_prefix}/libexec/ecartis/lists' \
        '%dir %attr(0750,%{l_rgrp},%{l_rgrp}) %{l_prefix}/libexec/ecartis/queue'

%files -f files

%clean

