Bug 2915 - Don't use /usr/libexec
Summary: Don't use /usr/libexec
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.4
Assignee: Saul Wold
QA Contact:
URL:
Whiteboard: (patch review)
Depends on:
Blocks:
 
Reported: 2012-08-08 04:40 UTC by Ross Burton
Modified: 2013-04-26 18:30 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2012-08-08 04:40:07 UTC
The FHS doesn't mention /usr/libexec and we should aim to be as FHS-compliant as possible.  Distros without libexec normally use /usr/lib/[source package name]/ instead.

This should be a two minute change to make, but verifying will be harder.  A sanity check that nothing was installed into /usr/libexec will be a start, but can we grep the installed scripts/binaries to verify that nothing has hardcoded /usr/libexec into an executable?
Comment 1 Saul Wold 2012-08-13 14:04:58 UTC
The first pass for this will be to add warnings via the sanity test, there is a large list of recipes that have libexec, so it's not a "two minute change"!

I will work on the first part of the sanity check and then add to it to create the second part, initially these will produce WARNINGS.
Comment 2 Mark Hatle 2012-08-13 17:13:01 UTC
Note, we should still support /usr/libexec if the user has configured the system for this.

So any sanity checks should check for the value of ${prefix}/libexec as libexecdir, and then avoid warnings/errors.

The suggested new default libexecdir format is:

${prefix}/lib/${BPN}
Comment 3 Richard Purdie 2012-10-18 11:46:41 UTC
The default has changed in master: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=1d18224b24a515a07170ce36dbd725cb203d3300
Comment 4 Enrico Scholz 2013-04-26 15:24:54 UTC
Unfortunately, this change breaks multilib and programs using libexecdir.  libexecdir is defined by the GNU standard as

| The definition of ‘libexecdir’ is the same for all packages

[http://www.gnu.org/prep/standards/html_node/Directory-Variables.html]

Making it dependent on architecture and ${PN} breaks programs which try to execute e.g. ${libexecdir}/sftp-server.

Blindly following FHS is a bad idea because FHS is far behind its time and does not provide solutions for problems like multilib.
Comment 5 Ross Burton 2013-04-26 15:31:38 UTC
One thing I bought up in the last few weeks thanks to the multilib/udev/systemd "fun" was that libexecdir should be defined like nonarch_libdir and hardcode "lib" so binaries don't move.  This doesn't entirely solve the ML problem as some libraries (ie pango, gdk-pixbuf) ship binaries in libexecdir, so they'll now conflict.
Comment 6 Mark Hatle 2013-04-26 15:39:40 UTC
What I'm used to seeing for libdir is something like:

noarch_libdir/${bpn}

That way the things live in '/usr/lib/recipe'.  No matter what the multilib is, everything will "just work".

The only tricky bit is if two different packages want to use the same location.  A common one will need to then be defined for both.

I think the real problem is that the libexecdir wasn't used reliably in the past, so people redefined it.. it lost some of it's meaning and then with the multilibs and things like systemd/udev it's made a comeback.  But with other interesting problems.
Comment 7 Ross Burton 2013-04-26 15:45:08 UTC
Agreed - probably best to define a non-ML libdir name as "lib" and use it for libexecdir, nonarch_libdir, etc.  Then at least these all not munged by libdir, and we've more symbols to re-use in the recipes.

Binaries that are tied to libraries have various forms of prior art - using gdk-pixbuf as an example as a library that has a utility binary, in Debian it's in the host-specific libdir and in Fedora it gets left in bindir but suffixed with the word size.  Both of these solutions work as the binary is 99% of the time called by postinst scripts.
Comment 8 Enrico Scholz 2013-04-26 15:46:13 UTC
libexecdir should/must not contain the package name because libexecdir is like bindir and programs hardcode calls to '${libexecdir}/foreign-script'.
Comment 9 Ross Burton 2013-04-26 15:55:57 UTC
Well we're not the only distro to put libexecdir into /usr/lib/[package], and it hasn't been a problem.  /usr/libexec *isn't* on the path and so anything being invoked in it has to use an absolute path anyway.
Comment 10 Enrico Scholz 2013-04-26 16:09:02 UTC
Which other distributions are making libexecdir dependent on ${PN}?
Comment 11 Ross Burton 2013-04-26 16:11:24 UTC
Debian and Ubuntu are obvious examples:

$ ls /usr/libexec
ls: cannot access /usr/libexec: No such file or directory
Comment 12 Enrico Scholz 2013-04-26 16:14:21 UTC
Debian defines libexecdir to be /usr/lib (minus multilib issues).

I speak about ${PN} in libexecdir; e.g. libexecdir would be

   /usr/lib/openssh-server   for openssh.bb
   /usr/lib/dropbear for dropbear.bb

dropbear calls '${libexecdir}/sftp-server' which is valid for openssh but not for dropbear.
Comment 13 Mark Hatle 2013-04-26 16:33:15 UTC
> I speak about ${PN} in libexecdir; e.g. libexecdir would be

BPN vs PN, since the PN can have the multilib in the name...

>   /usr/lib/openssh-server   for openssh.bb
>   /usr/lib/dropbear for dropbear.bb
>
> dropbear calls '${libexecdir}/sftp-server' which is valid for openssh but not for dropbear.

This is a place where coordination between packages is required.  In this case I'd expect openssh to set the standard and dropbear to either define it's own or use the definition from openssh.

I think the key thing is to define a reasonable value for the libexecdir, and then make sure recipes can override it easily as necessary.
Comment 14 Enrico Scholz 2013-04-26 16:43:25 UTC
> BPN vs PN, since the PN can have the multilib in the name...

ok; there is a difference between BPN and PN. But with both, libexecdir would be inconsistent between packages violating expectations raised by the GNU standard.


> This is a place where coordination between packages is required.  In this case
> I'd expect openssh to set the standard and dropbear to either define it's own
> or use the definition from openssh.

How would you refer to /usr/lib/openssh/sftp-server from within dropbear by using '${libexecdir}'?  Define a global SFTP_SERVER_PATH variable in bitbake.conf?
Comment 15 Mark Hatle 2013-04-26 17:00:06 UTC
> How would you refer to /usr/lib/openssh/sftp-server from within dropbear by using '${libexecdir}'?  Define a global SFTP_SERVER_PATH variable in bitbake.conf?

Following that few conversations, I'd have to say:

${nonarch_libdir}/openssh/sftp-server

The coordination is that both the openssh(-sftp) package and dropbear need to agree that the subdirectory 'openssh' is correct.  The nonarch_libdir would be /lib or /usr/lib depending on settings.

(Note, I don't see a nonarch_libdir defined, but I do see "nonarch_base_libdir" defined currently.  So this strategy may require enhancements.)

My suggestion would be:

export nonarch_base_libdir = "${base_prefix}/lib"
export nonarch_libdir = "${exec_prefix}/lib"
export libexecdir = "${nonarch_libdir}/${BPN}"

For things like systemd/udev who need the libexecdir to be in the root, they should be able to define:

libexecdir = "${nonarch_base_libdir}/${BPN}"

for things like the sftp above, both recipes could define:

libexecdir = "${nonarch_libdir}/openssh"

(or even)

libexecdir = "${nonarch_libdir}/sftp"
Comment 16 Enrico Scholz 2013-04-26 17:07:10 UTC
I disagree with the libexecdir definition.

| export libexecdir = "${nonarch_libdir}"

would be much better and matches nearly all other linux distributions (minus multilib and 'libexec' vs. 'lib' issues).

libexecdir must expand to the same value for every package.

Usually, packages place files into ${libexecdir}/@PACKAGE@  (aka the non-standard 'pkglibexecdir').  For packages like openssh, an explicit

| EXTRA_OECONF += "--libexecdir=${libexecdir}/openssh"

should be added so that files are not installed directly below /usr/lib
Comment 17 Ross Burton 2013-04-26 18:30:53 UTC
In my experience there isn't a "usually" for packages installing into $libexecdir/[binary] or $libexecdir/[package]/[binary], both are commonplace.