sgerrand / alpine-pkg-glibc

A glibc compatibility layer package for Alpine Linux
2.04k stars 280 forks source link

Fully replace `libc6-compat` and `musl-utils` #179

Open LukeShu opened 2 years ago

LukeShu commented 2 years ago

When upgrading 2.34→2.35, https://github.com/sgerrand/alpine-pkg-glibc/pull/171 also made the change that it drops the /lib64/ld-linux-x86-64.so.2 symlink and instead depend on libc6-compat's version of that symlink.

This broke us, as /lib/ld-linux-x86-64.so.2 was going for glibc, while /lib64/ld-linux-x86-64.so.2 was going for musl, and that managed to confuse our binary.


Dropping the symlink was justified by ERROR: glibc*: Packages must not put anything under /lib64, use /lib instead; but man apkbuild tells us about the lib64 value for options=:

Specifies that the package installs files under /lib64 or /usr/lib64 and that the test for those directories should be skipped. This is discouraged and should only be used for packages providing compatibility for GNU libc.

That's exactly the case for us! So say options="lib64" and add the symlink back. Since this means that we file-conflict with libc6-compat, explicitly declare that and say conflicts="libc6-compat".


What does libc6-compat do, what are the consequences of not being able to install both it and glibc at the same time? It adds glibc binary compatibility to musl, allowing binaries linked against glibc to use Alpine's native musl. So it doesn't really make sense to have both glibc and libc6-compat to be installed at once; if you have glibc installed that's a strong indicator that you want glibc-linked binaries to use the actual glibc and not musl. So the above conflicts= is probably the right thing. At the same time, the intent of libc6-compat can be written as "I'd like to be able to run binaries that are linked against glibc", so also say provides="libc6-compat".

The commit that added glibc-bin's dependency on libc6-compat (39878629cbf803bc70323f35dfeb674da9a5c0ac) said "This package not being installed is a very common cause of reported user errors." I'm not sure what those reported user errors are; that claim doesn't make much sense to me.


I also added a glibc-utils counterpart to musl-utils; it just symlinks programs from glibc-bin's /usr/glibc-compat in to /usr.


I also gave glibc-bin a dependency on perl, as mtrace uses perl in its shebang.


I have not actually built or tested this.

b01 commented 3 months ago

@LukeShu I believe that this PR is still VERY relevant and should be merged. But with the change I suggested:

depends="$depends !libc6-compat" # conflicts with this package

Would you be willing to rebase this PR with the latest and push an update?

gjrtimmer commented 2 days ago

I tried to build and install this PR, however, I ran into the following issue:

/pkgs/builder/x86_64 # apk add --allow-untrusted glibc-2.37-r0.apk
(1/1) Installing glibc (2.37-r0)
ERROR: glibc-2.37-r0: trying to overwrite etc/nsswitch.conf owned by alpine-baselayout-data-3.6.5-r0.
1 error; 13 MiB in 15 packages

@LukeShu any thoughts on this?