Bug 476553 - RPM build of Valgrind 3.22.0 fails under RHEL8
Summary: RPM build of Valgrind 3.22.0 fails under RHEL8
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.22 GIT
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-04 16:50 UTC by Peter Klotz
Modified: 2023-11-11 06:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Workaround to packge gdb Python script files (715 bytes, patch)
2023-11-11 06:42 UTC, Peter Klotz
Details
Patch needed to package libexec content (370 bytes, patch)
2023-11-11 06:48 UTC, Peter Klotz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Klotz 2023-11-04 16:50:51 UTC
SUMMARY
Building an RPM of Valgrind 3.22.0 does not work under Red Hat Enterprise Linux 8

STEPS TO REPRODUCE
1.  Execute "rpmbuild -tb valgrind-3.22.0.tar.bz2" on a fully patched RHEL 8.8 system
2.  One obtains the error messages below

OBSERVED RESULT
The error messages:

---------------------------------------
 /usr/bin/mkdir -p '/usr/libexec/valgrind'
 /usr/bin/install -c -m 644 m_gdbserver/valgrind-monitor.py m_gdbserver/valgrind-monitor-def.py '/usr/libexec/valgrind'
/usr/bin/install: cannot create regular file '/usr/libexec/valgrind/valgrind-monitor.py': Permission denied
/usr/bin/install: cannot create regular file '/usr/libexec/valgrind/valgrind-monitor-def.py': Permission denied
make[4]: *** [Makefile:9424: install-gdbscriptsDATA] Error 1
make[4]: Leaving directory '/home/user/rpmbuild/BUILD/valgrind-3.22.0/coregrind'
make[3]: *** [Makefile:9565: install-am] Error 2
make[3]: Leaving directory '/home/user/rpmbuild/BUILD/valgrind-3.22.0/coregrind'
make[2]: *** [Makefile:9558: install] Error 2
make[2]: Leaving directory '/home/user/rpmbuild/BUILD/valgrind-3.22.0/coregrind'
make[1]: *** [Makefile:918: install-recursive] Error 1
make[1]: Leaving directory '/home/user/rpmbuild/BUILD/valgrind-3.22.0'
make: *** [Makefile:1225: install] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.Jax4dz (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.Jax4dz (%install)
---------------------------------------

EXPECTED RESULT
It should build, like 3.21.0 did.
Comment 1 Mark Wielaard 2023-11-06 21:02:53 UTC
I created 3.22.0 rpms for epel8:
https://copr.fedorainfracloud.org/coprs/mjw/valgrind-3.22.0/
The system gdb is too old to support the valgrind python monitor commands, so it is build with --without-gdbscripts-dir.
Does that help?
Comment 2 Peter Klotz 2023-11-08 06:38:51 UTC
Hi Mark

Thanks, your suggestion brought me a lot closer to building the RPM.
However at the end I got messages about unpackaged files:

> Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/user/rpmbuild/BUILDROOT/valgrind-3.22.0.x86_64
> error: Installed (but unpackaged) file(s) found:
>    /usr/lib/debug/usr/libexec/valgrind/cachegrind-amd64-linux-3.22.0.x86_64.debug
>    ...
>    /usr/libexec/valgrind/32bit-core-valgrind-s1.xml
> 
> RPM build errors:
>     Installed (but unpackaged) file(s) found:
>    /usr/lib/debug/usr/libexec/valgrind/cachegrind-amd64-linux-3.22.0.x86_64.debug
>    ...
>    /usr/libexec/valgrind/32bit-core-valgrind-s1.xml
>    ...

To fix those, another patch was needed:
> diff -Nur valgrind-3.22.0/valgrind.spec valgrind-3.22.0.patched/valgrind.spec
> --- valgrind-3.22.0/valgrind.spec       2023-10-31 18:26:43.000000000 +0100
> +++ valgrind-3.22.0.patched/valgrind.spec       2023-11-08 07:13:21.246612838 +0100
> @@ -42,6 +42,7 @@
>  %{_includedir}/valgrind
>  %{_libdir}/valgrind
>  %{_libdir}/pkgconfig/*
> +%{_libexecdir}/valgrind
> 
>  %doc
>  %defattr(-,root,root)
Comment 3 Peter Klotz 2023-11-11 06:42:33 UTC
Created attachment 163036 [details]
Workaround to packge gdb Python script files

It seems gdb in RHEL8 is not too old for packaging valgrind-monitor-def.py and valgrind-monitor.py. The initial comment in the bug points to a permission problem because the RPM build tries to incorrectly write the files into /usr/libexec/valgrind.

In an RPM build the correct path would be '/home/user/rpmbuild/BUILDROOT/valgrind-3.22.0-1.x86_64/usr/libexec/valgrind', so the prefix is missing. The problem lies in the 'install-recursive' target of the build.

This patch is just a workaround, that always sets the directory but it would not work if the user opted for --without-gdbscripts-dir. Maybe someone who has a deeper understanding of the Valgrind build mechanism can come up with a patch that works in all cases.
Comment 4 Peter Klotz 2023-11-11 06:48:16 UTC
Created attachment 163037 [details]
Patch needed to package libexec content

As mentioned earlier in the bug, this patch is needed to properly package libexec files. Otherwise the RPM build mechanism complains about installed but unpackaged files. This was observed when building the RPM under RHEL8.