Skip to content

Commit

Permalink
addpkg(root/libgpiod): add v2.2
Browse files Browse the repository at this point in the history
libgpiod allows for checking and setting different GPIO pins in the
device, if kernel is new enough and GPIO_CDEV is enabled in the kernel
config.
  • Loading branch information
Grimler91 committed Dec 26, 2024
1 parent 892f07f commit 9358e53
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
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"
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;

0 comments on commit 9358e53

Please sign in to comment.