Netatalk/netatalk

2.4: Meson build system doesn't install to the same paths as autotools with the equivilent options?

Closed this issue · 13 comments

Describe the bug
I tried this:

    meson setup build \
        -Dwith-tests=true \
        -Dwith-init-hooks=false \
        -Dwith-zeroconf=false \
        -Dwith-cracklib=false \
        -Dwith-ddp=true \
        -Dwith-pgp-uam=true \
        -Dwith-srvloc=true \
        -Dwith-init-style=systemd \
        -Dlibexecdir=/usr/lib \
        -Dlocalstatedir=/var \
        -Dprefix=/usr \
        -Dsbindir=/usr/bin \
        -Dsysconfdir=/etc

I expected the paths to be equivalent to these:

    ./configure \
        --disable-install-privileged \
        --disable-zeroconf \
        --enable-ddp \
        --enable-pgp-uam \
        --enable-srvloc \
        --enable-systemd \
        --without-cracklib \
        --enable-shared \
        --libexecdir=/usr/lib \
        --localstatedir=/var \
        --prefix=/usr \
        --runstatedir=/run \
        --sbindir=/usr/bin \
        --sysconfdir=/etc \
        --with-systemd-prefix=/usr/lib

However I get the following really strange behaviour from the install root:

  1. /usr/etc/pam.d/netatalk (should be under /etc)
  2. /usr/var/spool/netatalk (should be under /var)
  3. Configs are now directly under /etc instead of under /etc/netatalk, so --sysconfdir is not the same as -Dsysconfdir (do I need to put -Dsysconfdir=/etc/netatalk)?
  4. Some headers are not installed identically:
    a. /usr/include/atalk/queue.h and /usr/include/atalk/rtmp.h are missing
    b. /usr/include/netatalk/at.h is new
  5. Some files in /usr/lib are missing:
    a. etc2ps.sh
  6. Reading through meson-options.txt I cannot find any equivalent to --with-systemd-prefix nor --runstatedir (nor are those two built into meson itself). Are they not needed any more? In particular, Arch does not use /var/run for runstate, just /run.

To Reproduce
The build commands above

Expected behavior
A way to get the same installed file system layout as with autotools.

Environment

  • Server OS: Arch Linux
  • Client OS Not appliccable
  • Netatalk Version 2.4.6

Logs
N/A

Additional context
N/A

Do you get a different result if you invoke the built-in options with -- rather than -D? I believe this is the correct syntax, as per: https://mesonbuild.com/Commands.html#setup

It's confusing, because they have a fallback where built-in options passed with -D are indeed recognized, but in particular prefix is buggy when used in this way, in my experience.

Regarding the config files, you should be able to use this to get the intended outcome: -Dwith-pkgconfdir-path=/etc/netatalk

The runstatedir path is defined in a funny way, not directly via either build system but with a -D_PATH_LOCKDIR compiler argument, according to the documentation: https://github.com/Netatalk/netatalk/blob/branch-netatalk-2-4/doc/DEVELOPER -- So one idea to make this work without changing the C code would be to add it as a global compiler argument in Meson https://mesonbuild.com/Adding-arguments.html (note for self.)

Regarding the systemd prefix, this is not currently possible in 2.x, but in 3.x we have a Meson option -Dwith-init-dir which I could port over. It will allow you to specify any arbitrary path for whatever init style that you have activated. Out of curiosity, is Arch putting the systemd unit files in a different dir than /usr/lib/systemd/system?

Regarding at.h, funnily enough you reported this a year ago in #409 and I fixed it for autotools. But the fix mustn't have made it into Meson

The missing queue.h and rtmp.h seem to be simple oversights. Should be easy to fix. Same goes for etc2ps.sh, which should go into libexecdir according to the Makefile.

Do you get a different result if you invoke the built-in options with -- rather than -D? I believe this is the correct syntax, as per: https://mesonbuild.com/Commands.html#setup

I will look into this when I get back to my computer this evening.

"pkgconfdir" sounds like it has to do with pkg-config? I guess not?

Out of curiosity, is Arch putting the systemd unit files in a different dir than /usr/lib/systemd/system?

No, and it actually seems that part is fine currently. I know Debian stable puts it under /lib/systemd/system because they haven't completed the /usr-merge yet. I don't remember why I needed the flag for autotools, was the default different there?

"pkgconfdir" sounds like it has to do with pkg-config? I guess not?

No, it refers to the config files of the "package" (netatalk) as opposed to the config files of the rest of the system. Hence the logical separation between pkgconfdir (/etc/netatalk) and sysconfdir (/etc). This is a convention inherited from netatalk's autotools build system.

Out of curiosity, is Arch putting the systemd unit files in a different dir than /usr/lib/systemd/system?

No, and it actually seems that part is fine currently. I know Debian stable puts it under /lib/systemd/system because they haven't completed the /usr-merge yet. I don't remember why I needed the flag for autotools, was the default different there?

The default in autotools is also /usr/lib/systemd/system actually...

@rdmark using --prefix, --localstatedir etc does not fix /usr/var or /usr/etc.

I now have:

    arch-meson "$_pkgname-$pkgver" build \
        -Dwith-tests=true \
        -Dwith-init-hooks=false \
        -Dwith-zeroconf=false \
        -Dwith-cracklib=false \
        -Dwith-kerberos=false \
        -Dwith-ddp=true \
        -Dwith-pgp-uam=true \
        -Dwith-srvloc=true \
        -Dwith-init-style=systemd \
        --localstatedir /var \
        --sysconfdir /etc \
        -Dwith-pkgconfdir-path=/etc/netatalk

where arch-meson (which should be used according to the packaging guidelines) is:

#!/bin/bash -ex
# Highly opinionated wrapper for Arch Linux packaging

exec meson setup \
  --prefix        /usr \
  --libexecdir    lib \
  --sbindir       bin \
  --buildtype     plain \
  --auto-features enabled \
  --wrap-mode     nodownload \
  -D              b_pie=true \
  -D              python.bytecompile=1 \
  "$@"

Here is the output of namcap (the Arch Linux linting tool):

namcap netatalk2-2.4.6-2-x86_64.pkg.tar.zst
netatalk2 W: Directory (usr/var/spool/netatalk) is empty
netatalk2 W: File (usr/etc/) exists in a non-standard directory.
netatalk2 W: File (usr/etc/pam.d/) exists in a non-standard directory.
netatalk2 W: File (usr/etc/pam.d/netatalk) exists in a non-standard directory.
netatalk2 W: File (usr/var/) exists in a non-standard directory.
netatalk2 W: File (usr/var/spool/) exists in a non-standard directory.
netatalk2 W: File (usr/var/spool/netatalk/) exists in a non-standard directory.
netatalk2 E: File in backup array (etc/pam.d/netatalk) not found in package
netatalk2 W: File (usr/bin/afppasswd) is setuid or setgid.
netatalk2 W: File (usr/var/spool/netatalk) has the world writable bit set.

Thanks for testing. Looking at the Debian package spec, I was reminded of these overrides for pam.d and spool:

-Dwith-pam-config-path=/etc/pam.d
-Dwith-spooldir=/var/spool/netatalk

If you set these, do the relevant linting failures get resolved?

As a side note, the last two linter warnings can be safely ignored. For one, afppasswd needs setuid in order for users to change their own passwords. See #938 ... And regarding the spool dir permissions, this is required for regular users to print with papd.

That worked. Hm I wonder what this is about:

netatalk2 W: Referenced library 'libatalk.so.0' is an uninstalled dependency (needed in files ['usr/lib/netatalk/uams_dhx_passwd.so', 'usr/bin/cnid_dbd', 'usr/bin/getzones', 'usr/bin/uniconv', 'usr/bin/dbd', 'usr/bin/adv1tov2', 'usr/bin/atalkd', 'usr/bin/nbpunrgstr', 'usr/bin/ad', 'usr/bin/afpd', 'usr/bin/showppd', 'usr/bin/papd', 'usr/bin/pap', 'usr/bin/aecho', 'usr/bin/megatron', 'usr/bin/a2boot', 'usr/bin/afppasswd', 'usr/bin/timelord', 'usr/bin/nbplkup', 'usr/bin/papstatus', 'usr/lib/netatalk/uams_randnum.so', 'usr/lib/netatalk/uams_dhx_pam.so', 'usr/bin/afpldaptest', 'usr/bin/cnid_metad', 'usr/bin/nbprgstr'])

I don't get that warning for the old autotools build. But it also looks like the autotools build was statically linked instead of dynamically linked?

EDIT: Also it seems the so-version isn't set (libatalk.so.0.0.0)?

So, because this bug ended up being about multiple small related issues (my bad), what seems to remain:

  • at.h
  • queue.h
  • rtmp.h
  • etc2ps.sh
  • ld.so.conf.d

That worked. Hm I wonder what this is about:

netatalk2 W: Referenced library 'libatalk.so.0' is an uninstalled dependency (needed in files ['usr/lib/netatalk/uams_dhx_passwd.so', 'usr/bin/cnid_dbd', 'usr/bin/getzones', 'usr/bin/uniconv', 'usr/bin/dbd', 'usr/bin/adv1tov2', 'usr/bin/atalkd', 'usr/bin/nbpunrgstr', 'usr/bin/ad', 'usr/bin/afpd', 'usr/bin/showppd', 'usr/bin/papd', 'usr/bin/pap', 'usr/bin/aecho', 'usr/bin/megatron', 'usr/bin/a2boot', 'usr/bin/afppasswd', 'usr/bin/timelord', 'usr/bin/nbplkup', 'usr/bin/papstatus', 'usr/lib/netatalk/uams_randnum.so', 'usr/lib/netatalk/uams_dhx_pam.so', 'usr/bin/afpldaptest', 'usr/bin/cnid_metad', 'usr/bin/nbprgstr'])

I don't get that warning for the old autotools build. But it also looks like the autotools build was statically linked instead of dynamically linked?

EDIT: Also it seems the so-version isn't set (libatalk.so.0.0.0)?

This is an odd one that I haven't seen before. What does it look like in your lib dir after installing? There should be a libatalk.so.0.0.0 library with libatalk.so.0 and libatalk.so symlinks pointing to it.

The library is defined like this currently:

libatalk = library(
    'atalk',
    libatalk_sources,
    include_directories: root_includes,
    dependencies: [libatalk_deps, libcnid_deps],
    link_whole: [
        ...
    ],
    version: '0.0.0',
    soversion: '0',
    install: true,
)

The library() target is flexible, allowing the user to define whether to build shared, static, or both libraries. The default behavior in autotools was to build both, while Meson builds shared only by default. If you want to emulate the old behavior, pass this to meson setup: -Ddefault_library=both

What is the policy in Arch for libraries? In Fedora and Debian, it is mandatory to package only shared libraries, so any static libraries have to be removed. Back in the autotools days, we had post-build steps to run rm on any .a files...

So, because this bug ended up being about multiple small related issues (my bad), what seems to remain:

* at.h

* queue.h

* rtmp.h

* etc2ps.sh

* ld.so.conf.d

The first four I can address in this ticket while the ld.so.conf.d situation has its own ticket that you created.

How about the runstatedir? I think you said you need to override the Linux default with /var for Arch?

This should do the trick for the missing files: #1398

Filed #1400 and #1401 for further improvements.

Closing this ticket for now! If you don't mind, I would ask you to file new tickets for other build system issues...