]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
build: add files needed to create a build container
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 20 Aug 2024 19:00:57 +0000 (15:00 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 18 Feb 2025 22:58:08 +0000 (17:58 -0500)
A build container contains all the tools and dependencies needed to
build ceph. It provides a Container file and small script that
helps bootstrap the container setup. This script installs a few extra
things we need before farming most of the work out to install-deps.sh.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit bde72fc478ce23f7cba8d163f914456e07996aab)

Dockerfile.build [new file with mode: 0644]
src/script/buildcontainer-setup.sh [new file with mode: 0644]

diff --git a/Dockerfile.build b/Dockerfile.build
new file mode 100644 (file)
index 0000000..cece359
--- /dev/null
@@ -0,0 +1,32 @@
+ARG DISTRO
+
+FROM scratch as bootstrap
+ARG CEPH_CTR_SRC=/usr/local/src/ceph
+COPY \
+    src/script/lib-build.sh \
+    src/script/run-make.sh \
+    ${CEPH_CTR_SRC}/src/script/
+COPY debian ${CEPH_CTR_SRC}/debian
+COPY \
+    ceph.spec.in \
+    do_cmake.sh \
+    install-deps.sh \
+    run-make-check.sh \
+    src/script/buildcontainer-setup.sh \
+    ${CEPH_CTR_SRC}
+
+
+FROM $DISTRO
+ENV FOR_MAKE_CHECK=1
+ARG DISTRO
+ARG CEPH_CTR_SRC=/usr/local/src/ceph
+ARG CLEAN_DNF=yes
+ARG CEPH_BRANCH=main
+COPY --from=bootstrap ${CEPH_CTR_SRC} ${CEPH_CTR_SRC}
+# Note that we do not use ENV for the following. This is because we do not
+# want them permamently stored in the container's layer.
+RUN DISTRO=$DISTRO \
+    CEPH_BRANCH=$CEPH_BRANCH \
+    CLEAN_DNF=$CLEAN_DNF \
+    CEPH_CTR_SRC=${CEPH_CTR_SRC} \
+    bash -x ${CEPH_CTR_SRC}/buildcontainer-setup.sh
diff --git a/src/script/buildcontainer-setup.sh b/src/script/buildcontainer-setup.sh
new file mode 100644 (file)
index 0000000..82ca11e
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+install_container_deps() {
+    source ./src/script/run-make.sh
+    prepare
+}
+
+dnf_clean() {
+    if [ "${CLEAN_DNF}" != no ]; then
+        dnf clean all
+        rm -rf /var/cache/dnf/*
+    fi
+}
+
+set -e
+export LOCALE=C
+cd ${CEPH_CTR_SRC}
+
+# If DISTRO_KIND is not already set, derive it from the container's os-release.
+if [ -z "$DISTRO_KIND" ]; then
+    . /etc/os-release
+    DISTRO_KIND="${ID}:${VERSION_ID}"
+fi
+
+# Execute a container setup process, installing the packges needed to build
+# ceph for the given <branch>~<distro_kind> pair. Some distros need extra
+# tools in the container image vs. vm hosts or extra tools needed to build
+# packages etc.
+case "${CEPH_BRANCH}~${DISTRO_KIND}" in
+    *~*centos*8)
+        dnf install -y java-1.8.0-openjdk-headless /usr/bin/rpmbuild wget
+        install_container_deps
+        dnf_clean
+    ;;
+    *~*centos*9|*~*centos*10*|*~fedora*)
+        dnf install -y /usr/bin/rpmbuild wget
+        install_container_deps
+        dnf_clean
+    ;;
+    *~*ubuntu*)
+        apt-get update
+        apt-get install -y wget reprepro
+        install_container_deps
+    ;;
+    *)
+        echo "Unknown action, branch or build: ${CEPH_BRANCH}~${DISTRO_KIND}" >&2
+        exit 2
+    ;;
+esac