* [meta-virtualization][PATCH] tini: Support posix basename from musl libc
@ 2025-03-09 23:48 Kyungjik Min
2025-03-20 19:28 ` Bruce Ashfield
0 siblings, 1 reply; 2+ messages in thread
From: Kyungjik Min @ 2025-03-09 23:48 UTC (permalink / raw)
To: meta-virtualization; +Cc: Kyungjik Min, Kyungjik Min
This fixes building with musl libc.
Signed-off-by: Kyungjik Min <dpmin7@gmail.com>
---
...upport-POSIX-basename-from-musl-libc.patch | 76 +++++++++++++++++++
recipes-containers/tini/tini_0.19.0.bb | 1 +
2 files changed, 77 insertions(+)
create mode 100644 recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
diff --git a/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch b/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
new file mode 100644
index 00000000..b504c37a
--- /dev/null
+++ b/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
@@ -0,0 +1,76 @@
+From 10479a6eef32f8e64fd5bf894dee9c7a6f21ce4c Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sun, 14 Apr 2024 15:33:51 +0200
+Subject: [PATCH] Support POSIX basename() from musl libc
+
+Musl libc 1.2.5 removed the definition of the basename() function from
+string.h and only provides it in libgen.h as the POSIX standard
+defines it.
+
+This change fixes compilation with musl libc 1.2.5.
+````
+build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:36: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
+ 227 | fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
+build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:25: error: format '%s' expects argument of type 'char *', but argument 3 has type 'int' [-Werror=format=]
+ 227 | fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
+ | ~^ ~~~~~~~~~~~~~~
+ | | |
+ | char * int
+ | %d
+
+````
+
+basename() modifies the input string, copy it first with strdup(), If
+strdup() returns NULL the code will handle it.
+
+Upstream-Status: Submitted [https://github.com/krallin/tini/pull/223]
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ src/tini.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+diff --git a/src/tini.c b/src/tini.c
+index 7914d3a..41d1506 100644
+--- a/src/tini.c
++++ b/src/tini.c
+@@ -14,6 +14,7 @@
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <stdbool.h>
++#include <libgen.h>
+
+ #include "tiniConfig.h"
+ #include "tiniLicense.h"
+@@ -224,14 +225,19 @@ int spawn(const signal_configuration_t* const sigconf_ptr, char* const argv[], i
+ }
+
+ void print_usage(char* const name, FILE* const file) {
+- fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
++ char *dirc, *bname;
++
++ dirc = strdup(name);
++ bname = basename(dirc);
++
++ fprintf(file, "%s (%s)\n", bname, TINI_VERSION_STRING);
+
+ #if TINI_MINIMAL
+- fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", basename(name));
++ fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", bname);
+ #else
+- fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", basename(name));
++ fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", bname);
+ #endif
+- fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", basename(name));
++ fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", bname);
+
+ fprintf(file, "Command line options:\n\n");
+
+@@ -261,6 +267,7 @@ void print_usage(char* const name, FILE* const file) {
+ fprintf(file, " %s: Send signals to the child's process group.\n", KILL_PROCESS_GROUP_GROUP_ENV_VAR);
+
+ fprintf(file, "\n");
++ free(dirc);
+ }
+
+ void print_license(FILE* const file) {
diff --git a/recipes-containers/tini/tini_0.19.0.bb b/recipes-containers/tini/tini_0.19.0.bb
index fd90f620..1f3ae8b2 100644
--- a/recipes-containers/tini/tini_0.19.0.bb
+++ b/recipes-containers/tini/tini_0.19.0.bb
@@ -9,6 +9,7 @@ SRC_URI = " \
git://github.com/krallin/tini.git;branch=master;protocol=https \
file://0001-Do-not-strip-the-output-binary-allow-yocto-to-do-thi.patch \
file://0001-tini.c-a-function-declaration-without-a-prototype-is.patch \
+ file://0001-Support-POSIX-basename-from-musl-libc.patch \
"
LICENSE = "MIT"
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [meta-virtualization][PATCH] tini: Support posix basename from musl libc
2025-03-09 23:48 [meta-virtualization][PATCH] tini: Support posix basename from musl libc Kyungjik Min
@ 2025-03-20 19:28 ` Bruce Ashfield
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2025-03-20 19:28 UTC (permalink / raw)
To: dpmin7; +Cc: meta-virtualization, Kyungjik Min
[-- Attachment #1: Type: text/plain, Size: 5509 bytes --]
I haven't forgotten about this, I'm just overloaded trying to complete some
package upgrades and will get to pending patches shortly.
Bruce
On Sun, Mar 9, 2025 at 7:48 PM Kyungjik Min via lists.yoctoproject.org
<dpmin7=gmail.com@lists.yoctoproject.org> wrote:
> This fixes building with musl libc.
>
> Signed-off-by: Kyungjik Min <dpmin7@gmail.com>
> ---
> ...upport-POSIX-basename-from-musl-libc.patch | 76 +++++++++++++++++++
> recipes-containers/tini/tini_0.19.0.bb | 1 +
> 2 files changed, 77 insertions(+)
> create mode 100644
> recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
>
> diff --git
> a/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
> b/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
> new file mode 100644
> index 00000000..b504c37a
> --- /dev/null
> +++
> b/recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch
> @@ -0,0 +1,76 @@
> +From 10479a6eef32f8e64fd5bf894dee9c7a6f21ce4c Mon Sep 17 00:00:00 2001
> +From: Hauke Mehrtens <hauke@hauke-m.de>
> +Date: Sun, 14 Apr 2024 15:33:51 +0200
> +Subject: [PATCH] Support POSIX basename() from musl libc
> +
> +Musl libc 1.2.5 removed the definition of the basename() function from
> +string.h and only provides it in libgen.h as the POSIX standard
> +defines it.
> +
> +This change fixes compilation with musl libc 1.2.5.
> +````
> +build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:36: error:
> implicit declaration of function 'basename'
> [-Wimplicit-function-declaration]
> + 227 | fprintf(file, "%s (%s)\n", basename(name),
> TINI_VERSION_STRING);
> +build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:25: error:
> format '%s' expects argument of type 'char *', but argument 3 has type
> 'int' [-Werror=format=]
> + 227 | fprintf(file, "%s (%s)\n", basename(name),
> TINI_VERSION_STRING);
> + | ~^ ~~~~~~~~~~~~~~
> + | | |
> + | char * int
> + | %d
> +
> +````
> +
> +basename() modifies the input string, copy it first with strdup(), If
> +strdup() returns NULL the code will handle it.
> +
> +Upstream-Status: Submitted [https://github.com/krallin/tini/pull/223]
> +
> +Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> +---
> + src/tini.c | 15 +++++++++++----
> + 1 file changed, 11 insertions(+), 4 deletions(-)
> +
> +diff --git a/src/tini.c b/src/tini.c
> +index 7914d3a..41d1506 100644
> +--- a/src/tini.c
> ++++ b/src/tini.c
> +@@ -14,6 +14,7 @@
> + #include <stdlib.h>
> + #include <unistd.h>
> + #include <stdbool.h>
> ++#include <libgen.h>
> +
> + #include "tiniConfig.h"
> + #include "tiniLicense.h"
> +@@ -224,14 +225,19 @@ int spawn(const signal_configuration_t* const
> sigconf_ptr, char* const argv[], i
> + }
> +
> + void print_usage(char* const name, FILE* const file) {
> +- fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
> ++ char *dirc, *bname;
> ++
> ++ dirc = strdup(name);
> ++ bname = basename(dirc);
> ++
> ++ fprintf(file, "%s (%s)\n", bname, TINI_VERSION_STRING);
> +
> + #if TINI_MINIMAL
> +- fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n",
> basename(name));
> ++ fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", bname);
> + #else
> +- fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] |
> --version\n\n", basename(name));
> ++ fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] |
> --version\n\n", bname);
> + #endif
> +- fprintf(file, "Execute a program under the supervision of a valid
> init process (%s)\n\n", basename(name));
> ++ fprintf(file, "Execute a program under the supervision of a valid
> init process (%s)\n\n", bname);
> +
> + fprintf(file, "Command line options:\n\n");
> +
> +@@ -261,6 +267,7 @@ void print_usage(char* const name, FILE* const file) {
> + fprintf(file, " %s: Send signals to the child's process
> group.\n", KILL_PROCESS_GROUP_GROUP_ENV_VAR);
> +
> + fprintf(file, "\n");
> ++ free(dirc);
> + }
> +
> + void print_license(FILE* const file) {
> diff --git a/recipes-containers/tini/tini_0.19.0.bb
> b/recipes-containers/tini/tini_0.19.0.bb
> index fd90f620..1f3ae8b2 100644
> --- a/recipes-containers/tini/tini_0.19.0.bb
> +++ b/recipes-containers/tini/tini_0.19.0.bb
> @@ -9,6 +9,7 @@ SRC_URI = " \
> git://github.com/krallin/tini.git;branch=master;protocol=https \
> file://0001-Do-not-strip-the-output-binary-allow-yocto-to-do-thi.patch \
> file://0001-tini.c-a-function-declaration-without-a-prototype-is.patch \
> + file://0001-Support-POSIX-basename-from-musl-libc.patch \
> "
>
> LICENSE = "MIT"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#9160):
> https://lists.yoctoproject.org/g/meta-virtualization/message/9160
> Mute This Topic: https://lists.yoctoproject.org/mt/111610536/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
[-- Attachment #2: Type: text/html, Size: 7937 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-20 19:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 23:48 [meta-virtualization][PATCH] tini: Support posix basename from musl libc Kyungjik Min
2025-03-20 19:28 ` Bruce Ashfield
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 NNTP newsgroup(s).