I'm using aws's ec2 instance and I need to install a newer version of GDB (I can't use yum install since there is no newer version available for amazon RHEL).

My workflow requires to do this process often and I thought of having a prepared RPM to implement this task. I'm new to the process of creating RPMs and I'm not sure how to do it, I started to write the file but I ran into some issues, I'd like to share with you the file, with the issues I got:

  1. I'd like to get some insight and understand if there's a better way of writing the spec file.
  2. Currently I'm getting errors since I need to use the pkg's "configure" before, but this requires creating a "build" directory and only run make from within that directory. Currently I solved this by make from within a directory I created within the BUILD/gdb-9.1 dir. But I'm sure there's a more idiomatic way of doing it.
  3. for this process to work, I first need to install gcc-c++ and expat-devel. I what is the best way to do it, currently my option are:
    1. put it as part of the rpm installation.
    2. run this command prior to the rpm installation. (yet I'd like the rpm to be something that it's the only this required, but I'm not sure if it's a good idea)
%define gdb_version       9.1
%define gdb_release       1

Name: gdb
Summary: GNU Debugger
Version: %{gdb_version}
Release: %{gdb_release}
License: GPL
URL: http://www.gnu.org/software/gdb/
Source0: gdb-%{gdb_version}.tar.gz
BuildRequires: readline-devel, ncurses-devel

GDB, the GNU Project debugger, allows you to see what is going on inside another program while it executes.


mkdir build
cd build
../configure \
--host=x86_64-redhat-linux-gnu \
--target=x86_64-redhat-linux-gnu \
--with-auto-load-dir=$debugdir:$datadir/auto-load:/usr/share/gdb/auto-load \
--with-auto-load-safe-path=$debugdir:$datadir/auto-load:/usr/share/gdb/auto-load \
--with-expat \
--with-gdb-datadir=/usr/share/gdb \
--with-jit-reader-dir=/usr/lib64/gdb \
--without-libunwind-ia64 \
--with-python=/usr \
--without-guile \
--with-separate-debug-dir=/usr/lib/debug \
--with-system-gdbinit=/etc/gdbinit \
make %{?_smp_mflags}

cd build
make install



1 Answer 1


Well, you want to build an RPM!

I'd like the rpm to be something that it's the only this required, but I'm not sure if it's a good idea

Well, what components does the software you install need to work? You make the package depend on these (explicitly through Requires:, or implicitly through the analysis of the libraries you link against), and they get installed if necessary. If you need them in a version that your OS doesn't offer, you'll have to supply these as RPMs as well.

Generally, you're trying to reinvent the wheel. There's already modern gdb packaging, so stick to that.

"EC2" doesn't at all tell us which version of amazon linux (which as far as I know is not RHEL) you're using, so I can't really advice on that, but if in doubt,

  1. Set up a privileged container, a VM or a machine that runs a modern Fedora (38, currently),
  2. Install fedpkg and mock thereon, sudo dnf install --refresh -y fedpkg mock
  3. clone the current gdb fedora RPM package: fedpkg clone rpms/gdb
  4. cd gdb
  5. fedpkg mockbuild --root /etc/mock/amazonlinux-2023-x86_64.cfg (check /etc/mock for alternative platforms) in the result, you get the .rpms in a subfolder.

Because the whole directory is a git repository, you can check out any previous version you want, but my guess is you want the most current and don't to have anything special after 3.

If you're really on amazonlinux2023: It seems the GPG keys for amazonlinux-2023 might currently be messed up, and you must set gpgcheck=0 for all three entries in /etc/mock/template/amazonlinux-2023.tpl. I don't like that any more than you probably do, but fixing that with the correct keyring is kind of out of scope for me currently.

  • I just checked, Im using Amazon Linux 2012. The thing with Fedora might be incompatible (though it's a nice way and i'll keep it in my mind).
    – danwgh
    Jul 24 at 13:00
  • Is compiling it once on this ec2 and just creating an RPM to install it sounds good? or there are better ways of doing something like this?
    – danwgh
    Jul 24 at 13:01
  • good. Also, already addressed this in my answer, I thought? Jul 24 at 13:01
  • there's no amazon Linux 2012. And you must have read only half my answer if you think this is going to be a fedora-compatibe package. Please read my whole answer! Jul 24 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .