#33 Add macros.build-constraints
Merged 2 years ago by salimma. Opened 2 years ago by salimma.
rpms/ salimma/epel-rpm-macros pull-in-build-constraints  into  epel8

file modified
+17 -6
@@ -1,6 +1,6 @@ 

  Name:           epel-rpm-macros

  Version:        8

- Release:        22

+ Release:        23

  Summary:        Extra Packages for Enterprise Linux RPM macros

  

  Group:          System Environment/Base
@@ -15,6 +15,8 @@ 

  Source2:        gpgverify

  Source3:        pythondist.attr

  Source9:        GPL

+ # misc macros

+ Source150:      macros.build-constraints

  

  BuildArch:      noarch

  Requires:       redhat-release >= %{version}
@@ -42,12 +44,11 @@ 

  

  %install

  #GPG Key

- # Can't depend upon %%rpmmacrodir yet, since we're providing it

  install -Dpm 644 %{SOURCE0} \

-     %buildroot/usr/lib/rpm/macros.d/macros.epel-rpm-macros

+     %{buildroot}%{_rpmmacrodir}/macros.epel-rpm-macros

  

  install -Dpm 644 %{SOURCE1} \

-     %buildroot/etc/rpm/macros.zzz-epel-override

+     %{buildroot}%{_sysconfdir}/rpm/macros.zzz-epel-override

  

  install -Dpm 755 %{SOURCE2} \

      %{buildroot}%{_rpmconfigdir}/gpgverify
@@ -55,16 +56,26 @@ 

  install -Dpm 644 %{SOURCE3} \

      %{buildroot}%{_fileattrsdir}/pythondist.attr

  

+ # misc macros

+ install -Dpm 644 %{SOURCE150} \

+     %{buildroot}%{_rpmmacrodir}/macros.build-constraints

+ 

  

  %files

  %license GPL

- /usr/lib/rpm/macros.d/macros.epel-rpm-macros

- /etc/rpm/macros.zzz-epel-override

+ %{_rpmmacrodir}/macros.epel-rpm-macros

+ %{_sysconfdir}/rpm/macros.zzz-epel-override

  %{_rpmconfigdir}/gpgverify

  %{_fileattrsdir}/pythondist.attr

+ # misc macros

+ %{_rpmmacrodir}/macros.build-constraints

  

  

  %changelog

+ * Mon Aug  2 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 8-23

+ - Add macros.build-constraints

+ - Refactor to use standard macros, not hard-coded paths

+ 

  * Wed Jul 14 2021 Miro Hrončok <mhroncok@redhat.com> - 8-22

  - Introduce %%py3_check_import

  

@@ -0,0 +1,10 @@ 

+ # Macros to constrain resource use during the build process

+ 

+ # m: memory limit in MBs per core; default is 1024

+ %limit_build(m:) \

+   _mem_per_process="%{-m:%{-m*}}%{!-m:1024}" \

+   _max_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo) \

+   _max_jobs="$(($_max_mem / ($_mem_per_process * 1024)))" \

+   _cur_max_jobs="%{_smp_build_ncpus}" \

+   test "${_cur_max_jobs}" -gt "${_max_jobs}" && _cur_max_jobs="${_max_jobs}" && echo "Warning: Reducing build parallelism to -j${_max_jobs} because of memory limits" \

+   %global _smp_build_ncpus "${_cur_max_jobs}"

For this Fedora 35 feature: https://bugzilla.redhat.com/show_bug.cgi?id=1982748

Having this in epel-rpm-macros would allow the same spec to also build on EPEL

I have provenpackager access, so if this looks good I'll also add it to epel7, but I would like at least one review first

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Note: let's wait until https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/139 is resolved; if that's not merged it should not be merged into EPEL instead. It might make more sense to actually have the packages that need this macro to pull in the RPM themselves

rebased onto ff46d322fde6c77ecca20d2c149df03ee00ae3b3

2 years ago

Use %{_rpmmacrodir} instead of /usr/lib/rpm/macros.d please.

Build succeeded.

Use %{_rpmmacrodir} instead of /usr/lib/rpm/macros.d please.

I can't, see line 47. That macro is defined in this RPM.

These are defined in RPM itself in RHEL 8: https://github.com/rpm-software-management/rpm/blob/rpm-4.14.x/macros.in#L148-L153

But alternatively, you can use %{_rpmconfigdir}/macros.d.

These are defined in RPM itself in RHEL 8: https://github.com/rpm-software-management/rpm/blob/rpm-4.14.x/macros.in#L148-L153

But alternatively, you can use %{_rpmconfigdir}/macros.d.

yeah, testing right now to make sure and I'll update the PR. That line 47 warning is likely carried over from EPEL7, so over there I might have to use %{_rpmconfigdir}/macros.d

1 new commit added

  • Refactor to use standard macros, not hard-coded paths
2 years ago

Updated. Oh yuck, on RHEL7, the /usr/lib/rpm/macros.d directory is owned by RPM, but rpm-build's macros go in /usr/lib/rpm instead (macros.{perl,php,python}). Only macros from epel-rpm-macros seem to go in macros.d. so I'll use '%{_rpmconfigdir}/macros.d` in EPEL7

I also replaced the hardcoded /etc/ to use %{_sysconfigdir}, longer but more proper

Build succeeded.

Why do we install this in /etc?

This looks good to me now. :thumbsup:

Why do we install this in /etc?

So that is my doing. The reason is that in EPEL5 and (I think) EPEL6 this package needed to override macro definitions from RHEL, and installing the macros in /etc was the only foolproof way I found to ensure that happened. But I don't think there is any need for that kind of game in EPEL7.

Can you rebase this now? (I guess we might switch this to rpmautospec once the bugs are worked out)

rebased onto f44829e

2 years ago

Pull-Request has been merged by salimma

2 years ago

Build succeeded.