From c1434a0b61a20772dc47bd9a4bda2aae668e4cea Mon Sep 17 00:00:00 2001 From: mirivlad Date: Mon, 8 Jun 2026 18:27:58 +0800 Subject: [PATCH] fix(release): use %{_sourcedir} in RPM spec instead of absolute paths rpmbuild runs %install from its own working directory where is undefined. Copy artifacts into SOURCES and use rpmbuild's %{_sourcedir} macro to locate them. --- scripts/release.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 7f9217a..18466bd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -144,6 +144,7 @@ build_rpm() { mkdir -p "$buildroot/usr/local/bin" mkdir -p "$buildroot/usr/share/doc/$pkg_name" + # Copy binary and systemd unit into the buildroot cp "$BUILD_DIR/$binary" "$buildroot/usr/local/bin/$pkg_name" chmod 755 "$buildroot/usr/local/bin/$pkg_name" @@ -154,6 +155,13 @@ build_rpm() { [[ -f "README.md" ]] && cp "README.md" "$buildroot/usr/share/doc/$pkg_name/" + # Also copy into SOURCES so rpmbuild %install can find them + cp "$BUILD_DIR/$binary" "$rpm_dir/SOURCES/$pkg_name" + if [[ -n "$systemd_unit" && -f "$systemd_unit" ]]; then + cp "$systemd_unit" "$rpm_dir/SOURCES/$(basename "$systemd_unit")" + fi + [[ -f "README.md" ]] && cp "README.md" "$rpm_dir/SOURCES/README.md" + # File list local file_list file_list="%attr(755, root, root) /usr/local/bin/$pkg_name" @@ -183,20 +191,20 @@ $description %install rm -rf %{buildroot} mkdir -p %{buildroot}/usr/local/bin -cp $BUILD_DIR/$binary %{buildroot}/usr/local/bin/$pkg_name +cp %{_sourcedir}/$pkg_name %{buildroot}/usr/local/bin/$pkg_name chmod 755 %{buildroot}/usr/local/bin/$pkg_name SPEC if [[ -n "$systemd_unit" && -f "$systemd_unit" ]]; then cat >> "$spec_file" <> "$spec_file" </dev/null || true +cp -r %{_sourcedir}/README.md %{buildroot}/usr/share/doc/$pkg_name/ 2>/dev/null || true %files /usr/local/bin/$pkg_name