FS#74486 - do not overwrite files if stripping fails

Attached to Project: Pacman
Opened by Ting-Wei Lan (lantw44) - Sunday, 17 April 2022, 15:44 GMT
Last edited by Allan McRae (Allan) - Tuesday, 02 August 2022, 01:07 GMT
Task Type Bug Report
Category makepkg
Status Closed
Assigned To Andreas Radke (AndyRTR)
Allan McRae (Allan)
David Runge (dvzrv)
Architecture All
Severity Low
Priority Normal
Reported Version 6.0.1
Due in Version 6.0.2
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
gnutls package has Guile bindings enabled, but all .go files it installs are empty. This causes my guix package (https://aur.archlinux.org/packages/guix#comment-861221) to fail to build because of broken Guile bindings.

Additional info:
gnutls 3.7.4-1

Steps to reproduce:
$ find /usr/lib/guile/2.2/site-ccache/gnutls* -ls
3420447 4 drwxr-xr-x 2 root root 4096 Apr 11 19:19 /usr/lib/guile/2.2/site-ccache/gnutls
3420448 0 -rw-r--r-- 1 root root 0 Mar 17 19:25 /usr/lib/guile/2.2/site-ccache/gnutls/extra.go
3420449 0 -rw-r--r-- 1 root root 0 Mar 17 19:25 /usr/lib/guile/2.2/site-ccache/gnutls.go
This task depends upon

Closed by  Allan McRae (Allan)
Tuesday, 02 August 2022, 01:07 GMT
Reason for closing:  Fixed
Additional comments about closing:  git commit 18152a211aeee07e655c2cc4438c25e558e3b8aa
Comment by loqs (loqs) - Sunday, 17 April 2022, 18:01 GMT
Please try disabling debug in the options array of the PKGBUILD and see if that produces valid .go files.

objcopy: Unable to recognise the format of the input file `./usr/lib/guile/2.2/site-ccache/gnutls.go'
objcopy: Unable to recognise the format of the input file `./usr/lib/guile/2.2/site-ccache/gnutls.go'
cat: ./usr/lib/guile/2.2/site-ccache/gnutls.go.Spj00D: No such file or directory
rm: cannot remove './usr/lib/guile/2.2/site-ccache/gnutls.go.Spj00D': No such file or directory
ln: failed to access '/build/gnutls/pkg/gnutls-debug/usr/lib/debug/./usr/lib/guile/2.2/site-ccache/gnutls.go.debug': No such file or directory
Comment by Ting-Wei Lan (lantw44) - Sunday, 24 April 2022, 04:06 GMT
Yes, .go files are valid when 'debug' is removed from options.

$ find /usr/lib/guile/2.2/site-ccache/gnutls* -ls
3420447 4 drwxr-xr-x 2 root root 4096 Apr 24 03:37 /usr/lib/guile/2.2/site-ccache/gnutls
3566673 72 -rw-r--r-- 1 root root 72261 Apr 24 03:06 /usr/lib/guile/2.2/site-ccache/gnutls/extra.go
3566643 192 -rw-r--r-- 1 root root 195765 Apr 24 03:06 /usr/lib/guile/2.2/site-ccache/gnutls.go

$ find /usr/lib/guile/2.2/site-ccache/gnutls* -exec file '{}' +
/usr/lib/guile/2.2/site-ccache/gnutls: directory
/usr/lib/guile/2.2/site-ccache/gnutls/extra.go: ELF 64-bit LSB shared object, no machine, version 1 (embedded), dynamically linked, with debug_info, not stripped
/usr/lib/guile/2.2/site-ccache/gnutls.go: ELF 64-bit LSB shared object, no machine, version 1 (embedded), dynamically linked, with debug_info, not stripped
Comment by Andreas Radke (AndyRTR) - Monday, 25 April 2022, 17:45 GMT
I can confirm this behavior caused by our debug build option either enabled or disabled.

@dvzrv: Any idea if this can be caused by our way creating the build package? It seems Debian/Fedora/Gentoo build guile extension without this issue.

Feel free to report it upstream if you think it should be fixed there:
https://gitlab.com/gnutls/gnutls/-/issues
Comment by Ting-Wei Lan (lantw44) - Sunday, 01 May 2022, 09:49 GMT
It looks like a problem of makepkg. In file /usr/share/makepkg/tidy/strip.sh, function strip_file:

objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
local tempfile=$(mktemp "$binary.XXXXXX")
objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary" "$tempfile"
cat "$tempfile" > "$binary"
rm "$tempfile"

If objcopy fails to process the file, 'tempfile' won't exist. Therefore, the cat command will break 'binary' by truncating it to zero size.

I think makepkg shouldn't break an ELF file it can't strip. It should check if objcopy succeeds before replacing the file.
Comment by Allan McRae (Allan) - Friday, 06 May 2022, 02:39 GMT
  • Field changed: Summary ([makepkg] gnutls guile bindings are empty files when creating debug packages → do not overwrite files if stripping fails)
  • Field changed: Category (Packages: Core → makepkg)
  • Field changed: Reported Version ( → 6.0.1)
  • Field changed: Due in Version (Undecided → 6.0.2)
  • Field changed: Architecture (All → All)
Moving to pacman tracker
Comment by Allan McRae (Allan) - Thursday, 12 May 2022, 12:41 GMT Comment by Ting-Wei Lan (lantw44) - Monday, 23 May 2022, 10:19 GMT
I confirm that the patch fixes the issue.

Loading...