#223 macros: add new distribution-specific macros for package configurations
Merged 5 months ago by sgallagh. Opened 5 months ago by amitshah.
rpms/ amitshah/fedora-release vendor-macros  into  rawhide

file modified
+27 -3
@@ -889,8 +889,28 @@ 

    %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 @@ 

  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 @@ 

  %%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

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 amitshah@fedoraproject.org

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

This looks reasonable to me, but we will wait until a decision is made in https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/211 before merging.

This might be my bad English, but I have no idea what "URLs used to output upstream / source of distribution" means.

This might be my bad English, but I have no idea what "URLs used to output upstream / source of distribution" means.

From context, I think it just means "URL of the distribution's homepage". Probably could be clarified in the comment, but I don't think it's critical.

@churchyard I think I wrote that from the spec file's POV - like in the gstreamer case, the URL that's used as "URL of the distribution":

-D package-origin='http://download.fedoraproject.org'

@churchyard I think I wrote that from the spec file's POV - like in the gstreamer case, the URL that's used as "URL of the distribution":

-D package-origin='http://download.fedoraproject.org'

Could you just change it to "The URL of the distribution homepage"?

Sure - I was going to do that as a follow-up, but I suppose I'll do it now. I haven't figured out how this PR workflow can take a v2 of a patch; I'll open a new one in the worst case.

rebased onto d2c6293

5 months ago

I just force-pushed to the same branch, and it looks like the PR's now updated with the updated wording.

Please merge.

Pull-Request has been merged by sgallagh

5 months ago

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

Is this macro also being added to RHEL? If not, then you can't actually replace the %{?rhel:} code.

A C9S merge req is open at https://gitlab.com/redhat/centos-stream/rpms/centos-release/-/merge_requests/33. I'm pushing for the devs to also backport this to RHEL releases.

Metadata