diff options
| author | Kyungjik Min <dpmin7@gmail.com> | 2025-03-10 08:48:17 +0900 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2025-03-24 18:45:34 +0000 |
| commit | dd625f5d907387d695dfaaab923f6dc1022209c1 (patch) | |
| tree | ed38a43622afe09610e1c4f8f70d473e86f5a098 /recipes-containers | |
| parent | 37ce8a486fa3be7ec75db97bf6b528d0b64126d8 (diff) | |
| download | meta-virtualization-dd625f5d907387d695dfaaab923f6dc1022209c1.tar.gz | |
tini: Support posix basename from musl libc
This fixes building with musl libc.
Signed-off-by: Kyungjik Min <dpmin7@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers')
| -rw-r--r-- | recipes-containers/tini/tini/0001-Support-POSIX-basename-from-musl-libc.patch | 76 | ||||
| -rw-r--r-- | recipes-containers/tini/tini_0.19.0.bb | 1 |
2 files changed, 77 insertions, 0 deletions
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 @@ | |||
| 1 | From 10479a6eef32f8e64fd5bf894dee9c7a6f21ce4c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Hauke Mehrtens <hauke@hauke-m.de> | ||
| 3 | Date: Sun, 14 Apr 2024 15:33:51 +0200 | ||
| 4 | Subject: [PATCH] Support POSIX basename() from musl libc | ||
| 5 | |||
| 6 | Musl libc 1.2.5 removed the definition of the basename() function from | ||
| 7 | string.h and only provides it in libgen.h as the POSIX standard | ||
| 8 | defines it. | ||
| 9 | |||
| 10 | This change fixes compilation with musl libc 1.2.5. | ||
| 11 | ```` | ||
| 12 | build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:36: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration] | ||
| 13 | 227 | fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING); | ||
| 14 | 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=] | ||
| 15 | 227 | fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING); | ||
| 16 | | ~^ ~~~~~~~~~~~~~~ | ||
| 17 | | | | | ||
| 18 | | char * int | ||
| 19 | | %d | ||
| 20 | |||
| 21 | ```` | ||
| 22 | |||
| 23 | basename() modifies the input string, copy it first with strdup(), If | ||
| 24 | strdup() returns NULL the code will handle it. | ||
| 25 | |||
| 26 | Upstream-Status: Submitted [https://github.com/krallin/tini/pull/223] | ||
| 27 | |||
| 28 | Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | ||
| 29 | --- | ||
| 30 | src/tini.c | 15 +++++++++++---- | ||
| 31 | 1 file changed, 11 insertions(+), 4 deletions(-) | ||
| 32 | |||
| 33 | diff --git a/src/tini.c b/src/tini.c | ||
| 34 | index 7914d3a..41d1506 100644 | ||
| 35 | --- a/src/tini.c | ||
| 36 | +++ b/src/tini.c | ||
| 37 | @@ -14,6 +14,7 @@ | ||
| 38 | #include <stdlib.h> | ||
| 39 | #include <unistd.h> | ||
| 40 | #include <stdbool.h> | ||
| 41 | +#include <libgen.h> | ||
| 42 | |||
| 43 | #include "tiniConfig.h" | ||
| 44 | #include "tiniLicense.h" | ||
| 45 | @@ -224,14 +225,19 @@ int spawn(const signal_configuration_t* const sigconf_ptr, char* const argv[], i | ||
| 46 | } | ||
| 47 | |||
| 48 | void print_usage(char* const name, FILE* const file) { | ||
| 49 | - fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING); | ||
| 50 | + char *dirc, *bname; | ||
| 51 | + | ||
| 52 | + dirc = strdup(name); | ||
| 53 | + bname = basename(dirc); | ||
| 54 | + | ||
| 55 | + fprintf(file, "%s (%s)\n", bname, TINI_VERSION_STRING); | ||
| 56 | |||
| 57 | #if TINI_MINIMAL | ||
| 58 | - fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", basename(name)); | ||
| 59 | + fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", bname); | ||
| 60 | #else | ||
| 61 | - fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", basename(name)); | ||
| 62 | + fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", bname); | ||
| 63 | #endif | ||
| 64 | - fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", basename(name)); | ||
| 65 | + fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", bname); | ||
| 66 | |||
| 67 | fprintf(file, "Command line options:\n\n"); | ||
| 68 | |||
| 69 | @@ -261,6 +267,7 @@ void print_usage(char* const name, FILE* const file) { | ||
| 70 | fprintf(file, " %s: Send signals to the child's process group.\n", KILL_PROCESS_GROUP_GROUP_ENV_VAR); | ||
| 71 | |||
| 72 | fprintf(file, "\n"); | ||
| 73 | + free(dirc); | ||
| 74 | } | ||
| 75 | |||
| 76 | 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 = " \ | |||
| 9 | git://github.com/krallin/tini.git;branch=master;protocol=https \ | 9 | git://github.com/krallin/tini.git;branch=master;protocol=https \ |
| 10 | file://0001-Do-not-strip-the-output-binary-allow-yocto-to-do-thi.patch \ | 10 | file://0001-Do-not-strip-the-output-binary-allow-yocto-to-do-thi.patch \ |
| 11 | file://0001-tini.c-a-function-declaration-without-a-prototype-is.patch \ | 11 | file://0001-tini.c-a-function-declaration-without-a-prototype-is.patch \ |
| 12 | file://0001-Support-POSIX-basename-from-musl-libc.patch \ | ||
| 12 | " | 13 | " |
| 13 | 14 | ||
| 14 | LICENSE = "MIT" | 15 | LICENSE = "MIT" |
