diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6a3a77 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/*.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..1cb985d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# yuicompressor + +The yuicompressor package \ No newline at end of file diff --git a/dead.package b/dead.package deleted file mode 100644 index 0a0853d..0000000 --- a/dead.package +++ /dev/null @@ -1,3 +0,0 @@ -Retired due to missing dependency jargs -For minifying javascript use uglify-js instead -For minifying css use python3-rcssmin instead diff --git a/sources b/sources new file mode 100644 index 0000000..d8dbdab --- /dev/null +++ b/sources @@ -0,0 +1,2 @@ +SHA512 (yuicompressor-2.4.8.tar.gz) = cb955fc3677f930403f4f97aaad5d6ca5ec6ee834f464005ddfd8d83c4a532180859b72d55a4025b13f05a6a0146a1391d93668452e57035d4fc4f4d7f20d00b +SHA512 (yuicompressor-rhino1_7R2.tar.gz) = 9613b61a435fb12906b1317b7c244346cbc59991cf7d775e726accd68b83c172dee71175e55cf85e48c07585a2c25f0b6e423fc6cd20961b465060f6bf7fae29 diff --git a/yuicompressor-java-version.patch b/yuicompressor-java-version.patch new file mode 100644 index 0000000..b6a2e20 --- /dev/null +++ b/yuicompressor-java-version.patch @@ -0,0 +1,14 @@ +diff -ur yuicompressor-2.4.8.orig/build.xml yuicompressor-2.4.8/build.xml +--- yuicompressor-2.4.8.orig/build.xml 2020-05-06 00:06:12.442911120 +0200 ++++ yuicompressor-2.4.8/build.xml 2020-05-06 00:11:53.587321510 +0200 +@@ -33,8 +33,8 @@ + deprecation="off" + debug="on" + includeantruntime="false" +- target="1.5" +- source="1.5"> ++ target="1.6" ++ source="1.6"> + + + diff --git a/yuicompressor-remove-jars.patch b/yuicompressor-remove-jars.patch new file mode 100644 index 0000000..c0fbfd1 --- /dev/null +++ b/yuicompressor-remove-jars.patch @@ -0,0 +1,26 @@ +diff -ur yuicompressor-2.4.8.orig/build.xml yuicompressor-2.4.8/build.xml +--- yuicompressor-2.4.8.orig/build.xml 2013-05-15 09:23:58.000000000 +0200 ++++ yuicompressor-2.4.8/build.xml 2017-12-20 11:55:21.853626638 +0100 +@@ -36,20 +36,16 @@ + target="1.5" + source="1.5"> + +- +- ++ + + + + + + +- +- +- + + ++ + + + diff --git a/yuicompressor-rhino.patch b/yuicompressor-rhino.patch new file mode 100644 index 0000000..c5776d9 --- /dev/null +++ b/yuicompressor-rhino.patch @@ -0,0 +1,255 @@ +diff -ur yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Decompiler.java yuicompressor-2.4.8/src/org/mozilla/javascript/Decompiler.java +--- yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Decompiler.java 2009-03-22 14:32:26.000000000 +0100 ++++ yuicompressor-2.4.8/src/org/mozilla/javascript/Decompiler.java 2017-12-05 17:33:46.070639980 +0100 +@@ -166,6 +166,18 @@ + appendString('/' + regexp + '/' + flags); + } + ++ void addJScriptConditionalComment(String str) ++ { ++ addToken(Token.CONDCOMMENT); ++ appendString(str); ++ } ++ ++ void addPreservedComment(String str) ++ { ++ addToken(Token.KEEPCOMMENT); ++ appendString(str); ++ } ++ + void addNumber(double n) + { + addToken(Token.NUMBER); +diff -ur yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Parser.java yuicompressor-2.4.8/src/org/mozilla/javascript/Parser.java +--- yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Parser.java 2009-03-22 14:32:24.000000000 +0100 ++++ yuicompressor-2.4.8/src/org/mozilla/javascript/Parser.java 2017-12-05 17:33:46.071639969 +0100 +@@ -2465,6 +2465,16 @@ + reportError("msg.unexpected.eof"); + break; + ++ case Token.CONDCOMMENT: ++ String condComment = ts.getString(); ++ decompiler.addJScriptConditionalComment(condComment); ++ return nf.createString(condComment); ++ ++ case Token.KEEPCOMMENT: ++ String keepComment = ts.getString(); ++ decompiler.addPreservedComment(keepComment); ++ return nf.createString(keepComment); ++ + default: + reportError("msg.syntax"); + break; +diff -ur yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Token.java yuicompressor-2.4.8/src/org/mozilla/javascript/Token.java +--- yuicompressor-2.4.8.orig/src/org/mozilla/javascript/Token.java 2009-03-22 14:32:26.000000000 +0100 ++++ yuicompressor-2.4.8/src/org/mozilla/javascript/Token.java 2017-12-05 17:33:46.072639958 +0100 +@@ -258,7 +258,11 @@ + LETEXPR = 157, + WITHEXPR = 158, + DEBUGGER = 159, +- LAST_TOKEN = 159; ++ ++ CONDCOMMENT = 160, // JScript conditional comment ++ KEEPCOMMENT = 161, // /*! ... */ comment ++ ++ LAST_TOKEN = 161; + + public static String name(int token) + { +diff -ur yuicompressor-2.4.8.orig/src/org/mozilla/javascript/TokenStream.java yuicompressor-2.4.8/src/org/mozilla/javascript/TokenStream.java +--- yuicompressor-2.4.8.orig/src/org/mozilla/javascript/TokenStream.java 2009-03-22 14:32:26.000000000 +0100 ++++ yuicompressor-2.4.8/src/org/mozilla/javascript/TokenStream.java 2017-12-05 17:33:46.072639958 +0100 +@@ -526,7 +526,7 @@ + stringBufferTop = 0; + + c = getChar(); +- strLoop: while (c != quoteChar) { ++ while (c != quoteChar) { + if (c == '\n' || c == EOF_CHAR) { + ungetChar(c); + parser.addError("msg.unterminated.string.lit"); +@@ -535,89 +535,47 @@ + + if (c == '\\') { + // We've hit an escaped character +- int escapeVal; + + c = getChar(); ++ + switch (c) { +- case 'b': c = '\b'; break; +- case 'f': c = '\f'; break; +- case 'n': c = '\n'; break; +- case 'r': c = '\r'; break; +- case 't': c = '\t'; break; +- +- // \v a late addition to the ECMA spec, +- // it is not in Java, so use 0xb +- case 'v': c = 0xb; break; +- +- case 'u': +- // Get 4 hex digits; if the u escape is not +- // followed by 4 hex digits, use 'u' + the +- // literal character sequence that follows. +- int escapeStart = stringBufferTop; +- addToString('u'); +- escapeVal = 0; +- for (int i = 0; i != 4; ++i) { +- c = getChar(); +- escapeVal = Kit.xDigitToInt(c, escapeVal); +- if (escapeVal < 0) { +- continue strLoop; +- } ++ ++ case '\\': // backslash ++ case 'b': // backspace ++ case 'f': // form feed ++ case 'n': // line feed ++ case 'r': // carriage return ++ case 't': // horizontal tab ++ case 'v': // vertical tab ++ case 'd': // octal sequence ++ case 'u': // unicode sequence ++ case 'x': // hexadecimal sequence ++ // Only keep the '\' character for those ++ // characters that need to be escaped... ++ // Don't escape quoting characters... ++ addToString('\\'); + addToString(c); +- } +- // prepare for replace of stored 'u' sequence +- // by escape value +- stringBufferTop = escapeStart; +- c = escapeVal; +- break; +- case 'x': +- // Get 2 hex digits, defaulting to 'x'+literal +- // sequence, as above. +- c = getChar(); +- escapeVal = Kit.xDigitToInt(c, 0); +- if (escapeVal < 0) { +- addToString('x'); +- continue strLoop; +- } else { +- int c1 = c; +- c = getChar(); +- escapeVal = Kit.xDigitToInt(c, escapeVal); +- if (escapeVal < 0) { +- addToString('x'); +- addToString(c1); +- continue strLoop; +- } else { +- // got 2 hex digits +- c = escapeVal; +- } +- } +- break; ++ break; + +- case '\n': +- // Remove line terminator after escape to follow +- // SpiderMonkey and C/C++ +- c = getChar(); +- continue strLoop; +- +- default: +- if ('0' <= c && c < '8') { +- int val = c - '0'; +- c = getChar(); +- if ('0' <= c && c < '8') { +- val = 8 * val + c - '0'; +- c = getChar(); +- if ('0' <= c && c < '8' && val <= 037) { +- // c is 3rd char of octal sequence only +- // if the resulting val <= 0377 +- val = 8 * val + c - '0'; +- c = getChar(); +- } ++ case '\n': ++ // Remove line terminator after escape ++ break; ++ ++ default: ++ if (isDigit(c)) { ++ // Octal representation of a character. ++ // Preserve the escaping (see Y! bug #1637286) ++ addToString('\\'); + } +- ungetChar(c); +- c = val; +- } ++ addToString(c); ++ break; + } ++ ++ } else { ++ ++ addToString(c); + } +- addToString(c); ++ + c = getChar(); + } + +@@ -760,16 +718,35 @@ + } + if (matchChar('*')) { + boolean lookForSlash = false; ++ StringBuffer sb = new StringBuffer(); + for (;;) { + c = getChar(); + if (c == EOF_CHAR) { + parser.addError("msg.unterminated.comment"); + return Token.ERROR; +- } else if (c == '*') { ++ } ++ sb.append((char) c); ++ if (c == '*') { + lookForSlash = true; + } else if (c == '/') { + if (lookForSlash) { +- continue retry; ++ sb.delete(sb.length()-2, sb.length()); ++ String s1 = sb.toString(); ++ String s2 = s1.trim(); ++ if (s1.startsWith("!")) { ++ // Remove the leading '!' ++ this.string = s1.substring(1); ++ return Token.KEEPCOMMENT; ++ } else if (s2.startsWith("@cc_on") || ++ s2.startsWith("@if") || ++ s2.startsWith("@elif") || ++ s2.startsWith("@else") || ++ s2.startsWith("@end")) { ++ this.string = s1; ++ return Token.CONDCOMMENT; ++ } else { ++ continue retry; ++ } + } + } else { + lookForSlash = false; +@@ -876,9 +853,9 @@ + if (startToken != Token.DIV) Kit.codeBug(); + } + +- boolean inCharSet = false; // true if inside a '['..']' pair + int c; +- while ((c = getChar()) != '/' || inCharSet) { ++ boolean inClass = false; ++ while ((c = getChar()) != '/' || inClass) { + if (c == '\n' || c == EOF_CHAR) { + ungetChar(c); + throw parser.reportError("msg.unterminated.re.lit"); +@@ -887,9 +864,9 @@ + addToString(c); + c = getChar(); + } else if (c == '[') { +- inCharSet = true; ++ inClass = true; + } else if (c == ']') { +- inCharSet = false; ++ inClass = false; + } + addToString(c); + } diff --git a/yuicompressor-rhino.sh b/yuicompressor-rhino.sh new file mode 100755 index 0000000..3e09318 --- /dev/null +++ b/yuicompressor-rhino.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +rhino=rhino1_7R2 + +wget -N http://ftp.mozilla.org/pub/mozilla.org/js/${rhino}.zip +rm -rf ${rhino} +unzip ${rhino}.zip ${rhino}/src/org/mozilla/* ${rhino}/LICENSE.txt +( cd ${rhino} ; tar -z -c --group root --owner root -f ../yuicompressor-${rhino}.tar.gz src LICENSE.txt ) +rm ${rhino}.zip diff --git a/yuicompressor-tests.patch b/yuicompressor-tests.patch new file mode 100644 index 0000000..3a2b94f --- /dev/null +++ b/yuicompressor-tests.patch @@ -0,0 +1,49 @@ +diff -ur yuicompressor-2.4.8.orig/tests/suite.sh yuicompressor-2.4.8/tests/suite.sh +--- yuicompressor-2.4.8.orig/tests/suite.sh 2013-05-15 09:23:58.000000000 +0200 ++++ yuicompressor-2.4.8/tests/suite.sh 2017-12-07 03:45:47.374338608 +0100 +@@ -1,7 +1,7 @@ +-#!/usr/bin/env bash ++#!/bin/sh + + cd $(dirname $0) +- ++ + # Get the jar to use. + jar="$(ls ../build/*.jar | sort | tail -n1)" + echo "jar: $jar" +@@ -15,18 +15,11 @@ + filetype="$( + echo $testfile | egrep -o '(cs|j)s' + )" +- +- if [ "$2" == "cssminjs" ]; then +- actual="$( +- java -jar ../lib/rhino-1.7R2.jar suite.rhino $testfile +- )" +- +- else +- actual="$( +- java -jar $jar --type $filetype $testfile +- )" +- fi +- ++ ++ actual="$( ++ java -cp $(build-classpath jargs):$jar com.yahoo.platform.yui.compressor.Bootstrap --type $filetype $testfile ++ )" ++ + if [ "$expected" == "$actual" ]; then + echo "Passed: $testfile" > /dev/stderr + else +@@ -52,11 +45,3 @@ + ls *.{css,js} | while read testfile; do + runtest $testfile || exit 1 + done +- +-echo +-echo "now testing the JS port of CSSMIN..." +-ls *.css | while read testfile; do +- runtest $testfile "cssminjs" || exit 1 +-done +- +-exit 0 diff --git a/yuicompressor.1 b/yuicompressor.1 new file mode 100644 index 0000000..6bded98 --- /dev/null +++ b/yuicompressor.1 @@ -0,0 +1,51 @@ +.TH YUI-COMPRESSOR "1" "January 2010" "yui-compressor " "User Commands" +.SH NAME +yuicompressor \- JavaScript/CSS minifier +.SH SYNOPSIS +.B yuicompressor +\fR[\fIoptions\fR] [\fIinput file\fR] +.SH DESCRIPTION +Global Options +.TP +\fB\-h\fR, \fB\-\-help\fR +Displays this information +.TP +\fB\-\-type\fR +Specifies the type of the input file +.TP +\fB\-\-charset\fR +Read the input file using +.TP +\fB\-\-line\-break\fR +Insert a line break after the specified column number +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Display informational messages and warnings +.TP +\fB\-o\fR +Place the output into . Defaults to stdout. +.PP +JavaScript Options +.TP +\fB\-\-nomunge\fR +Minify only, do not obfuscate +.TP +\fB\-\-preserve\-semi\fR +Preserve all semicolons +.TP +\fB\-\-disable\-optimizations\fR +Disable all micro optimizations +.PP +If no input file is specified, it defaults to stdin. In this case, the 'type' +option is required. Otherwise, the 'type' option is required only if the input +file extension is neither 'js' nor 'css'. +.SH EXAMPLES +The following example demonstrates how to use yuicompressor +.TP +.B yuicompressor -o compressed.js original.js +.SH SEE ALSO +.BR /usr/share/doc/yuicompressor/README.md +.SH AUTHOR +This manual page was written by Damien Raude-Morvan +and Michael Gilbert , +for the Debian GNU/Linux system (but may be used by others). diff --git a/yuicompressor.pom b/yuicompressor.pom new file mode 100644 index 0000000..2838b0b --- /dev/null +++ b/yuicompressor.pom @@ -0,0 +1,63 @@ + + + + 4.0.0 + com.yahoo.platform.yui + yuicompressor + 2.4.8 + jar + + yui compressor + http://developer.yahoo.com/yui/compressor/ + + + The YUI Compressor is a JavaScript compressor which, in addition to removing + comments and white-spaces, obfuscates local variables using the smallest + possible variable name. This obfuscation is safe, even when using constructs + such as 'eval' or 'with' (although the compression is not optimal is those + cases) Compared to jsmin, the average savings is around 20%. + + + + + BSD License + http://developer.yahoo.com/yui/license.html + repo + + + + + + yui-compressor-forum + http://yuilibrary.com/forum/viewforum.php?f=94/ + + + + + scm:git:git://github.com/yui/yuicompressor.git + http://github.com/yui/yuicompressor + + + + + julienlecomte + Julien Lecomte + + + isaacs + Isaac Z. Schlueter + + + + + + net.sf + jargs + 1.0 + + + + diff --git a/yuicompressor.spec b/yuicompressor.spec new file mode 100644 index 0000000..5c53892 --- /dev/null +++ b/yuicompressor.spec @@ -0,0 +1,121 @@ +Name: yuicompressor +Version: 2.4.8 +Release: 10%{?dist} +Summary: YUI Compressor - The Yahoo JavaScript and CSS Compressor + +# Source 0 is BSD, Source 1 is MPLv1.1 or GPLv2+ +License: BSD and (MPLv1.1 or GPLv2+) +URL: https://yui.github.com/%{name}/ +Source0: https://github.com/yui/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz +# The yuicompressor uses the javascript parser from rhino. +# However, it calls private functions not exported by the +# rhino jar, so it can not use the jar provided by the +# distribution. The upstream source unjars a bundled copy of +# the rhino jar and builds using its precompiled class files. +# This violates the no precompiled sources guidelines. Only +# part of the rhino source tree is used by yuicompressor. The +# upstream sources also contains modified versions of a few +# of the rhino sources. These changes are restored by patch 0. +# Source 1 is a slimmed down version of the rhino sources of +# the same version that is bundled in the upstream sources. +# Source 2 is the script used to create Source 1. +Source1: %{name}-rhino1_7R2.tar.gz +Source2: %{name}-rhino.sh +# Man page - copied from Debian +Source3: %{name}.1 +# Pom file based on template from upstream: +# https://github.com/yui/yuicompressor/raw/master/maven_central/template/pom.xml.template +Source4: %{name}.pom +# This patch restores yuicompressor's changes to the rhino +# sources overwritten by Source 1 +Patch0: %{name}-rhino.patch +# Remove references to prebuilt jars in build.xml +Patch1: %{name}-remove-jars.patch +# Fix test script - only test yuicompressor, not rhino +Patch2: %{name}-tests.patch +# Update source and target for JDK 11 +Patch3: %{name}-java-version.patch + +BuildArch: noarch +BuildRequires: ant +BuildRequires: javapackages-local +BuildRequires: mvn(net.sf:jargs) +Provides: bundled(rhino) = 1.7R2 +# Explicit requires for javapackages-tools since yuicompressor script +# uses /usr/share/java-utils/java-functions +Requires: javapackages-tools + +%description +The YUI Compressor is a JavaScript compressor which, in addition to +removing comments and white-spaces, obfuscates local variables using +the smallest possible variable name. This obfuscation is safe, even +when using constructs such as 'eval' or 'with' (although the +compression is not optimal in those cases) Compared to jsmin, the +average savings is around 20%. + +The YUI Compressor is also able to safely compress CSS files. The +decision on which compressor is being used is made on the file +extension (js or css). + +%prep +%setup -q -a 1 +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +# Remove prebuilt jars +rm -rf lib/* +ln -s $(build-classpath jargs) lib + +%build +%ant + +%install +%mvn_artifact %{SOURCE4} build/%{name}-%{version}.jar +%mvn_install + +%jpackage_script com.yahoo.platform.yui.compressor.Bootstrap "" "" jargs:%{name} %{name} true + +mkdir -p %{buildroot}%{_mandir}/man1 +install -m 644 %{SOURCE3} %{buildroot}%{_mandir}/man1 + +%check +tests/suite.sh + +%files -f .mfiles +%{_bindir}/%{name} +%doc %{_mandir}/man1/%{name}.1* +%doc README.md doc/CHANGELOG +%license LICENSE.TXT LICENSE.txt + +%changelog +* Wed Jul 29 2020 Fedora Release Engineering - 2.4.8-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Sat Jul 11 2020 Jiri Vanek - 2.4.8-9 +- Rebuilt for JDK-11, see https://fedoraproject.org/wiki/Changes/Java11 + +* Tue May 05 2020 Mattias Ellert - 2.4.8-8 +- Update source and target for JDK 11 + +* Fri Jan 31 2020 Fedora Release Engineering - 2.4.8-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Sat Jul 27 2019 Fedora Release Engineering - 2.4.8-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sun Feb 03 2019 Fedora Release Engineering - 2.4.8-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Aug 31 2018 Severin Gehwolf - 2.4.8-4 +- Add explicit requirement on javapackages-tools since yuicompressor + script uses java-functions. See RHBZ#1600426. + +* Sat Jul 14 2018 Fedora Release Engineering - 2.4.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 2.4.8-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Tue Dec 05 2017 Mattias Ellert - 2.4.8-1 +- Initial packaging for Fedora