Repository: intel/lkp-tests
Pull request #448: Create docker setup for rockylinux:9
Author: login: j-chiam
Created: 2025-03-05T01:56:17Z | Merged: 2025-03-05T14:46:12Z

Closes #415

Linked issue #415: docker: support rockylinux:9
### Acceptance Test
* run a few tests (pick 2-3) to confirm rt can be generated successfully
Linked issue comments: user: login: j-chiam
created_at: 2025-03-04T07:06:16Z
body: LKP_Team1 is working on this issue
author_association: NONE

Diff:
diff --git a/distro/adaptation-pkg/rocky b/distro/adaptation-pkg/rocky
new file mode 120000
index 000000000..95e189549
--- /dev/null
+++ b/distro/adaptation-pkg/rocky
@@ -0,0 +1 @@
+centos
\ No newline at end of file
diff --git a/distro/adaptation/centos-9 b/distro/adaptation/centos-9
index 237294423..34f982b02 100644
--- a/distro/adaptation/centos-9
+++ b/distro/adaptation/centos-9
@@ -13,7 +13,7 @@ grub-common: grub2-common
 libbabeltrace-ctf-dev: libbabeltrace-devel
 libbabeltrace-ctf1: libbabeltrace
 libbabeltrace-dev: libbabeltrace-devel
-libbpf-dev: libbpf-devel-1.3.0
+libbpf-dev: libbpf-devel
 libclang-dev: clang-devel
 libcunit1-dev: CUnit-devel
 libdw1: libdwarves1
diff --git a/distro/adaptation/rocky b/distro/adaptation/rocky
new file mode 120000
index 000000000..95e189549
--- /dev/null
+++ b/distro/adaptation/rocky
@@ -0,0 +1 @@
+centos
\ No newline at end of file
diff --git a/distro/adaptation/rocky-9 b/distro/adaptation/rocky-9
new file mode 120000
index 000000000..2e21de0dc
--- /dev/null
+++ b/distro/adaptation/rocky-9
@@ -0,0 +1 @@
+centos-9
\ No newline at end of file
diff --git a/distro/installer/rocky b/distro/installer/rocky
new file mode 120000
index 000000000..95e189549
--- /dev/null
+++ b/distro/installer/rocky
@@ -0,0 +1 @@
+centos
\ No newline at end of file
diff --git a/docker/rockylinux/Dockerfile b/docker/rockylinux/Dockerfile
new file mode 100644
index 000000000..3ae5fd139
--- /dev/null
+++ b/docker/rockylinux/Dockerfile
@@ -0,0 +1,27 @@
+# base image can be fedora:38, fedora:39 and etc
+ARG base_image
+FROM ${base_image}
+
+# lkp install generates hosts/$HOSTNAME during create_host_config. Here it requires
+# user to pass hostname arg to specify a consistent name instead of the container
+# hostname when building the image.
+ARG hostname=lkp-docker
+ENV HOSTNAME=${hostname}
+
+WORKDIR /lkp/lkp-tests
+
+COPY . ./
+
+RUN dnf upgrade -y && \
+    dnf install -y \
+    # kernel-tools installs turbostat
+    kernel-tools \
+    make \
+    # procps installs vmstat, sysctl, etc to partially persistent commonly used dependencies
+    procps \
+    perf \
+    hostname && \
+    make install && \
+    lkp install
+
+ENTRYPOINT ["bash", "-c", "sleep infinity"]
diff --git a/lib/detect-system.sh b/lib/detect-system.sh
index a08609d9d..08b5b71dc 100755
--- a/lib/detect-system.sh
+++ b/lib/detect-system.sh
@@ -152,6 +152,12 @@ detect_system()
 	then
 		_system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}'  ${rootfs}/etc/os-release | head -n 1)"
 		_system_name="Amazon Linux"
+    elif
+        [ -f ${rootfs}/etc/os-release ] &&
+            GREP_OPTIONS="" \command \grep 'ID="rocky"' ${rootfs}/etc/os-release >/dev/null
+    then
+        _system_name="Rocky"
+        _system_version="$(awk -F'=' '$1=="VERSION_ID"{gsub(/"/,"");print $2}' ${rootfs}/etc/os-release | awk -F'.' '{print $1}' | head -n 1)"
 	elif
 		[ -f ${rootfs}/etc/os-release ] &&
 			(GREP_OPTIONS="" \command \grep 'ID="opensuse-leap"' ${rootfs}/etc/os-release >/dev/null ||
diff --git a/lib/install.sh b/lib/install.sh
index cd941294d..ace203f6e 100755
--- a/lib/install.sh
+++ b/lib/install.sh
@@ -16,7 +16,7 @@ sync_distro_sources()
 		else
 			yum update
 		fi ;;
-	redhat) yum update ;;
+	redhat|rocky) yum update ;;
 	archlinux) yay -Sy --needed;;
 	opensuse)
 		zypper update ;;
@@ -151,6 +151,9 @@ map_python_packages()
 		opensuse-*)
 			map_python2_to_python3
 			;;
+		rocky-[9]*)
+			map_python2_to_python3
+			;;
 	esac
 }
 
diff --git a/lkp-exec/install b/lkp-exec/install
index 9195934e9..a23f14454 100755
--- a/lkp-exec/install
+++ b/lkp-exec/install
@@ -364,7 +364,7 @@ install_base_support()
 	create_host_config
 }
 
-enable_centos_source()
+enable_source_repository()
 {
 	if ! yum list installed | grep -q yum-utils; then
 		yum install -y yum-utils
@@ -388,7 +388,10 @@ distro=$_system_name_lowercase
 echo "distro=$distro"
 echo "version=$_system_version"
 
-[ "$distro" = "centos" ] && enable_centos_source
+# Enable source repositories for CentOS and Rocky Linux
+if [ "$distro" = "centos" ] || [ "$distro" = "rocky" ]; then
+    enable_source_repository
+fi
 
 DISTRO=$distro
 export DISTRO


Reviews:
user: login: rli9
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-05T03:45:04Z
user: login: rli9
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-05T03:49:35Z
user: login: rli9
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-05T03:50:24Z

Review comments:
diff_hunk: @@ -29,6 +29,7 @@ libpfm4: libpfm
 libpng12-dev:
 libpython2:
 libpython3: python3-libs
+libunwind:
path: distro/adaptation/centos-9
user: login: rli9
body: thanks, what is this change for? Seems libunwind package exists on centos-9
created_at: 2025-03-05T03:45:04Z
author_association: NONE
diff_hunk: @@ -148,6 +148,9 @@ map_python_packages()
 		centos-[9]*)
 			map_python2_to_python3
 			;;
+		redhat-[9]*)
path: lib/install.sh
user: login: rli9
body: is it possible to check detect-system.sh, so we can set _system_name="Rocky", but i'm not sure whether it contains file /etc/os-release or /etc/redhat-release, and what is the content.

If it can be named as Rocky, help add a soft link rockylinux-9 in distro-adaptation to point to centos-9.
created_at: 2025-03-05T03:49:35Z
author_association: NONE
diff_hunk: @@ -388,7 +388,10 @@ distro=$_system_name_lowercase
 echo "distro=$distro"
 echo "version=$_system_version"
 
-[ "$distro" = "centos" ] && enable_centos_source
+# Enable source repositories for CentOS and Rocky Linux
+if [ "$distro" = "centos" ] || [ "$distro" = "redhat" ]; then
path: lkp-exec/install
user: login: rli9
body: thanks, I think redhat also need this fix. For this issue, it's better the distro name can be rocky.
created_at: 2025-03-05T03:50:24Z
author_association: NONE

PR comments:
user: login: weishan18
created_at: 2025-03-05T01:58:20Z
body: Hackbench and schbench are able to run

- hackbench

![image](https://github.com/user-attachments/assets/cc79da90-cef4-4592-a6af-8640c356c44f)

- schbench

![image](https://github.com/user-attachments/assets/274bbf20-9e89-45fb-ac10-6ae2df82b787)

author_association: NONE
user: login: weishan18
created_at: 2025-03-05T09:27:38Z
body: @rli9 
Hi, thanks for the comments! I have updated the code, please help to review
![image](https://github.com/user-attachments/assets/29e5a411-1751-469f-91a0-6af8dac91ba3)

author_association: NONE
user: login: rli9
created_at: 2025-03-05T14:46:19Z
body: thanks for the patch
author_association: NONE