fix zstd name, split into bin, lib and static-bin targets

This commit is contained in:
Jakub Panek 2024-08-07 08:02:59 +02:00
parent 9f06fc8954
commit ead0d7ae52
No known key found for this signature in database
GPG key ID: D5E8A1F82F3BDA9D
3 changed files with 90 additions and 12 deletions

View file

@ -7,7 +7,7 @@ ENV SRC_HASH=98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1
FROM base as fetch
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
FROM fetch as build
FROM fetch as prep
COPY --from=stagex/busybox . /
COPY --from=stagex/python . /
COPY --from=stagex/gcc . /
@ -28,6 +28,10 @@ RUN --network=none <<-EOF
--cpu=x86_64 \
--endian=little \
-o meson.cross
EOF
FROM prep AS build
RUN --network=none <<-EOF
meson setup \
--prefix=/usr \
--libdir=/usr/lib \
@ -67,15 +71,72 @@ RUN --network=none <<-EOF
meson compile -C output
EOF
FROM prep AS build-static
RUN --network=none <<-EOF
meson setup \
--prefix=/usr \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--includedir=/usr/include \
--datadir=/usr/share \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localedir=/usr/share/locale \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--buildtype=plain \
--auto-features=auto \
--wrap-mode=nodownload \
--default-library=static \
--cross-file=meson.cross \
-Dbacktrace=disabled \
-Db_lto=false \
-Db_staticpic=true \
-Db_pie=true \
-Dpython.bytecompile=0 \
-Dwerror=false \
-Db_ndebug=true \
-Dbin_tests=false \
-Dbin_contrib=false \
-Dbin_programs=true \
-Dbacktrace=disabled \
-Dmulti_thread=enabled \
-Dlz4=disabled \
-Dlzma=disabled \
-Dzlib=disabled \
build/meson \
output
meson compile -C output
EOF
FROM build as install
RUN --network=none DESTDIR=/rootfs meson install --no-rebuild -C output
FROM stagex/filesystem as package-lib
FROM build-static as install-static
RUN --network=none DESTDIR=/rootfs meson install --no-rebuild -C output
# lib target
FROM scratch as install-lib
COPY --from=install /rootfs/usr/lib /usr/lib
COPY --from=install /rootfs/usr/libexec /usr/libexec
COPY --from=install /rootfs/usr/include /usr/include
COPY --from=install /rootfs/usr/share /usr/share
COPY --from=install /rootfs/var/lib /var/lib
FROM stagex/filesystem as package-lib
COPY --from=install-lib / /
# bin target
FROM scratch as install-bin
COPY --from=install /rootfs/usr/bin /usr/bin
FROM stagex/filesystem as package-bin
COPY --from=install /rootfs/. /
COPY --from=install-bin / /
# bin-static target
FROM scratch as install-static-bin
COPY --from=install-static /rootfs/usr/bin /usr/bin
FROM stagex/filesystem as package-static-bin
COPY --from=install-static-bin / /

View file

@ -22,9 +22,10 @@
# - support buildah and podman
define build
$(eval NAME := $(1))
$(eval VERSION := $(if $(2),$(2),latest))
$(eval TARGET := $(if $(3),$(3),package))
$(eval EXTRA_ARGS := $(if $(4),$(4),))
$(eval SUBPKG := $(if $(2),$(2),$(NAME)))
$(eval VERSION := $(if $(3),$(3),latest))
$(eval TARGET := $(if $(4),$(4),package))
$(eval EXTRA_ARGS := $(if $(5),$(5),))
$(eval REVISION := $(shell git rev-list HEAD -1 packages/$(NAME)))
$(eval TEMPFILE := out/.$(notdir $(basename $@)).tmp.tar)
$(eval BUILD_CMD := \
@ -34,14 +35,14 @@ define build
$(BUILDER) \
build \
--ulimit nofile=2048:16384 \
--tag $(REGISTRY_REMOTE)/$(NAME):$(VERSION) \
--tag $(REGISTRY_REMOTE)/$(SUBPKG):$(VERSION) \
--build-arg CACHE_BUST="$(shell date)" \
--build-arg SOURCE_DATE_EPOCH=1 \
--build-arg CORES=$(shell nproc --all) \
--platform $(PLATFORM) \
--progress=plain \
$(if $(filter latest,$(VERSION)),,--build-arg VERSION=$(VERSION)) \
--output type=oci,rewrite-timestamp=true,force-compression=true,name=$(NAME),annotation.org.opencontainers.image.revision=$(REVISION),annotation.org.opencontainers.image.version=$(VERSION),tar=false,dest=out/$(NAME) \
--output type=oci,rewrite-timestamp=true,force-compression=true,name=$(SUBPKG),annotation.org.opencontainers.image.revision=$(REVISION),annotation.org.opencontainers.image.version=$(VERSION),tar=false,dest=out/$(SUBPKG) \
--target $(TARGET) \
$(shell ./src/context.sh $(NAME)) \
$(EXTRA_ARGS) \

View file

@ -1061,7 +1061,7 @@ out/libzstd/index.json: \
out/pkgconf/index.json \
out/python/index.json \
out/zlib/index.json
$(call build,zstd,,package-lib)
$(call build,zstd,libzstd,,package-lib)
.PHONY: linux-airgap
linux-airgap: out/linux-airgap/index.json
@ -2559,4 +2559,20 @@ out/zstd/index.json: \
out/pkgconf/index.json \
out/python/index.json \
out/zlib/index.json
$(call build,zstd,,package-lib)
$(call build,zstd,zstd,,package-bin)
.PHONY: zstd-static
zstd-static: out/zstd-static/index.json
out/zstd-static/index.json: \
packages/zstd/Containerfile \
out/binutils/index.json \
out/busybox/index.json \
out/filesystem/index.json \
out/gcc/index.json \
out/meson/index.json \
out/musl/index.json \
out/ninja/index.json \
out/pkgconf/index.json \
out/python/index.json \
out/zlib/index.json
$(call build,zstd,zstd-static,,package-static-bin)