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.
This commit is contained in:
parent
1dbb1f8c68
commit
c1434a0b61
|
|
@ -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
|
||||
mkdir -p %{buildroot}/lib/systemd/system
|
||||
cp $systemd_unit %{buildroot}/lib/systemd/system/
|
||||
cp %{_sourcedir}/$(basename "$systemd_unit") %{buildroot}/lib/systemd/system/
|
||||
SPEC
|
||||
fi
|
||||
|
||||
cat >> "$spec_file" <<SPEC
|
||||
mkdir -p %{buildroot}/usr/share/doc/$pkg_name
|
||||
cp -r README.md %{buildroot}/usr/share/doc/$pkg_name/ 2>/dev/null || true
|
||||
cp -r %{_sourcedir}/README.md %{buildroot}/usr/share/doc/$pkg_name/ 2>/dev/null || true
|
||||
|
||||
%files
|
||||
/usr/local/bin/$pkg_name
|
||||
|
|
|
|||
Loading…
Reference in New Issue