Shawn Iwinski 2394a8
#
Shawn Iwinski f02e51
# Fedora spec file for php-masterminds-html5
Shawn Iwinski 2394a8
#
cc96d9
# Copyright (c) 2015-2019 Shawn Iwinski <shawn.iwinski@gmail.com>
Shawn Iwinski 2394a8
#
Shawn Iwinski 2394a8
# License: MIT
Shawn Iwinski 2394a8
# http://opensource.org/licenses/MIT
Shawn Iwinski 2394a8
#
Shawn Iwinski 2394a8
# Please preserve changelog entries
Shawn Iwinski 2394a8
#
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%global github_owner     Masterminds
Shawn Iwinski 2394a8
%global github_name      html5-php
4780c7
%global github_version   2.7.0
4780c7
%global github_commit    104443ad663d15981225f99532ba73c2f1d6b6f2
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%global composer_vendor  masterminds
Shawn Iwinski 2394a8
%global composer_project html5
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
# "php" : ">=5.3.0"
Shawn Iwinski 2394a8
%global php_min_ver 5.3.0
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
# Build using "--without tests" to disable tests
Shawn Iwinski f02e51
%global with_tests 0%{!?_without_tests:1}
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%{!?phpdir:  %global phpdir  %{_datadir}/php}
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Name:          php-%{composer_vendor}-%{composer_project}
Shawn Iwinski 2394a8
Version:       %{github_version}
4780c7
Release:       1%{?dist}
Shawn Iwinski 2394a8
Summary:       An HTML5 parser and serializer
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
License:       MIT
Shawn Iwinski 2394a8
URL:           http://masterminds.github.io/html5-php
Shawn Iwinski 2394a8
Source0:       https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
Shawn Iwinski 2394a8
4780c7
Patch0:        https://patch-diff.githubusercontent.com/raw/Masterminds/html5-php/pull/170.patch
4780c7
Shawn Iwinski 2394a8
BuildArch:     noarch
Shawn Iwinski 2394a8
# Autoload generation
Shawn Iwinski 2394a8
BuildRequires: %{_bindir}/phpab
Shawn Iwinski 2394a8
# Tests
Shawn Iwinski 2394a8
%if %{with_tests}
Shawn Iwinski 2394a8
## composer.json
Shawn Iwinski 2394a8
BuildRequires: php(language) >= %{php_min_ver}
cc96d9
BuildRequires: php-composer(phpunit/phpunit) >= 4.8.35
Shawn Iwinski 2394a8
BuildRequires: php-ctype
Shawn Iwinski 2394a8
BuildRequires: php-dom
4780c7
## phpcompatinfo (computed from version 2.7.0)
Shawn Iwinski 2394a8
BuildRequires: php-iconv
Shawn Iwinski 2394a8
BuildRequires: php-json
Shawn Iwinski 2394a8
BuildRequires: php-mbstring
Shawn Iwinski 2394a8
BuildRequires: php-pcre
Shawn Iwinski 2394a8
BuildRequires: php-reflection
Shawn Iwinski 2394a8
BuildRequires: php-spl
Shawn Iwinski 2394a8
%endif
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
# composer.json
Shawn Iwinski 2394a8
Requires:      php(language) >= %{php_min_ver}
Shawn Iwinski 2394a8
Requires:      php-ctype
Shawn Iwinski 2394a8
Requires:      php-dom
4780c7
# phpcompatinfo (computed from version 2.7.0)
Shawn Iwinski 2394a8
Requires:      php-iconv
Shawn Iwinski 2394a8
Requires:      php-mbstring
Shawn Iwinski 2394a8
Requires:      php-pcre
Shawn Iwinski 2394a8
Requires:      php-spl
4780c7
# notice: xml only detected for utf8_decode
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
# Composer
Shawn Iwinski 2394a8
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%description
Shawn Iwinski 2394a8
The need for an HTML5 parser in PHP is clear. This project initially began with
Shawn Iwinski 2394a8
the seemingly abandoned html5lib project original source. But after some initial
Shawn Iwinski 2394a8
refactoring work, we began a new parser.
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
* An HTML5 serializer
Shawn Iwinski 2394a8
* Support for PHP namespaces
Shawn Iwinski 2394a8
* Composer support
Shawn Iwinski 2394a8
* Event-based (SAX-like) parser
Shawn Iwinski 2394a8
* DOM tree builder
Shawn Iwinski 2394a8
* Interoperability with QueryPath
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%prep
Shawn Iwinski 2394a8
%setup -qn %{github_name}-%{github_commit}
4780c7
%patch0 -p1 -b .pr170
Shawn Iwinski 2394a8
0405be
: Docs
Shawn Iwinski 2394a8
mkdir -p docs/{Parser,Serializer}
Shawn Iwinski 2394a8
mv composer.json *.md docs/
Shawn Iwinski 2394a8
mv src/HTML5/Parser/*.md docs/Parser/
Shawn Iwinski 2394a8
mv src/HTML5/Serializer/*.md docs/Serializer/
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%build
Shawn Iwinski 2394a8
: Generate autoloader
Shawn Iwinski 2394a8
# Vendor-level autoloader to pick up "Masterminds/HTML5" class
Shawn Iwinski 2394a8
%{_bindir}/phpab --nolower --output src/autoload-html5.php src
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%install
Shawn Iwinski 2394a8
mkdir -p  %{buildroot}%{phpdir}/Masterminds
Shawn Iwinski 2394a8
cp -pr src/* %{buildroot}%{phpdir}/Masterminds/
Shawn Iwinski 2394a8
# Project-level autoloader for consistency with other pkgs
Shawn Iwinski 2394a8
ln -s ../autoload-html5.php %{buildroot}%{phpdir}/Masterminds/HTML5/autoload.php
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%check
Shawn Iwinski 2394a8
%if %{with_tests}
Shawn Iwinski 2394a8
: Generate test autoloader
Shawn Iwinski 2394a8
%{_bindir}/phpab --nolower --output test/autoload.php test
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
: Create mock Composer autoloader
Shawn Iwinski 2394a8
mkdir vendor
Shawn Iwinski 2394a8
cat > vendor/autoload.php <<'AUTOLOAD'
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
require '%{buildroot}%{phpdir}/Masterminds/HTML5/autoload.php';
Shawn Iwinski 2394a8
require __DIR__ . '/../test/autoload.php';
Shawn Iwinski 2394a8
AUTOLOAD
Shawn Iwinski 2394a8
ef0c94
: Upstream tests
ef0c94
RETURN_CODE=0
ef0c94
PHPUNIT=$(which phpunit)
4780c7
for PHP_EXEC in "" %{?rhel:php54 php55 php56 php70} php71 php72 php73 php74; do
ef0c94
    if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then
ef0c94
        $PHP_EXEC $PHPUNIT --verbose || RETURN_CODE=1
ef0c94
    fi
ef0c94
done
ef0c94
exit $RETURN_CODE
Shawn Iwinski 2394a8
%else
Shawn Iwinski 2394a8
: Tests skipped
Shawn Iwinski 2394a8
%endif
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%files
Shawn Iwinski 2394a8
%{!?_licensedir:%global license %%doc}
Shawn Iwinski 2394a8
%license LICENSE.txt
Shawn Iwinski 2394a8
%doc docs/*
Shawn Iwinski 2394a8
%{phpdir}/Masterminds
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
Shawn Iwinski 2394a8
%changelog
4780c7
* Fri Oct 11 2019 Remi Collet <remi@remirepo.net> - 2.7.0-1
4780c7
- update to 2.7.0
4780c7
- add patch for PHP 7.4 from
4780c7
  https://github.com/Masterminds/html5-php/pull/170
4780c7
c49569
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-2
c49569
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
c49569
cc96d9
* Sat May 25 2019 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.6.0-1
cc96d9
- Update to 2.6.0 (RHBZ #1687215)
cc96d9
7bf821
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-4
7bf821
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
7bf821
aa1d8f
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-3
aa1d8f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
aa1d8f
b25af9
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.0-2
b25af9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
b25af9
ef0c94
* Fri Sep 08 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.3.0-1
ef0c94
- Update to 2.3.0 (RHBZ #1488271)
ef0c94
- Test with SCLs if available
ef0c94
e9ea48
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-3
e9ea48
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
e9ea48
12ffb0
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.2-2
12ffb0
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
12ffb0
0405be
* Sun Sep 25 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.2.2-1
0405be
- Updated to 2.2.2 (RHBZ #1378444)
0405be
7e2318
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.2-2
7e2318
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
7e2318
Shawn Iwinski f02e51
* Sun Jun 28 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.1.2-1
Shawn Iwinski f02e51
- Updated to 2.1.2 (RHBZ #1229011)
Shawn Iwinski f02e51
b32db5
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.1-2
b32db5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
b32db5
Shawn Iwinski 2394a8
* Fri May 22 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.1.1-1
Shawn Iwinski 2394a8
- Initial package