Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please port the gnu --prefix and --libdir options to meson #474

Open
0strodamus opened this issue Nov 14, 2021 · 14 comments
Open

Please port the gnu --prefix and --libdir options to meson #474

0strodamus opened this issue Nov 14, 2021 · 14 comments

Comments

@0strodamus
Copy link

Please port the gnu --prefix and --libdir options to meson before removing the gnu make build system.

Passing options "--prefix=/usr --libdir=/usr/lib" results in command "meson configure build" showing the correct values under "User defined options" such as:
bindir : /usr/bin
libdir : /usr/lib
sysconfdir : /etc

However, the "meson compile" build still installs things in the default locations. This results in a "meson install" failure of "ln: failed to create symbolic link '/home/.../openrc-0.44.8-1/pkg/openrc/usr/bin/service': No such file or directory" due to the file actually being in '/home/.../openrc-0.44.8-1/pkg/openrc/bin/service' (missing /usr).

I can use the option "-D rootprefix=/usr" like Artix is doing to workaround this, however then I find oddities like "openvpn_dir:=/usr/etc/openvpn" (incorrect /usr prefix) in /usr/share/openrc/support/init.d.examples/openvpn instead of "openvpn_dir:=/etc/openvpn".

I don't feel comfortable migrating my system to meson builds until they are a 1:1 match with the gnu make builds. Thanks in advance for any consideration to porting these options before removing gnu make support and for providing openrc. Your hard work is much appreciated!

@williamh
Copy link
Contributor

It looks like the issue is with rootprefix not being smart enough by default to detect whether a system has the /usr merge. Currently the default rootprefix is '/', but it should be '/usr' if /bin is a symlink. To fix this, I'll need to require >= meson 0.53.0. I will run a test on ci to make sure that is possible.

The issues you are seeing in the "support" directory are a separate issue that exists with the gnu make build system as well.

williamh added a commit that referenced this issue Nov 28, 2021
This requires at leaste meson 0.53.0 since it uses the fs module.

This is for #474.
williamh added a commit that referenced this issue Nov 29, 2021
I can't think of a reason to do this since these scripts are just
examples.

This is for #474.
williamh added a commit that referenced this issue Nov 29, 2021
I can't think of a reason to do this since these scripts are just
examples.

This is for #474.
@0strodamus
Copy link
Author

0strodamus commented Nov 30, 2021

Thanks for the response and code changes. I tried compiling the 0.44.9 tarball with meson-0.60.2, with commit "build: set rootprefix_default to /usr if on a /usr merged system" patched in, and without option "-D rootprefix=/usr". The "meson install" failure "ln: failed to create symbolic link..." I reported is fixed. The init.d example files now match between gnu make and meson builds. I only noticed a few differences summarized by the diff below.

diff '--color=auto' -aurN gnu-make/usr/include/rc.h meson/usr/include/rc.h
--- gnu-make/usr/include/rc.h	2021-11-29 16:51:34.000000000 -0700
+++ meson/usr/include/rc.h	2021-11-29 17:10:25.000000000 -0700
@@ -52,7 +52,7 @@
 /* PKG_PREFIX is where packages are installed if different from the base OS
  * On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD
  * /usr/pkg. */
-#undef RC_PKG_PREFIX
+#define RC_PKG_PREFIX		"/usr"
 #ifdef RC_PKG_PREFIX
 #  define RC_PKG_INITDIR        RC_PKG_PREFIX "/etc/init.d"
 #  define RC_PKG_CONFDIR        RC_PKG_PREFIX "/etc/conf.d"
diff '--color=auto' -aurN gnu-make/usr/lib/openrc/sh/functions.sh meson/usr/lib/openrc/sh/functions.sh
--- gnu-make/usr/lib/openrc/sh/functions.sh	2021-11-29 16:51:34.000000000 -0700
+++ meson/usr/lib/openrc/sh/functions.sh	2021-11-29 17:10:25.000000000 -0700
@@ -62,7 +62,7 @@
 		case "$p" in
 			/usr/lib/openrc/bin|/usr/lib/openrc/sbin);;
 			/usr/bin|/usr/bin|/usr/bin|/usr/sbin);;
-			/bin|/sbin);;
+			/usr/bin|/usr/sbin);;
 			/usr/local/bin|/usr/local/sbin);;
 			*) path="$path${path:+:}$p";;
 		esac
@@ -80,7 +80,7 @@
 
 # Make a sane PATH
 _PREFIX=/usr
-_PKG_PREFIX=
+_PKG_PREFIX=/usr
 _LOCAL_PREFIX=/usr/local
 _LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local}
 _PATH=/usr/lib/openrc/bin
diff '--color=auto' -aurN gnu-make/usr/lib/openrc/sh/gendepends.sh meson/usr/lib/openrc/sh/gendepends.sh
--- gnu-make/usr/lib/openrc/sh/gendepends.sh	2021-11-29 16:51:34.000000000 -0700
+++ meson/usr/lib/openrc/sh/gendepends.sh	2021-11-29 17:21:37.459285411 -0700
@@ -56,7 +56,7 @@
 _done_dirs=
 for _dir in \
 /etc/init.d \
-/etc/init.d \
+/usr/etc/init.d \
 /usr/local/etc/init.d
 do
 	[ -d "$_dir" ] || continue

To summarize, when building with meson, I'm seeing duplicates of /usr/bin and /usr/sbin in the _sanitize_path function in file functions.sh and /usr/etc/init.d in the _done_dirs variable in file gendepends.sh (maybe this is a valid path for /etc on some systems?).

I don't know how helpful this information is, but I wanted to report back with something. Thanks again for everything!

EDIT: replaced autotools with gnu make

@williamh
Copy link
Contributor

@0strodamus I deliberately didn't include the extra commit you patched in because it will break one of my downstream users. Alpine is using muon instead of meson, and they don't have support for fs.is_symlink yet. Also, I don't know how you are doing an autotools build, there is no support for autotools in the repository.

@0strodamus
Copy link
Author

My mistake, I meant gnu make. I corrected my original post. Sorry for any confusion!

@williamh
Copy link
Contributor

@0strodamus No problem. :-)

Can you show me the commands you are using to do the build (both for meson and gnu make) I?
I want to attempt to figure out why you are encountering those differences.

@0strodamus
Copy link
Author

Sure! I hope I'm not doing something stupid!

For gnu make, I'm using command:

_args=(
  SYSCONFDIR=/etc
  PREFIX=/usr
  BINDIR=/usr/bin
  SBINDIR=/usr/bin
  LIBDIR=/usr/lib
  LIBMODE=0644
  SHLIBDIR=/usr/lib
  LIBEXECDIR=/usr/lib/openrc
  MKAUDIT=no
  MKSELINUX=no
  MKPAM=pam
  MKTERMCAP=ncurses
  MKNET=no
  MKBASHCOMP=yes
  MKZSHCOMP=no
  MKPKGCONFIG=yes
  BRANDING='Arch Linux'
  )
make "${_args[@]}"

For meson, I'm applying Artix Linux's librcdir patch and using commands:

meson setup "${srcdir}"/${pkgname}-${pkgver} build \
  -D sysconfdir=/etc \
  -D bindir=/usr/bin \
  -D sbindir=/usr/bin \
  -D librcdir=/usr/lib/openrc \
  -D audit=disabled \
  -D bash-completions=true \
  -D branding="\"Arch Linux\"" \
  -D newnet=false \
  -D os=Linux \
  -D pam=true \
  -D pkgconfig=true \
  -D selinux=disabled \
  -D split-usr=true \
  -D sysvinit=false \
  -D termcap=ncurses \
  -D zsh-completions=false \
  -D b_lto=true \
  -D b_pie=true \
  --buildtype plain --auto-features enabled --wrap-mode nodownload --prefix=/usr --libdir=/usr/lib
meson configure build
meson compile -C build

@williamh
Copy link
Contributor

@0strodamus Sorry I didn't get back to this right away. Based on your diffs, it looks like the only remaining issue is the setting of PKG_PREFIX, right?

@0strodamus
Copy link
Author

No problem. PKG_PREFIX and also /bin|/sbin are getting removed/replaced by duplicate /usr/bin|/usr/sbin entries in functions.sh when building with meson.

@eli-schwartz
Copy link

Maybe also relevant: mesonbuild/meson#2561

Seems like much of the complexity here is for the purpose of circumventing this limitation? Four years later, it is under consideration again to remove the restriction.

FWIW muon doesn't seem to care. So it would also be possible to just build with muon. But it would still be good to discuss removing the restriction in meson too.

@williamh
Copy link
Contributor

@eli-schwartz Maybe. I took the idea of ROOTPREFIX from http://github.com/systemd/systemd. I guess they have a similar issue where prefix is /usr but some things are installed optionally on /.

@williamh
Copy link
Contributor

williamh commented Dec 31, 2021

@eli-schwartz I am unable to build openrc with muon. The last time I attempted it, the fs module didn't have the is_symlink() function, e.g. something like this fails:

fs = import('fs')
if fs.is_symlink('/bin')
# do something
endif

Also , as of right now, muon can't be bootstrapped.
I don't want to hijack this bug with muon issues, so the short version is it is broken.

@eli-schwartz
Copy link

I see that openrc has added is_symlink usage since the time that I tested building openrc via muon.

(Sure it can be bootstrapped, there is a giant section in the README.md with the header "building", and the only build instructions for the project are for bootstrapping. This is not something easy to confuse.)

@williamh
Copy link
Contributor

@eli-schwartz This is what happens when I try to bootstrap the current git version.
http://dpaste.com/FG3N25L5J.txt

@eli-schwartz
Copy link

That error message says that the mandoc program is required but not found. (Specifically, it is required if the docs are built, which is the case when -Ddocs=enabled, or when -Ddocs=auto and the scdoc program is also found.)

You would get the same error if you tried building with meson and didn't disable the docs option, so I wouldn't call that a "bootstrap" error...

@vapier vapier changed the title Please port the gnu --prefix and --libdir options to meson before removing the gnu make build system. Please port the gnu --prefix and --libdir options to meson Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants