Skip to content

Commit

Permalink
Merge pull request #249 from vespa-engine/toregge/build-test-rpms-for…
Browse files Browse the repository at this point in the history
…-almalinux-9

Add AlmaLinux 9 versions of rpm build scripts.
  • Loading branch information
aressem authored Oct 16, 2024
2 parents 0b8c429 + aee3c48 commit b6f4db5
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 1 deletion.
1 change: 1 addition & 0 deletions build/almalinux-9/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile.test
12 changes: 12 additions & 0 deletions build/almalinux-9/Dockerfile.test.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

FROM almalinux:9

# Java requires proper locale for unicode. Set container=docker to allow systemd in container mode.
ENV LANG=C.UTF-8 container=docker

# Change git reference for a specific version of the vespa.spec file.
# Use a tag or SHA to allow for reproducible builds.
ENV VESPA_SRC_REF="ae3f3a5ad659da2e34490cb6a2dd648745ac8248"

RUN @@MOUNTS_CMD@@ /bin/sh /include/install-build-dependencies.sh @@VESPADEV_RPM_SOURCE@@
43 changes: 43 additions & 0 deletions build/almalinux-9/build-test-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

ALMALINUX_VERSION=9test

# shellcheck disable=SC2209
VESPADEV_RPM_SOURCE=test

case "$1" in
test|external)
VESPADEV_RPM_SOURCE=$1
shift;;
esac

case "$VESPADEV_RPM_SOURCE" in
test) rpmbuild/refresh-test-repo;;
esac

IMG="vespaengine/vespa-build-almalinux-${ALMALINUX_VERSION}:latest"

WORKDIR=$(cd "$(dirname "$0")" && env pwd)
cd "$WORKDIR" || exit 1

# shellcheck disable=SC1091
. ../../shared/common.sh

MOUNTS_CMD=

case "$CONTAINER_ENGINE" in
podman) DOCKERFILE_MOUNTS_CMD=
MOUNTS_CMD="-v $WORKDIR/include:/include -v $WORKDIR/rpmbuild:/work"
;;
docker) DOCKERFILE_MOUNTS_CMD="--mount=type=bind,target=/include/,source=include/,rw --mount=type=bind,target=/work/,source=rpmbuild/,ro"
MOUNTS_CMD=""
;;
esac

sed -e "s;@@MOUNTS_CMD@@;$DOCKERFILE_MOUNTS_CMD;" -e "s,@@VESPADEV_RPM_SOURCE@@,$VESPADEV_RPM_SOURCE," Dockerfile.test.tmpl > Dockerfile.test

# shellcheck disable=SC2086
echo BUILDING: docker build --progress plain $MOUNTS_CMD -t "${IMG}" -f Dockerfile.test "$@" "$WORKDIR"
# shellcheck disable=SC2086
$CONTAINER_ENGINE build --progress plain $MOUNTS_CMD -t "${IMG}" -f Dockerfile.test "$@" "$WORKDIR"
14 changes: 13 additions & 1 deletion build/almalinux-9/include/install-build-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

set -xeu

VESPADEV_RPM_SOURCE="${1:-external}"

case "$VESPADEV_RPM_SOURCE" in
external|test) ;;
*) echo "Bad \$VESPADEV_RPM_SOURCE: $VESPADEV_RPM_SOURCE" 1>&2
exit 1;;
esac

# Enable and install repositories
dnf -y install epel-release
dnf -y install dnf-plugins-core
dnf -y copr enable @vespa/vespa "epel-9-$(arch)"
case "$VESPADEV_RPM_SOURCE" in
external) dnf -y copr enable @vespa/vespa "epel-9-$(arch)";;
test) /work/setup-test-repo;;
esac
dnf config-manager --enable crb

# Java requires proper locale for unicode
Expand Down Expand Up @@ -115,3 +126,4 @@ fi
# Cleanup
dnf clean all --enablerepo='*'
rm -rf /var/cache/yum
rm -f /etc/yum.repos.d/vespa-test.repo
27 changes: 27 additions & 0 deletions build/almalinux-9/rpmbuild/build-rpm-inner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh -ex
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

# shellcheck source=../../../shared-rpmbuild/build-rpm-inner-common.sh
. /shared-work/build-rpm-inner-common.sh

enable_repos()
{
dnf -y install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
dnf -y install 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
}

enable_modules()
{
dnf -y module enable maven:3.8
dnf -y module enable ruby:3.1
}

enable_cuda_repos()
{
enable_cuda_repos_helper rhel9
}

build_rpm_inner_common "$@"
11 changes: 11 additions & 0 deletions build/almalinux-9/rpmbuild/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

cd "$(cd "$(dirname "$0")" && env pwd)" || exit 1

. ../../../shared-rpmbuild/build-rpm-common.sh

DOCKER_IMAGE=almalinux:9
CONTAINER_SHORTNAME=a9

build_rpm_common "$@"
17 changes: 17 additions & 0 deletions build/almalinux-9/rpmbuild/refresh-test-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

WORKDIR=$(cd "$(dirname "$0")" && env pwd)
cd "$WORKDIR" || exit 1

. ../../../shared/common.sh


if test -f /usr/bin/createrepo_c
then
mkdir -p "RPMS/$(arch)"
createrepo_c "RPMS/$(arch)"
else
# shellcheck disable=SC2016
$CONTAINER_ENGINE run --rm -v "$WORKDIR:/work" docker.io/almalinux:9 bash -c 'dnf -y install createrepo_c && mkdir -p /work/RPMS/$(arch) && createrepo_c /work/RPMS/$(arch) && chown -R --ref /work/build-rpm-inner.sh /work/RPMS'
fi
7 changes: 7 additions & 0 deletions build/almalinux-9/rpmbuild/setup-test-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

# To be run inside a docker container
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --add-repo=/work/vespa-test.repo
dnf config-manager --enable vespa-test
7 changes: 7 additions & 0 deletions build/almalinux-9/rpmbuild/vespa-test.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
[vespa-test]
name=vespa-test
baseurl=file:///work/RPMS/$basearch
enabled=0
gpgcheck=0

0 comments on commit b6f4db5

Please sign in to comment.