public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Adrian Ratiu" <adrian.ratiu@collabora.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/proj/guru:dev commit in: dev-libs/libtypec/, dev-libs/libtypec/files/
Date: Fri, 12 Apr 2024 16:45:00 +0000 (UTC)	[thread overview]
Message-ID: <1712940280.1525837f407ffd338515ca42a0f349df824e74c0.adrian.ratiu@gentoo> (raw)

commit:     1525837f407ffd338515ca42a0f349df824e74c0
Author:     Adrian Ratiu <adrian.ratiu <AT> collabora <DOT> com>
AuthorDate: Fri Mar  8 10:46:19 2024 +0000
Commit:     Adrian Ratiu <adrian.ratiu <AT> collabora <DOT> com>
CommitDate: Fri Apr 12 16:44:40 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=1525837f

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 <AT> collabora.com>

 dev-libs/libtypec/Manifest                         |  1 +
 ...CMakeLists.txt-fix-pkgconfig-install-path.patch | 26 ++++++++++
 ...sfs_ops-define-feature-test-macro-for-nft.patch | 45 ++++++++++++++++++
 ...-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch | 55 ++++++++++++++++++++++
 dev-libs/libtypec/libtypec-0.5.0.ebuild            | 30 ++++++++++++
 dev-libs/libtypec/metadata.xml                     | 15 ++++++
 6 files changed, 172 insertions(+)

diff --git a/dev-libs/libtypec/Manifest b/dev-libs/libtypec/Manifest
new file mode 100644
index 0000000000..3e3836b094
--- /dev/null
+++ b/dev-libs/libtypec/Manifest
@@ -0,0 +1 @@
+DIST libtypec-0.5.0-Source.tar.gz 41621 BLAKE2B 09b7e592b4e52f5b6f568675335dc2366902fa8e2d67c5f1c6d2895345d4f4e2e880fc5336ae849133da7794ab457c7cd2dd31111655a68247a15b45d1a6fca6 SHA512 a5f404400f6a08f67f026bbc115fa2278586a0c6b8e9f3766162967d43c111e8985563692a1648efb3a3d3a4cd5047dd903f8733d72a40a175c7bb6be130dcb3

diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-CMakeLists.txt-fix-pkgconfig-install-path.patch b/dev-libs/libtypec/files/libtypec-0.5.0-CMakeLists.txt-fix-pkgconfig-install-path.patch
new file mode 100644
index 0000000000..7412d6a537
--- /dev/null
+++ b/dev-libs/libtypec/files/libtypec-0.5.0-CMakeLists.txt-fix-pkgconfig-install-path.patch
@@ -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
+

diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-define-feature-test-macro-for-nft.patch b/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-define-feature-test-macro-for-nft.patch
new file mode 100644
index 0000000000..ea83dcf7d1
--- /dev/null
+++ b/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-define-feature-test-macro-for-nft.patch
@@ -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
+

diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch b/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch
new file mode 100644
index 0000000000..01ed6d674a
--- /dev/null
+++ b/dev-libs/libtypec/files/libtypec-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch
@@ -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
+

diff --git a/dev-libs/libtypec/libtypec-0.5.0.ebuild b/dev-libs/libtypec/libtypec-0.5.0.ebuild
new file mode 100644
index 0000000000..02697c52d9
--- /dev/null
+++ b/dev-libs/libtypec/libtypec-0.5.0.ebuild
@@ -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
+}

diff --git a/dev-libs/libtypec/metadata.xml b/dev-libs/libtypec/metadata.xml
new file mode 100644
index 0000000000..67b3cc5f8c
--- /dev/null
+++ b/dev-libs/libtypec/metadata.xml
@@ -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>


             reply	other threads:[~2024-04-12 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12 16:45 Adrian Ratiu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-15 11:58 [gentoo-commits] repo/proj/guru:dev commit in: dev-libs/libtypec/, dev-libs/libtypec/files/ Adrian Ratiu
2024-05-15 15:48 Adrian Ratiu
2024-07-02 15:48 Adrian Ratiu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1712940280.1525837f407ffd338515ca42a0f349df824e74c0.adrian.ratiu@gentoo \
    --to=adrian.ratiu@collabora.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox