Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addpkg(root/libgpiod): add v2.2 #22689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions root-packages/libgpiod/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TERMUX_PKG_HOMEPAGE=https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
TERMUX_PKG_DESCRIPTION="C library and tools for interacting with the GPIO character device. Requires kernel v4.6 or higher"
Grimler91 marked this conversation as resolved.
Show resolved Hide resolved
TERMUX_PKG_LICENSE="LGPL-2.1"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2.2
TERMUX_PKG_SRCURL="https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-${TERMUX_PKG_VERSION}.tar.gz"
TERMUX_PKG_SHA256=ae35329db7027c740e90c883baf27c26311f0614e6a7b115771b28188b992aec
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--enable-tools=yes
ac_cv_func_versionsort=yes
"

termux_step_pre_configure() {
autoreconf -vfi
}
4 changes: 4 additions & 0 deletions root-packages/libgpiod/gpiod.subpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="Tools for interacting with Linux GPIO character device"
TERMUX_SUBPKG_INCLUDE="
bin/*
"
45 changes: 45 additions & 0 deletions root-packages/libgpiod/versionsort.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- ./tools/tools-common.c~ 2024-10-22 08:57:17.000000000 +0000
+++ ./tools/tools-common.c 2024-12-24 10:09:30.231824790 +0000
@@ -476,6 +476,42 @@
return 1;
}

+int strverscmp(const char *l0, const char *r0)
+{
+ const unsigned char *l = (const void *)l0;
+ const unsigned char *r = (const void *)r0;
+ size_t i, dp, j;
+ int z = 1;
+
+ /* Find maximal matching prefix and track its maximal digit
+ * suffix and whether those digits are all zeros. */
+ for (dp=i=0; l[i]==r[i]; i++) {
+ int c = l[i];
+ if (!c) return 0;
+ if (!isdigit(c)) dp=i+1, z=1;
+ else if (c!='0') z=0;
+ }
+
+ if (l[dp]!='0' && r[dp]!='0') {
+ /* If we're not looking at a digit sequence that began
+ * with a zero, longest digit string is greater. */
+ for (j=i; isdigit(l[j]); j++)
+ if (!isdigit(r[j])) return 1;
+ if (isdigit(r[j])) return -1;
+ } else if (z && dp<i && (isdigit(l[i]) || isdigit(r[i]))) {
+ /* Otherwise, if common prefix of digit sequence is
+ * all zeros, digits order less than non-digits. */
+ return (unsigned char)(l[i]-'0') - (unsigned char)(r[i]-'0');
+ }
+
+ return l[i] - r[i];
+}
+
+static int versionsort(const struct dirent **a, const struct dirent **b)
+{
+ return strverscmp((*a)->d_name, (*b)->d_name);
+}
+
int all_chip_paths(char ***paths_ptr)
{
int i, j, num_chips, ret = 0;
Loading