From 9d0f6bd85e4f7a97b6c2221d7ddc17855ca38523 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 24 Feb 2020 22:20:45 +0100 Subject: [PATCH] github: build RPMs without git checkout Make RPM building more similar to how RPMs will be built in koji. This downloads the specfile from github at the given commit, appends the commit sha to the specfile and uses spectools to download the correct sources from github. This should be equivalent to what is done in the makefile, the only behavioral difference is that the rpms are now versioned based on the git sha they are built from. The main purpose of this change is to avoid any differences between the CI and the real RPMs due to bugs in the Makefile. Correctly versioned RPMs will also be handy for testing/debugging/deployment. Signed-off-by: Tom Gundersen --- .github/workflows/build_rpms.yml | 46 ++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_rpms.yml b/.github/workflows/build_rpms.yml index a42f49e5..d7251c7b 100644 --- a/.github/workflows/build_rpms.yml +++ b/.github/workflows/build_rpms.yml @@ -25,33 +25,51 @@ jobs: echo "fastestmirror=1" >> /etc/dnf/dnf.conf echo "install_weak_deps=0" >> /etc/dnf/dnf.conf dnf -y upgrade - dnf -y install dnf-plugins-core git make rpm-build - mkdir rpms + dnf -y install dnf-plugins-core rpm-build rpmdevtools - - name: Clone repository - uses: actions/checkout@v2 - with: - path: osbuild + - name: Fetch .spec file + run: | + mkdir spec + # Fetch the spec file at the given commit, and prepend the commit sha to it + curl "https://raw.githubusercontent.com/osbuild/osbuild/${GITHUB_SHA}/osbuild.spec" -o osbuild.spec + echo "%global commit ${GITHUB_SHA}" | cat - osbuild.spec > spec/osbuild.spec - name: Install RPM build dependencies - run: dnf -y builddep osbuild/osbuild.spec + run: dnf -y builddep spec/osbuild.spec + + - name: Fetch sources + run: | + mkdir sources + spectool -g spec/osbuild.spec -C sources/ + + - name: Build SRPM + run: | + mkdir srpms + rpmbuild -bs \ + --define "_sourcedir sources" \ + --define "_srcrpmdir srpms" \ + spec/osbuild.spec - name: Build RPMs run: | - pushd osbuild - make rpm - popd - cp -av osbuild/output/*/*.rpm rpms/ - date > rpms/timestamp.txt + mkdir rpmbuild rpms build + rpmbuild -bb \ + --define "_sourcedir `pwd`/sources" \ + --define "_specdir `pwd`/spec" \ + --define "_builddir `pwd`/rpmbuild" \ + --define "_srcrpmdir `pwd`/srpms" \ + --define "_rpmdir `pwd`/rpms" \ + --define "_buildrootdir `pwd`/build" \ + spec/osbuild.spec - name: "Upload artifacts" uses: actions/upload-artifact@v1 with: - name: Packages + name: rpms path: rpms/ - name: Test RPM installation run: | - pushd rpms + pushd rpms/noarch dnf -y install $(ls *.rpm) popd