Add fedora rpm building
All checks were successful
CI / test (push) Successful in 36s
Lint / test (push) Successful in 26s
Trivy / test (push) Successful in 16s

This commit is contained in:
Miguel Jacq 2025-12-27 16:54:46 +11:00
parent e652e9dbf3
commit ad32d27ea2
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
3 changed files with 163 additions and 0 deletions

86
Dockerfile.rpmbuild Normal file
View file

@ -0,0 +1,86 @@
# syntax=docker/dockerfile:1
FROM fedora:42
RUN set -eux; \
dnf -y update; \
dnf -y install \
rpm-build \
rpmdevtools \
redhat-rpm-config \
gcc \
make \
findutils \
tar \
gzip \
rsync \
python3 \
python3-devel \
python3-setuptools \
python3-wheel \
pyproject-rpm-macros \
python3-rpm-macros \
python3-yaml \
python3-tomli \
python3-defusedxml \
python3-jinja2 \
openssl-devel \
python3-poetry-core ; \
dnf -y clean all
# Build runner script (copies repo, tars, runs rpmbuild)
RUN set -eux; cat > /usr/local/bin/build-rpm <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
SRC="${SRC:-/src}"
WORKROOT="${WORKROOT:-/work}"
OUT="${OUT:-/out}"
mkdir -p "${WORKROOT}" "${OUT}"
WORK="${WORKROOT}/src"
rm -rf "${WORK}"
mkdir -p "${WORK}"
rsync -a --delete \
--exclude '.git' \
--exclude '.venv' \
--exclude 'dist' \
--exclude 'build' \
--exclude '__pycache__' \
--exclude '.pytest_cache' \
--exclude '.mypy_cache' \
"${SRC}/" "${WORK}/"
cd "${WORK}"
# Determine version from pyproject.toml unless provided
if [ -n "${VERSION:-}" ]; then
ver="${VERSION}"
else
ver="$(grep -m1 '^version = ' pyproject.toml | sed -E 's/version = "([^"]+)".*/\1/')"
fi
TOPDIR="${WORKROOT}/rpmbuild"
mkdir -p "${TOPDIR}"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
tarball="${TOPDIR}/SOURCES/jinjaturtle-${ver}.tar.gz"
tar -czf "${tarball}" --transform "s#^#jinjaturtle/#" .
spec_src="rpm/jinjaturtle.spec"
cp -v "${spec_src}" "${TOPDIR}/SPECS/jinjaturtle.spec"
rpmbuild -ba "${TOPDIR}/SPECS/jinjaturtle.spec" \
--define "_topdir ${TOPDIR}" \
--define "upstream_version ${ver}"
shopt -s nullglob
cp -v "${TOPDIR}"/RPMS/*/*.rpm "${OUT}/" || true
cp -v "${TOPDIR}"/SRPMS/*.src.rpm "${OUT}/" || true
echo "Artifacts copied to ${OUT}"
EOF
RUN chmod +x /usr/local/bin/build-rpm
WORKDIR /work
ENTRYPOINT ["/usr/local/bin/build-rpm"]

View file

@ -42,3 +42,34 @@ for dist in ${DISTS[@]}; do
debfile=$(ls -1 dist/${release}/*.deb) debfile=$(ls -1 dist/${release}/*.deb)
reprepro -b /home/user/git/repo includedeb "${release}" "${debfile}" reprepro -b /home/user/git/repo includedeb "${release}" "${debfile}"
done done
# RPM
sudo apt-get -y install createrepo-c rpm
docker build -f Dockerfile.rpmbuild -t jinjaturtle:f42 --progress=plain .
docker run --rm -v "$PWD":/src -v "$PWD/dist/rpm":/out jinjaturtle:f42
sudo chown -R "${USER}" "$PWD/dist"
REPO_ROOT="${HOME}/git/repo_rpm"
RPM_REPO="${REPO_ROOT}/rpm/x86_64"
BUILD_OUTPUT="${HOME}/git/jinjaturtle/dist"
REMOTE="letessier.mig5.net:/opt/repo_rpm"
KEYID="00AE817C24A10C2540461A9C1D7CDE0234DB458D"
echo "==> Updating RPM repo..."
mkdir -p "$RPM_REPO"
for file in `ls -1 "${BUILD_OUTPUT}/rpm"`; do
rpmsign --addsign "${BUILD_OUTPUT}/rpm/$file"
done
cp "${BUILD_OUTPUT}/rpm/"*.rpm "$RPM_REPO/"
createrepo_c "$RPM_REPO"
echo "==> Signing repomd.xml..."
qubes-gpg-client --local-user "$KEYID" --detach-sign --armor "$RPM_REPO/repodata/repomd.xml" > "$RPM_REPO/repodata/repomd.xml.asc"
echo "==> Syncing repo to server..."
rsync -aHPvz --exclude=.git --delete "$REPO_ROOT/" "$REMOTE/"
echo "Done!"

46
rpm/jinjaturtle.spec Normal file
View file

@ -0,0 +1,46 @@
%global upstream_version 0.3.4
Name: jinjaturtle
Version: %{upstream_version}
Release: 1%{?dist}.jinjaturtle1
Summary: Convert config files into Ansible defaults and Jinja2 templates.
License: GPL-3.0-or-later
URL: https://git.mig5.net/mig5/jinjaturtle
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
BuildRequires: python3-poetry-core
Requires: python3-yaml
Requires: python3-tomli
Requires: python3-defusedxml
Requires: python3-jinja2
%description
Convert config files into Ansible defaults and Jinja2 templates.
%prep
%autosetup -n jinjaturtle
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files jinjaturtle
%files -f %{pyproject_files}
%license LICENSE
%doc README.md
%{_bindir}/jinjaturtle
%changelog
* Sat Dec 27 2025 Miguel Jacq <mig@mig5.net> - %{version}-%{release}
- Initial RPM packaging for Fedora 42