From af62c434650fce6dbc25fecb1271b49e4b4776ed Mon Sep 17 00:00:00 2001 From: toto Date: Tue, 3 Mar 2026 22:26:00 +0000 Subject: [PATCH] fix(rpm): copy files to BUILD dir instead of source archive Simplified rpmbuild process: - Copy files directly to BUILD directory (no tar archive) - Use --noclean flag to preserve BUILD contents - Use %{_builddir} macro in spec file instead of %{_sourcedir} This avoids the complexity of source archive creation/extraction and fixes the 'No such file or directory' error. Co-authored-by: Qwen-Coder --- Dockerfile.package | 12 ++++++------ packaging/rpm/logcorrelator.spec | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Dockerfile.package b/Dockerfile.package index 3e7da35..6f33408 100644 --- a/Dockerfile.package +++ b/Dockerfile.package @@ -32,18 +32,18 @@ mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} # Copy spec file cp /build/packaging/rpm/logcorrelator.spec /root/rpmbuild/SPECS/ -# Create source archive (required by rpmbuild) -# Archive contains the pre-built binary and all config files -tar -czf /root/rpmbuild/SOURCES/logcorrelator-${VERSION}.tar.gz \ - -C /tmp/pkgroot \ - usr etc var +# Copy files directly to BUILD directory (no archive needed) +# This is simpler than creating/extracting a source archive +cp -r /tmp/pkgroot/* /root/rpmbuild/BUILD/ # Build RPM using rpmbuild +# Use --noclean to keep BUILD directory contents rpmbuild -bb /root/rpmbuild/SPECS/logcorrelator.spec \ --define "version ${VERSION}" \ --define "dist .${DIST_NAME}" \ --define "_topdir /root/rpmbuild" \ - --define "_rpmdir /packages/rpm/${DIST_NAME}" + --define "_rpmdir /packages/rpm/${DIST_NAME}" \ + --noclean # Ensure output directory exists and copy RPM mkdir -p /packages/rpm/${DIST_NAME} diff --git a/packaging/rpm/logcorrelator.spec b/packaging/rpm/logcorrelator.spec index 82f2bba..a419ec0 100644 --- a/packaging/rpm/logcorrelator.spec +++ b/packaging/rpm/logcorrelator.spec @@ -32,8 +32,10 @@ Notes de sécurité : - /var/run/logcorrelator est en 755 pour permettre la création de sockets %prep -# No source extraction needed - binary is pre-built -# Files are already in the source archive +# Files are already in BUILD directory (copied by build-rpm.sh) +# No extraction needed +echo "Files available in BUILD directory:" +ls -la %{_builddir}/ %install # Create directory structure in buildroot @@ -45,18 +47,18 @@ mkdir -p %{buildroot}/var/lib/logcorrelator mkdir -p %{buildroot}/etc/systemd/system mkdir -p %{buildroot}/etc/logrotate.d -# Install binary (from source archive extracted in SOURCES) -install -m 0755 %{_sourcedir}/usr/bin/logcorrelator %{buildroot}/usr/bin/logcorrelator +# Install binary (from BUILD directory) +install -m 0755 %{_builddir}/usr/bin/logcorrelator %{buildroot}/usr/bin/logcorrelator # Install config files -install -m 0640 %{_sourcedir}/etc/logcorrelator/logcorrelator.yml %{buildroot}/etc/logcorrelator/logcorrelator.yml -install -m 0640 %{_sourcedir}/etc/logcorrelator/logcorrelator.yml.example %{buildroot}/etc/logcorrelator/logcorrelator.yml.example +install -m 0640 %{_builddir}/etc/logcorrelator/logcorrelator.yml %{buildroot}/etc/logcorrelator/logcorrelator.yml +install -m 0640 %{_builddir}/etc/logcorrelator/logcorrelator.yml.example %{buildroot}/etc/logcorrelator/logcorrelator.yml.example # Install systemd service -install -m 0644 %{_sourcedir}/etc/systemd/system/logcorrelator.service %{buildroot}/etc/systemd/system/logcorrelator.service +install -m 0644 %{_builddir}/etc/systemd/system/logcorrelator.service %{buildroot}/etc/systemd/system/logcorrelator.service # Install logrotate config -install -m 0644 %{_sourcedir}/etc/logrotate.d/logcorrelator %{buildroot}/etc/logrotate.d/logcorrelator +install -m 0644 %{_builddir}/etc/logrotate.d/logcorrelator %{buildroot}/etc/logrotate.d/logcorrelator %post # Create logcorrelator user and group