##
##  yuicompressor.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:         yuicompressor
Summary:      JavaScript/CSS Compressor
URL:          http://developer.yahoo.com/yui/compressor/
Vendor:       Julien Lecomte, Isaac Schlueter
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      BSD
Version:      2.4.6
Release:      20110430

#   list of sources
Source0:      http://yuilibrary.com/downloads/yuicompressor/yuicompressor-%{version}.zip
Source1:      yuicompressor.sh
Patch0:       yuicompressor.patch

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

%description
    The YUI Compressor is a JavaScript and CSS minifier designed to be
    100% safe and yield a higher compression ratio than most other tools.

%track
    prog yuicompressor = {
        version   = %{version}
        url       = http://yuilibrary.com/downloads/
        regex     = yuicompressor-(__VER__)\.zip
    }

%prep
    %setup -q -T -c
    ( cd .. && unzip -q -x %{SOURCE0} ) || exit $?
    find . -name "*.orig" -print | xargs rm -f
    %patch -p0

%build
    ( cd src
      jar -x <../build/yuicompressor-%{version}.jar
      find . -name "*.orig" -print | xargs rm -f
      javac -Vsun-jdk -cp . org/mozilla/javascript/Token.java
      javac -Vsun-jdk -cp . org/mozilla/javascript/TokenStream.java
      javac -Vsun-jdk -cp . org/mozilla/javascript/Parser.java
      javac -Vsun-jdk -cp . org/mozilla/javascript/Decompiler.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/JavaScriptToken.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/ScriptOrFnScope.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/JavaScriptCompressor.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/CssCompressor.java
      javac -Vsun-jdk -cp . com/yahoo/platform/yui/compressor/YUICompressor.java
    ) || exit $?
    mv src/META-INF .
    jar -cfm build/yuicompressor-%{version}.jar META-INF/MANIFEST.MF -C src/ .

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yuicompressor \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat1
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE yuicompressor.sh} \
        $RPM_BUILD_ROOT%{l_prefix}/bin/yuicompressor
    %{l_shtool} install -c -m 644 \
        build/yuicompressor-%{version}.jar \
        $RPM_BUILD_ROOT%{l_prefix}/lib/yuicompressor/yuicompressor.jar
    %{l_shtool} install -c -m 644 \
        doc/README \
        $RPM_BUILD_ROOT%{l_prefix}/man/cat1/yuicompressor.1
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

