msys2 / MSYS2-packages

Package scripts for MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
1.3k stars 490 forks source link

stdbuf doesn't work due to missing libstdbuf.so #541

Open elieux opened 8 years ago

elieux commented 8 years ago

I think this is caused by makepkg pre-packaging renames.

Problem:

$ stdbuf.exe -oL -eL -i0 sh
      0 [main] sh 9992 C:\msys64\usr\bin\sh.exe: *** fatal error - error while loading shared libraries: /usr/lib/coreutils/lib stdbuf.so: cannot open shared object file: No such file or directory
Hangup

Workaround:

$ mv /usr/lib/coreutils/libstdbuf.so.exe /usr/lib/coreutils/libstdbuf.sox
$ cp /usr/lib/coreutils/libstdbuf.sox /usr/lib/coreutils/libstdbuf.so
$ mv /usr/lib/coreutils/libstdbuf.sox /usr/lib/coreutils/libstdbuf.so.exe
larsxschneider commented 7 years ago

With the latest Git for Windows 2.14.1 we get the same error using stdbuf:

$ stdbuf -oL ls
      0 [main] ls 5460 C:\Program Files\Git\usr\bin\ls.exe: *** fatal error - error while loading shared libraries: /usr/lib/coreutils/libstdbuf.so: cannot open shared object file: No such file or directory
Hangup

If we rename C:\Program Files\Git\usr\lib\coreutils\libstdbuf.so.exe to C:\Program Files\Git\usr\lib\coreutils\libstdbuf.so then it works.

@Alexpux / @dscho : Can you give me a hint where this could be fixed? Thanks!

dscho commented 7 years ago

@larsxschneider pacman to the rescue:

$ pacman -Qo /usr/lib/coreutils/libstdbuf.so.exe
/usr/lib/coreutils/libstdbuf.so.exe is owned by coreutils 8.26-1

So the culprit is that something in coreutils is built incorrectly.

Looking at the corresponding PKGBUILD file, I see that there is supposedly a fix for it already: https://github.com/Alexpux/MSYS2-packages/blob/e6d639a60034244bf3be0b2e61e1d910f7894c21/coreutils/PKGBUILD#L38

However, that fix obviously does not work, or it works and nobody bothered to rebuild the package since. The latter seems not to be the case, as the latest change to PKGBUILD was b6fa9fd7e2a62e5837614c4167699d9b07326172 that updated to 8.26-1, which is the current version, so that sed call must have already been in there.

mati865 commented 7 years ago

@dscho sed part was introduced back in 2015 for 8.24 version.

Makefile could have changed in 8.25 which was uploaded for MSYS2 3 weeks before this issue has been created.

dscho commented 7 years ago

d9773f0a8, indeed. I just test-built, and I can reproduce the problem, even if the sed call worked correctly, and the libstdbuf.so file is compiled. The problem is the install step.

dscho commented 7 years ago

The output that shows the problem:

[...]
 src/ginstall -c -m 644 ../coreutils-8.26/doc/coreutils.info '/usr/src/MSYS2-packages/coreutils/pkg/coreutils/usr/share/info'
  src/ginstall -c src/libstdbuf.so '/usr/src/MSYS2-packages/coreutils/pkg/coreutils/usr/lib/coreutils/./libstdbuf.so.exe'
 src/ginstall -c -m 644 'man/kill.1' '/usr/src/MSYS2-packages/coreutils/pkg/coreutils/usr/share/man/man1/gkill.1'
  src/ginstall -c src/kill.exe '/usr/src/MSYS2-packages/coreutils/pkg/coreutils/usr/bin/./gkill.exe'
[...]

And I think the problem comes from the install-binPROGRAMS in the Makefile.in file:

install-binPROGRAMS: $(bin_PROGRAMS)
    @$(NORMAL_INSTALL)
    @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
    if test -n "$$list"; then \
      echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
      $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
    fi; \
    for p in $$list; do echo "$$p $$p"; done | \
    sed 's/$(EXEEXT)$$//' | \
    while read p p1; do if test -f $$p \
      ; then echo "$$p"; echo "$$p"; else :; fi; \
    done | \
    sed -e 'p;s,.*/,,;n;h' \
        -e 's|.*|.|' \
        -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
    sed 'N;N;N;s,\n, ,g' | \
    $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
      { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
        if ($$2 == $$4) files[d] = files[d] " " $$1; \
        else { print "f", $$3 "/" $$4, $$1; } } \
      END { for (d in files) print "f", d, files[d] }' | \
    while read type dir files; do \
        if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
        test -z "$$files" || { \
          echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
          $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
        } \
    ; done

It is not really wrong per se, the problem seems more that libstdbuf.so is listed as a program.

dscho commented 7 years ago

And here is my proposed fix: https://github.com/Alexpux/MSYS2-packages/pull/1019