diff mbox series

[v2] opkg: Use own version of portable basename function

Message ID 20231211035116.2278394-1-raj.khem@gmail.com
State Accepted, archived
Commit f76d44192919c0b9a2f66ba93190322fe5bcb3ed
Headers show
Series [v2] opkg: Use own version of portable basename function | expand

Commit Message

Khem Raj Dec. 11, 2023, 3:51 a.m. UTC
Fixes build with upcoming musl release.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Use the v2 of upstream patch

 ...Use-libgen.h-to-provide-basename-API.patch | 62 +++++++++++++++++++
 meta/recipes-devtools/opkg/opkg_0.6.2.bb      |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg/opkg/0001-libopkg-Use-libgen.h-to-provide-basename-API.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/opkg/opkg/0001-libopkg-Use-libgen.h-to-provide-basename-API.patch b/meta/recipes-devtools/opkg/opkg/0001-libopkg-Use-libgen.h-to-provide-basename-API.patch
new file mode 100644
index 00000000000..cff091fabf9
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-libopkg-Use-libgen.h-to-provide-basename-API.patch
@@ -0,0 +1,62 @@ 
+From 7a1c13a48cf020c40dda1721d5c2ffd95e8e669a Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 10 Dec 2023 19:39:29 -0800
+Subject: [PATCH v2] libopkg: Use libgen.h to provide basename API
+
+Also ensure that copy of filename is passed into archive_entry_set_pathname
+so it can be operated upon by posix basename which expect non-const
+character pointer as input.
+
+This became evident with latest musl where basename declaration was
+dropped from string.h [1]
+
+[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
+
+Upstream-Status: Submitted [https://lists.yoctoproject.org/g/opkg/message/12]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+v2: Do not override basename wholesale
+
+ libopkg/opkg_archive.c | 6 ++++--
+ libopkg/opkg_remove.c  | 1 +
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/libopkg/opkg_archive.c b/libopkg/opkg_archive.c
+index 03a4afb..b099f5b 100644
+--- a/libopkg/opkg_archive.c
++++ b/libopkg/opkg_archive.c
+@@ -20,6 +20,7 @@
+ 
+ #include <archive.h>
+ #include <archive_entry.h>
++#include <libgen.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+@@ -797,8 +798,9 @@ int gz_write_archive(const char *filename, const char *gz_filename)
+     }
+ 
+     /* Remove path hierarchy, as we are only compressing a single file */
+-    archive_entry_set_pathname(entry, basename(filename));
+-
++    char* tmp = xstrdup(filename);
++    archive_entry_set_pathname(entry, basename(tmp));
++    free(tmp);
+     r = archive_write_header(a, entry);
+     if (r != ARCHIVE_OK) {
+         opkg_msg(ERROR, "Failed to create compressed file: '%s' : %s (errno=%d)",
+diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
+index 889c672..5254388 100644
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -20,6 +20,7 @@
+ 
+ #include "config.h"
+ 
++#include <libgen.h>
+ #include <stdio.h>
+ #include <glob.h>
+ #include <unistd.h>
+-- 
+2.43.0
+
diff --git a/meta/recipes-devtools/opkg/opkg_0.6.2.bb b/meta/recipes-devtools/opkg/opkg_0.6.2.bb
index 46be137354c..b2e675ae48b 100644
--- a/meta/recipes-devtools/opkg/opkg_0.6.2.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.6.2.bb
@@ -15,6 +15,7 @@  PE = "1"
 SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz \
            file://opkg.conf \
            file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \
+           file://0001-libopkg-Use-libgen.h-to-provide-basename-API.patch \
            file://run-ptest \
            "