From a04ac1195c4d2ad19bedc9112b86426d759410a6 Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Fri, 22 Mar 2024 13:58:37 +0100 Subject: [PATCH] Resolves: RHEL-25977 - Fix failing build and tests --- .fmf/version | 1 + gating.yaml | 7 ++ ...compatible-pointer-type-for-old_warn.patch | 46 +++++++ ...t-pointer-confusion-in-Tcl_GetByteAr.patch | 45 +++++++ perl-Tk-Fix-build-with-clang-16.patch | 12 ++ ...ointer-type-in-function-GetTextIndex.patch | 12 ++ ...void-using-incompatible-pointer-type.patch | 24 ++++ perl-Tk.spec | 114 ++++++++++++++---- plans/sanity.fmf | 5 + tests/upstream-tests.fmf | 16 +++ 10 files changed, 256 insertions(+), 26 deletions(-) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 perl-Tk-Avoid-using-incompatible-pointer-type-for-old_warn.patch create mode 100644 perl-Tk-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch create mode 100644 perl-Tk-Fix-build-with-clang-16.patch create mode 100644 perl-Tk-Fix-incompatible-pointer-type-in-function-GetTextIndex.patch create mode 100644 perl-Tk-pregcomp2.c-Avoid-using-incompatible-pointer-type.patch create mode 100644 plans/sanity.fmf create mode 100644 tests/upstream-tests.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..b9d19a4 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - rhel-* +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/perl-Tk-Avoid-using-incompatible-pointer-type-for-old_warn.patch b/perl-Tk-Avoid-using-incompatible-pointer-type-for-old_warn.patch new file mode 100644 index 0000000..b678f3a --- /dev/null +++ b/perl-Tk-Avoid-using-incompatible-pointer-type-for-old_warn.patch @@ -0,0 +1,46 @@ +From c4cd966ed0997e2acb1fdcaf112c55a78ed50847 Mon Sep 17 00:00:00 2001 +From: Christopher Chavez +Date: Mon, 19 Feb 2024 14:18:43 -0600 +Subject: [PATCH] Avoid using incompatible pointer type for `old_warn` + +See https://github.com/eserte/perl-tk/issues/98#issuecomment-1944054296 +--- + Event/Event.xs | 2 +- + tkGlue.c | 7 +------ + 2 files changed, 2 insertions(+), 7 deletions(-) + +diff --git a/Event/Event.xs b/Event/Event.xs +index 82bbb244..f2c95234 100644 +--- a/Event/Event.xs ++++ b/Event/Event.xs +@@ -1532,7 +1532,7 @@ PROTOTYPES: DISABLE + BOOT: + { + #ifdef pWARN_NONE +- SV *old_warn = PL_curcop->cop_warnings; ++ void *old_warn = PL_curcop->cop_warnings; + PL_curcop->cop_warnings = pWARN_NONE; + #endif + newXS("Tk::Event::INIT", XS_Tk__Event_INIT, file); +diff --git a/tkGlue.c b/tkGlue.c +index 68a7e0fa..ca4a13aa 100644 +--- a/tkGlue.c ++++ b/tkGlue.c +@@ -5543,13 +5543,8 @@ _((pTHX)) + char *XEventMethods = "abcdfhkmopstvwxyABDEKNRSTWXY#"; + char buf[128]; + CV *cv; +-#if PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 9) +-#define COP_WARNINGS_TYPE STRLEN* +-#else +-#define COP_WARNINGS_TYPE SV* +-#endif + #ifdef pWARN_NONE +- COP_WARNINGS_TYPE old_warn = PL_curcop->cop_warnings; ++ void *old_warn = PL_curcop->cop_warnings; + PL_curcop->cop_warnings = pWARN_NONE; + #endif + +-- +2.43.0 + diff --git a/perl-Tk-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch b/perl-Tk-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch new file mode 100644 index 0000000..1935073 --- /dev/null +++ b/perl-Tk-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch @@ -0,0 +1,45 @@ +From a26233c844c52f49ef9cca5f88dd9063aac60d0f Mon Sep 17 00:00:00 2001 +From: Niko Tyni +Date: Thu, 11 Jan 2024 18:28:58 +0000 +Subject: [PATCH] Fix STRLEN vs int pointer confusion in + Tcl_GetByteArrayFromObj() + +Perl 5.37.2, more precisely commit + + https://github.com/Perl/perl5/commit/1ef9039bccbfe64f47f201b6cfb7d6d23e0b08a7 + +changed the implementation of SvPV() et al., breaking t/balloon.t, +t/canvas2.t and t/photo.t on big-endian 64-bit architectures such as +ppc64 and s390x because StringMatchGIF() no longer recognized GIF files. + +This is because Tcl_GetByteArrayFromObj() was calling SvPV() with an int +pointer instead of a correct STRLEN pointer, and the new implementation +is more sensitive to this: it assigns the pointers as-is, resulting in +the int pointer pointing at the wrong end of the 64-bit length. + +Other functions taking a length pointer, at least Tcl_GetStringFromObj() +already seem to do things correctly, so presumably this is not a +systematic issue. +--- + objGlue.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/objGlue.c b/objGlue.c +index d4927ea..dbd6a50 100644 +--- a/objGlue.c ++++ b/objGlue.c +@@ -627,7 +627,10 @@ Tcl_GetByteArrayFromObj(Tcl_Obj * objPtr, int * lengthPtr) + sv_utf8_downgrade(objPtr, 0); + if (lengthPtr) + { +- return (unsigned char *) SvPV(objPtr, *lengthPtr); ++ STRLEN len; ++ unsigned char *s = SvPV(objPtr, len); ++ *lengthPtr = len; ++ return s; + } + else + { +-- +2.30.2 + diff --git a/perl-Tk-Fix-build-with-clang-16.patch b/perl-Tk-Fix-build-with-clang-16.patch new file mode 100644 index 0000000..4c4a8cd --- /dev/null +++ b/perl-Tk-Fix-build-with-clang-16.patch @@ -0,0 +1,12 @@ +diff -up Tk-804.036/pTk/Xlib.t.orig Tk-804.036/pTk/Xlib.t +--- Tk-804.036/pTk/Xlib.t.orig 2024-02-15 10:07:51.542657507 +0100 ++++ Tk-804.036/pTk/Xlib.t 2024-02-15 10:08:51.500167194 +0100 +@@ -331,7 +331,7 @@ VFUNC(int,XIntersectRegion,V_XIntersectR + #endif /* !DO_X_EXCLUDE */ + + #ifndef XKeycodeToKeysym +-VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, unsigned int, int))) ++VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, KeyCode, int))) + #endif /* #ifndef XKeycodeToKeysym */ + + #ifndef XKeysymToString diff --git a/perl-Tk-Fix-incompatible-pointer-type-in-function-GetTextIndex.patch b/perl-Tk-Fix-incompatible-pointer-type-in-function-GetTextIndex.patch new file mode 100644 index 0000000..633d530 --- /dev/null +++ b/perl-Tk-Fix-incompatible-pointer-type-in-function-GetTextIndex.patch @@ -0,0 +1,12 @@ +diff -up Tk-804.036/pTk/mTk/generic/tkCanvText.c.orig Tk-804.036/pTk/mTk/generic/tkCanvText.c +--- Tk-804.036/pTk/mTk/generic/tkCanvText.c.orig 2024-02-16 13:50:00.966946199 +0100 ++++ Tk-804.036/pTk/mTk/generic/tkCanvText.c 2024-02-16 13:50:26.060152547 +0100 +@@ -1234,7 +1234,7 @@ GetTextIndex(interp, canvas, itemPtr, ob + * index. */ + { + TextItem *textPtr = (TextItem *) itemPtr; +- size_t length; ++ int length; + int c; + TkCanvas *canvasPtr = (TkCanvas *) canvas; + Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; diff --git a/perl-Tk-pregcomp2.c-Avoid-using-incompatible-pointer-type.patch b/perl-Tk-pregcomp2.c-Avoid-using-incompatible-pointer-type.patch new file mode 100644 index 0000000..9a493ea --- /dev/null +++ b/perl-Tk-pregcomp2.c-Avoid-using-incompatible-pointer-type.patch @@ -0,0 +1,24 @@ +From 5c646b1cc55e18648918f101961afd1589a58168 Mon Sep 17 00:00:00 2001 +From: Christopher Chavez +Date: Mon, 19 Feb 2024 13:50:44 -0600 +Subject: [PATCH] pregcomp2.c: Avoid using incompatible pointer type + +See https://github.com/eserte/perl-tk/issues/98#issuecomment-1948125587 +--- + config/pregcomp2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/config/pregcomp2.c b/config/pregcomp2.c +index 98506999..bb0b4539 100644 +--- a/config/pregcomp2.c ++++ b/config/pregcomp2.c +@@ -4,5 +4,5 @@ + + int main() { + SV* sv = newSViv(0); +- regexp* rx = pregcomp(sv, 0); ++ void* rx = pregcomp(sv, 0); + } +-- +2.43.0 + diff --git a/perl-Tk.spec b/perl-Tk.spec index 53e50d7..aecbcf2 100644 --- a/perl-Tk.spec +++ b/perl-Tk.spec @@ -1,11 +1,8 @@ -%{!?perl_vendorarch: %define perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)} -%define perlver %(eval "`%{__perl} -V:version`"; echo $version) - %global use_x11_tests 1 Name: perl-Tk Version: 804.036 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Perl Graphical User Interface ToolKit License: (GPL-1.0-or-later OR Artistic-1.0-Perl) AND SWL @@ -17,7 +14,21 @@ Patch1: perl-Tk-debian.patch.gz # fix segfaults as in #235666 because of broken cashing code Patch2: perl-Tk-seg.patch Patch3: perl-Tk-c99.patch +# Fix STRLEN vs int pointer confusion in Tcl_GetByteArrayFromObj() +# It breaks tests with Perl 5.38 on s390* (BZ#2222638) +Patch4: perl-Tk-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch +# Fix build with clang 16 +# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271521 +Patch5: perl-Tk-Fix-build-with-clang-16.patch +# Avoid using incompatible pointer type in pregcomp2.c +Patch6: perl-Tk-pregcomp2.c-Avoid-using-incompatible-pointer-type.patch +# Avoid using incompatible pointer type for `old_warn` +# https://github.com/eserte/perl-tk/issues/98 +Patch7: perl-Tk-Avoid-using-incompatible-pointer-type-for-old_warn.patch +# Avoid using incompatible pointer type in function 'GetTextIndex' +# https://github.com/eserte/perl-tk/issues/103 +Patch8: perl-Tk-Fix-incompatible-pointer-type-in-function-GetTextIndex.patch # Versions before this have Unicode issues BuildRequires: make @@ -104,6 +115,9 @@ Provides: perl(Tk) = %{version} %global __provides_exclude %__provides_exclude|perl\\(Tk::Widget\\)$ %global __provides_exclude %__provides_exclude|perl\\(Tk::Wm\\)$ +# Filter modules bundled for tests +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(TkTest\\) %description This a re-port of a perl interface to Tk8.4. @@ -121,63 +135,105 @@ Requires: perl-Tk = %{version}-%{release} %description devel %{summary} +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +# X11 tests: +Requires: xorg-x11-server-Xvfb +Requires: xorg-x11-xinit +Requires: google-noto-sans-fonts +Requires: font(:lang=en) +Requires: liberation-sans-fonts + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n Tk-%{version} -find . -type f -exec %{__perl} -pi -e \ -'s,^(#!)(/usr/local)?/bin/perl\b,$1%{__perl}, if ($. == 1)' {} \; +find . -type f -exec perl -MConfig -pi -e \ +'s,^(#!)(/usr/local)?/bin/perl\b,$Config{startperl}, if ($. == 1)' {} \; chmod -x pod/Popup.pod Tixish/lib/Tk/balArrow.xbm # fix for widget as docs %patch -P 0 -%{__perl} -pi -e \ +perl -pi -e \ 's,\@demopath\@,%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}}/demos,g' demos/widget # debian patch #%%patch -P 1 -p1 # patch to fix #235666 ... seems like caching code is broken %patch -P 2 -p1 -b .seg %patch -P 3 -p1 -b .c99 +%patch -P 4 -p1 +%patch -P 5 -p1 +%patch -P 6 -p1 +%patch -P 7 -p1 +%patch -P 8 -p1 -# Temporary disable tests failing with Perl 5.38 BZ#2222638 -%ifarch s390 s390x -for F in t/balloon.t t/canvas2.t t/photo.t ; do - rm "$F" - perl -i -ne 'print $_ unless m{^\Q'"$F"'\E}' MANIFEST +# Help generators to recognize Perl scripts +for F in t/*.t; do + perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!.*perl\b}{$Config{startperl}}' "$F" + chmod +x "$F" done -%endif %build -%{__perl} Makefile.PL INSTALLDIRS=vendor X11LIB=%{_libdir} XFT=1 -find . -name Makefile | xargs %{__perl} -pi -e 's/^\tLD_RUN_PATH=[^\s]+\s*/\t/' -make %{?_smp_mflags} +perl Makefile.PL INSTALLDIRS=vendor X11LIB=%{_libdir} XFT=1 NO_PACKLIST=1 NO_PERLLOCAL=1 +find . -name Makefile | xargs perl -pi -e 's/^\tLD_RUN_PATH=[^\s]+\s*/\t/' +%{make_build} %check - %if %{use_x11_tests} - xvfb-run -a make test + xvfb-run -d make test %endif %install -make pure_install DESTDIR=$RPM_BUILD_ROOT +%{make_install} -find $RPM_BUILD_ROOT -type f -name .packlist -delete -find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -delete -find $RPM_BUILD_ROOT -type d -depth -exec rmdir {} 2>/dev/null \; +find %{buildroot} -type f -name '*.bs' -size 0 -delete -chmod -R u+rwX,go+rX,go-w $RPM_BUILD_ROOT/* +chmod -R u+rwX,go+rX,go-w %{buildroot}/* mkdir __demos -cp -pR $RPM_BUILD_ROOT%{perl_vendorarch}/Tk/demos __demos +cp -pR %{buildroot}%{perl_vendorarch}/Tk/demos __demos find __demos/ -type f -exec chmod -x {} \; +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +rm %{buildroot}%{_libexecdir}/%{name}/t/pod.t +mkdir -p %{buildroot}%{_libexecdir}/%{name}/demos/demos/images +cp demos/demos/images/cursor* %{buildroot}%{_libexecdir}/%{name}/demos/demos/images +perl -i -pe 's{-Mblib", "blib/script}{%{_bindir}}' %{buildroot}%{_libexecdir}/%{name}/t/exefiles.t +perl -i -ne 'print $_ unless m{gedi}' %{buildroot}%{_libexecdir}/%{name}/t/exefiles.t + +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/bash +set -e +# Some tests write into temporary files/directories +DIR=$(mktemp -d) +pushd "$DIR" +cp -a %{_libexecdir}/%{name}/* ./ +xvfb-run -d prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +popd +rm -rf "$DIR" +EOF +chmod +x %{buildroot}%{_libexecdir}/%{name}/test + %files %doc Changes README README.linux ToDo pTk/*license* __demos/demos demos/widget COPYING %doc blib/man1/widget.1 %{_bindir}/p* %{_bindir}/tkjpeg %{perl_vendorarch}/auto/Tk -%{perl_vendorarch}/T* +%{perl_vendorarch}/Tie* +%{perl_vendorarch}/Tk* %exclude %{perl_vendorarch}/Tk/MMutil.pm %exclude %{perl_vendorarch}/Tk/install.pm %exclude %{perl_vendorarch}/Tk/MakeDepend.pm -%{_mandir}/man*/* +%{_mandir}/man1/ptked* +%{_mandir}/man1/ptksh* +%{_mandir}/man1/tkjpeg* +%{_mandir}/man3/Tie* +%{_mandir}/man3/Tk* %exclude %{_mandir}/man1/widget.1* %exclude %{_bindir}/gedi %exclude %{_bindir}/widget @@ -189,8 +245,14 @@ find __demos/ -type f -exec chmod -x {} \; %{perl_vendorarch}/Tk/install.pm %{perl_vendorarch}/Tk/MakeDepend.pm +%files tests +%{_libexecdir}/%{name} %changelog +* Fri Mar 22 2024 Jitka Plesnikova - 804.036-13 +- Fix failing build and tests +- Resolves: RHEL-25977 + * Fri Jul 21 2023 Fedora Release Engineering - 804.036-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild diff --git a/plans/sanity.fmf b/plans/sanity.fmf new file mode 100644 index 0000000..a72ded4 --- /dev/null +++ b/plans/sanity.fmf @@ -0,0 +1,5 @@ +summary: Sanity tests +discover: + how: fmf +execute: + how: tmt diff --git a/tests/upstream-tests.fmf b/tests/upstream-tests.fmf new file mode 100644 index 0000000..2b7dc0f --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,16 @@ +summary: Upstream tests +contact: Jitka Plesnikova +component: perl-Tk +require: + - perl-Tk-tests +test: /usr/libexec/perl-Tk/test +enabled: true +tag: + - rhel-buildroot + - TestCaseCopy + - Tier1 +tier: '1' +adjust: + - enabled: false + when: distro < rhel-9 or distro < centos-stream-9 + continue: false