I recently had to rebuild Emacs to diagnose a problem. It turned out the problem wasn’t the Ubuntu Emacs build, but since I had to figure it out, I’m writing it down so I will remember next time.
Grab the GNU public keys
GNU has to be different. Rather than signing with some sane thing, they sign their files with gpg. 🙄 Anyway, here’s how to do that:
$ curl https://ftp.gnu.org/gnu/gnu-keyring.gpg --output gnu-keyring.gpg$ gpg --import gnu-keyring.gpg
# Yes, it just imported 552 keys.
Download Emacs and validate the signature
Feel free to substitute your favorite mirror for ftp.gnu.org
$ curl https://ftp.gnu.org/gnu/emacs/emacs-29.4.tar.gz.sig --output emacs-29.4.tar.gz.sig
$ curl https://ftp.gnu.org/gnu/emacs/emacs-29.4.tar.gz --output emacs-29.4.tar.gz
$ gpg --verify emacs-29.4.tar.gz.sig
emacs-29.4.tar.gz
gpg: Signature made Sat 22 Jun 2024 08:04:31 AM MST
gpg: using RSA key BB02E407AE9EAA87C9E72A1D2D4E1FE95957135D
gpg: issuer "stefankangas@gmail.com"gpg: Good signature from "Stefan Kangas <stefan@marxist.se>" [expired]
gpg: aka "Stefan Kangas <skangas@skangas.se>" [expired]
gpg: Note: This key has expired!
Primary key fingerprint: CEA1 DE21 AB10 8493 CC9C 6574 2E82 323B 8F43 53EE
Subkey fingerprint: BB02 E407 AE9E AA87 C9E7 2A1D 2D4E 1FE9 5957 135D
I guess? that means it’s trustworthy?
Install dependencies
In order to build you’ll need some dependencies, so install those using apt.
$ sudo apt install libgtk-3-dev libgif-dev libgnutls28-dev texinfo
Extract, build and install Emacs
Next, extract the files. Then configure Emacs for your environment, build it and finally install it.
$ tar xzvf emacs-29.4.tar.gz
$ cd emacs-29.4/
$ ./configure (or use ./configure --with-x-toolkit=no if you don't want X support)
$ make clean; make
$ sudo make install (this installs emacs in /usr/local/bin)
$ /usr/local/bin/emacs
(if you want to uninstall)
$ sudo make uninstall
This build installed Emacs in /usr/local/bin, which is ahead of /usr/bin in my path, so I can have both the version I built and the package version installed at the same time. Either change your path, alias emacs=/usr/local/bin/emacs, or uninstall the Ubuntu emacs package.
Clean up
Once you’re done, you can remove libgtk-3-dev, libgif-dev, libgnutls28-dev and texinfo. Or keep ‘em around, they won’t hurt anything.