Add libxslt-reproducible.patch to make xml output deterministic (boo#1062303)

OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libxslt?expand=0&rev=105
This commit is contained in:
Pedro Monreal Gonzalez 2024-10-28 08:57:29 +00:00 committed by Git OBS Bridge
commit 0b66c025c3
12 changed files with 1801 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,27 @@
From 02a57a01c603462ce8cc65fc64076a107ccf758e Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Fri, 1 Dec 2023 21:05:19 +0100
Subject: [PATCH] tests: Fix build with older libxml2
Fixes #99.
---
tests/runtest.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/runtest.c b/tests/runtest.c
index ea08824..f61c66a 100644
--- a/tests/runtest.c
+++ b/tests/runtest.c
@@ -456,7 +456,8 @@ initializeLibxml2(void) {
xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
xmlSetGenericErrorFunc(NULL, testErrorHandler);
xsltSetGenericErrorFunc(NULL, testErrorHandler);
- xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
+ xmlSetStructuredErrorFunc(NULL,
+ (xmlStructuredErrorFunc) testStructuredErrorHandler);
exsltRegisterAll();
xsltRegisterTestModule();
xsltMaxDepth = 200;
--
2.45.1

7
baselibs.conf Normal file
View File

@ -0,0 +1,7 @@
libxslt1
obsoletes "libxslt-<targettype>"
libxslt-devel
requires -libxslt-<targettype>
requires "libxslt1-<targettype> = <version>"
obsoletes "libxslt-devel-<targettype> < <version>"
provides "libxslt-devel-<targettype> = <version>"

View File

@ -0,0 +1,11 @@
--- libxslt-1.1.39/tests/runtest.c.old 2023-11-16 12:36:28.000000000 +0000
+++ libxslt-1.1.39/tests/runtest.c 2024-05-05 16:25:22.656618600 +0000
@@ -269,7 +269,7 @@ xmlParserPrintFileContextInternal(xmlPar
}
static void
-testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, const xmlError *err) {
+testStructuredErrorHandler(void *ctx ATTRIBUTE_UNUSED, xmlError *err) {
char *file = NULL;
int line = 0;
int code = -1;

View File

@ -0,0 +1,11 @@
--- a/xsltproc/xsltproc.c
+++ b/xsltproc/xsltproc.c
@@ -544,7 +544,7 @@
sec = xsltNewSecurityPrefs();
xsltSetDefaultSecurityPrefs(sec);
- defaultEntityLoader = xmlGetExternalEntityLoader();
+ defaultEntityLoader = getenv("RPM_PACKAGE_NAME") ? xmlNoNetExternalEntityLoader : xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(xsltprocExternalEntityLoader);
for (i = 1; i < argc; i++) {

3
libxslt-1.1.39.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2a20ad621148339b0759c4d4e96719362dee64c9a096dbba625ba053846349f0
size 1578216

44
libxslt-random-seed.patch Normal file
View File

@ -0,0 +1,44 @@
commit 047a0fd99e64c554c4edf44cc67ee765b09af017
Author: Marcus Meissner <meissner@suse.de>
Date: Tue Apr 4 16:27:39 2017 +0200
initialize the random seed
Index: libxslt-v1.1.36/libexslt/math.c
===================================================================
--- libxslt-v1.1.36.orig/libexslt/math.c
+++ libxslt-v1.1.36/libexslt/math.c
@@ -12,6 +12,12 @@
#include <math.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <time.h>
+
#include "exslt.h"
/**
@@ -460,6 +468,20 @@ static double
exsltMathRandom (void) {
double ret;
int num;
+ long seed;
+ static int randinit = 0;
+
+ if (!randinit) {
+ int fd = open("/dev/urandom",O_RDONLY);
+
+ seed = time(NULL); /* just in case /dev/urandom is not there */
+ if (fd != -1) {
+ read (fd, &seed, sizeof(seed));
+ close (fd);
+ }
+ srand(seed);
+ randinit = 1;
+ }
num = rand();
ret = (double)num / (double)RAND_MAX;

View File

@ -0,0 +1,75 @@
https://gitlab.gnome.org/GNOME/libxslt/-/issues/123
From c45ed81aeb50a7fb6799a166270d6ccc9ffa63b2 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Thu, 19 Sep 2024 21:49:46 +0200
Subject: [PATCH] variables: Fix non-deterministic generated IDs
Evaluate global variables in deterministic order. Otherwise, generated
IDs could be non-deterministic if generate-id() is called.
Fixes #123.
---
libxslt/variables.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 93cb0747..09069aa3 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -1259,13 +1259,6 @@ error:
return(result);
}
-static void
-xsltEvalGlobalVariableWrapper(void *payload, void *data,
- const xmlChar *name ATTRIBUTE_UNUSED) {
- xsltEvalGlobalVariable((xsltStackElemPtr) payload,
- (xsltTransformContextPtr) data);
-}
-
/**
* xsltEvalGlobalVariables:
* @ctxt: the XSLT transformation context
@@ -1278,6 +1271,7 @@ xsltEvalGlobalVariableWrapper(void *payload, void *data,
int
xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
xsltStackElemPtr elem;
+ xsltStackElemPtr head = NULL;
xsltStylesheetPtr style;
if ((ctxt == NULL) || (ctxt->document == NULL))
@@ -1321,6 +1315,8 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
xsltFreeStackElem(def);
return(-1);
}
+ def->next = head;
+ head = def;
} else if ((elem->comp != NULL) &&
(elem->comp->type == XSLT_FUNC_VARIABLE)) {
/*
@@ -1343,9 +1339,19 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
}
/*
- * This part does the actual evaluation
+ * This part does the actual evaluation. Note that scanning the hash
+ * table would result in a non-deterministic order, leading to
+ * non-deterministic generated IDs.
*/
- xmlHashScan(ctxt->globalVars, xsltEvalGlobalVariableWrapper, ctxt);
+ elem = head;
+ while (elem != NULL) {
+ xsltStackElemPtr next;
+
+ xsltEvalGlobalVariable(elem, ctxt);
+ next = elem->next;
+ elem->next = NULL;
+ elem = next;
+ }
return(0);
}
--
GitLab

1363
libxslt.changes Normal file

File diff suppressed because it is too large Load Diff

189
libxslt.spec Normal file
View File

@ -0,0 +1,189 @@
#
# spec file for package libxslt
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define libver 1
%define libexver 0
Name: libxslt
Version: 1.1.39
Release: 0
Summary: XSL Transformation Library
License: GPL-2.0-or-later AND MIT
Group: Development/Libraries/C and C++
URL: https://gitlab.gnome.org/GNOME/libxslt
Source0: https://download.gnome.org/sources/%{name}/1.1/%{name}-%{version}.tar.xz
Source1: baselibs.conf
Source2: xslt-config.1
# PATCH-FIX-OPENSUSE -- libxslt-1.1.24-no-net-autobuild.patch
# The xmlGetExternalEntityLoader() tries to fetch/parse some information via
# internet, which OBS's build environment does not allow it.
Patch0: libxslt-1.1.24-no-net-autobuild.patch
# PATCH-FIX-UPSTREAM -- libxslt-random-seed.patch
# https://bugzilla.suse.com/show_bug.cgi?id=934119
# https://bugzilla.gnome.org/show_bug.cgi?id=758400
# Initialize the random seed to ensure libxslt's math.random() function
# produces unpredictable outputs.
Patch1: libxslt-random-seed.patch
# PATCH-FIX_UPSTREAM -- gcc14-runtest-no-const.patch
Patch2: gcc14-runtest-no-const.patch
# PATCH-FIX-UPSTREAM -- 0001-tests-Fix-build-with-older-libxml2.patch
Patch3: 0001-tests-Fix-build-with-older-libxml2.patch
Patch4: libxslt-reproducible.patch
#
### SUSE patches starts on 1000
# PATCH-FIX-SUSE
#Patch1000:
#
BuildRequires: fdupes
BuildRequires: gcc
BuildRequires: libgcrypt-devel
BuildRequires: pkgconfig
BuildRequires: pkgconfig(libxml-2.0) >= 2.9.12
Obsoletes: libxslt-python
%description
This C library allows you to transform XML files into other XML files
(or HTML, text, and more) using the standard XSLT stylesheet
transformation mechanism.
It is based on libxml (version 2) for XML parsing, tree manipulation,
and XPath support. It is written in plain C, making as few assumptions
as possible and sticks closely to ANSI C/POSIX for easy embedding.
It includes support for the EXSLT set of extension functions as well
as some common extensions present in other XSLT engines.
%package -n libxslt%{libver}
Summary: XSL Transformation Library
License: LGPL-2.1-or-later
Group: System/Libraries
%description -n libxslt%{libver}
This C library allows you to transform XML files into other XML files
(or HTML, text, and more) using the standard XSLT stylesheet
transformation mechanism.
It is based on libxml (version 2) for XML parsing, tree manipulation,
and XPath support. It is written in plain C, making as few assumptions
as possible and sticks closely to ANSI C/POSIX for easy embedding.
It includes support for the EXSLT set of extension functions as well
as some common extensions present in other XSLT engines.
%package -n libexslt%{libexver}
Summary: EXSLT Library
License: LGPL-2.1-or-later
Group: System/Libraries
%description -n libexslt%{libexver}
This is the EXSLT C library developed for libxslt.
EXSLT is a community initiative to provide extensions to XSLT.
%package devel
Summary: Development files for libxslt
License: LGPL-2.1-or-later
Group: Development/Libraries/C and C++
Requires: %{name}-tools = %{version}
Requires: glibc-devel
Requires: libexslt%{libexver} = %{version}
Requires: libgcrypt-devel
Requires: libxslt%{libver} = %{version}
%description devel
libxslt allows you to transform XML files into other XML files
(or HTML, text, and more) using the standard XSLT stylesheet
transformation mechanism.
This subpackage contains the header files for developing
applications that want to make use of the XSLT libraries.
%package tools
Summary: Extended Stylesheet Language (XSL) Transformation utilities
License: GPL-2.0-or-later AND MIT
Group: Development/Tools/Other
Provides: %{name} = %{version}
Provides: xsltproc = %{version}
%description tools
This package contains xsltproc, a command line interface to the XSLT engine.
xtend the
%prep
%autosetup -p1
%build
%configure \
--disable-static \
--without-python \
--disable-silent-rules
%make_build
%check
%make_build check
%install
%make_install
# Unwanted doc stuff
rm -fr %{buildroot}%{_datadir}/doc
# Install the manual page for xslt-config
install -D -m0644 %{SOURCE2} %{buildroot}%{_mandir}/man1/xslt-config.1
#kill all "la" files
find %{buildroot} -type f -name "*.la" -delete -print
# Hardlink same-content files
%fdupes %{buildroot}%{_datadir}
%ldconfig_scriptlets -n libxslt%{libver}
%ldconfig_scriptlets -n libexslt%{libexver}
%files -n libxslt%{libver}
%license COPYING* Copyright
%{_libdir}/libxslt.so.%{libver}*
%files -n libexslt%{libexver}
%license COPYING* Copyright
%{_libdir}/libexslt.so.%{libexver}*
%files tools
%license COPYING* Copyright
%doc AUTHORS NEWS TODO FEATURES
%{_bindir}/xsltproc
%{_mandir}/man1/xsltproc.1%{?ext_man}
%files devel
%license COPYING* Copyright
%{_libdir}/libxslt.so
%{_libdir}/libexslt.so
%{_libdir}/*.sh
%{_libdir}/pkgconfig/libxslt.pc
%{_libdir}/pkgconfig/libexslt.pc
%dir %{_libdir}/cmake/libxslt/
%{_libdir}/cmake/libxslt/FindGcrypt.cmake
%{_libdir}/cmake/libxslt/libxslt-config.cmake
%{_includedir}/*
%{_datadir}/aclocal/*
%{_bindir}/xslt-config
%{_mandir}/man1/xslt-config.1%{?ext_man}
%{_mandir}/man3/*
%dir %{_datadir}/gtk-doc/
%dir %{_datadir}/gtk-doc/html/
%{_datadir}/gtk-doc/html/libexslt/
%{_datadir}/gtk-doc/html/libxslt/
%doc doc/*.html doc/tutorial doc/tutorial2
%changelog

47
xslt-config.1 Normal file
View File

@ -0,0 +1,47 @@
.mso www.tmac
.TH XSLT-CONFIG 1 2011-06-24 GNOME "The XSLT C library for GNOME"
.SH NAME
xslt-config \- provides compilation or linking flags for programs using libxslt
.SH SYNOPSIS
.B xslt-config --cflags
.br
.B xslt-config --libs
.SH DESCRIPTION
.B xslt-config
is a small shell script which is installed as part of
.B libxslt
usual install process which provides compilation or linking flags for programs using it.
Use
.IP
.B xslt-config --cflags
.PP
to get the compilation flags and
.IP
.B xslt-config --libs
.PP
to get the linker flags. Usually this is done directly from the Makefile as:
.IP
.B CFLAGS=`xslt-config --cflags`
.br
.B LIBS=`xslt-config --libs`
.SH NOTES
If you use the
.SM EXSLT
extensions from the program then you should prepend
.B -lexslt
to the
.B LIBS
options
.SH SEE ALSO
.URL http://xmlsoft.org/XSLT/ "The XSLT C library for GNOME"