kbuild: rpm-pkg: Fix generating debuginfo manually.
PATCH 1/1 kbuild: rpm-pkg: Fix generating debuginfo manually.
The ${OBJCOPY} and ${READELF} are not expanded into path to readelf and objcopy binary so just use the binary name with the %{_bindir} makro.
--- scripts/package/kernel.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/package/kernel.spec +2 -2
@@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf while read -r mod; do mod="${mod%.o}.ko" dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}" - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') + buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug" mkdir -p "${dbg%/*}" "${link%/*}" - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" + %{_bindir}/objcopy --only-keep-debug "${mod}" "${dbg}" ln -sf --relative "${dbg}" "${link}" echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
Signature · 1 line
2.53.0
Nathan Chancellor
maintainerHi Lukas,
Thanks for the patch!
Quoted 14 lines · Lukas Herbolt
The ${OBJCOPY} and ${READELF} are not expanded into path to readelf and objcopy binary so just use the binary name with the %{_bindir} makro.
Signed-off-by Lukas Herbolt <[email protected]>--- scripts/package/kernel.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/package/kernel.spec +0
-0
scripts/package/kernel.spec echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf · line 112
Quoted 5 lines
scripts/package/kernel.spec +1
-1@@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf while read -r mod; do mod="${mod%.o}.ko" dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}" - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') + buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p')
When using the binrpm-pkg target within Kbuild, I do see these expanded to their Kbuild value:
++ .../toolchains/gcc/15.2.0/bin/x86_64-linux-readelf -n net/ipv6/netfilter/nf_reject_ipv6.ko ++ sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p'
but I guess use of the spec file is not limited to being within Kbuild? How are you using it? I guess using the srcrpm-pkg and building it manually?
I would prefer to keep use of these variables so that the user's choice of toolchain is properly respected. The proper way to fix this is likely using a fallback only when the variable is not defined. Does this work for your usecase?
scripts/package/kernel.spec +2 -2
@@ -109,11 +109,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf while read -r mod; do mod="${mod%.o}.ko" dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}" - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') + buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug" mkdir -p "${dbg%/*}" "${link%/*}" - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" + "${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}" ln -sf --relative "${dbg}" "${link}" echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
Quoted 32 lines · Nathan Chancellor
Hi Lukas,
Thanks for the patch!
Quoted 22 lines · Lukas Herbolt
The ${OBJCOPY} and ${READELF} are not expanded into path to readelf and objcopy binary so just use the binary name with the %{_bindir} makro.
Signed-off-by Lukas Herbolt <[email protected]>--- scripts/package/kernel.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/package/kernel.spec +0
-0@@ -109,11 +109,11 @@ echo/usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf
while read -r mod; do
mod="${mod%.o}.ko"dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"scripts/package/kernel.spec +0
-1- buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID:\(..\)\(.*\)@\1/\2@p')
scripts/package/kernel.spec +1
-0+ buildid=$(%{_bindir}/eu-readelf -n "${mod}" | sed -n 's@^.*Build ID:Quoted 1 line
\(..\)\(.*\)@\1/\2@p')
When using the binrpm-pkg target within
Kbuild, I do see these expanded to theirKbuildvalue:
Quoted 7 lines
++ .../toolchains/gcc/15.2.0/bin/x86_64-linux-readelf -n
net/ipv6/netfilter/nf_reject_ipv6.ko
++ sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p'but I guess use of the spec file is not limited to being within
Kbuild? How are you using it? I guess using the srcrpm-pkg and building it manually?
Yes exactly; make srcrpm-pkg and then mock --rebuild <src.rpm> (which actually runs rpmbuild in chroot).
Looking into it I guess the variables should be expanded after the make srcrpm-pkg, but if I check the spec file:
I can see:
buildid=$("${READELF}" ....
So the mkspec is not expanding the variable.
Quoted 20 lines
I would prefer to keep use of these variables so that the user's choice of toolchain is properly respected. The proper way to fix this is likely using a fallback only when the variable is not defined. Does this work for your usecase?
scripts/package/kernel.spec +0
-0@@ -109,11 +109,11 @@ echo/usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf
while read -r mod; do
mod="${mod%.o}.ko"dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"scripts/package/kernel.spec +0
-1- buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID:\(..\)\(.*\)@\1/\2@p')
scripts/package/kernel.spec +1
-0+ buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID:\(..\)\(.*\)@\1/\2@p')
scripts/package/kernel.spec echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf · line 119
Quoted 8 lines
scripts/package/kernel.spec +1
-1link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug" mkdir -p "${dbg%/*}" "${link%/*}" - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" + "${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}" ln -sf --relative "${dbg}" "${link}" echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
Yeah that works for me.
Signature · 1 line
-lhe