diff options
Diffstat (limited to 'php-wikimedia-wikidiff2.spec')
| -rw-r--r-- | php-wikimedia-wikidiff2.spec | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/php-wikimedia-wikidiff2.spec b/php-wikimedia-wikidiff2.spec new file mode 100644 index 0000000..73021d5 --- /dev/null +++ b/php-wikimedia-wikidiff2.spec @@ -0,0 +1,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 |
