##
##  pegdown.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_pegdown_cli    0.1.3
%define       V_pegdown        1.2.1
%define       V_parboiled_core 1.1.4
%define       V_parboiled_java 1.1.4
%define       V_asm            5.2
%define       V_args4j         2.0.16

#   package information
Name:         pegdown
Summary:      PEG-Based Markdown Progressor
URL:          http://pegdown.org/
Vendor:       Mathias Doenitz
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Print
License:      Apache
Version:      %{V_pegdown}
Release:      20161223

#   list of sources
Source0:      http://cdn.bitbucket.org/ur6lad/pegdown-cli/downloads/pegdown-cli-%{V_pegdown_cli}.jar
Source1:      https://github.com/downloads/sirthias/pegdown/pegdown-%{V_pegdown}.jar
Source2:      https://github.com/downloads/sirthias/parboiled/parboiled-core-%{V_parboiled_core}.jar
Source3:      https://github.com/downloads/sirthias/parboiled/parboiled-java-%{V_parboiled_core}.jar
Source4:      http://download.forge.objectweb.org/asm/asm-%{V_asm}-bin.zip
Source5:      http://download.java.net/maven/2/args4j/args4j/%{V_args4j}/args4j-%{V_args4j}.jar
Source6:      pegdown.sh

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101, JAVA-JDK

%description
    Pegdown is a pure-Java Markdown processor based on a parboiled PEG
    parser -- clean, lightweight, easy to extend. Pegdown is nearly 100%
    compatible with the original Markdown specification and fully passes
    the original Markdown test suite. Pegdown-CLI is a command line
    interface to Pegdown.

%track
    prog pegdown:pegdown-cli = {
        version   = %{V_pegdown_cli}
        url       = http://code.pi.co.ua/pegdown-cli/downloads
        regex     = pegdown-cli-(__VER__)\.jar
    }
    prog pegdown:pegdown = {
        version   = %{V_pegdown}
        url       = https://github.com/sirthias/pegdown/downloads
        regex     = pegdown-(__VER__)\.jar
    }
    prog pegdown:parboiled-core = {
        version   = %{V_parboiled_core}
        url       = https://github.com/sirthias/parboiled/downloads
        regex     = parboiled-core-(__VER__)\.jar
    }
    prog pegdown:parboiled-java = {
        version   = %{V_parboiled_java}
        url       = https://github.com/sirthias/parboiled/downloads
        regex     = parboiled-java-(__VER__)\.jar
    }
    prog pegdown:asm = {
        version   = %{V_asm}
        url       = http://download.forge.objectweb.org/asm/
        regex     = asm-(\d+\.\d+)-bin\.zip
    }
    prog pegdown:args4j = {
        version   = %{V_args4j}
        url       = http://download.java.net/maven/2/args4j/args4j/
        regex     = (2\.0\.\d+)/
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 4

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE pegdown.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/pegdown
    %{l_shtool} install -c -m 644 \
        %{SOURCE0} $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/pegdown-cli.jar
    %{l_shtool} install -c -m 644 \
        %{SOURCE1} $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/pegdown.jar
    %{l_shtool} install -c -m 644 \
        %{SOURCE2} $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/parboiled-core.jar
    %{l_shtool} install -c -m 644 \
        %{SOURCE3} $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/parboiled-java.jar
    %{l_shtool} install -c -m 644 \
        asm-%{V_asm}/lib/all/asm-all-%{V_asm}.jar $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/asm-all.jar
    %{l_shtool} install -c -m 644 \
        %{SOURCE5} $RPM_BUILD_ROOT%{l_prefix}/lib/pegdown/args4j.jar
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

