Skip to content

Commit

Permalink
ansible: add rhel9_arm_cross containers
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlau committed Sep 4, 2024
1 parent 164cd5b commit 315f6f0
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ansible/roles/docker/files/cc-selector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,33 @@
# cross-compiler-ubuntu1804-armv7-gcc-8
# cross-compiler-rhel8-armv7-gcc-8-glibc-2.28
# cross-compiler-rhel8-armv7-gcc-10-glibc-2.28
# cross-compiler-rhel9-armv7-gcc-12-glibc-2.28

rpi_newer_tools_base="/opt/raspberrypi/rpi-newer-crosstools/"
base_4_9_4="${rpi_newer_tools_base}x64-gcc-4.9.4-binutils-2.28/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"
base_6="${rpi_newer_tools_base}x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"
base_8="${rpi_newer_tools_base}x64-gcc-8.3.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"
base_8_glibc_2_28="${rpi_newer_tools_base}x64-gcc-8.3.0-glibc-2.28/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"
base_10_glibc_2_28="${rpi_newer_tools_base}x64-gcc-10.3.0-glibc-2.28/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"
base_12_glibc_2_28="${rpi_newer_tools_base}x64-gcc-12.3.0-glibc-2.28/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-"

flags_armv6="-march=armv6zk"
flags_armv7="-march=armv7-a"

function run {
local label="$1"

export arm_type=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel8)-(armv[67])-gcc-.*$/\2/')
export gcc_version=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel8)-armv[67]-gcc-(4\.9\.4|6|8|10)/\2/')
export arm_type=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel[89])-(armv[67])-gcc-.*$/\2/')
export gcc_version=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel[89])-armv[67]-gcc-(4\.9\.4|6|8|10|12)/\2/')
export git_branch="cc-${arm_type}"
export host_os=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel8)-(armv[67])-gcc-.*$/\1/')
export host_os=$(echo $label | sed -E 's/^cross-compiler-(ubuntu1[68]04|rhel[89])-(armv[67])-gcc-.*$/\1/')

if [[ ! "$arm_type" =~ ^armv[67]$ ]]; then
echo "Could not determine ARM type from '$label'"
exit 1
fi
if [[ ! "$gcc_version" =~ ^(4\.9\.4|6|8|8-glibc-2.28|10-glibc-2.28)$ ]]; then
echo "Could not determine ARM type from '$label'"
if [[ ! "$gcc_version" =~ ^(4\.9\.4|6|8|8-glibc-2\.28|10-glibc-2\.28|12-glibc-2\.28)$ ]]; then
echo "Could not determine gcc version from '$label'"
exit 1
fi

Expand All @@ -49,10 +51,11 @@ function run {

export ARCH="${arm_type}l"
export DESTCPU=arm
if [ "$host_os" = "rhel8" ]; then
if [ "$host_os" = "rhel8" ] || [ "$host_os" = "rhel9" ]; then
current_gcc_version="$(gcc -dumpversion)"
# Additional gcc versions are installed via gcc-toolset-<n> packages.
# No such package exists for the default gcc version (8 on RHEL 8).
# No such package exists for the default gcc version (8 on RHEL 8,
# 11 on RHEL 9).
if [ "${current_gcc_version}" != "${gcc_host_version}" ]; then
if ! . /opt/rh/gcc-toolset-${gcc_host_version}/enable; then
echo "Host gcc version mismatch (wanted ${gcc_host_version} but got ${current_gcc_version})."
Expand Down
67 changes: 67 additions & 0 deletions ansible/roles/docker/templates/rhel9_arm_cross.Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM registry.access.redhat.com/ubi9:latest

ENV LC_ALL C
ENV USER {{ server_user }}
ENV JOBS {{ server_jobs | default(ansible_processor_vcpus) }}
ENV SHELL /bin/bash
ENV PATH /usr/lib64/ccache:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV NODE_COMMON_PIPE /home/{{ server_user }}/test.pipe
ENV NODE_TEST_DIR /home/{{ server_user }}/tmp
ENV OSTYPE linux-gnu
ENV OSVARIANT docker
ENV DESTCPU {{ arch }}
ENV ARCH {{ arch }}

# ccache is not in the default repositories so get it from EPEL 8.
RUN dnf install --disableplugin=subscription-manager -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
&& dnf update --disableplugin=subscription-manager -y \
&& dnf install --disableplugin=subscription-manager -y \
ccache \
gcc-c++ \
gcc-toolset-12 \
gcc-toolset-12-libstdc++-devel \
gcc-toolset-12-libstdc++-devel.i686 \
git \
glibc-devel.i686 \
java-17-openjdk-headless \
libatomic.i686 \
libstdc++-devel \
libstdc++-devel.i686 \
make \
python3 \
python3-pip \
procps-ng \
xz \
&& dnf --disableplugin=subscription-manager clean all

RUN groupadd -r -g {{ server_user_gid.stdout_lines[0] }} {{ server_user }} \
&& adduser -r -m -d /home/{{ server_user }}/ \
-g {{ server_user_gid.stdout_lines[0] }} \
-u {{ server_user_uid.stdout_lines[0] }} {{ server_user }}

VOLUME /home/{{ server_user }}/ /home/{{ server_user }}/.ccache

ENV PYTHON /usr/bin/python3

RUN pip3 install tap2junit=={{ tap2junit_version }}

RUN git clone --depth=1 https://github.com/rvagg/rpi-newer-crosstools.git /opt/raspberrypi/rpi-newer-crosstools

COPY cc-selector.sh /opt/raspberrypi/cc-selector.sh

RUN chmod 755 /opt/raspberrypi/cc-selector.sh

USER {{ server_user }}:{{ server_user }}

ENV CCACHE_TEMPDIR /home/{{ server_user }}/.ccache/{{ item.name }}

WORKDIR /home/{{ server_user }}

CMD cd /home/{{ server_user }} \
&& curl https://ci.nodejs.org/jnlpJars/agent.jar -O \
&& java -Xmx{{ server_ram|default('128m') }} \
-jar /home/{{ server_user }}/agent.jar \
-url {{ jenkins_url }} \
-name {{ item.name }} \
-secret {{ item.secret }}
2 changes: 2 additions & 0 deletions jenkins/scripts/VersionSelectorScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def buildExclusions = [
[ /^cross-compiler-ubuntu1804-armv7-gcc-8/, anyType, gte(18) ],
[ /^cross-compiler-rhel8-armv7-gcc-8-glibc-2.28/, anyType, gte(20) ],
[ /^cross-compiler-rhel8-armv7-gcc-10-glibc-2.28/, anyType, lt(20) ],
[ /^cross-compiler-rhel8-armv7-gcc-10-glibc-2.28/, anyType, gte(23) ],
[ /^cross-compiler-rhel9-armv7-gcc-12-glibc-2.28/, anyType, lt(23) ],

// Windows -----------------------------------------------
// https://github.com/nodejs/build/blob/main/doc/windows-visualstudio-supported-versions.md
Expand Down

0 comments on commit 315f6f0

Please sign in to comment.