From 48ee71b9afded44bafeb56ad6575ab8fd52e98bd Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 16 Nov 2020 14:17:25 +0100 Subject: [PATCH] mockbuild: use mock to build source rpm Running `make srpm` on the host can have different results from building the SRPM in mock. Stop using the Makefile altogether for this, which is meant for developer convenience only. The interface is clear: a tarball generated from `git archive` and defining the `commit` variable. Less stuff to install on the host, too. --- schutzbot/mockbuild.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/schutzbot/mockbuild.sh b/schutzbot/mockbuild.sh index 8691d3995..5fc057290 100755 --- a/schutzbot/mockbuild.sh +++ b/schutzbot/mockbuild.sh @@ -55,7 +55,7 @@ fi # Install requirements for building RPMs in mock. greenprint "📦 Installing mock requirements" -sudo dnf -y install createrepo_c make mock rpm-build s3cmd +sudo dnf -y install createrepo_c mock s3cmd # Print some data. @@ -63,14 +63,20 @@ greenprint "🧬 Using mock config: ${MOCK_CONFIG}" greenprint "📦 SHA: ${COMMIT}" greenprint "📤 RPMS will be uploaded to: ${REPO_URL}" -# Build source RPMs. -greenprint "🔧 Building source RPMs." -make srpm +greenprint "🔧 Building source RPM" +git archive --prefix "osbuild-composer-${COMMIT}/" --output "osbuild-composer-${COMMIT}.tar.gz" HEAD +sudo mock -r "$MOCK_CONFIG" --buildsrpm \ + --define "commit ${COMMIT}" \ + --spec ./osbuild-composer.spec \ + --sources "./osbuild-composer-${COMMIT}.tar.gz" \ + --resultdir ./srpm -# Compile RPMs in a mock chroot -greenprint "🎁 Building RPMs with mock" -sudo mock -r "$MOCK_CONFIG" --resultdir "$REPO_DIR" --with=tests \ - rpmbuild/SRPMS/*.src.rpm +greenprint "🎁 Building RPMs" +sudo mock -r "$MOCK_CONFIG" \ + --define "commit ${COMMIT}" \ + --with=tests \ + --resultdir "$REPO_DIR" \ + srpm/*.src.rpm # Change the ownership of all of our repo files from root to our CI user. sudo chown -R "$USER" "${REPO_DIR%%/*}"