blob: 73021d5df412f0517a17ba37e5098cff41c140a9 (
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
|
# remirepo spec file for php-wikimedia-wikidiff2
#
# SPDX-FileCopyrightText: Copyright 2026 Remi Collet
# SPDX-License-Identifier: CECILL-2.1
# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
#
# Please, preserve the changelog entries
#
%{?scl:%scl_package php-wikimedia-wikidiff2}
%bcond_without tests
%global gh_owner wikimedia
%global gh_project mediawiki-php-wikidiff2
%global ext_name wikidiff2
%global pie_vend %{gh_owner}
%global pie_proj %{ext_name}
%global ini_name 40-%{ext_name}.ini
%global forgeurl https://github.com/%{gh_owner}/%{gh_project}
%global tag %{version}
# for EL-8 to avoid TAG usage
%global archivename %{gh_project}-%{tag}
Name: %{?scl_prefix}php-%{pie_vend}-%{pie_proj}
Summary: Formats changes between two input texts
License: GPL-2.0-or-later
Version: 1.14.2
Release: 1%{?dist}
%forgemeta
URL: %{forgeurl}
Source0: %{forgesource}
# https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1
Patch0: 0001-Cleanups-in-config.m4.patch
# https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1
Patch1: 0001-display-configuration-in-phpinfo.patch
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc-c++
BuildRequires: %{?scl_prefix}php-devel >= 8.2
BuildRequires: pkgconfig(libthai) >= 0.1.25
Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api}
Requires: %{?scl_prefix}php(api) = %{php_core_api}
# Extension
Provides: %{?scl_prefix}php-%{ext_name} = %{version}
Provides: %{?scl_prefix}php-%{ext_name}%{?_isa} = %{version}
# PIE
Provides: %{?scl_prefix}php-pie(%{pie_vend}/%{pie_proj}) = %{version}
%description
Wikidiff2 is a PHP extension which formats changes between two input texts,
producing HTML or JSON.
It performs word-level diffs, including support for Thai word segmentation.
It can detect moved and split lines.
Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}.
%prep
%forgesetup
%patch -P0 -p1 -b .pr1
%patch -P1 -p1 -b .pr2
# Sanity check, really often broken
extver=$(sed -n '/#define WIKIDIFF2_VERSION_STRING/{s/.* "//;s/".*$//;p}' src/php_wikidiff2.cpp)
if test "x${extver}" != "x%{version}"; then
: Error: Upstream extension version is ${extver}, expecting %{version}.
exit 1
fi
# Drop in the bit of configuration
cat << 'EOF' | tee %{ini_name}
; Enable '%{ext_name}' extension module
extension = %{ext_name}
; Configuration
;wikidiff2.change_threshold = 0.2
;wikidiff2.moved_line_threshold = 0.4
;wikidiff2.moved_paragraph_detection_cutoff = 100
;wikidiff2.max_word_level_diff_complexity = 40000000
;wikidiff2.max_split_size = 1
;wikidiff2.initial_split_threshold = 0.1
;wikidiff2.final_split_threshold = 0.6
EOF
%build
%{?dtsenable}
%{__phpize}
sed -e 's/INSTALL_ROOT/DESTDIR/' -i build/Makefile.global
%configure \
--with-php-config=%{__phpconfig} \
--with-libdir=%{_lib} \
--enable-wikidiff2
%make_build
%install
%{?dtsenable}
# Install the NTS stuff
%make_install
install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name}
%check
: Minimal load test for NTS extension
%{__php} --no-php-ini \
--define extension=%{buildroot}%{php_extdir}/%{ext_name}.so \
--modules | grep '^%{ext_name}$'
%{__php} --no-php-ini \
--define extension=%{buildroot}%{php_extdir}/%{ext_name}.so \
--ri %{ext_name}
%if %{with tests}
: Upstream test suite for NTS extension
TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{ext_name}.so" \
%{__php} -n run-tests.php --show-diff %{?_smp_mflags}
%endif
%files
%license COPYING
%doc composer.json
%doc *.md
%config(noreplace) %{php_inidir}/%{ini_name}
%{php_extdir}/%{ext_name}.so
%changelog
* Fri Jun 12 2026 Remi Collet <remi@remirepo.net> - 1.14.2-1
- new package
- open https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/1 Cleanups in config.m4
- open https://github.com/wikimedia/mediawiki-php-wikidiff2/pull/2 display configuration
|