* [PATCH] mbuto: Fix handling of binaries in /usr/libexec
@ 2024-08-26 19:11 Stefano Brivio
2024-08-27 0:59 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2024-08-26 19:11 UTC (permalink / raw)
To: Stefano Brivio; +Cc: David Gibson, Sevinj Aghayeva, passt-dev
The FHS says that binaries under /usr/libexec are not intended to run
directly on the host, and not, as I incorrectly assumed (probably from
some outdated distribution guidelines), on other hosts only:
https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s07.html
If we move them to /usr/bin in the guest image, the helpers or
programs that are supposed to run those binaries might not find them.
We have, however, cases like /usr/libexec/qemu-kvm on some
distributions where we might have programs, on the host, which are
meant to run them, but we don't want to copy those to the guest image,
and we want to run the binary we copied from /usr/libexec directly.
This was the reason why I initially added this special handling.
Instead of doing that, simply add /usr/libexec to the guest's $PATH,
from the $FIXUP script.
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
mbuto | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/mbuto b/mbuto
index a2a8147..c2fffa0 100755
--- a/mbuto
+++ b/mbuto
@@ -48,10 +48,13 @@ COPIES="${COPIES:-}"
# Workers for time-consuming tasks such as stripping modules, see workers()
THREADS="$(nproc)"
-# Fix-up script to run before /init, can be omitted
+# Fix-up script to run before /init, can be omitted. Note that we're adding
+# /usr/libexec to PATH because, while a given program might not be intended to
+# directly run on the host (that's what /usr/libexec is for), we might need to
+# run it directly on the guest instead.
[ -z "${FIXUP}" ] && FIXUP='#!/bin/sh
-export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:
+export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:/usr/libexec:
mount -t proc proc /proc
mount -t sysfs sys /sys
@@ -752,14 +755,7 @@ prog_add() {
unset IFS
[ -z "${__bin}" ] && err "Can't source ${1}"
- # Binaries in /usr/libexec are meant to run on other hosts only, so they
- # can't reside in /usr/libexec on the target image. Move to /usr/bin.
- if [ "$("${DIRNAME}" "${__bin}")" = "/usr/libexec" ]; then
- __bindir="${wd}/usr/bin"
- else
- __bindir="${wd}$("${DIRNAME}" "${__bin}")"
- fi
-
+ __bindir="${wd}$("${DIRNAME}" "${__bin}")"
"${MKDIR}" -p "${__bindir}"
"${CP}" --preserve=all "${__bin}" "${__bindir}"
--
@@ -48,10 +48,13 @@ COPIES="${COPIES:-}"
# Workers for time-consuming tasks such as stripping modules, see workers()
THREADS="$(nproc)"
-# Fix-up script to run before /init, can be omitted
+# Fix-up script to run before /init, can be omitted. Note that we're adding
+# /usr/libexec to PATH because, while a given program might not be intended to
+# directly run on the host (that's what /usr/libexec is for), we might need to
+# run it directly on the guest instead.
[ -z "${FIXUP}" ] && FIXUP='#!/bin/sh
-export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:
+export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:/usr/libexec:
mount -t proc proc /proc
mount -t sysfs sys /sys
@@ -752,14 +755,7 @@ prog_add() {
unset IFS
[ -z "${__bin}" ] && err "Can't source ${1}"
- # Binaries in /usr/libexec are meant to run on other hosts only, so they
- # can't reside in /usr/libexec on the target image. Move to /usr/bin.
- if [ "$("${DIRNAME}" "${__bin}")" = "/usr/libexec" ]; then
- __bindir="${wd}/usr/bin"
- else
- __bindir="${wd}$("${DIRNAME}" "${__bin}")"
- fi
-
+ __bindir="${wd}$("${DIRNAME}" "${__bin}")"
"${MKDIR}" -p "${__bindir}"
"${CP}" --preserve=all "${__bin}" "${__bindir}"
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mbuto: Fix handling of binaries in /usr/libexec
2024-08-26 19:11 [PATCH] mbuto: Fix handling of binaries in /usr/libexec Stefano Brivio
@ 2024-08-27 0:59 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2024-08-27 0:59 UTC (permalink / raw)
To: Stefano Brivio; +Cc: Sevinj Aghayeva, passt-dev
[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]
On Mon, Aug 26, 2024 at 09:11:56PM +0200, Stefano Brivio wrote:
> The FHS says that binaries under /usr/libexec are not intended to run
> directly on the host, and not, as I incorrectly assumed (probably from
> some outdated distribution guidelines), on other hosts only:
> https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s07.html
>
> If we move them to /usr/bin in the guest image, the helpers or
> programs that are supposed to run those binaries might not find them.
>
> We have, however, cases like /usr/libexec/qemu-kvm on some
> distributions where we might have programs, on the host, which are
> meant to run them, but we don't want to copy those to the guest image,
> and we want to run the binary we copied from /usr/libexec directly.
> This was the reason why I initially added this special handling.
>
> Instead of doing that, simply add /usr/libexec to the guest's $PATH,
> from the $FIXUP script.
>
> Suggested-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> mbuto | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/mbuto b/mbuto
> index a2a8147..c2fffa0 100755
> --- a/mbuto
> +++ b/mbuto
> @@ -48,10 +48,13 @@ COPIES="${COPIES:-}"
> # Workers for time-consuming tasks such as stripping modules, see workers()
> THREADS="$(nproc)"
>
> -# Fix-up script to run before /init, can be omitted
> +# Fix-up script to run before /init, can be omitted. Note that we're adding
> +# /usr/libexec to PATH because, while a given program might not be intended to
> +# directly run on the host (that's what /usr/libexec is for), we might need to
> +# run it directly on the guest instead.
> [ -z "${FIXUP}" ] && FIXUP='#!/bin/sh
>
> -export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:
> +export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin:/usr/libexec:
>
> mount -t proc proc /proc
> mount -t sysfs sys /sys
> @@ -752,14 +755,7 @@ prog_add() {
> unset IFS
> [ -z "${__bin}" ] && err "Can't source ${1}"
>
> - # Binaries in /usr/libexec are meant to run on other hosts only, so they
> - # can't reside in /usr/libexec on the target image. Move to /usr/bin.
> - if [ "$("${DIRNAME}" "${__bin}")" = "/usr/libexec" ]; then
> - __bindir="${wd}/usr/bin"
> - else
> - __bindir="${wd}$("${DIRNAME}" "${__bin}")"
> - fi
> -
> + __bindir="${wd}$("${DIRNAME}" "${__bin}")"
> "${MKDIR}" -p "${__bindir}"
> "${CP}" --preserve=all "${__bin}" "${__bindir}"
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-27 1:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-26 19:11 [PATCH] mbuto: Fix handling of binaries in /usr/libexec Stefano Brivio
2024-08-27 0:59 ` David Gibson
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).