##
##  tla2tools.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 information
Name:         tla2tools
Summary:      TLA+2 Tools
URL:          http://research.microsoft.com/en-us/um/people/lamport/tla/tools.html
Vendor:       Leslie Lamport
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      MIT
Version:      20140313
Release:      20140427

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/tla/tla2tools-%{version}.jar

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

%description
    TLA stands for the Temporal Logic of Actions, but it has become a
    shorthand for referring to the TLA+ specification language and the
    PlusCal algorithm language, together with their associated tools.
    TLA+ is based on the idea that the best way to describe things
    formally is with simple mathematics, and that a specification
    language should contain as little as possible beyond what is needed
    to write simple mathematics precisely. TLA+ is especially well
    suited for writing high-level specifications of concurrent and
    distributed systems. PlusCal is an algorithm language that, at first
    glance, looks like a typical tiny toy programming language. However,
    a PlusCal expression can be any TLA+ expression, which means
    anything that can be expressed with mathematics. This makes PlusCal
    much more expressive than any (real or toy) programming language. A
    PlusCal algorithm is translated into a TLA+ specification, to which
    the TLA+ tools can be applied.

%track
    prog tla2tools = {
        version   = %{version}
        url       = http://code.google.com/p/tla2tools/downloads/list
        regex     = tla2tools-(__VER__)\.jar
    }

%prep
    %setup -q -T -c

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/lib/tla2tools
    for tool in tlc2.TLC:tlc tla2sany.SANY:sany pcal.trans:pluscal tla2tex.TLA:tlatex; do
        class=`echo $tool | sed -e 's;:.*$;;'`
        program=`echo $tool | sed -e 's;^.*:;;'`
        ( echo "#!/bin/sh"
          echo "exec %{l_prefix}/bin/java \\"
          echo "    -cp %{l_prefix}/lib/tla2tools/tla2tools.jar \\"
          echo "    $class \\"
          echo "    \${1+\"\$@\"}"
        ) >$program
        %{l_shtool} install -c -m 755 \
            $program $RPM_BUILD_ROOT%{l_prefix}/bin/
    done
    %{l_shtool} install -c -m 644 \
        %{SOURCE tla2tools-%{version}.jar} \
        $RPM_BUILD_ROOT%{l_prefix}/lib/tla2tools/tla2tools.jar
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

