##
##  axkit.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.
##

#   versions of individual parts
%define       V_perl                                  5.12
%define       V_axkit                                 1.7
%define       V_apache_axkit_language_xsp_objectaglib 0.09000
%define       V_apache_axkit_plugin_session           1
%define       V_axkit_app_gallery                     0.5
%define       V_axkit_app_taboo                       0.51
%define       V_axkit_plugin_disablexsltparams        0.01
%define       V_axkit_provider_html                   1.0
%define       V_axkit_xsp_attrparam                   0.01
%define       V_axkit_xsp_basicsession                0.22
%define       V_axkit_xsp_charsetconv                 0.02
%define       V_axkit_xsp_cookie                      1.41
%define       V_axkit_xsp_esql                        1.4
%define       V_axkit_xsp_exception                   1.6
%define       V_axkit_xsp_ifparam                     1.4
%define       V_axkit_xsp_l10n                        0.05000
%define       V_axkit_xsp_md5                         0.01
%define       V_axkit_xsp_minisession                 1.10000
%define       V_axkit_xsp_param                       1.4
%define       V_axkit_xsp_perform                     1.83
%define       V_axkit_xsp_queryparam                  0.02
%define       V_axkit_xsp_sendmail                    1.5
%define       V_axkit_xsp_session                     0.11
%define       V_axkit_xsp_util                        1.6
%define       V_axkit_xsp_webutils                    1.6
%define       V_http_ghttp                            1.07

#   package information
Name:         axkit
Summary:      Apache XML Application Server
URL:          http://www.axkit.org/
Vendor:       AxKit.com Ltd
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Web
License:      GPL/Artistic
Version:      %{V_axkit}
Release:      20100415

#   list of sources
Source0:      http://www.apache.org/dist/xml/axkit/AxKit-%{V_axkit}.tar.gz
Source1:      http://www.cpan.org/modules/by-module/AxKit/Apache-AxKit-Language-XSP-ObjectTaglib-%{V_apache_axkit_language_xsp_objectaglib}.tar.gz
Source2:      http://www.cpan.org/modules/by-module/AxKit/Apache-AxKit-Plugin-Session-%{V_apache_axkit_plugin_session}.tar.gz
Source3:      http://www.cpan.org/modules/by-module/AxKit/AxKit-Plugin-DisableXSLTParams-%{V_axkit_plugin_disablexsltparams}.tar.gz
Source4:      http://www.cpan.org/modules/by-module/AxKit/AxKit-Provider-HTML-%{V_axkit_provider_html}.tar.gz
Source5:      http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-AttrParam-%{V_axkit_xsp_attrparam}.tar.gz
Source6:      http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-BasicSession-%{V_axkit_xsp_basicsession}.tar.gz
Source7:      http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Util-%{V_axkit_xsp_util}.tar.gz
Source8:      http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-CharsetConv-%{V_axkit_xsp_charsetconv}.tar.gz
Source9:      http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Cookie-%{V_axkit_xsp_cookie}.tar.gz
Source10:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-WebUtils-%{V_axkit_xsp_webutils}.tar.gz
Source11:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-ESQL-%{V_axkit_xsp_esql}.tar.gz
Source12:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Exception-%{V_axkit_xsp_exception}.tar.gz
Source13:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-IfParam-%{V_axkit_xsp_ifparam}.tar.gz
Source14:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-L10N-%{V_axkit_xsp_l10n}.tar.gz
Source15:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-MD5-%{V_axkit_xsp_md5}.tar.gz
Source16:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Minisession-%{V_axkit_xsp_minisession}.tar.gz
Source17:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Param-%{V_axkit_xsp_param}.tar.gz
Source18:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-PerForm-%{V_axkit_xsp_perform}.tar.gz
Source19:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-QueryParam-%{V_axkit_xsp_queryparam}.tar.gz
Source20:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Sendmail-%{V_axkit_xsp_sendmail}.tar.gz
Source21:     http://www.cpan.org/modules/by-module/AxKit/AxKit-XSP-Session-%{V_axkit_xsp_session}.tar.gz
Source22:     http://www.cpan.org/modules/by-module/HTTP/HTTP-GHTTP-%{V_http_ghttp}.tar.gz
Source23:     axkit-apache.conf
Source24:     axkit-index.xsp
Source25:     rc.axkit

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl, perl-openpkg
PreReq:       OpenPKG, openpkg >= 20160101, perl
BuildPreReq:  apache-perl, perl-apache
PreReq:       apache-perl, perl-apache
BuildPreReq:  perl-crypto, perl-comp, perl-ldap, perl-time
PreReq:       perl-crypto, perl-comp, perl-ldap, perl-time
BuildPreReq:  perl-xml::with_sablotron = yes
PreReq:       perl-xml::with_sablotron = yes
BuildPreReq:  perl-xml::with_libxml = yes
PreReq:       perl-xml::with_libxml = yes
BuildPreReq:  libghttp
PreReq:       libghttp

%description
    Apache AxKit is an XML Application Server for Apache. It provides
    on-the-fly conversion from XML to any format, such as HTML, WAP
    or text using either W3C standard techniques, or flexible custom
    code. AxKit also uses a built-in Perl interpreter to provide some
    amazingly powerful techniques for XML transformation.

%track
    prog axkit:AxKit = {
        version   = %{V_axkit}
        url       = http://www.apache.org/dist/xml/axkit/
        regex     = AxKit-(__VER__)\.tar\.gz
    }
    prog axkit:Apache-AxKit-Language-XSP-ObjectTaglib = {
        version   = %{V_apache_axkit_language_xsp_objectaglib}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = Apache-AxKit-Language-XSP-ObjectTaglib-(__VER__)\.tar\.gz
    }
    prog axkit:Apache-AxKit-Plugin-Session = {
        version   = %{V_apache_axkit_plugin_session}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = Apache-AxKit-Plugin-Session-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-Plugin-DisableXSLTParams = {
        version   = %{V_axkit_plugin_disablexsltparams}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-Plugin-DisableXSLTParams-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-Provider-HTML = {
        version   = %{V_axkit_provider_html}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-Provider-HTML-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-AttrParam = {
        version   = %{V_axkit_xsp_attrparam}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-AttrParam-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-BasicSession = {
        version   = %{V_axkit_xsp_basicsession}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-BasicSession-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Util = {
        version   = %{V_axkit_xsp_util}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Util-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-CharsetConv = {
        version   = %{V_axkit_xsp_charsetconv}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-CharsetConv-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Cookie = {
        version   = %{V_axkit_xsp_cookie}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Cookie-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-WebUtils = {
        version   = %{V_axkit_xsp_webutils}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-WebUtils-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-ESQL = {
        version   = %{V_axkit_xsp_esql}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-ESQL-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Exception = {
        version   = %{V_axkit_xsp_exception}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Exception-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-IfParam = {
        version   = %{V_axkit_xsp_ifparam}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-IfParam-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-L10N = {
        version   = %{V_axkit_xsp_l10n}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-L10N-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-MD5 = {
        version   = %{V_axkit_xsp_md5}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-MD5-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Minisession = {
        version   = %{V_axkit_xsp_minisession}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Minisession-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Param = {
        version   = %{V_axkit_xsp_param}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Param-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-PerForm = {
        version   = %{V_axkit_xsp_perform}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-PerForm-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-QueryParam = {
        version   = %{V_axkit_xsp_queryparam}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-QueryParam-(__VER__)\.tar\.gz
    }
    prog axkit:AxKit-XSP-Sendmail = {
        version   = %{V_axkit_xsp_sendmail}0
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Sendmail-(__VER__)\.tar\.gz
        transform = "s/^(\d+\.\d)$/${1}0/; $_"
    }
    prog axkit:AxKit-XSP-Session = {
        version   = %{V_axkit_xsp_session}
        url       = http://www.cpan.org/modules/by-module/AxKit/
        regex     = AxKit-XSP-Session-(__VER__)\.tar\.gz
    }
    prog axkit:HTTP-GHTTP = {
        version   = %{V_http_ghttp}
        url       = http://www.cpan.org/modules/by-module/HTTP/
        regex     = HTTP-GHTTP-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5
    %setup -q -T -D -a 6
    %setup -q -T -D -a 7
    %setup -q -T -D -a 8
    %setup -q -T -D -a 9
    %setup -q -T -D -a 10
    %setup -q -T -D -a 11
    %setup -q -T -D -a 12
    %setup -q -T -D -a 13
    %setup -q -T -D -a 14
    %setup -q -T -D -a 15
    %setup -q -T -D -a 16
    %setup -q -T -D -a 17
    %setup -q -T -D -a 18
    %setup -q -T -D -a 19
    %setup -q -T -D -a 20
    %setup -q -T -D -a 21
    %setup -q -T -D -a 22

%build

%install
    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
        $RPM_BUILD_ROOT%{l_prefix}/etc/axkit \
        $RPM_BUILD_ROOT%{l_prefix}/share/axkit \
        $RPM_BUILD_ROOT%{l_prefix}/var/axkit/cache \
        $RPM_BUILD_ROOT%{l_prefix}/var/axkit/run \
        $RPM_BUILD_ROOT%{l_prefix}/var/axkit/log

    #   prepare installation
    %{l_prefix}/bin/perl-openpkg prepare

    #   install AxKit components
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE0} \
        --args --skip configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE1}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE2}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE3}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE4}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE5}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE6}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE7}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE8}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE9}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE10} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE11} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE12} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE13} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE14} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE15} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE16} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE17} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE18} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE19} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE20} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE21} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE22} \
        --args "LIBS='%{l_ldflags}'" \
        --args "INC='%{l_cppflags}'" \
        configure build install

    #   finalize Perl module installation
    %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup

    #   install run-command script
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE rc.axkit} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/

    #   install custom Apache configuration
    l_hostname=`%{l_shtool} echo -e %h`
    l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        -e "s;@l_hostname@;$l_hostname;g" \
        -e "s;@l_domainname@;$l_domainname;g" \
        %{SOURCE axkit-apache.conf} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/axkit/

    #   install index files
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE axkit-index.xsp} $RPM_BUILD_ROOT%{l_prefix}/share/axkit/index.xsp

    #   install demo files
    (   cd AxKit-%{V_axkit}
        #   LibXSLT > 1.59 doesn't work with AxKit 1.7: use Sablotron
        %{l_shtool} subst -e 's/LibXSLT/Sablot/' `find demo -name ".htaccess" -print`
        cp -rp demo/* $RPM_BUILD_ROOT%{l_prefix}/share/axkit/
    ) || exit $?

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} `cat perl-openpkg-files` \
        '%config %{l_prefix}/etc/axkit/*'

%files -f files

%clean

%post
    if [ ".$1" = .1 ]; then
        #   display information about steps the admin should perform next
        ( echo "You should now start Apache with"
          echo "  \$ $RPM_INSTALL_PREFIX/bin/openpkg rc axkit start"
          echo "and access the Axkit homepage under:"
          echo "  http://localhost:8080/"
        ) | %{l_rpmtool} msg -b -t notice
    fi

%preun
    if [ ".$1" = .0 ]; then
        #   remove AxKit cache files
        rm -rf $RPM_INSTALL_PREFIX/var/axkit/* 2>/dev/null || true
    fi

