From ef0e81dba97c61f7b4c15ebc91468253b758005d Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Mon, 7 Mar 2022 16:29:39 +0100 Subject: [PATCH 48/63] Packit: build SRPM in Copr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TL;DR: * specify the list of deps needed to prepare SRPM in the .packit file * move leapp-el7toel8-deps.spec into other_specs subdir * update the make commands for the building of packages Previously we have prepared SRPM "locally" and then uploaded it to the COPR server for the building. However, since Jan 2023 we are required to build SRPMs on the COPR server itself. As in this project we have to manage 2 SPEC files for two buildings: - leapp-el7toel8-deps.spec Creating metapackage resolving issues with dependencies on the target system; created RPMs are archived and are used as one of sources for building of leapp-repository. - leapp-repository.spec The main spec file used for the entire project, which requires archive with the deps packages. Currently it's not possible to tell COPR which specific spec file should be used and if they are in the same directory, COPR fails with the error message about multiple SPEC files. But COPR is ok having multiple spec files in a project when they are in separate directories. To fix that, we are moving the deps spec file into the separate directory. Also, explicitly set the `_rpmfilename` macro. This is super important as the COPR build servers are using Mock, which redefines the macro, so packages are stored inside RPMS directory, instead RPMS/%{ARCH}. The macro must be defined with double '%'. Using just single %, the macro is expanded when the specfile is loaded, but it is expected to be expanded during the build process when particular subpackages (RPMs) are created, so each RPM has the right name. Using the single %, all RPMs would have the name of the SRPM - which means effectively that only one RPM per build would be created. (hopefully the explanation is clear :)) This change was finished by Peťa and Pavel Raiskup. Tomas was "only" the initial author. For more details, please open the PR: https://github.com/oamg/leapp-repository/pull/848 🎉🎉🎉🍻 Signed-off-by: Tomas Tomecek Co-authored-by: Petr Stodulk --- .packit.yaml | 3 +++ Makefile | 22 ++++++++++++++----- packaging/leapp-repository.spec | 4 ++-- .../leapp-el7toel8-deps.spec | 0 4 files changed, 22 insertions(+), 7 deletions(-) rename packaging/{ => other_specs}/leapp-el7toel8-deps.spec (100%) diff --git a/.packit.yaml b/.packit.yaml index fb407829..f1d59ce1 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -8,6 +8,9 @@ downstream_package_name: leapp-repository upstream_tag_template: 'v{version}' merge_pr_in_ci: false +srpm_build_deps: +- make + # This is just for the build from the CLI - all other builds for jobs use own # actions actions: diff --git a/Makefile b/Makefile index 7342d4bf..b1489e4f 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ DIST_VERSION ?= 7 PKGNAME=leapp-repository DEPS_PKGNAME=leapp-el7toel8-deps VERSION=`grep -m1 "^Version:" packaging/$(PKGNAME).spec | grep -om1 "[0-9].[0-9.]**"` -DEPS_VERSION=`grep -m1 "^Version:" packaging/$(DEPS_PKGNAME).spec | grep -om1 "[0-9].[0-9.]**"` +DEPS_VERSION=`grep -m1 "^Version:" packaging/other_specs/$(DEPS_PKGNAME).spec | grep -om1 "[0-9].[0-9.]**"` REPOS_PATH=repos _SYSUPG_REPOS="$(REPOS_PATH)/system_upgrade" LIBRARY_PATH= @@ -178,7 +178,7 @@ source: prepare mkdir -p packaging/tmp/ @__TIMESTAMP=$(TIMESTAMP) $(MAKE) _build_subpkg @__TIMESTAMP=$(TIMESTAMP) $(MAKE) DIST_VERSION=$$(($(DIST_VERSION) + 1)) _build_subpkg - @tar -czf packaging/sources/deps-pkgs.tar.gz -C packaging/RPMS/noarch `ls packaging/RPMS/noarch | grep -o "[^/]*rpm$$"` + @tar -czf packaging/sources/deps-pkgs.tar.gz -C packaging/RPMS/noarch `ls -1 packaging/RPMS/noarch | grep -o "[^/]*rpm$$"` @rm -f packaging/RPMS/noarch/*.rpm srpm: source @@ -195,8 +195,19 @@ srpm: source _build_subpkg: @echo "--- Build RPM: $(DEPS_PKGNAME)-$(DEPS_VERSION)-$(RELEASE).. ---" - @cp packaging/$(DEPS_PKGNAME).spec packaging/$(DEPS_PKGNAME).spec.bak + @cp packaging/other_specs/$(DEPS_PKGNAME).spec packaging/$(DEPS_PKGNAME).spec @sed -i "s/1%{?dist}/$(RELEASE)%{?dist}/g" packaging/$(DEPS_PKGNAME).spec + # Let's be explicit about the path to the binary RPMs; Copr builders can override this + # IMPORTANT: + # Also, explicitly set the _rpmfilename macro. This is super important as + # the COPR build servers are using Mock, which redefines the macro, so packages + # are stored inside RPMS directory, instead RPMS/%{ARCH}. The macro must be + # defined with double '%'. Using just single %, the macro is expanded when + # the specfile is loaded, but it is expected to be expanded during + # the build process when particular subpackages (RPMs) are created, so + # each RPM has the right name. Using the single %, all RPMs would have the + # name of the SRPM - which means effectively that only one RPM per build + # would be created. (hopefully the explanation is clear :)) @rpmbuild -ba packaging/$(DEPS_PKGNAME).spec \ --define "_sourcedir `pwd`/packaging/sources" \ --define "_srcrpmdir `pwd`/packaging/SRPMS" \ @@ -205,8 +216,9 @@ _build_subpkg: --define "_rpmdir `pwd`/packaging/RPMS" \ --define "rhel $$(($(DIST_VERSION) + 1))" \ --define "dist .el$$(($(DIST_VERSION) + 1))" \ - --define "el$$(($(DIST_VERSION) + 1)) 1" || FAILED=1 - @mv packaging/$(DEPS_PKGNAME).spec.bak packaging/$(DEPS_PKGNAME).spec + --define "el$$(($(DIST_VERSION) + 1)) 1" \ + --define "_rpmfilename %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" || FAILED=1 + @rm -f packaging/$(DEPS_PKGNAME).spec _build_local: source @echo "--- Build RPM: $(PKGNAME)-$(VERSION)-$(RELEASE).. ---" diff --git a/packaging/leapp-repository.spec b/packaging/leapp-repository.spec index 0ffba71c..044e7275 100644 --- a/packaging/leapp-repository.spec +++ b/packaging/leapp-repository.spec @@ -196,9 +196,9 @@ Requires: dracut %build %if 0%{?rhel} == 7 -cp -a leapp*deps-el8*rpm repos/system_upgrade/el7toel8/files/bundled-rpms/ +cp -a leapp*deps*el8.noarch.rpm repos/system_upgrade/el7toel8/files/bundled-rpms/ %else -cp -a leapp*deps-el9*rpm repos/system_upgrade/el8toel9/files/bundled-rpms/ +cp -a leapp*deps*el9.noarch.rpm repos/system_upgrade/el8toel9/files/bundled-rpms/ %endif diff --git a/packaging/leapp-el7toel8-deps.spec b/packaging/other_specs/leapp-el7toel8-deps.spec similarity index 100% rename from packaging/leapp-el7toel8-deps.spec rename to packaging/other_specs/leapp-el7toel8-deps.spec -- 2.39.0