pkg-dist.mk, pkg.sh: Build RPMs in dist/build

pkg.sh hardcodes $HOME/rpmbuild as the rpmbuild topdir while make computes
the same location separately as PKG_DIR_BUILD, and a sandboxed shell cannot
build at all: rpmbuild writes its scratch trees and results under the
topdir, outside the project.

- Default PKG_DIR_BUILD to $(TOPDIR)/dist/build for non-root builds and
  pass it to pkg.sh as the new -T option (root keeps /usr/src/packages;
  local.mk can still override)
- Build with --define _topdir pointing at that directory, resolved to an
  absolute path, so the scratch tree, RPMS and SRPMS stay in the project
  tree where make clean drops them

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.87.0
This commit is contained in:
Jan Lindemann 2026-09-22 17:34:02 +02:00
commit c33d72f4d4
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
2 changed files with 12 additions and 5 deletions

View file

@ -524,11 +524,12 @@ build_pkg()
case "$PKG_FORMAT" in
rpm)
# --- build RPMs and copy them to source directory
local rpmbuild_root=$HOME/rpmbuild
[ `id -u` = 0 ] && rpmbuild_root=/usr/src/packages
local rpmbuild_root=${RPMBUILD_ROOT:-$HOME/rpmbuild}
mkdir -p $rpmbuild_root
rpmbuild_root=$(readlink -f $rpmbuild_root)
local rpmbuild_srpms=$rpmbuild_root/SRPMS
local rpmbuild_rpms=$rpmbuild_root/RPMS/$PKG_ARCH
rpmbuild -ta $DIST_PCKG_DIR/$tar_archive
rpmbuild --define "_topdir $rpmbuild_root" -ta $DIST_PCKG_DIR/$tar_archive
cp $rpmbuild_srpms/$src_base.src.rpm $DIST_PCKG_DIR/
cp $rpmbuild_rpms/$PKG_PROJECT-*-$version.$PKG_ARCH.rpm $DIST_PCKG_DIR/
;;
@ -1138,6 +1139,7 @@ PROJECT_DESCR_FILE=$TOPDIR/make/project.conf
DIST_SRC_DIR=dist/src
DIST_INST_DIR=dist/src
DIST_PCKG_DIR=dist/pckg
RPMBUILD_ROOT=""
PKG_PROJECT="$PROJECT"
PKG_REQUIRES_RUN=""
PKG_RECOMMENDS_RUN=""
@ -1160,6 +1162,10 @@ while [ ${1:0:1} = - ]; do
eval DIST_SRC_DIR=\"$2\"
shift
;;
-T)
eval RPMBUILD_ROOT=\"$2\"
shift
;;
-p)
eval DIST_PCKG_DIR=\"$2\"
shift