summaryrefslogtreecommitdiffstats
path: root/php-zetacomponents-document.spec
blob: 4490c170da504002baa9138d92771af7bc193a78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# remirepo spec file for php-zetacomponents-document
#
# Fedora spec file for php-zetacomponents-document
#
# Copyright (c) 2017-2022 Shawn Iwinski <shawn@iwin.ski>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     zetacomponents
%global github_name      Document
%global github_version   1.3.3
%global github_commit    196884f00871ea7dcbca9ab8bc85716f626e9cc3

%global composer_vendor  zetacomponents
%global composer_project document

# "zetacomponents/base": "~1.8"
#     NOTE: Min and max versions added to contain to one major version.
%global zetacomponents_base_min_ver 1.8
%global zetacomponents_base_max_ver 2.0
# "zetacomponents/unit-test": "dev-master"
#     NOTE: Min and max versions added to contain to one major version.
%global zetacomponents_unit_test_min_ver 1.0
%global zetacomponents_unit_test_max_ver 2.0

# Build using "--with tests" to enable tests
%bcond_with tests

%global  ezcdir  %{_datadir}/php/ezc

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       1%{?github_release}%{?dist}
Summary:       Provides a general conversion framework for different documents

Group:         Development/Libraries
License:       ASL 2.0
URL:           http://zetacomponents.org/
Source0:       https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz

BuildArch:     noarch
# Autoloader
BuildRequires: php-fedora-autoloader-devel
# Tests
%if %{with tests}
## composer.json
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(zetacomponents/base) >= %{zetacomponents_base_min_ver} with php-composer(zetacomponents/base) < %{zetacomponents_base_max_ver})
BuildRequires: (php-composer(zetacomponents/unit-test) >= %{zetacomponents_unit_test_min_ver} with php-composer(zetacomponents/unit-test) < %{zetacomponents_unit_test_max_ver})
%else
BuildRequires: php-composer(zetacomponents/base) <  %{zetacomponents_base_max_ver}
BuildRequires: php-composer(zetacomponents/base) >= %{zetacomponents_base_min_ver}
BuildRequires: php-composer(zetacomponents/unit-test) <  %{zetacomponents_unit_test_max_ver}
BuildRequires: php-composer(zetacomponents/unit-test) >= %{zetacomponents_unit_test_min_ver}
%endif
## phpcompatinfo (computed from version 1.3.1)
BuildRequires: php(language) >= 5.3.0
BuildRequires: phpunit8
BuildRequires: php-ctype
BuildRequires: php-date
BuildRequires: php-dom
BuildRequires: php-iconv
BuildRequires: php-libxml
BuildRequires: php-pcre
BuildRequires: php-spl
BuildRequires: php-xsl
%endif

# composer.json
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(zetacomponents/base) >= %{zetacomponents_base_min_ver} with php-composer(zetacomponents/base) < %{zetacomponents_base_max_ver})
%else
Requires:      php-composer(zetacomponents/base) <  %{zetacomponents_base_max_ver}
Requires:      php-composer(zetacomponents/base) >= %{zetacomponents_base_min_ver}
%endif
# phpcompatinfo (computed from version 1.3.1)
Requires:      php(language) >= 5.3.0
Requires:      php-ctype
Requires:      php-date
Requires:      php-dom
Requires:      php-iconv
Requires:      php-libxml
Requires:      php-pcre
Requires:      php-spl
Requires:      php-xsl
# Autoloader
Requires:      php-composer(fedora/autoloader)

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
The document component offers transformations between different semantic markup
languages, like:
* ReStructured text [1]
* XHTML [2]
* Docbook [3]
* eZ Publish XML markup [4]
* Wiki markup languages, like: Creole [5], Dokuwiki [6] and Confluence [7]
* Open Document Text [8] as used by OpenOffice.org [9] and other office suites

Each format supports conversions from and to docbook as a central intermediate
format and may implement additional shortcuts for conversions from and to other
formats. Not each format can express the same semantics, so there may be some
information lost.

Autoloader: %{ezcdir}/Document/autoload.php

[1] http://docutils.sourceforge.net/rst.html
[2] http://www.w3.org/TR/xhtml1/
[3] http://www.docbook.org/
[4] http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/XML-tags
[5] http://www.wikicreole.org/
[6] http://www.dokuwiki.org/dokuwiki
[7] http://confluence.atlassian.com/renderer/notationhelp.action?section=all
[8] http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office
[9] http://www.openoffice.org/


%prep
%setup -qn %{github_name}-%{github_commit}


%build
: Create autoloader
%{_bindir}/phpab \
   --output src/autoload.php \
   src
cat <<AUTOLOAD | tee -a  src/autoload.php

\Fedora\Autoloader\Dependencies::required(array(
    '%{ezcdir}/Base/autoloader.php',
));
AUTOLOAD

: Compat autoloader filename with other php-zetacomponents-* packages
ln -s autoload.php src/autoloader.php


%install
mkdir -p %{buildroot}%{ezcdir}/autoload

: Library
cp -pr src %{buildroot}%{ezcdir}/Document

: ezcBase autoloader
cp -pr src/*_autoload.php \
       %{buildroot}%{ezcdir}/autoload/


%check
%if %{with tests}
: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
require_once '%{ezcdir}/UnitTest/autoloader.php';
require_once '%{buildroot}%{ezcdir}/Document/autoload.php';
BOOTSTRAP

: Skip tests requiring network access
sed -e 's/function testConversionFailure/function SKIP_testConversionFailure/' \
    -e 's/function testLoadXmlDocumentFromFile/function SKIP_testLoadXmlDocumentFromFile/' \
    -i tests/converter_docbook_html_xsl_test.php

: Skip tests known to fail
rm -f tests/pdf/table_column_width_test.php
sed -e 's/function testCreateFromDocbook/function SKIP_testCreateFromDocbook/' \
    -e 's/function testCommonConversions/function SKIP_testCommonConversions/' \
    -i tests/document_odt_docbook_test.php
sed -i 's/function testParseRstFile/function SKIP_testParseRstFile/' \
    tests/document_rst_parser_test.php \
    tests/document_rst_visitor_docbook_test.php \
    tests/document_rst_visitor_xhtml_test.php
sed 's/function testLoadXmlDocumentFromFile/function SKIP_testLoadXmlDocumentFromFile/' \
    -i tests/converter_docbook_rst_test.php

: Upstream tests
RETURN_CODE=0
PHPUNIT=$(which phpunit8)
for PHP_EXEC in php php74 php80 php81; do
    if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then
        $PHP_EXEC $PHPUNIT --verbose --bootstrap bootstrap.php || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE.txt
%doc *.rst
%doc ChangeLog
%doc composer.json
%{ezcdir}/autoload/document_autoload.php
%{ezcdir}/Document


%changelog
* Tue Feb 15 2022 Remi Collet <remi@remirepo.net> - 1.3.3-1
- update to 1.3.3

* Mon May 28 2018 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.3.1-3
- Fix FTBS (RHBZ #1556121)
- Disable tests by default for F28+ and RHEL 8+
- Add range version dependencies for Fedora >= 27 || RHEL >= 8

* Sun Jun 04 2017 Shawn Iwinski <shawn@iwin.ski> - 1.3.1-1
- Initial package