summaryrefslogtreecommitdiffstats
path: root/php-zetacomponents-document.spec
blob: ee97e829018d7daff9cb462a20c5490a1cae83e4 (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
#
# Fedora spec file for php-zetacomponents-document
#
# Copyright (c) 2017 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.1
%global github_commit    688abfde573cf3fe0730f82538fbd7aa9fc95bc8

%global composer_vendor  zetacomponents
%global composer_project document

# "zetacomponents/base": "*"
#     NOTE: Min and max versions added to contain to one major version.
%global zetacomponents_base_min_ver 1.0
%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 "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}

%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
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}
## phpcompatinfo (computed from version 1.3.1)
BuildRequires: php(language) >= 5.3.0
BuildRequires: php-composer(phpunit/phpunit)
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
Requires:      php-composer(zetacomponents/base) <  %{zetacomponents_base_max_ver}
Requires:      php-composer(zetacomponents/base) >= %{zetacomponents_base_min_ver}
# 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 phpunit)
for PHP_EXEC in "" %{?rhel:php54 php55} php56 php70 php71 php72; 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 NOTICE
%doc *.rst
%doc ChangeLog
%doc composer.json
%{ezcdir}/autoload/document_autoload.php
%{ezcdir}/Document


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