From 02807d3d9636af569b6d41106321022b794f47f2 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 28 Oct 2024 16:47:49 -0600 Subject: [PATCH] ceph-dev-new-build: Set up sccache if requested Signed-off-by: Zack Cerza --- ceph-dev-new-build/build/build_rpm | 1 + ceph-dev-new-build/build/setup_rpm | 6 ++++ .../config/definitions/ceph-dev-new-build.yml | 1 + scripts/setup_sccache.sh | 33 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 scripts/setup_sccache.sh diff --git a/ceph-dev-new-build/build/build_rpm b/ceph-dev-new-build/build/build_rpm index c2a6ac5c..22987d4f 100644 --- a/ceph-dev-new-build/build/build_rpm +++ b/ceph-dev-new-build/build/build_rpm @@ -48,6 +48,7 @@ PACKAGE_MANAGER_VERSION="$RPM_VERSION-$RPM_RELEASE" BUILDAREA=$(setup_rpm_build_area ./rpm/$dist) build_rpms ${BUILDAREA} "${CEPH_EXTRA_RPMBUILD_ARGS}" +[ "$SCCACHE" = true ] && sccache -s build_ceph_release_rpm ${BUILDAREA} true # Make sure we execute at the top level directory diff --git a/ceph-dev-new-build/build/setup_rpm b/ceph-dev-new-build/build/setup_rpm index 0c130940..8a6908b6 100644 --- a/ceph-dev-new-build/build/setup_rpm +++ b/ceph-dev-new-build/build/setup_rpm @@ -76,3 +76,9 @@ if [ "$THROWAWAY" = false ] ; then # TODO if this exits we need to post to shaman a success check_binary_existence $VENV $chacra_check_url fi + +if [ "$SCCACHE" = true ] ; then + write_sccache_conf + write_aws_credentials + install_sccache +fi diff --git a/ceph-dev-new-build/config/definitions/ceph-dev-new-build.yml b/ceph-dev-new-build/config/definitions/ceph-dev-new-build.yml index 90ee5a8a..92c1d560 100644 --- a/ceph-dev-new-build/config/definitions/ceph-dev-new-build.yml +++ b/ceph-dev-new-build/config/definitions/ceph-dev-new-build.yml @@ -90,6 +90,7 @@ !include-raw: - ../../build/validate_rpm - ../../../scripts/build_utils.sh + - ../../../scripts/setup_sccache.sh - ../../build/setup_rpm - ../../build/build_rpm # osc build scripts diff --git a/scripts/setup_sccache.sh b/scripts/setup_sccache.sh new file mode 100644 index 00000000..2b9b8ccf --- /dev/null +++ b/scripts/setup_sccache.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# vim: ts=4 sw=4 expandtab + +set -ex + +function write_sccache_conf() { + export SCCACHE_CONF=$WORKSPACE/sccache.conf + cat << EOF > $SCCACHE_CONF +[cache.s3] +bucket = "ceph-sccache" +endpoint = "s3.us-south.cloud-object-storage.appdomain.cloud" +use_ssl = true +key_prefix = "" +server_side_encryption = false +no_credentials = false +region = "auto" +EOF +} + +function write_aws_credentials() { + export AWS_PROFILE=default + mkdir -p $HOME/.aws + cat << EOF > $HOME/.aws/credentials +[default] +aws_access_key_id = ${AWS_ACCESS_KEY_ID} +aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY} +EOF +} + +function install_sccache () { + SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v0.8.2/sccache-v0.8.2-$(uname -m)-unknown-linux-musl.tar.gz" + curl -L $SCCACHE_URL | sudo tar --no-anchored --strip-components=1 -C /usr/local/bin/ -xzf - sccache +} -- 2.39.5