From d2c6293787e19348cf630343f1be1d5c7af75d50 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Jul 27 2022 17:11:51 +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="%{?dist_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} +%{?dist_name} %{version}-%{release} _FOO # Remove the info and other generated files added by the FSF release ``` Signed-off-by: Amit Shah --- diff --git a/fedora-release.spec b/fedora-release.spec index cde523c..b786e84 100644 --- a/fedora-release.spec +++ b/fedora-release.spec @@ -889,8 +889,28 @@ ln -s fedora-release %{buildroot}%{_sysconfdir}/system-release %global prerelease \ Prerelease %endif +# ------------------------------------------------------------------------- +# Definitions for /etc/os-release and for macros in macros.dist. These +# macros are useful for spec files where distribution-specific identifiers +# are used to customize packages. + +# Name of vendor / name of distribution. Typically used to identify where +# the binary comes from in --help or --version messages of programs. +# Examples: gdb.spec, clang.spec +%global dist_vendor Fedora +%global dist_name Fedora Linux + +# URL of the homepage of the distribution +# Example: gstreamer1-plugins-base.spec +%global dist_home_url https://fedoraproject.org/ + +# Bugzilla / bug reporting URLs shown to users. +# Examples: gcc.spec +%global dist_bug_report_url https://bugzilla.redhat.com/ +# ------------------------------------------------------------------------- + cat << EOF >> os-release -NAME="Fedora Linux" +NAME="%{dist_name}" VERSION="%{dist_version} (%{release_name}%{?prerelease})" ID=fedora VERSION_ID=%{dist_version} @@ -900,10 +920,10 @@ PRETTY_NAME="Fedora Linux %{dist_version} (%{release_name}%{?prerelease})" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:%{dist_version}" -HOME_URL="https://fedoraproject.org/" +HOME_URL="%{dist_home_url}" DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/%{doc_version}/system-administrators-guide/" SUPPORT_URL="https://ask.fedoraproject.org/" -BUG_REPORT_URL="https://bugzilla.redhat.com/" +BUG_REPORT_URL="%{dist_bug_report_url}" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=%{bug_version} REDHAT_SUPPORT_PRODUCT="Fedora" @@ -1185,6 +1205,10 @@ cat >> %{buildroot}%{_rpmconfigdir}/macros.d/macros.dist << EOF %%fc%{dist_version} 1 %%dist %%{!?distprefix0:%%{?distprefix}}%%{expand:%%{lua:for i=0,9999 do print("%%{?distprefix" .. i .."}") end}}.fc%%{fedora}%%{?with_bootstrap:%{__bootstrap}} %endif +%%dist_vendor %{dist_vendor} +%%dist_name %{dist_name} +%%dist_home_url %{dist_home_url} +%%dist_bug_report_url %{dist_bug_report_url} EOF # Install licenses