Building Emacs using `PKGBUILD`, tests failing when doing `make check`

I’m trying to compile Emacs 29.4 from source with my own build options, using makepkg and a PKGBUILD file.

I borrowed heavily from the Arch version here, with a few changes.

In my PKGBUILD file I decided to include a make -k check to test the build:

check (){
        cd "$pkgname-$pkgver"
        make -k check
}

Unfortunately, I keep getting an error from emacs-tests/bwrap/allows-stdout:

SUMMARY OF TEST RESULTS
-----------------------
Files examined: 471
Ran 7205 tests, 7036 results as expected, 2 unexpected, 167 skipped
2 files contained unexpected results:
src/emacs-tests.log
lisp/progmodes/flymake-tests.log
make[2]: *** [Makefile:341: check-doit] Error 1
make[2]: Leaving directory '/home/nonreligious/src/emacs-29.4-build/src/emacs-my-build-29.4/test'
make[1]: *** [Makefile:310: check] Error 2
make[1]: Leaving directory '/home/nonreligious/src/emacs-29.4-build/src/emacs-my-build-29.4/test'
make: *** [Makefile:1105: check] Error 2
==> ERROR: A failure occurred in check().
Aborting...

The relevant part of test/src/emacs-tests.log is shown at the of this Reddit post.

Is this an actual problem? Should I just skip the check() part of PKBGUILD (which isn’t in the official Arch PKGBUILD file)?

Does anyone else have experience doing this?

I don’t have any experience doing this, but there is likely no harm in trying it without that option.

If you’re testing software, I’d suggest doing it in a Virtual Machine, though.

Error opening /var/log/audit/audit.log (No such file or directory)

Do you even have audit enabled? - I know I don’t.
My grub command line looks like this:
GRUB_CMDLINE_LINUX_DEFAULT="mitigations=off audit=0 udev.log_priority=3"

That file indeed does not exist and this is normal (for me) and intentional.

And even if it is enabled, the audit messages might not go to this file, but to the system journal instead.
journalctl ...
But that I don’t know.

1 Like

@BG405 Thanks. I think this is fairly safe as things go, provided you are careful. Fortunately, I’ve just been running makepkg so that an installable package is created, but not makepkg -i to install that package. After makepkg, there’s a built Emacs located in the package subdirectory that can be run to test if everything works before installation. As far as I can tell, everything seems fine, but I want to double check.

@Nachlese This is interesting – could you say more about how audit is configured? My /etc/default/grub has no mention of audit in it, and auditd.service is inactive (dead) according to systemctl.

1 Like

No, I can’t. (but as it turns out I will anyway :wink: )
I knew that I didn’t want it, because I wouldn’t look at it’s log messages anyway, so I disabled it by way of this grub parameter (and out of habit).

Then this sounds like a good explanation for the non-existent log file.

The Arch wiki says:

Audit can be enabled at boot-time by setting audit=1 as kernel parameter.

… it needs to be explicitly enabled -
therefore:
not having that log file present is perfectly normal

1 Like

@Nachlese Thanks very much for the info! I did look at the Arch wiki but wasn’t quite sure how prevalent use of audit is.

I guess my options are either to forget about the tests and make -k check, or to figure out a way of getting the tests to bypass the audit logs.

1 Like

I’d say that it is not important how prevalent it’ use is
but rather whether you want or even need the functionality.

If this is the only test that failed (and you know why it failed), why not just forget about it?
You could also create that file, thereby cheating on yourself :nerd_face: so that the test will be happy …

2 Likes

You could also create that file, thereby cheating on yourself :nerd_face: so that the test will be happy

That’s a good suggestion … which would be very ironic because part of the reason I’m trying to use the PKGBUILD framework is because I was recommended that it would be better to install packages this way rather than just installing it via make and registering it with pacman via another shortcut (see here).

I’ll see how it goes!

1 Like

… no, not ironic

You decided to run the built in tests, which are not run, not enabled, when you use the compilation options in the PKGBUILD.

You should know what these tests do - why they are there - what they test for - and what it means when a test fails.

In this case:
I don’t know the test condition or purpose - you can know (learn) that by looking at the file that defines the test conditions.
… it seems to be the simple existence of the file - you just need to look at the file that runs the test …

What you seem to misunderstand:

the PKGBUILD is the very same as you running “make” with specific parameters, so that the result will well integrate with the system.
You could just as well run “make” yourself - but then the package manager wouldn’t “know” about what you did (which is the entire purpose of a package manager - to reliably keep track of what is in the system, how to update it, how to remove it).
You can do all that yourself - greetings from LFS (Linux from Scratch) - but even they have implemented a way of tracking what is done to the system.

I assure you, this is the one part I do understand! The point is that I have previously built Emacs by downloading and extracting the tarball and running make via ./configure. The problem was that even after symlinking the package so that my system would detect it, there were issues with “helper” programs for Emacs packages not recognizing the current Emacs version, so I had to write a pseudo-package file for Emacs (with only details like the name and version number) and ran makepkg -i so that this would register my built Emacs in the package database.

This time, rather than go the “fake” way I decided to do the “proper” thing and put all my configuration flags into a PKGBUILD file and build + register it in (more-or-less) one go. Unfortunately I’ve tried to be extra careful and run the tests as well, but now it seems the best advice would be to “fake” the test condition and continue (or not just run the tests). Hence the irony.

(Or maybe to you “irony” is just something in an Alanis Morissette song …)

Here is the PKGBUILD for Emacs

from here:

Arch Linux / Packaging / Packages / emacs · GitLab

coming from here:
https://archlinux.org/packages/extra/x86_64/emacs/

and taking the “Source files” link top right.

No need to create your own - just adapt it to run your tests …

Yes, as I said in my original post, this is what I’ve done! Including the modification to add the tests, which is what the whole issue is about.

Hmm - what issue?
The failed test for a non existent file? - Of which you know why it doesn’t exist?

I don’t follow.

1 Like

I added

check (){
	cd "$pkgname-$pkgver"
	make -k check 
}

among other modifications, to the default PKGBUILD file, because I previously used to run tests when building Emacs “by hand”.

However, including this would cause the whole makepkg process to abort, because of the test result shown above. I wasn’t sure what the cause of this test failure was – something trivial or something wrong with the build process, because it doesn’t occur when I build “by hand”.

there are multiple “make” steps in this PKGBUILD

perhaps your check() function wasn’t placed right inside the PKGBUILD?

I’m tinkering right now - first it needs to finish building the thing - then I’ll try to learn and run the “make test” by hand …
my system is not the fastest - and this happens in a VM as well

Thanks for looking into this – it’s late where I am so I’ll have to pick this up in the morning.

there are multiple “make” steps in this PKGBUILD
perhaps your check() function wasn’t placed right inside the PKGBUILD?

I doubt it, because I’ve followed both the ArchWiki page on this and the PKGBUILD.proto file in /usr/share/pacman.

How ?

this is the original PKGBUILD
# Maintainer: Juergen Hoetzel <juergen@archlinux.org>
# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Renchi Raju <renchi@green.tam.uiuc.edu>

pkgbase=emacs
pkgname=(emacs emacs-nativecomp emacs-nox emacs-wayland)
pkgver=29.4
pkgrel=3
arch=('x86_64')
url='https://www.gnu.org/software/emacs/emacs.html'
license=('GPL3')
depends=(
  gmp
  gnutls
  jansson
  lcms2
  libacl.so
  libasound.so
  libdbus-1.so
  libfontconfig.so
  libfreetype.so
  libgdk-3.so
  libgdk_pixbuf-2.0.so
  libgif.so
  libgio-2.0.so
  libglib-2.0.so
  libgobject-2.0.so
  libgpm.so
  libgtk-3.so
  libharfbuzz.so
  libice
  libjpeg.so
  libncursesw.so
  libotf
  libpango-1.0.so
  libpng
  librsvg-2.so
  libsm
  sqlite libsqlite3.so
  libsystemd.so
  libtiff.so
  libtree-sitter.so
  libwebp.so
  libwebpdemux.so
  libxfixes
  libxml2.so
  m17n-lib
  zlib
)
makedepends=(libgccjit)
source=(https://ftp.gnu.org/gnu/emacs/${pkgname}-${pkgver}.tar.xz{,.sig})
b2sums=('825fd2665b6427dbc3cb618b40df2f71fa6b08883bdd07be6d8acf0039df2aeebd294e679e98f4c64a9dd9bdad93589fc7c176cf3860d4fb823fce23f7f2b3cd'
        'SKIP')
validpgpkeys=('17E90D521672C04631B1183EE78DAE0F3115E06B'  # Eli Zaretskii <eliz@gnu.org>
              'CEA1DE21AB108493CC9C65742E82323B8F4353EE') # Stefan Kangas <stefankangas@gmail.com>

prepare() {
  cp --reflink=auto -ar ${pkgname}-${pkgver} ${pkgbase}-${pkgver}-nativecomp
  cp --reflink=auto -ar ${pkgname}-${pkgver} ${pkgbase}-${pkgver}-nox
  cp --reflink=auto -ar ${pkgname}-${pkgver} ${pkgbase}-${pkgver}-wayland
}

build() {
  local _confflags="--sysconfdir=/etc \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --with-tree-sitter \
    --localstatedir=/var \
    --with-cairo \
    --disable-build-details \
    --with-harfbuzz \
    --with-libsystemd \
    --with-modules"

  export ac_cv_lib_gif_EGifPutExtensionLast=yes

  cd ${pkgname}-${pkgver}
  ./configure $_confflags \
    --with-x-toolkit=gtk3
  make

  cd ../${pkgbase}-${pkgver}-nativecomp
  ./configure \
    --with-x-toolkit=gtk3 \
    --with-native-compilation=aot \
    $_confflags
  make bootstrap

  cd ../${pkgbase}-${pkgver}-nox
  ./configure \
    --without-x \
    --without-sound \
    $_confflags
  make

  cd ../${pkgbase}-${pkgver}-wayland
  ./configure \
    --with-pgtk \
    --with-native-compilation=aot \
    $_confflags
  make bootstrap
}

package_emacs() {
  pkgdesc='The extensible, customizable, self-documenting real-time display editor'

  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  # remove conflict with ctags package
  mv "${pkgdir}"/usr/bin/{ctags,ctags.emacs}
  mv "${pkgdir}"/usr/share/man/man1/{ctags.1.gz,ctags.emacs.1}

  # fix user/root permissions on usr/share files
  find "${pkgdir}"/usr/share/emacs/${pkgver} -exec chown root:root {} \;
}

package_emacs-nativecomp() {
  pkgdesc='The extensible, customizable, self-documenting real-time display editor with native compilation enabled'
  depends+=(libgccjit)
  provides=(emacs)
  conflicts=(emacs)

  cd ${pkgbase}-${pkgver}-nativecomp
  make DESTDIR="${pkgdir}" install

  # remove conflict with ctags package
  mv "${pkgdir}"/usr/bin/{ctags,ctags.emacs}
  mv "${pkgdir}"/usr/share/man/man1/{ctags.1.gz,ctags.emacs.1}

  # fix user/root permissions on usr/share files
  find "${pkgdir}"/usr/share/emacs/${pkgver} -exec chown root:root {} \;
}

package_emacs-nox() {
  pkgdesc='The extensible, customizable, self-documenting real-time display editor without X11 support'
  depends=(
    gmp
    gnutls
    hicolor-icon-theme
    jansson
    lcms2
    libacl.so
    libdbus-1.so
    libgpm.so
    libncursesw.so
    libsystemd.so
    libtree-sitter.so
    libxml2.so
    zlib
  )
  provides=(emacs)
  conflicts=(emacs)

  cd ${pkgbase}-${pkgver}-nox
  make DESTDIR="${pkgdir}" install

  # remove conflict with ctags package
  mv "${pkgdir}"/usr/bin/{ctags,ctags.emacs}
  mv "${pkgdir}"/usr/share/man/man1/{ctags.1.gz,ctags.emacs.1}

  # fix user/root permissions on usr/share files
  find "${pkgdir}"/usr/share/emacs/${pkgver} -exec chown root:root {} \;
}

package_emacs-wayland() {
  pkgdesc='The extensible, customizable, self-documenting real-time display editor with native compilation and PGTK enabled'
  depends+=(libgccjit)
  provides=(emacs)
  conflicts=(emacs)

  cd ${pkgbase}-${pkgver}-wayland
  make DESTDIR="${pkgdir}" install

  # remove conflict with ctags package
  mv "${pkgdir}"/usr/bin/{ctags,ctags.emacs}
  mv "${pkgdir}"/usr/share/man/man1/{ctags.1.gz,ctags.emacs.1}

  # fix user/root permissions on usr/share files
  find "${pkgdir}"/usr/share/emacs/${pkgver} -exec chown root:root {} \;
}

it’s half eleven pm here but I’ll still stay a bit

I use the following (I’ve left out the dependency list here for ease of reading, but that’s included as well)

# Maintainer: Nonreligious <nonreligious@gmail.com>
pkgbase='emacs'
pkgname='emacs-nonreligious-build'
pkgver=29.4
pkgrel=3
pkgdesc='My local version of the extensible, customizable, self-documenting real-time display editor.'
arch=('x86_64')
license=('GPL3')
url='https://www.gnu.org/software/emacs/emacs.html'
provides=('emacs')
conflicts=('emacs')
source=(${pkgname}-${pkgver}.tar.xz{,.sig})
b2sums=('825fd2665b6427dbc3cb618b40df2f71fa6b08883bdd07be6d8acf0039df2aeebd294e679e98f4c64a9dd9bdad93589fc7c176cf3860d4fb823fce23f7f2b3cd'
        'SKIP')

validpgpkeys=('17E90D521672C04631B1183EE78DAE0F3115E06B'  # Eli Zaretskii <eliz@gnu.org>
              'CEA1DE21AB108493CC9C65742E82323B8F4353EE') # Stefan Kangas <stefankangas@gmail.com>

prepare() {
  cp --reflink=auto -ar ${pkgname}-${pkgver} ${pkgbase}-${pkgver}
}

build() {
    local _confflags="--sysconfdir=/etc \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --localstatedir=/var \
    --with-cairo \
    --with-harfbuzz \
    --with-libsystemd \
    --with-modules \
    --with-x-toolkit=gtk3
    --with-xwidgets \
    --with-imagemagick \
    --with-mailutils \
    --with-native-compilation=aot \
    --with-tree-sitter"
    
   # --with-x-toolkit=lucid \ 
    
    cd ${pkgname}-${pkgver}
    ./configure $_confflags
    # use bootstrap because of native-compilation ...
    make bootstrap
  
    export ac_cv_lib_gif_EGifPutExtensionLast=yes
}

check (){
	cd "$pkgname-$pkgver"
	# -k flag for --keep-going, continue as much as possible after error
	make -k check 
}

package() {
    cd ${pkgname}-${pkgver}
    
    # $pkgdir will be emacs-29.4-build/pkg/emacs
    make DESTDIR="${pkgdir}" install 

    # remove conflict with ctags package
    mv "${pkgdir}"/usr/bin/{ctags,ctags.emacs}
    mv "${pkgdir}"/usr/share/man/man1/{ctags.1.gz,ctags.emacs.1}
   
    # fix user/root permissions on usr/share files
    find "${pkgdir}"/usr/share/emacs/${pkgver} -exec chown root:root {} \;
}

… which I wouldn’t even try - because there is a reason that the (original) PKGBUILD looks like it does

I’m thankful for the work the maintainer has put into it.
Your’s looks a lot simpler, it’s certainly shorter.

but:
there is a reason that the (original) PKGBUILD looks like it does :man_shrugging:

… the thing is still compiling here - see how long it’ll take

It looks like it does because they’re building what they believe to be all the most popular Emacs configurations that Arch-based distro users want! This is a simplification of it to get rid of the useless emacs-wayland builds which I don’t need for my system.

Come on, don’t be afraid of tinkering with code – that’s what Linux is all about!