From 8685dcf9a3e5b7113e40b5ac1c00d974c3101430 Mon Sep 17 00:00:00 2001 From: Enrique Belarte Luque Date: Thu, 6 Feb 2025 05:22:58 -0600 Subject: [PATCH] Update config files Add a single point of settings and functions to download external driver version lists Signed-off-by: Enrique Belarte Luque --- Containerfile | 4 ++-- argfile.conf | 13 ++++++++----- scripts/check-changes.py | 1 - scripts/re-matrix.py | 11 ++++++++++- scripts/read-argfile.py | 16 ++++++++++++++++ 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 scripts/read-argfile.py diff --git a/Containerfile b/Containerfile index 28f0032..6b5406a 100644 --- a/Containerfile +++ b/Containerfile @@ -75,11 +75,11 @@ RUN dnf -y install git git-lfs xz && \ rm -rf /var/cache/yum RUN --mount=type=secret,id=${AUTH_SECRET}/PRIVATE_GITLAB_TOKEN echo "export PRIVATE_GITLAB_TOKEN="$(cat /run/secrets/${AUTH_SECRET}/PRIVATE_GITLAB_TOKEN) >> /tmp/envfile RUN source /tmp/envfile && \ - git clone https://gitlab-ci-token:${PRIVATE_GITLAB_TOKEN}@gitlab.com/ebelarte/artifact-storage.git && \ + git clone https://gitlab-ci-token:${PRIVATE_GITLAB_TOKEN}@${UPLOAD_ARTIFACT_REPO} && \ cd artifact-storage && \ git lfs install && \ git lfs track "*.tar.xz" && \ - git remote set-url origin "https://gitlab-ci-token:${PRIVATE_GITLAB_TOKEN}@gitlab.com/ebelarte/artifact-storage.git" && \ + git remote set-url origin "https://gitlab-ci-token:${PRIVATE_GITLAB_TOKEN}@{UPLOAD_ARTIFACT_REPO}" && \ git config --global user.email "ebelarte-build-and-sign-tests@tests.redhat.com" && \ git config --global user.name "CI build LFS bot" && \ tar -cvJf ${DRIVER_VENDOR}-${DRIVER_VERSION}-${KERNEL_VERSION}.tar.xz /opt/drivers && \ diff --git a/argfile.conf b/argfile.conf index 53c5b07..9c59a7e 100644 --- a/argfile.conf +++ b/argfile.conf @@ -1,11 +1,14 @@ -DRIVER_REPO=https://github.com/NVIDIA/open-gpu-kernel-modules.git -DRIVER_VERSION=565.77 -DRIVER_VENDOR=nvidia-opengpu -ADDITIONAL_BUILD_DEPS=gcc-c++ DTK_IMAGE=quay.io/redhat-user-workloads/partners-kmod-accel-tenant/pa-driver-toolkit:ee183d162f9f41f83be39c4b362165e0eec8051f -DRIVER_IMAGE=registry.redhat.io/ubi9/ubi@sha256:b632d0cc6263372a90e9097dcac0a369e456b144a66026b9eac029a22f0f6e07 +ADDITIONAL_BUILD_DEPS=gcc-c++ SIGNER_SDK_IMAGE=quay.io/redhat-user-workloads/partners-kmod-accel-tenant/klerk:75ad7b90c81b5056b69ff5407a3a2e218d4bbdbc +DRIVER_IMAGE=registry.redhat.io/ubi9/ubi@sha256:b632d0cc6263372a90e9097dcac0a369e456b144a66026b9eac029a22f0f6e07 +# AWS settings AWS_DEFAULT_REGION=us-east-1 AUTH_SECRET=external-auth-secret AWS_KMS_KEY_LABEL=my-test-key +# Vendor settings +DRIVER_VER_JSON=https://raw.githubusercontent.com/rh-ecosystem-edge/build-and-sign/refs/heads/main/data/driver-list.json +DRIVER_REPO=https://github.com/NVIDIA/open-gpu-kernel-modules.git +DRIVER_VERSION=565.77 +DRIVER_VENDOR=nvidia-opengpu UPLOAD_ARTIFACT_REPO=gitlab.com/ebelarte/artifact-storage.git diff --git a/scripts/check-changes.py b/scripts/check-changes.py index 175beb7..4652014 100644 --- a/scripts/check-changes.py +++ b/scripts/check-changes.py @@ -3,7 +3,6 @@ import requests import os -# File paths matrix_json_file = "data/combined_output.json" argsfile = "argfile.conf" token = os.getenv("TOKEN") diff --git a/scripts/re-matrix.py b/scripts/re-matrix.py index c0709e5..00ca877 100644 --- a/scripts/re-matrix.py +++ b/scripts/re-matrix.py @@ -1,9 +1,18 @@ import json import os import md5mod +import urllib.request +import read-argfile + +# Download driver_info_file from argfile.conf +config = read_key_value_file() +DRIVER_VER_JSON = config.get("DRIVER_VER_JSON", "Key 'DRIVER_VER_JSON' not found.") +download_dir = "/vendor" +os.makedirs(download_dir, exist_ok=True) # Sources for kernel versions and driver versions -driver_info_file = "data/driver-list.json" +driver_info_file = download_file(DRIVER_VER_JSON, os.path.join(download_dir, os.path.basename(DRIVER_VER_JSON))) if DRIVER_VER_JSON.startswith("http") else "Invalid URL" +#driver_info_file = "data/driver-list.json" kernel_versions_file = "data/kernel-list.json" matrix_file = "data/combined_output.json" diff --git a/scripts/read-argfile.py b/scripts/read-argfile.py new file mode 100644 index 0000000..479de3c --- /dev/null +++ b/scripts/read-argfile.py @@ -0,0 +1,16 @@ +def read_key_value_file(filename="argfile.conf"): + data = {} + with open(filename, "r") as file: + for line in file: + line = line.strip() + if line and "=" in line: + key, value = line.split("=", 1) + data[key.strip()] = value.strip() + return data + +def download_file(url, save_path): + try: + urllib.request.urlretrieve(url, save_path) + return save_path + except Exception as e: + return f"Error downloading file: {e}"