2023-06-17 20:24:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# Author: Nils Freydank <nils.freydank@posteo.de>
|
|
|
|
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
|
|
|
|
set -uxa
|
|
|
|
|
|
|
|
GPG_SIGNING_KEY="${GPG_SIGNING_KEY:-0x0F1DEAB2D36AD112}"
|
|
|
|
|
2023-07-29 17:30:39 +02:00
|
|
|
REGISTRY="${REGISTRY:-git.holgersson.xyz/gentoo-related/gentoo-binpkg-builder}"
|
|
|
|
VERSION="${VERSION:-$(date --utc +%Y%m%d_%H%M%S)}"
|
2023-07-02 10:43:36 +02:00
|
|
|
IMAGE_TAG="${REGISTRY}:${VERSION}"
|
|
|
|
|
2023-06-17 20:24:22 +02:00
|
|
|
REPOS="${REPOS:-/var/db/repos}"
|
|
|
|
DISTFILES="${DISTFILES:-/var/cache/distfiles-podman-1}"
|
|
|
|
BINPKG="${BINPKG:-/var/cache/packages-podman-1}"
|
2023-08-31 21:46:08 +02:00
|
|
|
LOGDIR="${LOGDIR:-$(pwd)/log}"
|
2023-06-17 20:24:22 +02:00
|
|
|
DOCKER_FILE="${DOCKER_FILE:-$(pwd)/Dockerfile}"
|
|
|
|
|
2023-10-01 18:50:23 +02:00
|
|
|
PODMAN_BUILD_ARGS=(
|
2023-08-06 21:34:30 +02:00
|
|
|
# Do not leak the host's /etc/host into the container.
|
|
|
|
--no-hosts
|
2023-06-17 20:24:22 +02:00
|
|
|
# Limit the memory to be used.
|
|
|
|
--memory=20G
|
|
|
|
--memory-swap=1G
|
|
|
|
--shm-size=2G
|
|
|
|
# Share the gentoo repo, overlays etc.
|
|
|
|
-v "${REPOS}:/var/db/repos:ro"
|
|
|
|
# Share the distfiles, i.e. typically source archives.
|
|
|
|
-v "${DISTFILES}:/var/cache/distfiles:rw,U"
|
|
|
|
# Share the binpkgs r/w cache.
|
|
|
|
-v "${BINPKG}:/var/cache/packages:rw,U"
|
|
|
|
# Keep the logs out of the container.
|
|
|
|
-v "${LOGDIR}:/var/log:rw,U"
|
|
|
|
# Use the given OCI file/Dockerfile.
|
|
|
|
-f "${DOCKER_FILE}"
|
|
|
|
# Tag the generated image.
|
|
|
|
-t "${IMAGE_TAG}"
|
|
|
|
# Label the image.
|
|
|
|
--label="gentoo-nfr-${IMAGE_TAG}"
|
|
|
|
# Sign the image.
|
|
|
|
#--sign-by="${GPG_SIGNING_KEY}"
|
2023-06-17 23:29:18 +02:00
|
|
|
# Rebuild everything w/o cache.
|
2023-06-17 20:24:22 +02:00
|
|
|
--no-cache
|
|
|
|
)
|
|
|
|
|
2023-10-01 18:50:24 +02:00
|
|
|
exit_err()
|
|
|
|
{
|
|
|
|
echo "${@}"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
|
2023-06-17 20:24:22 +02:00
|
|
|
mkdir -p "${REPOS}"
|
|
|
|
mkdir -p "${DISTFILES}"
|
|
|
|
mkdir -p "${BINPKG}"
|
|
|
|
mkdir -p "${LOGDIR}"
|
|
|
|
|
|
|
|
podman pull gentoo/stage3:amd64-nomultilib-systemd
|
2023-10-01 18:50:23 +02:00
|
|
|
podman build "${PODMAN_BUILD_ARGS[@]}"
|
2023-06-17 20:24:22 +02:00
|
|
|
|
2023-07-02 10:43:36 +02:00
|
|
|
# Update the tag 'latest'.
|
|
|
|
podman tag rm "${REGISTRY}:latest"
|
|
|
|
podman tag "${REGISTRY}:${VERSION}" "${REGISTRY}:latest"
|
|
|
|
|
2023-06-17 20:24:22 +02:00
|
|
|
# vim:fileencoding=utf-8:ts=4:syntax=bash:expandtab
|