From 84f33b97d70d9603be797c144724f07609e9e0e7 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Fri, 1 May 2026 11:12:21 +0300 Subject: [PATCH] kbuild: Fix rpm builds in userspace Signed-off-by: Denys Fedoryshchenko --- .github/workflows/docker_images.yml | 5 ++--- kernelci/kbuild.py | 17 +++++++++++++++++ pyproject.toml | 2 +- requirements-dev.txt | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker_images.yml b/.github/workflows/docker_images.yml index 41aa628431..91d5180a17 100644 --- a/.github/workflows/docker_images.yml +++ b/.github/workflows/docker_images.yml @@ -52,7 +52,7 @@ jobs: run: | pip3 install --upgrade pip cd kernelci-core - python3 -m pip install '.[dev]' --break-system-packages + python3 -m pip install -r requirements-dev.txt --break-system-packages sudo cp -R config /etc/kernelci/ - name: Cache apt packages uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.4 @@ -148,7 +148,7 @@ jobs: run: | pip3 install --upgrade pip cd kernelci-core - python3 -m pip install '.[dev]' --break-system-packages + python3 -m pip install -r requirements-dev.txt --break-system-packages sudo cp -R config /etc/kernelci/ - name: Cache apt packages uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # v1.5.4 @@ -202,4 +202,3 @@ jobs: DHNAME=$(./kci docker name --prefix=kernelci/staging- ${{ matrix.kcicmd }}) docker tag $NAME $DHNAME docker push $DHNAME - diff --git a/kernelci/kbuild.py b/kernelci/kbuild.py index 0e45449974..b198849079 100644 --- a/kernelci/kbuild.py +++ b/kernelci/kbuild.py @@ -847,6 +847,16 @@ def _build_with_tuxmake(self): tuxmake_cmd = " ".join(cmd_parts) print(f"[_build_with_tuxmake] Command: {tuxmake_cmd}") print(f"[_build_with_tuxmake] Output directory: {self._af_dir}") + # rpm defaults to /var/lib/rpm which a non-root build user cannot + # write to. Redirect _dbpath and _topdir into the workspace via + # ~/.rpmmacros so rpmdb and any rpmbuild invoked by tuxmake's + # *rpm-pkg targets share a writable location. + rpm_root = f"{self._workspace}/rpm" + self.addcmd(f"mkdir -p {rpm_root}/db {rpm_root}/build") + self.addcmd( + f"printf '%%_dbpath {rpm_root}/db\\n" + f"%%_topdir {rpm_root}/build\\n' > $HOME/.rpmmacros" + ) self.addcmd("rpmdb --initdb 2>/dev/null || true") self.addcmd("stage=1") # stage 1 failure is build failure self.addcmd(tuxmake_cmd) @@ -868,6 +878,13 @@ def _build_with_tuxmake(self): f"fi" ) + # Collect any rpm/srpm artifacts produced under our _topdir + # (set in ~/.rpmmacros above) so they land in af_dir for upload. + self.addcmd( + f"find {rpm_root}/build \\( -name '*.rpm' -o -name '*.src.rpm' \\) " + f"-exec cp {{}} {self._af_dir}/ \\; 2>/dev/null || true" + ) + self.addcmd("cd ..") if not self._dtbs_check and self._kselftest: diff --git a/pyproject.toml b/pyproject.toml index a55ba46a00..de399210de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,7 @@ dev = [ "mypy==1.19.1", "pre-commit==4.3.0", "pytest-mock==3.15.1", - "ruff >= 0.9.0", + "ruff==0.11.5", "types-PyYAML==6.0.12.20250915", "types-requests==2.32.4.20260107", "types-urllib3==1.26.25.14", diff --git a/requirements-dev.txt b/requirements-dev.txt index f06d89a817..2292bd49cc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ mypy==1.19.1 pre-commit==4.3.0 pytest-mock==3.15.1 -ruff>=0.9.0 +ruff==0.11.5 types-PyYAML==6.0.12.20250915 types-requests==2.32.4.20260107 types-urllib3==1.26.25.14