Skip to content

Commit

Permalink
Allow to build zbm in containerized Debian env.
Browse files Browse the repository at this point in the history
Added Dockerfile.debian so it does not conflict with the main Dockerfile. Also adjusted build-init.sh to support apt.
  • Loading branch information
BohdanTkachenko committed Apr 1, 2024
1 parent 864cac1 commit 7df5785
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 10 deletions.
86 changes: 86 additions & 0 deletions releng/docker/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# syntax=docker/dockerfile:1.4
#
# This Dockerfile creates a container that will create an EFI executable and
# separate kernel/initramfs components from a ZFSBootMenu repository. The
# container will pre-populate its /zbm directory with a clone of the master
# branch of the upstream ZFSBootMenu branch and build the images from that.
#
# To use a different ZFSBootMenu repository or version, bind-mound the
# repository you want on /zbm inside the container.
#
# Note - this Dockerfile depends on Docker >= 23 and the docker buildx plugin.

# Use the official Debian container. Allow to customize tag,so different Debian
# version could be used.
ARG DEBIAN_TAG=bookworm-slim
FROM debian:$DEBIAN_TAG
LABEL org.opencontainers.image.authors="ZFSBootMenu Team, https://zfsbootmenu.org"

ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/lib/apt/lists \
set -eux; \
sed -i 's/Components: main/Components: main contrib non-free/' /etc/apt/sources.list.d/debian.sources && \
apt-get update && \
apt-get install --no-install-recommends -y \
bash \
ca-certificates \
cryptsetup \
curl \
dosfstools \
dracut \
dracut-network \
e2fsprogs \
efibootmgr \
fzf \
gdisk \
iproute2 \
iputils-arping \
iputils-clockdiff \
iputils-ping \
iputils-tracepath \
kbd \
kexec-tools \
kpartx \
less \
libboolean-perl \
libsort-versions-perl \
libyaml-pp-perl \
linux-headers-amd64 \
linux-image-amd64 \
mbuffer \
ncurses-base \
openssh-server \
parted \
pigz \
procps \
systemd-boot-efi \
util-linux \
zfs-dracut \
zfsutils-linux \
zstd \
&& \
curl -L -o /usr/bin/yq-go https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && \
chmod +x /usr/bin/yq-go

ARG ZFSBOOTMENU_VERSION="2.3.0"

# ZFSBootMenu commit hash, tag or branch name used by
# default to build ZFSBootMenu images (default: master)
ARG ZBM_COMMIT_HASH=
# Record a commit hash if one was provided
RUN [ -z "${ZBM_COMMIT_HASH}" ] || echo "${ZBM_COMMIT_HASH}" > /etc/zbm-commit-hash

# Include the specified Debian package in the image
# (multiple entries must be seperated by spaces)
ARG PACKAGES=
# Run ${PACKAGES} install in seperate layer so that the zfs dkms packages
# are not rebuilt when ${PACKAGES} change. reuse.
# Install ZFSBootMenu dependencies and components necessary to build images
RUN --mount=type=cache,target=/var/lib/apt/lists \
[ -z "${PACKAGES}" ] || apt-get update && apt-get install -y ${PACKAGES}

RUN rm -rf /var/lib/apt/lists/*

COPY --chmod=755 build-init.sh /
# Run the build script with no arguments by default
ENTRYPOINT [ "/build-init.sh", "-m", "apt" ]
34 changes: 24 additions & 10 deletions releng/docker/build-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ Usage: $0 [options]
(Default: \${BUILDROOT}/build)
-p <package>
Install the named Void Linux package in the container
before building. May be specified more than once to
install more than one package. (This triggers a full
XBPS package upgrade before installation.)
Install the named package in the container before building.
May be specified more than once to install more than one
package. (This triggers a full package upgrade before
installation.)
-m <package manager>
Specify a different package manager backend.
Supported backends: xbps, apt
(Default: xbps)
-t <tag>
Specify specific tag or commit hash to fetch
Expand Down Expand Up @@ -60,7 +65,7 @@ GENARGS=()

SKIP_VERSIONING=

while getopts "hb:o:t:e:p:V" opt; do
while getopts "hb:o:t:e:p:m:V" opt; do
case "${opt}" in
b)
BUILDROOT="${OPTARG}"
Expand All @@ -74,6 +79,9 @@ while getopts "hb:o:t:e:p:V" opt; do
p)
PACKAGES+=( "${OPTARG}" )
;;
m)
PACKAGE_MANAGER="${OPTARG}"
;;
e)
CONFIGEVALS+=( "${OPTARG}" )
;;
Expand Down Expand Up @@ -111,11 +119,17 @@ if [ -z "${ZBMTAG}" ]; then
fi

if [ "${#PACKAGES[@]}" -gt 0 ]; then
# Trigger a sync and upgrade to make sure the package is installable
xbps-install -Syu xbps

# Install all requested packages
xbps-install -Sy "${PACKAGES[@]}"
# First will trigger a sync and upgrade to make sure the package is installable,
# then install all requested packages
if [ "${PACKAGE_MANAGER}" == "xbps" ]; then
xbps-install -Syu xbps
xbps-install -Sy "${PACKAGES[@]}"
elif [ "${PACKAGE_MANAGER}" == "apt" ]; then
apt-get update
apt-get install -y "${PACKAGES[@]}"
else
error "unsupported package manager backend: ${PACKAGE_MANAGER}"
fi
fi

# If a custom rc.pre.d exists, run every executable file therein
Expand Down

0 comments on commit 7df5785

Please sign in to comment.