Skip to content

Commit

Permalink
Add support for wikidiff2 (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Apr 30, 2024
1 parent 7413b1f commit 91038e2
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/special-requirements
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ simdjson !jessie !stretch
sodium !jessie
sqlsrv !7.1-alpine3.9 !7.1-alpine3.10 !arm
vips !alpine3.9 !jessie
wikidiff2 !jessie !stretch
1 change: 1 addition & 0 deletions data/supported-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ uv 8.0 8.1 8.2 8.3
vips 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
vld 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
wddx 5.5 5.6 7.0 7.1 7.2 7.3
wikidiff2 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
xdebug 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
xdiff 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
xhprof 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
Expand Down
90 changes: 89 additions & 1 deletion install-php-extensions
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,14 @@ buildRequiredPackageLists() {
wddx@debian)
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile libxml2-dev"
;;
wikidiff2@alpine)
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libstdc++"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile git"
;;
wikidiff2@debian)
buildRequiredPackageLists_persistent="$buildRequiredPackageLists_persistent libthai0"
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile git libthai-dev"
;;
xdebug@alpine)
if test $PHP_MAJMIN_VERSION -ge 800; then
buildRequiredPackageLists_volatile="$buildRequiredPackageLists_volatile linux-headers"
Expand Down Expand Up @@ -2232,6 +2240,59 @@ installLibMPDec() {
cd - >/dev/null
}

# Check if libdatrie is installed
#
# Return:
# 0 (true)
# 1 (false)
isLibDatrieInstalled() {
if ! test -f /usr/local/lib/libdatrie.so && ! test -f /usr/lib/libdatrie.so && ! test -f /usr/lib/x86_64*/libdatrie.so; then
return 1
fi
if ! test -f /usr/local/include/datrie/trie.h && ! test -f /usr/include/datrie/trie.h; then
return 1
fi
return 0
}

# Install libdatrie
installLibDatrie() {
printf 'Installing libdatrie\n'
installLibDatrie_src="$(getPackageSource https://github.com/tlwg/libdatrie/releases/download/v0.2.13/libdatrie-0.2.13.tar.xz)"
cd -- "$installLibDatrie_src"
./configure
make -j$(getProcessorCount)
make install
cd - >/dev/null
}

# Check if libdatrie is installed
#
# Return:
# 0 (true)
# 1 (false)
isLibThaiInstalled() {
return 1
if ! test -f /usr/local/lib/libthai.so && ! test -f /usr/lib/libthai.so && ! test -f /usr/lib/x86_64*/libthai.so; then
return 1
fi
if ! test -f /usr/local/include/thai/thailib.h && ! test -f /usr/include/thai/thailib.h; then
return 1
fi
return 0
}

# Install libdatrie
installLibThai() {
printf 'Installing libthai\n'
installLibThai_src="$(getPackageSource https://github.com/tlwg/libthai/releases/download/v0.1.29/libthai-0.1.29.tar.xz)"
cd -- "$installLibThai_src"
./configure
make -j$(getProcessorCount)
make install
cd - >/dev/null
}

# Install Composer
installComposer() {
installComposer_version="$(getWantedPHPModuleVersion @composer)"
Expand Down Expand Up @@ -4053,6 +4114,33 @@ installRemoteModule() {
fi
fi
;;
wikidiff2)
case "$DISTRO" in
alpine)
if ! isLibDatrieInstalled; then
installLibDatrie
fi
if ! isLibThaiInstalled; then
installLibThai
fi
;;
esac
if test -z "$installRemoteModule_version"; then
if test $PHP_MAJMIN_VERSION -le 702; then
installRemoteModule_version=1.13.0
else
installRemoteModule_version="$(git -c versionsort.suffix=- ls-remote --tags --refs --quiet --exit-code --sort=version:refname https://github.com/wikimedia/mediawiki-php-wikidiff2.git 'refs/tags/*.*.*' | tail -1 | cut -d/ -f3)"
fi
fi
installRemoteModule_src="$(getPackageSource "https://codeload.github.com/wikimedia/mediawiki-php-wikidiff2/tar.gz/refs/tags/$installRemoteModule_version")"
cd -- "$installRemoteModule_src"
phpize
./configure
make -j$(getProcessorCount)
make install
cd - >/dev/null
installRemoteModule_manuallyInstalled=1
;;
xdebug)
if test -z "$installRemoteModule_version"; then
if test $PHP_MAJMIN_VERSION -le 500; then
Expand Down Expand Up @@ -4507,7 +4595,7 @@ fixLetsEncrypt() {
invokeAptGetUpdate
fi
printf -- '- installing newer ca-certificates package\n'
DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends $IPE_APTGET_INSTALLOPTIONS ca-certificates
DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends ${IPE_APTGET_INSTALLOPTIONS:-} ca-certificates
fi
;;
*)
Expand Down
13 changes: 13 additions & 0 deletions scripts/tests/wikidiff2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php

require_once __DIR__ . '/_bootstrap.php';

$diff = wikidiff2_inline_json_diff("a\nb\nc", "a\nd\nc", 1);
$data = json_decode($diff, true);
if (!is_array($data)) {
fwrite(STDERR, "Unexpected result of wikidiff2_inline_json_diff():\n{$diff}\n");
exit(1);
}
echo "wikidiff2 works as expected\n";
exit(0);

0 comments on commit 91038e2

Please sign in to comment.