From c21c7e88ef1c934b73f858233dc1dcd0dd3240e5 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 9 Dec 2022 16:06:23 +0000 Subject: [PATCH 1/3] Patch in the release builds musl ships with an incorrect value for NGROUPS_MAX in limits.h. This affects OCaml's Unix.getgroups function. Fortunately, for the opam binary, this can be worked around simply by ensuring /usr/include/limits.h has been patched before OCaml is compiled. This would not work for Unix.initgroups, but fortunately opam doesn't need that. --- master_changes.md | 1 + release/Dockerfile.in | 1 + 2 files changed, 2 insertions(+) diff --git a/master_changes.md b/master_changes.md index 20e3f877d44..df512ee3f72 100644 --- a/master_changes.md +++ b/master_changes.md @@ -71,6 +71,7 @@ users) ## Infrastructure ## Release scripts + * Workaround incorrect `NGROUPS_MAX` in `` in musl for release builds [#5383 @dra27] ## Admin diff --git a/release/Dockerfile.in b/release/Dockerfile.in index fd10c573325..018ec5b8f9a 100644 --- a/release/Dockerfile.in +++ b/release/Dockerfile.in @@ -4,6 +4,7 @@ FROM multiarch/alpine:%TARGET_TAG% LABEL Description="opam release builds" Vendor="OCamlPro" Version="1.0" RUN apk add gcc g++ make coreutils openssl +RUN sed -i -e '/ NGROUPS_MAX /s/32/65536/' /usr/include/limits.h RUN addgroup -S opam && adduser -S opam -G opam -s /bin/sh From abe02fc6ff39c0191406c83de8fc91ab4eeca0b3 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Fri, 9 Dec 2022 16:29:25 +0000 Subject: [PATCH 2/3] Only add -lsha_stubs for opam master Allows the release scripts on master to build opam 2.1 release tags. --- release/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release/Makefile b/release/Makefile index 1c5f1ec0bf6..394b19b757d 100644 --- a/release/Makefile +++ b/release/Makefile @@ -52,17 +52,19 @@ build/%.image: build/Dockerfile.% docker build -t opam-build-$* -f $^ build touch $@ +SHA_LINK = $(if $(shell tar xOf "$(OUTDIR)/opam-full-$(VERSION).tar.gz" opam-full-$(VERSION)/src_ext/Makefile.sources | grep -F URL_sha),-lsha_stubs) + # Actually, this is for alpine 3.13, and varies CLINKING_linux = \ -Wl,-Bstatic \ --lunix -lmccs_stubs -lmccs_glpk_stubs -lsha_stubs \ +-lunix -lmccs_stubs -lmccs_glpk_stubs $(SHA_LINK) \ -lstdc++ \ -static-libgcc \ -static # -Wl,-Bdynamic CLINKING_macos = \ --lunix -lmccs_stubs -lmccs_glpk_stubs -lsha_stubs \ +-lunix -lmccs_stubs -lmccs_glpk_stubs $(SHA_LINK) \ -lstdc++ CLINKING_openbsd = $(CLINKING_macos) From b6dc7de4df571fab6050fe1a1b2a8e9265083ae9 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 14 Dec 2022 14:40:07 +0000 Subject: [PATCH 3/3] Patch OCaml instead of limits.h --- release/Dockerfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/Dockerfile.in b/release/Dockerfile.in index 018ec5b8f9a..cd5cb183751 100644 --- a/release/Dockerfile.in +++ b/release/Dockerfile.in @@ -4,7 +4,6 @@ FROM multiarch/alpine:%TARGET_TAG% LABEL Description="opam release builds" Vendor="OCamlPro" Version="1.0" RUN apk add gcc g++ make coreutils openssl -RUN sed -i -e '/ NGROUPS_MAX /s/32/65536/' /usr/include/limits.h RUN addgroup -S opam && adduser -S opam -G opam -s /bin/sh @@ -15,6 +14,7 @@ RUN tar xzf %OCAMLV%.tar.gz WORKDIR ocaml-%OCAMLV% RUN sed -i 's/gnueabi/*eabi/' configure RUN sed -i 's/musl/musl*/' configure +RUN sed -i -e 's/NGROUPS_MAX/65536/' otherlibs/unix/getgroups.c RUN ./configure %CONF% -prefix /usr/local RUN make "-j$(nproc)" && make install && rm -rf /root/ocaml-%OCAMLV% /root/ocaml-%OCAMLV%.tar.gz