##
##  apacheflex.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:         apacheflex
Summary:      Apache Flex SDK
URL:          http://incubator.apache.org/flex/
Vendor:       Apache Software Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Flash
License:      Apache
Version:      4.16.1
Release:      20171123

#   list of sources
Source0:      http://www.us.apache.org/dist/flex/%{version}/binaries/apache-flex-sdk-%{version}-bin.tar.gz

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

%description
    This is the Adobe Flash/Flex SDK for developing Flash/Flex
    applications. It includes the Adobe ActionScript compiler and
    companion tools.

%track
    prog apacheflex = {
        version   = %{version}
        url       = http://flex.apache.org/download-binaries.html
        regex     = apache-flex-sdk-(4\.\d+\.\d+)-bin\.tar\.gz
    }

%prep
    %setup -q -n apache-flex-sdk-%{version}-bin

%build
    rm -f bin/*.exe bin/*.bat bin/*.config
    rm -f lib/*.txt
    perl -p -i.orig -e 's/\r\n/\n/sg;' bin/*
    rm -f bin/*.orig
    chmod a+rx bin/*

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/lib/apacheflex
    cp -r ant bin lib frameworks templates \
        $RPM_BUILD_ROOT%{l_prefix}/lib/apacheflex/
    find $RPM_BUILD_ROOT%{l_prefix}/lib/apacheflex -type f -print | xargs chmod a+r
    find $RPM_BUILD_ROOT%{l_prefix}/lib/apacheflex -type d -print | xargs chmod a+rx
    for prog in aasdoc acompc amxmlc asdoc compc copylocale digest fcsh fdb mxmlc optimizer; do
        ( echo "#!/bin/sh"
          echo "PATH=\"%{l_prefix}/bin:$PATH\"; export PATH"
          echo "FLEX_HOME=\"%{l_prefix}/lib/apacheflex\"; export FLEX_HOME"
          echo "exec %{l_prefix}/lib/apacheflex/bin/$prog \${1+\"\$@\"}"
        ) >$RPM_BUILD_ROOT%{l_prefix}/bin/$prog
        chmod a+x $RPM_BUILD_ROOT%{l_prefix}/bin/$prog
    done
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

