dev-libs/libtypec: new package, add 0.5

thesamesam suggested on github [1] we add this ebuild
to GURU first, to get more testing before we eventually
add it to the main repo.

I'm in the process of upstreaming the 3 patches added
in this ebuild [2].

[1] https://github.com/gentoo/gentoo/pull/35666
[2] https://github.com/Rajaram-Regupathy/libtypec/pull/32
Closes: https://bugs.gentoo.org/910433
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
This commit is contained in:
Adrian Ratiu
2024-03-08 11:46:19 +01:00
parent 213201df2d
commit 1525837f40
6 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1 @@
DIST libtypec-0.5.0-Source.tar.gz 41621 BLAKE2B 09b7e592b4e52f5b6f568675335dc2366902fa8e2d67c5f1c6d2895345d4f4e2e880fc5336ae849133da7794ab457c7cd2dd31111655a68247a15b45d1a6fca6 SHA512 a5f404400f6a08f67f026bbc115fa2278586a0c6b8e9f3766162967d43c111e8985563692a1648efb3a3d3a4cd5047dd903f8733d72a40a175c7bb6be130dcb3

View File

@@ -0,0 +1,26 @@
From 8614051a1ff9856c3de932045dc149e758c2b0b1 Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Fri, 12 Apr 2024 17:08:09 +0300
Subject: [PATCH] CMakeLists.txt: fix pkgconfig install path
pkgconfig pc files need to go under libdir instead of datadir.
Suggested-by: Sam James <sam@gentoo.org>
Upstream-Status: In-Progress [https://github.com/Rajaram-Regupathy/libtypec/pull/32]
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d533ab..aecf4e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,4 +59,4 @@ configure_file(
)
install(FILES ${CMAKE_BINARY_DIR}/libtypec.pc
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
--
2.43.2

View File

@@ -0,0 +1,45 @@
From f1ecf54f8190351b6b1c2f163375405c4b238f64 Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Fri, 12 Apr 2024 17:42:38 +0300
Subject: [PATCH] libtypec_sysfs_ops: define feature test macro for nftw
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
According to the man page [1], the definiton of nftw() is
hidden behind the _XOPEN_SOURCE 500 feature test, so we
must enable it to avoid warnings or errors (if the toolchain
is configured to treat them as errors) like this:
/var/tmp/portage/dev-libs/libtypec-0.5.0/work/libtypec-0.5.0-Source/libtypec_sysfs_ops.c:1059:13:
warning: implicit declaration of function nftw; did you mean ftw?
[-Wimplicit-function-declaration]
1059 | if (nftw ("/dev/bus/usb/", count_billbrd_if, fd_limit, 0) != 0)
| ^~~~
| ftw
[1] https://linux.die.net/man/3/nftw
Upstream-Status: In-Progress [https://github.com/Rajaram-Regupathy/libtypec/pull/32]
---
libtypec_sysfs_ops.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libtypec_sysfs_ops.c b/libtypec_sysfs_ops.c
index 747b562..bfb5246 100644
--- a/libtypec_sysfs_ops.c
+++ b/libtypec_sysfs_ops.c
@@ -29,6 +29,11 @@ SOFTWARE.
* @brief Functions for libtypec sysfs based operations
*/
+/**
+ * required for enalbing nftw(), which is part of SUSv1.
+ */
+#define _XOPEN_SOURCE 500
+
#include "libtypec_ops.h"
#include <dirent.h>
#include <stdio.h>
--
2.43.2

View File

@@ -0,0 +1,55 @@
From d11cd006700bada6ac09da4d58794474018650e4 Mon Sep 17 00:00:00 2001
From: Adrian Ratiu <adrian.ratiu@collabora.com>
Date: Fri, 12 Apr 2024 18:36:15 +0300
Subject: [PATCH] libtypec_sysfs_ops: fix nftw() fun pointer def
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
According to the __ntfw_func_t definiton [1], and ftw
documentation [2], ntfw() is being passed a wrong fun
argument, which is expected for the deprecated ftw(),
not for ntfw().
This got hidden by the fact that _XOPEN_SOURCE >= 500
feature flag was disabled, so the C compilers just
issued an implicit declaration warning/error.
Example:
/var/tmp/portage/dev-libs/libtypec-0.5.0/work/libtypec-0.5.0-Source/libtypec_sysfs_ops.c:1064:36:
warning: passing argument 2 of nftw from incompatible pointer type
[-Wincompatible-pointer-types]
1064 | if (nftw ("/dev/bus/usb/", count_billbrd_if, fd_limit, 0) != 0)
| ^~~~~~~~~~~~~~~~
| |
| int (*)(const char *, const struct stat *, int)
In file included from /var/tmp/portage/dev-libs/libtypec-0.5.0/work/libtypec-0.5.0-Source/libtypec_sysfs_ops.c:48:
/usr/include/ftw.h:179:51: note: expected __nftw_func_t {aka int (*)(const char *, const struct stat *, int, struct FTW *)} but argument is of type int (*)(const char *, const struct stat *, int)
179 | extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors,
| ~~~~~~~~~~~~~~^~~~~~
[1]
https://www.gnu.org/software/libc/manual/html_node/Working-with-Directory-Trees.html#index-_005f_005fnftw_005ffunc_005ft
[2] https://man7.org/linux/man-pages/man3/ftw.3.html
Upstream-Status: In-Progress [https://github.com/Rajaram-Regupathy/libtypec/pull/32]
---
libtypec_sysfs_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libtypec_sysfs_ops.c b/libtypec_sysfs_ops.c
index bfb5246..e496e5f 100644
--- a/libtypec_sysfs_ops.c
+++ b/libtypec_sysfs_ops.c
@@ -476,7 +476,7 @@ static unsigned int get_fixed_supply_pdo(char *path, int src_snk)
}
-static int count_billbrd_if(const char *usb_path, const struct stat *sb, int typeflag)
+static int count_billbrd_if(const char *usb_path, const struct stat *sb, int typeflag, struct FTW *ftw)
{
FILE *fd;
--
2.43.2

View File

@@ -0,0 +1,30 @@
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit cmake
DESCRIPTION="Library to interface with USB Type-c/Power Delivery devices"
HOMEPAGE="https://github.com/Rajaram-Regupathy/libtypec"
SRC_URI="https://github.com/Rajaram-Regupathy/libtypec/releases/download/${P}/${P}-Source.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
S="${WORKDIR}/${P}-Source"
PATCHES=(
"${FILESDIR}/${PN}-0.5.0-CMakeLists.txt-fix-pkgconfig-install-path.patch"
"${FILESDIR}/${PN}-0.5.0-sysfs_ops-define-feature-test-macro-for-nft.patch"
"${FILESDIR}/${PN}-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch"
)
src_configure() {
# don't force CFLAGS to allow Gentoo toolchain to set them
local mycmakeargs=(
-DLIBTYPEC_STRICT_CFLAGS=OFF
)
cmake_src_configure
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<longdescription>
“libtypec” is aimed to provide a generic interface abstracting all
platform complexity for user space to develop tools for efficient
USB-C port management. The library can also enable development of
diagnostic and debug tools to debug system issues around USB-C/USB
PD topology.
</longdescription>
<!-- maintainer-needed -->
<upstream>
<remote-id type="github">Rajaram-Regupathy/libtypec</remote-id>
</upstream>
</pkgmetadata>