Add packaging tooling
Build and provide rpm of demus-packaging-utils / Build and deploy an rpm to the demus.dk repo (f42) (release) Failing after 34s
Build and provide rpm of demus-packaging-utils / Build and deploy an rpm to the demus.dk repo (f43) (release) Failing after 33s
Build and provide rpm of demus-packaging-utils / Build and deploy an rpm to the demus.dk repo (f44) (release) Failing after 33s
Build and provide rpm of demus-packaging-utils / Build and deploy an rpm to the demus.dk repo (rawhide) (release) Failing after 9s

* regenerate-from-spec: Regenerate tool-generated sources referred to in a spec file
* go-vendor-update: An alias that replicates the parameters used by go2rpm to generate the vendor archive and configuration. It is used in the above regenerate script.
* verify_source_checksum rpm macro: Validate that the checksums in a sources file included in a spec matches the unpacked files.
This commit is contained in:
2026-06-05 11:32:54 +02:00
parent e0d563b313
commit 153d894253
6 changed files with 95 additions and 1 deletions
+5 -1
View File
@@ -1,3 +1,7 @@
# demus-packaging-utils
Aliases and scripts to assist in rpm packaging workflows
Aliases, scripts and rpm macros to assist in rpm packaging workflows
* regenerate-from-spec: Regenerate tool-generated sources referred to in a spec file
* go-vendor-update: An alias that replicates the parameters used by go2rpm to generate the vendor archive and configuration. It is used in the above regenerate script.
* verify_source_checksum rpm macro: Validate that the checksums in a sources file included in a spec matches the unpacked files.
+48
View File
@@ -0,0 +1,48 @@
Name: demus-packaging-utils
Version: 0.1.0
Release: %autorelease
Summary: Aliases and scripts to assist in rpm packaging workflows
License: GPL3
Source: go-vendor-update.sh
Source: regenerate-from-spec.sh
Source: macros.demus-packaging
Source: LICENSE
Source: README.md
Requires: bash go-vendor-tools
BuildArch: noarch
%description
* Alias to regenerate vendor archive in a go2rpm spec generated with the vendor profile
%global regen_basename %(basename "%{S:1}" .sh)
%prep
%if %{exists:%{S:2}}
%{load:%{S:2}}
%verify_source_checksum
%endif
%build
%install
%{__install} -m 0755 -d %{buildroot}%{_sysconfdir}/profile.d
%{__install} -m 0755 -d %{buildroot}%{_bindir}
%{__install} -m 0755 -d %{buildroot}%{_rpmmacrodir}
%{__install} -p -m 644 -t %{buildroot}%{_sysconfdir}/profile.d %{S:0}
%{__install} -p -m 755 %{S:1} %{buildroot}%{_bindir}/%regen_basename
%{__install} -p -m 755 %{S:2} %{buildroot}%{_rpmmacrodir}/
%{__install} -p -m 644 %{S:3} %{S:4} %{_builddir}
%files
%doc README.md
%license LICENSE
%{_sysconfdir}/profile.d/*
%{_bindir}/%regen_basename
%{_rpmmacrodir}/*
%changelog
%autochangelog
+2
View File
@@ -0,0 +1,2 @@
# Update go vendor archive and config emulating the way go2rpm does it
alias go-vendor-update='go_vendor_archive create --config go-vendor-tools.toml --write-config '
+11
View File
@@ -0,0 +1,11 @@
# Verify that the checksums listed in the given file match the checksums of the files in the current directory.
# If the checksum doesn't match an message is printed and the subshell is exited with a non-zero status,
# in order to fail the build.
# The macro should be the first statement in the %prep section.
#
# Control variables, flags and arguments:
# -s path to the file containing the list of checksums. If not provided, the default value is 'sources'
%verify_source_checksum(s:) %{expand:
%define checksumresult %{expand:%(cksum --check --quiet "%{-s:%{-s*}}%{!-s:sources}" 2>/dev/null)}
%[ %{len:%checksumresult} > 0 ? "echo -e 'ERROR: Checksums do not match\\n%{checksumresult}'; exit 1" : "%{nil}" ]
}
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# Update various generated artifacts in rpm packages
# * Go vendor archive and config
# * COPR source file
shopt -s extglob
if [ $# -ne 1 ] || ! [[ "$1" =~ .*.\.spec$ ]]; then
echo "Please provide one .spec file"
echo "Usage: regenerate-from-spec <specfile>.spec"
exit 1
fi
if grep -q go-vendor-tools.toml "$1"; then
echo Updating go vendor archive
go-vendor-update "$1"
fi
# Update the sources checksums
# We assume all files are lowercase except README and LICENSE files
echo Calculating checksums
cksum -a sha512 {[a-z],README*,LICENSE*}!(ources) > sources
echo Done
+6
View File
@@ -0,0 +1,6 @@
SHA512 (demus-packaging-utils.spec) = 42deb38489e0c6b72b7556263ebffe6d55faa730027201379f7e7cb989b4faeed05c590d69914e5bc635ecb420dddc42710a546e972db2730695b2c3e40b4350
SHA512 (go-vendor-update.sh) = 4ba1a21e84d91d37e66a7ade8eea09bb278ac87d8ea731420c0f56064424cbcc43e1d1f3d80b727472c6a6adeaefb22c909e949b7009c0f6e6bb7c3ace9268dc
SHA512 (macros.demus-packaging) = 84bd7b1e4f55a3603f96bc55df4cf1b4103a15dbcdea04b39978da0878f35abae4972b8d43aba5fe19eb45a238244ca2b1b782fa5dbc1300e0b738cbe807b8f5
SHA512 (regenerate-from-spec.sh) = 4ff702f94a97aa99a4ec8a4e899ef09e08ce8217eb0212c60a533677da46669ed7b56d26e6243fbd24de2ceba9480a62de84ed8be01223744da75433fa77341f
SHA512 (README.md) = 72a6f0085fea6d2b5736c4fa98f31db8fb42462db6fe65d44de7e99405982cc2330e270f6fb042d598d4136bd2a933e226ae85fb99828e07af6ab2b74a5c89f2
SHA512 (LICENSE) = ccb0f3b838dff6254510f19c2bd6f5c48e38b8c40a5bf93d38482f4fb31015823741d3f160b6836ec99bd8f4e6c5fa9a5c9196ecdd7775b793f3ada50467aabd