diff --git a/gdb-6.3-rh-testversion-20041202.patch b/gdb-6.3-rh-testversion-20041202.patch index 718e53a..59132bf 100644 --- a/gdb-6.3-rh-testversion-20041202.patch +++ b/gdb-6.3-rh-testversion-20041202.patch @@ -1,38 +1,34 @@ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Elena Zannoni +From: Andrew Burgess Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.3-rh-testversion-20041202.patch -;; Match the Fedora's version info. -;;=fedora +;; Check distro name is included in the version output. -2003-02-24 Elena Zannoni - - * gdb.gdb/selftest.exp: Add matching on specific Red Hat only version - string. - -diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp ---- a/gdb/testsuite/gdb.gdb/selftest.exp -+++ b/gdb/testsuite/gdb.gdb/selftest.exp -@@ -53,6 +53,9 @@ proc test_with_self { } { - -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { - pass "printed version with cast" - } -+ -re ".\[0-9\]+ = .(Fedora Linux|Red Hat Enterprise Linux) \[\\(\\)0-9.a-z\\-\]+.*$gdb_prompt $" { -+ pass "printed version Fedora or Red Hat Enterprise Linux only" -+ } - } - - # start the "xgdb" process -diff --git a/gdb/top.c b/gdb/top.c ---- a/gdb/top.c -+++ b/gdb/top.c -@@ -2382,7 +2382,7 @@ The second argument is the terminal the UI runs on."), &cmdlist); - struct internalvar *major_version_var = create_internalvar ("_gdb_major"); - struct internalvar *minor_version_var = create_internalvar ("_gdb_minor"); - int vmajor = 0, vminor = 0, vrevision = 0; -- sscanf (version, "%d.%d.%d", &vmajor, &vminor, &vrevision); -+ sscanf (version, "%*[^0123456789]%d.%d.%d", &vmajor, &vminor, &vrevision); - set_internalvar_integer (major_version_var, vmajor); - set_internalvar_integer (minor_version_var, vminor + (vrevision > 0)); - } +diff --git a/gdb/testsuite/gdb.base/fedora-version.exp b/gdb/testsuite/gdb.base/fedora-version.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/fedora-version.exp +@@ -0,0 +1,22 @@ ++# Copyright 2023 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Start with a fresh gdb ++clean_restart ++ ++# Check the version string contains either the Fedora or RHEL distro ++# name, and that the version number looks roughly correct in format. ++gdb_test "show version" \ ++ "GNU gdb \\((Fedora Linux|Red Hat Enterprise Linux)\\) \[0-9\]+\\.\[0-9\]+-\[0-9\]+.*" diff --git a/gdb.spec b/gdb.spec index 0d6e9ed..f7e9735 100644 --- a/gdb.spec +++ b/gdb.spec @@ -520,9 +520,55 @@ find -name "*.info*"|xargs rm -f find -name "*.orig" | xargs rm -f ! find -name "*.rej" # Should not happen. -# Change the version that gets printed at GDB startup, so it is distro-specific. +# In the past a distro name prefix was added to the version string in +# version.in. +# +# However, placing text at the start of version.in can cause problems; +# GDB will have a version string that starts with text rather than a +# number as is the case with upstream GDB, and for most (all?) other +# distros. +# +# GDB's version string is exposed to users as part of the Python API, +# and it is not uncommon for users to try and grok the version number +# from this string. Having Fedora/RHEL GDB not start with the major +# version number can be unexpected, and might cause tools/script that +# work for other builds of GDB to fail with Fedora/RHEL GDB. +# +# So, we switched to use the more standard --with-pkgversion configure +# option. This ensures the distro name is still included in the 'gdb +# --version' output, but the text is no longer part of the string +# exposed in the Python API. +# +# Unfortunately, for RHEL the dist_name macro is not defined. At +# least not on RHEL 9 or earlier. So, if dist_name is not defined, +# but the rhel macro is, then we use a hard-coded RHEL appropriate +# string. +# +# FIXME: It would be nice to rewrite this using %elif, but this is not +# supported on older (pre 9) RHEL systems. + +%if 0%{?dist_name:1} + +%global pkgversion_configure_flag --with-pkgversion=%{dist_name} + +%else + +%if 0%{?fedora:1} +%global pkgversion_configure_flag --with-pkgversion=Fedora Linux +%endif + +%if 0%{?rhel:1} +%global pkgversion_configure_flag --with-pkgversion=Red Hat Enterprise Linux +%endif + +%endif + +# Change the version that gets printed by GDB. The 'version' here is +# usually the same as the original upstream version on which we are +# based. The 'release' is new information we're adding and identifies +# the modifications we've made to upstream. cat > gdb/version.in << _FOO -%{?dist_name} %{version}-%{release} +%{?version_prefix:%version_prefix }%{version}-%{release} _FOO # Remove the info and other generated files added by the FSF release @@ -644,6 +690,9 @@ export PKG_CONFIG_PATH=%{_libdir}/pkgconfig ../configure \ ${COMMON_GDB_CONFIGURE_FLAGS} \ ${GDB_MINIMAL_CONFIGURE_FLAGS} \ +%if 0%{?pkgversion_configure_flag:1} + "%{pkgversion_configure_flag}" \ +%endif --with-auto-load-dir='$debugdir:$datadir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}' \ --with-auto-load-safe-path='$debugdir:$datadir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}' \ %ifarch sparc sparcv9 @@ -744,6 +793,9 @@ $(: ppc64 host build crashes on ppc variant of libexpat.so ) \ ../configure \ ${COMMON_GDB_CONFIGURE_FLAGS} \ ${GDB_FULL_CONFIGURE_FLAGS} \ +%if 0%{?pkgversion_configure_flag:1} + "%{pkgversion_configure_flag}" \ +%endif --with-auto-load-dir='$debugdir:$datadir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}' \ --with-auto-load-safe-path='$debugdir:$datadir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}' \ %ifarch sparc sparcv9 @@ -1192,6 +1244,11 @@ fi %endif %changelog +* Wed Mar 29 2023 Andrew Burgess +- Used --with-pkgversion to place the distribution name in the version + string rather than placing the string directly into the version.in + file. + * Fri Mar 24 2023 Kevin Buettner - 13.1-2 - Backport fix for RHBZ 2177655. (Luis Machado)