From 3429bf6183a1855a4a5086507d81faf2105f06e3 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Jul 20 2022 13:37:00 +0000 Subject: macros: add new distribution-specific macros for package configurations Define macros for commonly-used strings/urls to distinguish distributions. Spec files have lots of "%{?fedora:}" and "%{?rhel}" conditionals which can be defined in one place. Amazon Linux is a new downstream distribution of Fedora that will add its own definitions as well, so consolidate all of these in a new macros file. The macros here have been tested with local builds of clang and gdb. Once this change is merged, I will submit updates to a few packages. As examples, this is how clang.spec and gdb.spec will look after this change: clang.spec: ``` @@ -358,7 +360,7 @@ CFLAGS="$CFLAGS -Wno-address -Wno-nonnull -Wno-maybe-uninitialized" \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \ -DBUILD_SHARED_LIBS=OFF \ - -DCLANG_REPOSITORY_STRING="%{?fedora:Fedora}%{?rhel:Red Hat} %{version}-%{release}" \ + -DCLANG_REPOSITORY_STRING="%{distro_vendor} %{version}-%{release}" \ %ifarch %{arm} -DCLANG_DEFAULT_LINKER=lld \ %endif ``` gdb.spec: ``` -# Change the version that gets printed at GDB startup, so it is RH specific. +# Change the version that gets printed at GDB startup, so it is distro-specific. cat > gdb/version.in << _FOO -%if 0%{!?rhel:1} -Fedora %{version}-%{release} -%else # !0%{!?rhel:1} -Red Hat Enterprise Linux %{version}-%{release} -%endif # !0%{!?rhel:1} +%{distro_name} %{version}-%{release} _FOO # Remove the info and other generated files added by the FSF release ``` Signed-off-by: Amit Shah --- diff --git a/macros.distro b/macros.distro new file mode 100644 index 0000000..785c043 --- /dev/null +++ b/macros.distro @@ -0,0 +1,50 @@ +# Distribution-specific macros + +# Name of the vendor or distribution. Typically used to identify where +# the binary comes from in --help or --version messages of programs. +# Examples: gdb.spec, clang.spec + +%distro_vendor %{lua: +local vendor = 'Fedora' +if macros.rhel then + vendor = 'Red Hat' +end +if macros.amzn then + vendor = 'Amazon Linux' +end +return vendor +} + +%distro_name %{lua: +local name = 'Fedora' +if macros.rhel then + name = 'Red Hat Enterprise Linux' +end +if macros.amzn then + name = 'Amazon Linux' +end +return name +} + +# URLs used to output upstream / source of distribution. +# Example: gstreamer1-plugins-base.spec +%distro_url %{lua: +local url = 'https://download.fedoraproject.org' +if macros.rhel then + url = 'https://redhat.com' +end +if macros.amzn then + url = 'https://aws.amazon.com/linux' +end +return url +} + +# Bugzilla / bug reporting URLs shown to users. +# Examples: gcc.spec +%distro_url_bugs %{lua: +local url_bugs = 'https://bugzilla.redhat.com' +if macros.amzn then + url_bugs = 'https://github.com/amazonlinux' +end +return url_bugs +} diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index f88f5ec..6dd9755 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -9,7 +9,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config Version: %{baserelease} -Release: 1%{?dist} +Release: 2%{?dist} # No version specified. License: GPL+ URL: https://src.fedoraproject.org/rpms/redhat-rpm-config @@ -48,6 +48,7 @@ Source152: macros.fedora-misc Source153: macros.forge Source155: macros.ldconfig Source156: macros.vpath +Source157: macros.distro # Build policy scripts # this comes from https://github.com/rpm-software-management/rpm/pull/344 @@ -205,6 +206,7 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.forge %{_rpmconfigdir}/macros.d/macros.ldconfig %{_rpmconfigdir}/macros.d/macros.vpath +%{_rpmconfigdir}/macros.d/macros.distro %dir %{_rpmluadir}/fedora %dir %{_rpmluadir}/fedora/srpm %dir %{_rpmluadir}/fedora/rpm