From 1ec4c2532d54db5322944465d7b37faa7d38a95f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 10 Oct 2016 15:58:07 +0200 Subject: php-patchwork-jsqueeze; 2.0.5 (backported from Fedora) --- composer.json | 27 +++++++++ php-patchwork-jsqueeze-get-source.sh | 71 ++++++++++++++++++++++ php-patchwork-jsqueeze.spec | 113 +++++++++++++++++++++++++++-------- 3 files changed, 185 insertions(+), 26 deletions(-) create mode 100644 composer.json create mode 100755 php-patchwork-jsqueeze-get-source.sh diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9c29860 --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "patchwork/jsqueeze", + "type": "library", + "description": "Efficient JavaScript minification in PHP", + "keywords": ["javascript","compression","minification"], + "homepage": "https://github.com/tchwork/jsqueeze", + "license": "(Apache-2.0 or GPL-2.0)", + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "Patchwork\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/php-patchwork-jsqueeze-get-source.sh b/php-patchwork-jsqueeze-get-source.sh new file mode 100755 index 0000000..4ad1051 --- /dev/null +++ b/php-patchwork-jsqueeze-get-source.sh @@ -0,0 +1,71 @@ +#/bin/sh + +GIT=`which git` +RPM=`which rpm` + +if [ -z "$GIT" ] +then + echo "ERROR: 'git' command not found" 1>&2 + exit 1 +elif [ -z "$RPM" ] +then + echo "ERROR: 'rpm' command not found" 1>&2 + exit 1 +fi + +function print { + echo -e "\e[0;33m>>>>> ${1}\e[0m" +} + +if [ -x "$1" ] +then + SPEC=$1 +else + SPEC=`ls *.spec | head -1` +fi + +NAME=`echo $SPEC | sed 's#\.spec##'` +VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'` + +print "SPEC = $SPEC" +print "NAME = $NAME" + +GIT_OWNER=`egrep '%global\s*github_owner' $SPEC | awk '{print $3}'` +GIT_NAME=`egrep '%global\s*github_name' $SPEC | awk '{print $3}'` +GIT_COMMIT=`egrep '%global\s*github_commit' $SPEC | awk '{print $3}'` +GIT_REPO=https://github.com/${GIT_OWNER}/${GIT_NAME} +GIT_DIR=`echo $GIT_REPO | sed 's#.*/##'` + +print "GIT_OWNER = $GIT_OWNER" +print "GIT_NAME = $GIT_NAME" +print "GIT_COMMIT = $GIT_COMMIT" +print "GIT_REPO = $GIT_REPO" +print "GIT_DIR = $GIT_DIR" + +TEMP_DIR=$(mktemp --dir) +TAR_FILE=$PWD/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz +CMP_FILE=$PWD/composer.json + +pushd $TEMP_DIR + print "Cloning git repo..." + $GIT clone $GIT_REPO + + pushd $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT + cp composer.json $CMP_FILE + popd + + TAR_DIR=${GIT_NAME}-${GIT_COMMIT} + print "TAR_DIR = $TAR_DIR" + + mv $GIT_DIR $TAR_DIR + + print "TAR_FILE = $TAR_FILE" + + [ -e $TAR_FILE ] && rm -f $TAR_FILE + tar --exclude-vcs -czf $TAR_FILE $TAR_DIR + chmod 0644 $TAR_FILE +popd + +rm -rf $TEMP_DIR diff --git a/php-patchwork-jsqueeze.spec b/php-patchwork-jsqueeze.spec index ce0b23e..2fb304f 100644 --- a/php-patchwork-jsqueeze.spec +++ b/php-patchwork-jsqueeze.spec @@ -1,15 +1,33 @@ -%global github_owner tchwork -%global github_name jsqueeze -%global github_version 2.0.3 -%global github_commit 074a7ac403d1fae262fd662c43c04b62d71c3e50 -%global packagist_owner patchwork -%global packagist_name jsqueeze -%global psr4_namespace Patchwork - -# phpci (uses namespacing) -%global php_min_ver 5.3.0 - -Name: php-%{packagist_owner}-%{packagist_name} +# remirepo spec file for php-patchwork-jsqueeze, from: +# +# Fedora spec file for php-patchwork-jsqueeze +# +# Copyright (c) 2016 Adam Williamson +# Shawn Iwinski +# +# License: MIT +# http://opensource.org/licenses/MIT +# +# Please preserve changelog entries +# + +%global github_owner tchwork +%global github_name jsqueeze +%global github_version 2.0.5 +%global github_commit 693d64850eab2ce6a7c8f7cf547e1ab46e69d542 + +%global composer_vendor patchwork +%global composer_project jsqueeze + +# "php": ">=5.3.0" +%global php_min_ver 5.3.0 + +# Build using "--without tests" to disable tests +%global with_tests 0%{!?_without_tests:1} + +%{!?phpdir: %global phpdir %{_datadir}/php} + +Name: php-%{composer_vendor}-%{composer_project} Version: %{github_version} Release: 1%{?dist} Summary: Efficient JavaScript minification @@ -17,24 +35,35 @@ Summary: Efficient JavaScript minification Group: Development/Libraries License: ASL 2.0 or GPLv2 URL: https://github.com/%{github_owner}/%{github_name} -# Must use commit-based not tag-based github tarball: -# https://fedoraproject.org/wiki/Packaging:SourceURL#Github -Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz + +# GitHub export does not include tests. +# Run php-patchwork-jsqueeze.sh to create full source. +Source0: %{name}-%{github_version}-%{github_commit}.tar.gz +Source1: %{name}-get-source.sh BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch -# For tests +# Autoloader +BuildRequires: %{_bindir}/phpab +# Tests +%if %{with_tests} +## composer.json BuildRequires: php(language) >= %{php_min_ver} -BuildRequires: %{_bindir}/phpunit +BuildRequires: php-composer(phpunit/phpunit) +## phpcompatinfo (computed from version 2.0.5) +BuildRequires: php-pcre +%endif Requires: php(language) >= %{php_min_ver} +# phpcompatinfo (computed from version 2.0.5) Requires: php-pcre -Provides: php-composer(%{packagist_owner}/%{packagist_name}) = %{version} +Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} %description JSqueeze shrinks / compresses / minifies / mangles Javascript code. + It's a single PHP class that is developed, maintained and thoroughly tested since 2003 on major JavaScript frameworks (e.g. jQuery). @@ -44,24 +73,49 @@ semi-colons are missing. In term of compression ratio, it compares to YUI Compressor and UglifyJS. +Autoloader: %{phpdir}/Patchwork/autoload-jsqueeze.php + %prep %setup -qn %{github_name}-%{github_commit} %build -# Empty build section, nothing required +: Generate autoloader +%{_bindir}/phpab --output src/autoload-jsqueeze.php src/ +cat src/autoload-jsqueeze.php %install rm -rf %{buildroot} -# use PSR-0 layout relative to _datadir/php -mkdir -p %{buildroot}%{_datadir}/php/%{psr4_namespace} -cp -pr src/* %{buildroot}%{_datadir}/php/%{psr4_namespace} + +mkdir -p %{buildroot}%{phpdir}/Patchwork +cp -pr src/* %{buildroot}%{phpdir}/Patchwork/ %check -%{_bindir}/phpunit +%if %{with_tests} +# remirepo:11 +run=0 +ret=0 +if which php56; then + php56 %{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Patchwork/autoload-jsqueeze.php + run=1 +fi +if which php71; then + php71 %{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Patchwork/autoload-jsqueeze.php + run=1 +fi +if [ $run -eq 0 ]; then +: Run upstream test suite +%{_bindir}/phpunit --verbose \ + --bootstrap %{buildroot}%{phpdir}/Patchwork/autoload-jsqueeze.php +# remirepo:2 +fi +exit $ret +%else +: Tests skipped +%endif %clean @@ -71,12 +125,19 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} -%license LICENSE.ASL20 LICENSE.GPLv2 -%doc README.md composer.json -%{_datadir}/php/%{psr4_namespace} +%license LICENSE.* +%doc *.md +%doc composer.json +%dir %{phpdir}/Patchwork + %{phpdir}/Patchwork/autoload-jsqueeze.php + %{phpdir}/Patchwork/JSqueeze.php %changelog +* Mon Oct 10 2016 Shawn Iwinski - 2.0.5-1 +- Update to 2.0.5 (RHBZ #1383300, #1383302) +- Add spec license + * Thu Oct 15 2015 Remi Collet - 2.0.2-2 - update to 2.0.3 -- cgit