55# --------------------------------------------------------------------------
66
77ARG BASE_VERSION=15-pkg
8+
9+ # Builder: compile s6 from ports with FreeBSD 14 compat symver patch.
10+ # The FreeBSD 15 pkg for s6 links setgroups() against libsys syscall 596
11+ # (freebsd15_setgroups), which does not exist on FreeBSD 14. Injecting
12+ # .symver via CFLAGS forces setgroups@FBSD_1.0 (syscall 80) in every
13+ # compilation unit, making the resulting binaries work on both FreeBSD 14+15.
14+ FROM ghcr.io/daemonless/base-core:${BASE_VERSION} AS s6-builder
15+
16+ RUN pkg update && pkg install -y \
17+ FreeBSD-clang FreeBSD-clibs-dev FreeBSD-toolchain FreeBSD-bmake gmake \
18+ && pkg clean -ay && rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
19+
20+ COPY patches/fbsd14_compat.h /tmp/fbsd14_compat.h
21+
22+ # Fetch only the ports we need (skalibs -> execline -> s6) plus build infra
23+ RUN fetch -qo /tmp/ports.tar.zst \
24+ "https://download.freebsd.org/ports/ports/ports.tar.zst" && \
25+ mkdir -p /usr/ports && \
26+ tar -xf /tmp/ports.tar.zst -C /usr/ports --strip-components=1 \
27+ ports/devel/skalibs \
28+ ports/lang/execline \
29+ ports/sysutils/s6 \
30+ ports/Mk ports/Templates ports/Keywords && \
31+ rm /tmp/ports.tar.zst
32+
33+ # Build skalibs -> execline -> s6 from ports in dependency order.
34+ # CFLAGS in make.conf propagates to all ports. USE_PACKAGE_DEPENDS_ONLY
35+ # satisfies external build deps (gmake etc.) from pkg without building them.
36+ # pkg create produces packages that pkg add installs in the final stage.
37+ RUN echo 'CFLAGS+=-include /tmp/fbsd14_compat.h' >> /etc/make.conf && \
38+ mkdir -p /tmp/packages && \
39+ make -C /usr/ports/devel/skalibs BATCH=yes USE_PACKAGE_DEPENDS_ONLY=yes install clean && \
40+ pkg create -o /tmp/packages skalibs && \
41+ make -C /usr/ports/lang/execline BATCH=yes USE_PACKAGE_DEPENDS_ONLY=yes install clean && \
42+ pkg create -o /tmp/packages execline && \
43+ make -C /usr/ports/sysutils/s6 BATCH=yes USE_PACKAGE_DEPENDS_ONLY=yes install clean && \
44+ pkg create -o /tmp/packages s6 && \
45+ rm -rf /usr/ports
46+
47+ # Production image
848FROM ghcr.io/daemonless/base-core:${BASE_VERSION}
949
1050ARG PACKAGES="s6"
@@ -23,10 +63,12 @@ LABEL org.opencontainers.image.title="FreeBSD Base" \
2363
2464COPY root/ /
2565
26- RUN pkg update && \
27- pkg install -y ${PACKAGES} && \
28- pkg clean -ay && \
29- rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
66+ # Install s6 and deps from packages built in builder (patched for FreeBSD 14 compat)
67+ COPY --from=s6-builder /tmp/packages/ /tmp/packages/
68+ RUN pkg add /tmp/packages/skalibs-*.pkg && \
69+ pkg add /tmp/packages/execline-*.pkg && \
70+ pkg add /tmp/packages/s6-*.pkg && \
71+ rm -rf /tmp/packages
3072
3173RUN mkdir -p /etc/cont-init.d \
3274 /etc/services.d \
0 commit comments