All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
@ 2020-06-16 16:42 mchalain
  2020-06-17 20:38 ` Thomas Petazzoni
  0 siblings, 1 reply; 9+ messages in thread
From: mchalain @ 2020-06-16 16:42 UTC (permalink / raw)
  To: buildroot

Gpiod is a little daemon to trig gpio event and launch scripts on level
changing events.
As udev or mdev, it reads rules files to attach scripts on events. and
launch the scripts with environment variables to describe the event.
It uses libgpiod to monitor the gpio and libconfig to read the rules.
It is tested on Raspberry Pi (0,3,4) with success, during few months.

Signed-off-by: mchalain <marc.chalain@gmail.com>
---
 package/Config.in             |  1 +
 package/gpiod/Config.in       | 14 ++++++++++
 package/gpiod/S20gpiod        | 41 +++++++++++++++++++++++++++
 package/gpiod/gpiod.hash      |  1 +
 package/gpiod/gpiod.mk        | 52 +++++++++++++++++++++++++++++++++++
 package/gpiod/gpiod_defconfig |  0
 6 files changed, 109 insertions(+)
 create mode 100644 package/gpiod/Config.in
 create mode 100755 package/gpiod/S20gpiod
 create mode 100644 package/gpiod/gpiod.hash
 create mode 100644 package/gpiod/gpiod.mk
 create mode 100644 package/gpiod/gpiod_defconfig

diff --git a/package/Config.in b/package/Config.in
index d32eadab88..d529442fe7 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -457,6 +457,7 @@ endmenu
 	source "package/freescale-imx/Config.in"
 	source "package/fxload/Config.in"
 	source "package/gcnano-binaries/Config.in"
+	source "package/gpiod/Config.in"
 	source "package/gpm/Config.in"
 	source "package/gpsd/Config.in"
 	source "package/gptfdisk/Config.in"
diff --git a/package/gpiod/Config.in b/package/gpiod/Config.in
new file mode 100644
index 0000000000..e9d5dc47f9
--- /dev/null
+++ b/package/gpiod/Config.in
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_GPIOD
+	bool "gpiod: gpio monitor daemon"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
+	select BR2_PACKAGE_LIBGPIOD
+	select BR2_PACKAGE_LIBCONFIG
+	help
+	  GPIOD monitors gpio events and start scripts.
+	  The daemon loads rules defining a gpio and
+	  the scripts to launch when the level of gpio changes.
+
+comment "gpiod: needs a toolchain w/ support of MMU and headers > 4.8"
+	depends on !BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
diff --git a/package/gpiod/S20gpiod b/package/gpiod/S20gpiod
new file mode 100755
index 0000000000..1a912c8e43
--- /dev/null
+++ b/package/gpiod/S20gpiod
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Starts gpiod.
+#
+
+RUNDIR=/var/run
+SBINDIR=/usr/sbin
+BINDIR=/usr/bin
+
+start() {
+	printf "Starting gpiod: "
+	start-stop-daemon -S -q --exec ${SBINDIR}/gpiod -- -D -p ${RUNDIR}/gpiod.pid
+	[ $? == 0 ] && echo "OK" || echo "FAILED"
+}
+stop() {
+	printf "Stopping gpiod: "
+	${SBINDIR}/gpiod -K -p ${RUNDIR}/gpiod.pid
+	echo "OK"
+}
+restart() {
+	stop
+	start
+}
+
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart|reload)
+	restart
+	;;
+  *)
+	echo "Usage: $0 {start|stop|restart}"
+	exit 1
+esac
+
+exit $?
+
diff --git a/package/gpiod/gpiod.hash b/package/gpiod/gpiod.hash
new file mode 100644
index 0000000000..4a9c10297c
--- /dev/null
+++ b/package/gpiod/gpiod.hash
@@ -0,0 +1 @@
+sha256 f7c12fafcfb02515ae34d9502b4121d7980606fb53b57bee35143bd985bfdddc  gpiod-1.0.tar.gz
diff --git a/package/gpiod/gpiod.mk b/package/gpiod/gpiod.mk
new file mode 100644
index 0000000000..ed99f1d3be
--- /dev/null
+++ b/package/gpiod/gpiod.mk
@@ -0,0 +1,52 @@
+################################################################################
+#
+# gpiod
+#
+################################################################################
+
+GPIOD_VERSION = 1.0
+GPIOD_SITE = $(call github,mchalain,gpiod,$(GPIOD_VERSION))
+
+GPIOD_MAKE_OPTS+=prefix=/usr
+GPIOD_MAKE_OPTS+=sysconfdir=/etc/gpiod
+#GPIOD_MAKE_OPTS+=DEBUG=y
+
+GPIOD_KCONFIG_FILE=$(GPIOD_PKGDIR)/gpiod_defconfig
+GPIOD_KCONFIG_EDITORS = config
+GPIOD_KCONFIG_OPTS = $(GPIOD_MAKE_OPTS)
+
+GPIOD_DEPENDENCIES += libgpiod
+GPIOD_DEPENDENCIES += libconfig
+
+define GPIOD_LIBCONFIG_OPTS
+	$(call KCONFIG_ENABLE_OPT,LIBCONFIG,$(@D)/.config)
+endef
+
+define GPIOD_KCONFIG_FIXUP_CMDS
+	$(GPIOD_LIBCONFIG_OPTS)
+endef
+
+define GPIOD_BUILD_CMDS
+	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
+		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS)
+endef
+
+define GPIOD_INSTALL_TARGET_CMDS
+	$(INSTALL) -d -m 755 $(TARGET_DIR)/etc/gpiod/rules.d
+	$(MAKE) -C $(@D) $(GPIOD_MAKE_OPTS) \
+		DESTDIR="$(TARGET_DIR)" DEVINSTALL=n install
+endef
+
+define GPIOD_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 $(GPIOD_PKGDIR)/gpiod.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/gpiod.service
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	ln -fs ../../../../usr/lib/systemd/system/gpiod.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/gpiod.service
+endef
+define GPIOD_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 755 $(GPIOD_PKGDIR)/S20gpiod \
+		$(TARGET_DIR)/etc/init.d/S20gpiod
+endef
+
+$(eval $(kconfig-package))
diff --git a/package/gpiod/gpiod_defconfig b/package/gpiod/gpiod_defconfig
new file mode 100644
index 0000000000..e69de29bb2
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-16 16:42 [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon mchalain
@ 2020-06-17 20:38 ` Thomas Petazzoni
  2020-06-19 15:37   ` Marc Chalain
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2020-06-17 20:38 UTC (permalink / raw)
  To: buildroot

On Tue, 16 Jun 2020 18:42:00 +0200
mchalain <marc.chalain@gmail.com> wrote:

> Gpiod is a little daemon to trig gpio event and launch scripts on level
> changing events.
> As udev or mdev, it reads rules files to attach scripts on events. and
> launch the scripts with environment variables to describe the event.
> It uses libgpiod to monitor the gpio and libconfig to read the rules.
> It is tested on Raspberry Pi (0,3,4) with success, during few months.
> 
> Signed-off-by: mchalain <marc.chalain@gmail.com>

Thanks a lot for your contribution. I have not reviewed it carefully.
However, while it looks potentially interesting, I am personally always
a bit concerned in packaging software components that look like
"personal projects". This project has only been written by you, there
are no contributions from others, no stars, no fork on Github, nothing
indicates that anyone but you is using gpiod.

So I am wondering if it is not too early to have that in Buildroot. On
the other hand, you could certainly say that having it in Buildroot
would give it some exposure that might encourage some users to try it
out.

Anyway, we will need your Signed-off-by to use your full first name and
last name, properly capitalized.


> diff --git a/package/gpiod/Config.in b/package/gpiod/Config.in
> new file mode 100644
> index 0000000000..e9d5dc47f9
> --- /dev/null
> +++ b/package/gpiod/Config.in
> @@ -0,0 +1,14 @@
> +config BR2_PACKAGE_GPIOD
> +	bool "gpiod: gpio monitor daemon"
> +	depends on BR2_USE_MMU
> +	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8

This needs a comment:

	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8 # libgpiod

> +	select BR2_PACKAGE_LIBGPIOD
> +	select BR2_PACKAGE_LIBCONFIG
> +	help
> +	  GPIOD monitors gpio events and start scripts.
> +	  The daemon loads rules defining a gpio and
> +	  the scripts to launch when the level of gpio changes.
> +
> +comment "gpiod: needs a toolchain w/ support of MMU and headers > 4.8"
> +	depends on !BR2_USE_MMU
> +	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8

No, this should be:

comment "gpiod needs a toolchain w/ kernel headers >= 4.8"
	depends on BR2_USE_MMU
	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8

> +RUNDIR=/var/run
> +SBINDIR=/usr/sbin
> +BINDIR=/usr/bin
> +
> +start() {
> +	printf "Starting gpiod: "
> +	start-stop-daemon -S -q --exec ${SBINDIR}/gpiod -- -D -p ${RUNDIR}/gpiod.pid
> +	[ $? == 0 ] && echo "OK" || echo "FAILED"
> +}
> +stop() {
> +	printf "Stopping gpiod: "
> +	${SBINDIR}/gpiod -K -p ${RUNDIR}/gpiod.pid
> +	echo "OK"
> +}

Please follow the template package/busybox/S01syslogd for your init
script.


> diff --git a/package/gpiod/gpiod.hash b/package/gpiod/gpiod.hash
> new file mode 100644
> index 0000000000..4a9c10297c
> --- /dev/null
> +++ b/package/gpiod/gpiod.hash
> @@ -0,0 +1 @@
> +sha256 f7c12fafcfb02515ae34d9502b4121d7980606fb53b57bee35143bd985bfdddc  gpiod-1.0.tar.gz

We need a hash for the license file.

> diff --git a/package/gpiod/gpiod.mk b/package/gpiod/gpiod.mk
> new file mode 100644
> index 0000000000..ed99f1d3be
> --- /dev/null
> +++ b/package/gpiod/gpiod.mk
> @@ -0,0 +1,52 @@
> +################################################################################
> +#
> +# gpiod
> +#
> +################################################################################
> +
> +GPIOD_VERSION = 1.0
> +GPIOD_SITE = $(call github,mchalain,gpiod,$(GPIOD_VERSION))

We need GPIOD_LICENSE and GPIOD_LICENSE_FILES.

> +GPIOD_MAKE_OPTS+=prefix=/usr
> +GPIOD_MAKE_OPTS+=sysconfdir=/etc/gpiod

Just one assignment, and unconditional:

GPIOD_MAKE_OPTS = \
	prefix=/usr \
	sysconfdir=/etc/gpiod

> +#GPIOD_MAKE_OPTS+=DEBUG=y

Drop comments please.

> +
> +GPIOD_KCONFIG_FILE=$(GPIOD_PKGDIR)/gpiod_defconfig
> +GPIOD_KCONFIG_EDITORS = config
> +GPIOD_KCONFIG_OPTS = $(GPIOD_MAKE_OPTS)
> +
> +GPIOD_DEPENDENCIES += libgpiod
> +GPIOD_DEPENDENCIES += libconfig

One line for dependencies, and unconditional:

GPIOD_DEPENDENCIES = libgpiod libconfig

> +define GPIOD_LIBCONFIG_OPTS
> +	$(call KCONFIG_ENABLE_OPT,LIBCONFIG,$(@D)/.config)
> +endef
> +
> +define GPIOD_KCONFIG_FIXUP_CMDS
> +	$(GPIOD_LIBCONFIG_OPTS)
> +endef
> +
> +define GPIOD_BUILD_CMDS
> +	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
> +		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS)
> +endef
> +
> +define GPIOD_INSTALL_TARGET_CMDS
> +	$(INSTALL) -d -m 755 $(TARGET_DIR)/etc/gpiod/rules.d

Why do you need this ?

> +	$(MAKE) -C $(@D) $(GPIOD_MAKE_OPTS) \
> +		DESTDIR="$(TARGET_DIR)" DEVINSTALL=n install

I don't think you need DEVINSTALL=n here

> +endef
> +
> +define GPIOD_INSTALL_INIT_SYSTEMD
> +	$(INSTALL) -D -m 644 $(GPIOD_PKGDIR)/gpiod.service \
> +		$(TARGET_DIR)/usr/lib/systemd/system/gpiod.service

This is OK. Perhaps use $(@D) instead of $(GPIOD_PKGDIR)

However, the service file was missing in your patch.

> +	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> +	ln -fs ../../../../usr/lib/systemd/system/gpiod.service \
> +		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/gpiod.service

These two commands are not needed, systemd preset-all is going to take
care of this.

> +endef
> +define GPIOD_INSTALL_INIT_SYSV
> +	$(INSTALL) -D -m 755 $(GPIOD_PKGDIR)/S20gpiod \
> +		$(TARGET_DIR)/etc/init.d/S20gpiod
> +endef
> +
> +$(eval $(kconfig-package))

I'm a bit skeptical on the usage of kconfig-package here. You are *not*
using kconfig at all. You have a makefile that emulates some of the
kconfig behavior, but you're not using kconfig. So if we later change
how kconfig-package behave, to use some kconfig functionality that you
do not emulate, things will no longer work for the gpiod package.

> diff --git a/package/gpiod/gpiod_defconfig b/package/gpiod/gpiod_defconfig
> new file mode 100644
> index 0000000000..e69de29bb2

So it's just empty ?

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-17 20:38 ` Thomas Petazzoni
@ 2020-06-19 15:37   ` Marc Chalain
  2020-06-19 19:39     ` Alexander Dahl
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Chalain @ 2020-06-19 15:37 UTC (permalink / raw)
  To: buildroot

Hello,
Before to send a new patch I have some questions:

Le mer. 17 juin 2020 ? 22:38, Thomas Petazzoni <thomas.petazzoni@bootlin.com>
a ?crit :

> On Tue, 16 Jun 2020 18:42:00 +0200
> mchalain <marc.chalain@gmail.com> wrote:
>
> > Gpiod is a little daemon to trig gpio event and launch scripts on level
> > changing events.
> > As udev or mdev, it reads rules files to attach scripts on events. and
> > launch the scripts with environment variables to describe the event.
> > It uses libgpiod to monitor the gpio and libconfig to read the rules.
> > It is tested on Raspberry Pi (0,3,4) with success, during few months.
> >
> > Signed-off-by: mchalain <marc.chalain@gmail.com>
>
> Thanks a lot for your contribution. I have not reviewed it carefully.
> However, while it looks potentially interesting, I am personally always
> a bit concerned in packaging software components that look like
> "personal projects". This project has only been written by you, there
> are no contributions from others, no stars, no fork on Github, nothing
> indicates that anyone but you is using gpiod.
>
> This project comes from a professional project. I didn't find any tool
to launch an application on a switch event. I thought that is stupid to
write
code in the application only for that, when there isn't time mandatory.
This is a personal project, but I hope to reuse it in the future.

So I am wondering if it is not too early to have that in Buildroot. On
> the other hand, you could certainly say that having it in Buildroot
> would give it some exposure that might encourage some users to try it
> out.
>
> Anyway, we will need your Signed-off-by to use your full first name and
> last name, properly capitalized.
>
>
> > diff --git a/package/gpiod/Config.in b/package/gpiod/Config.in
> > new file mode 100644
> > index 0000000000..e9d5dc47f9
> > --- /dev/null
> > +++ b/package/gpiod/Config.in
> > @@ -0,0 +1,14 @@
> > +config BR2_PACKAGE_GPIOD
> > +     bool "gpiod: gpio monitor daemon"
> > +     depends on BR2_USE_MMU
> > +     depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
>
> This needs a comment:
>
>         depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8 # libgpiod
>
OK done

> > +     select BR2_PACKAGE_LIBGPIOD
> > +     select BR2_PACKAGE_LIBCONFIG
> > +     help
> > +       GPIOD monitors gpio events and start scripts.
> > +       The daemon loads rules defining a gpio and
> > +       the scripts to launch when the level of gpio changes.
> > +
> > +comment "gpiod: needs a toolchain w/ support of MMU and headers > 4.8"
> > +     depends on !BR2_USE_MMU
> > +     depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
>
> No, this should be:
>
> comment "gpiod needs a toolchain w/ kernel headers >= 4.8"
>         depends on BR2_USE_MMU
>         depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
>
> Are you sure for  "depends on BR2_USE_MMU" and not "depends on
!BR2_USE_MMU" ?

> +RUNDIR=/var/run
> > +SBINDIR=/usr/sbin
> > +BINDIR=/usr/bin
> > +
> > +start() {
> > +     printf "Starting gpiod: "
> > +     start-stop-daemon -S -q --exec ${SBINDIR}/gpiod -- -D -p
> ${RUNDIR}/gpiod.pid
> > +     [ $? == 0 ] && echo "OK" || echo "FAILED"
> > +}
> > +stop() {
> > +     printf "Stopping gpiod: "
> > +     ${SBINDIR}/gpiod -K -p ${RUNDIR}/gpiod.pid
> > +     echo "OK"
> > +}
>
> Please follow the template package/busybox/S01syslogd for your init
> script.
>
> OK done

>
> > diff --git a/package/gpiod/gpiod.hash b/package/gpiod/gpiod.hash
> > new file mode 100644
> > index 0000000000..4a9c10297c
> > --- /dev/null
> > +++ b/package/gpiod/gpiod.hash
> > @@ -0,0 +1 @@
> > +sha256
> f7c12fafcfb02515ae34d9502b4121d7980606fb53b57bee35143bd985bfdddc
> gpiod-1.0.tar.gz
>
> We need a hash for the license file.
>
> OK done

> diff --git a/package/gpiod/gpiod.mk b/package/gpiod/gpiod.mk
> > new file mode 100644
> > index 0000000000..ed99f1d3be
> > --- /dev/null
> > +++ b/package/gpiod/gpiod.mk
> > @@ -0,0 +1,52 @@
> >
> +################################################################################
> > +#
> > +# gpiod
> > +#
> >
> +################################################################################
> > +
> > +GPIOD_VERSION = 1.0
> > +GPIOD_SITE = $(call github,mchalain,gpiod,$(GPIOD_VERSION))
>
> We need GPIOD_LICENSE and GPIOD_LICENSE_FILES.
>
> OK done

> +GPIOD_MAKE_OPTS+=prefix=/usr
> > +GPIOD_MAKE_OPTS+=sysconfdir=/etc/gpiod
>
> Just one assignment, and unconditional:
>
> GPIOD_MAKE_OPTS = \
>         prefix=/usr \
>         sysconfdir=/etc/gpiod
>
> > +#GPIOD_MAKE_OPTS+=DEBUG=y
>
> Drop comments please.
>
> OK done

> > +
> > +GPIOD_KCONFIG_FILE=$(GPIOD_PKGDIR)/gpiod_defconfig
> > +GPIOD_KCONFIG_EDITORS = config
> > +GPIOD_KCONFIG_OPTS = $(GPIOD_MAKE_OPTS)
> > +
> > +GPIOD_DEPENDENCIES += libgpiod
> > +GPIOD_DEPENDENCIES += libconfig
>
> One line for dependencies, and unconditional:
>
> GPIOD_DEPENDENCIES = libgpiod libconfig
>
> OK done

> > +define GPIOD_LIBCONFIG_OPTS
> > +     $(call KCONFIG_ENABLE_OPT,LIBCONFIG,$(@D)/.config)
> > +endef
> > +
> > +define GPIOD_KCONFIG_FIXUP_CMDS
> > +     $(GPIOD_LIBCONFIG_OPTS)
> > +endef
> > +
> > +define GPIOD_BUILD_CMDS
> > +     $(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
> > +             $(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS)
> > +endef
> > +
> > +define GPIOD_INSTALL_TARGET_CMDS
> > +     $(INSTALL) -d -m 755 $(TARGET_DIR)/etc/gpiod/rules.d
>
> Why do you need this ?
>
> For the same reason as the gpiod_defconfig is empty. LIBCONFIG is the only
option of gpiod.
In a future version, I would like to remove the dependencies to libconfig,
and I prepared that here.
I will remove the configuration in the makefile, and add the entry in the
configuration file.

> +     $(MAKE) -C $(@D) $(GPIOD_MAKE_OPTS) \
> > +             DESTDIR="$(TARGET_DIR)" DEVINSTALL=n install
>
> I don't think you need DEVINSTALL=n here
>
> Yes, it's right. This option disallows the headers files, but there aren't
headers files.

> +endef
> > +
> > +define GPIOD_INSTALL_INIT_SYSTEMD
> > +     $(INSTALL) -D -m 644 $(GPIOD_PKGDIR)/gpiod.service \
> > +             $(TARGET_DIR)/usr/lib/systemd/system/gpiod.service
>
> This is OK. Perhaps use $(@D) instead of $(GPIOD_PKGDIR)
>
> However, the service file was missing in your patch.
>
> OK done

> > +     mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> > +     ln -fs ../../../../usr/lib/systemd/system/gpiod.service \
> > +
>  $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/gpiod.service
>
> These two commands are not needed, systemd preset-all is going to take
> care of this.
>
> OK thank, I remembered to need that, a few years ago.

> +endef
> > +define GPIOD_INSTALL_INIT_SYSV
> > +     $(INSTALL) -D -m 755 $(GPIOD_PKGDIR)/S20gpiod \
> > +             $(TARGET_DIR)/etc/init.d/S20gpiod
> > +endef
> > +
> > +$(eval $(kconfig-package))
>
> I'm a bit skeptical on the usage of kconfig-package here. You are *not*
> using kconfig at all. You have a makefile that emulates some of the
> kconfig behavior, but you're not using kconfig. So if we later change
> how kconfig-package behave, to use some kconfig functionality that you
> do not emulate, things will no longer work for the gpiod package.
>
> Big question... I can use CONFIGURE_CMDS, but if the kconfig system from
the
kernel changes, what will you do ?
The version compatibility of each build system is a debate in development
community
for many years,
I remember of many discussions about the version of autotools and m4, the
discussions
about the best usage between to load all makefiles only once or to run each
one by one.
And I don't speak about the trolls about the best tools "autotools more
stable
"scons easer with python" "cmake the greatest", some people add another
wrapper
arount cmake.
I prefer to use only Makefile, it's proof, flexible and it does a good job.
I'm sure that
in 10 or 20 years, some body will be able to write and correct a Makefile.
After I can write a CONFIGURE_CMDS to do the same as kconfig-package but
it's less flexible to change the options (yes the only one option of the
application ;)
Tell me your preference.

> diff --git a/package/gpiod/gpiod_defconfig b/package/gpiod/gpiod_defconfig
> > new file mode 100644
> > index 0000000000..e69de29bb2
>
> So it's just empty ?
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200619/ae3c4475/attachment.html>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-19 15:37   ` Marc Chalain
@ 2020-06-19 19:39     ` Alexander Dahl
  2020-06-19 20:25       ` Marc Chalain
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Dahl @ 2020-06-19 19:39 UTC (permalink / raw)
  To: buildroot

Hei hei,

On Fri, Jun 19, 2020 at 05:37:55PM +0200, Marc Chalain wrote:
> > Thanks a lot for your contribution. I have not reviewed it carefully.
> > However, while it looks potentially interesting, I am personally always
> > a bit concerned in packaging software components that look like
> > "personal projects". This project has only been written by you, there
> > are no contributions from others, no stars, no fork on Github, nothing
> > indicates that anyone but you is using gpiod.
> >
> > This project comes from a professional project. I didn't find any tool
> to launch an application on a switch event. I thought that is stupid to
> write
> code in the application only for that, when there isn't time mandatory.
> This is a personal project, but I hope to reuse it in the future.

I had a similar problem last year. There's triggerhappy which I first
noticed on raspbian, but that was already too heavy and did not
fullfill my needs (pressing a button for five seconds and acting after
that). 

I know OpenWrt has something similar, but I found it was embedded to
deep in their code to just use that part and they stripped out all
that evdev stuff from kernel and userspace (probably to shrink size).

However, I defined my button in dts as key, not just as gpio, because
it is actually a key and linux has infrastructure for that.
Furthermore there are reliable userspace libraries to not reinvent the
wheel. I was able to build something around libevdev in two days.

Besides: your gpiod uses the well known libgpiod, but is not part of
that project, right? That is a little puzzling, people will mix that
up. 

Greets
Alex

-- 
/"\ ASCII RIBBON | ?With the first link, the chain is forged. The first
\ / CAMPAIGN     | speech censured, the first thought forbidden, the
 X  AGAINST      | first freedom denied, chains us all irrevocably.?
/ \ HTML MAIL    | (Jean-Luc Picard, quoting Judge Aaron Satie)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200619/07176cbb/attachment.asc>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-19 19:39     ` Alexander Dahl
@ 2020-06-19 20:25       ` Marc Chalain
  2020-06-20 12:33         ` Alexander Dahl
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Chalain @ 2020-06-19 20:25 UTC (permalink / raw)
  To: buildroot

Hello

Le ven. 19 juin 2020 ? 21:39, Alexander Dahl <post@lespocky.de> a ?crit :

> Hei hei,
>
> On Fri, Jun 19, 2020 at 05:37:55PM +0200, Marc Chalain wrote:
> > > Thanks a lot for your contribution. I have not reviewed it carefully.
> > > However, while it looks potentially interesting, I am personally always
> > > a bit concerned in packaging software components that look like
> > > "personal projects". This project has only been written by you, there
> > > are no contributions from others, no stars, no fork on Github, nothing
> > > indicates that anyone but you is using gpiod.
> > >
> > > This project comes from a professional project. I didn't find any tool
> > to launch an application on a switch event. I thought that is stupid to
> > write
> > code in the application only for that, when there isn't time mandatory.
> > This is a personal project, but I hope to reuse it in the future.
>
> I had a similar problem last year. There's triggerhappy which I first
> noticed on raspbian, but that was already too heavy and did not
> fullfill my needs (pressing a button for five seconds and acting after
> that).
>
> I know OpenWrt has something similar, but I found it was embedded to
> deep in their code to just use that part and they stripped out all
> that evdev stuff from kernel and userspace (probably to shrink size).
>
> However, I defined my button in dts as key, not just as gpio, because
> it is actually a key and linux has infrastructure for that.
> Furthermore there are reliable userspace libraries to not reinvent the
> wheel. I was able to build something around libevdev in two days.
>
> This solution may be complicated when you use some buttons for an
application,
and just another button for a system feature. You have to manage several
keyboards,
 to name each one by udev (or mdev) to use the good one with each
application.
A daemon on GPIO will never replace a keyboard. When you need several
events
key and a short time response, a keyboard is more powerful.
The Daemon is useful for few events in the life of the system, and you
don't want
modify an application.

Besides: your gpiod uses the well known libgpiod, but is not part of
> that project, right? That is a little puzzling, people will mix that
> up.
>
> Yes I'm sorry for the name. I wanted to use direct access to the
/dev/gpiochip,
and after I saw that libgpiod was a kernel.org project. I should change the
name
but it's the right name for its usage, and it uses libgpiod, then the
daemon promotes
the library. Another name would have been stupid.
I will propose the daemon to the libgpiod developer, when I will be ready.

Greets
> Alex
>
> --
> /"\ ASCII RIBBON | ?With the first link, the chain is forged. The first
> \ / CAMPAIGN     | speech censured, the first thought forbidden, the
>  X  AGAINST      | first freedom denied, chains us all irrevocably.?
> / \ HTML MAIL    | (Jean-Luc Picard, quoting Judge Aaron Satie)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200619/26ac141e/attachment.html>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-19 20:25       ` Marc Chalain
@ 2020-06-20 12:33         ` Alexander Dahl
  2020-06-20 17:29           ` Marc Chalain
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Dahl @ 2020-06-20 12:33 UTC (permalink / raw)
  To: buildroot

Hei hei,

On Fri, Jun 19, 2020 at 10:25:52PM +0200, Marc Chalain wrote:
> Le ven. 19 juin 2020 ? 21:39, Alexander Dahl <post@lespocky.de> a ?crit :
> > However, I defined my button in dts as key, not just as gpio, because
> > it is actually a key and linux has infrastructure for that.
> > Furthermore there are reliable userspace libraries to not reinvent the
> > wheel. I was able to build something around libevdev in two days.
> >
> This solution may be complicated when you use some buttons for an
> application,
> and just another button for a system feature. You have to manage several
> keyboards,
>  to name each one by udev (or mdev) to use the good one with each
> application.

No and no.

There's no keyboard involved, the keycode I used is not even assigned
to a key usually found on keyboards. The system has neither udev nor
mdev, the key is ready by just defining it in dts.

> A daemon on GPIO will never replace a keyboard. When you need several
> events
> key and a short time response, a keyboard is more powerful.
> The Daemon is useful for few events in the life of the system, and you
> don't want
> modify an application.

This is exactly my usecase, a tiny daemon doing basically nothing but
waiting for a button press once a year or so.

> > Besides: your gpiod uses the well known libgpiod, but is not part of
> > that project, right? That is a little puzzling, people will mix that
> > up.
> >
> Yes I'm sorry for the name. I wanted to use direct access to the
> /dev/gpiochip,
> and after I saw that libgpiod was a kernel.org project. I should change the
> name
> but it's the right name for its usage, and it uses libgpiod, then the
> daemon promotes
> the library. Another name would have been stupid.
> I will propose the daemon to the libgpiod developer, when I will be ready.

Looking forward to that. :-)

Greets
Alex

-- 
/"\ ASCII RIBBON | ?With the first link, the chain is forged. The first
\ / CAMPAIGN     | speech censured, the first thought forbidden, the
 X  AGAINST      | first freedom denied, chains us all irrevocably.?
/ \ HTML MAIL    | (Jean-Luc Picard, quoting Judge Aaron Satie)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200620/4920bc97/attachment.asc>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-20 12:33         ` Alexander Dahl
@ 2020-06-20 17:29           ` Marc Chalain
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Chalain @ 2020-06-20 17:29 UTC (permalink / raw)
  To: buildroot

hello,
just to speak clearly and explain that I agree with you

compatible = "gpio-keys";
label = "mediakey";
nextkey: gpiokey,next {
label = "next";
gpios = <&gpio 22 1>;
linux,code = <163>; /* 163 KEY_NEXTSONG */
status = "disabled";
};
for me this is a keyboard definition with one key.
I think that we spoke about exactly the same thing.

Le sam. 20 juin 2020 ? 14:33, Alexander Dahl <post@lespocky.de> a ?crit :

> Hei hei,
>
> On Fri, Jun 19, 2020 at 10:25:52PM +0200, Marc Chalain wrote:
> > Le ven. 19 juin 2020 ? 21:39, Alexander Dahl <post@lespocky.de> a ?crit
> :
> > > However, I defined my button in dts as key, not just as gpio, because
> > > it is actually a key and linux has infrastructure for that.
> > > Furthermore there are reliable userspace libraries to not reinvent the
> > > wheel. I was able to build something around libevdev in two days.
> > >
> > This solution may be complicated when you use some buttons for an
> > application,
> > and just another button for a system feature. You have to manage several
> > keyboards,
> >  to name each one by udev (or mdev) to use the good one with each
> > application.
>
> No and no.
>
> There's no keyboard involved, the keycode I used is not even assigned
> to a key usually found on keyboards. The system has neither udev nor
> mdev, the key is ready by just defining it in dts.
>
> > A daemon on GPIO will never replace a keyboard. When you need several
> > events
> > key and a short time response, a keyboard is more powerful.
> > The Daemon is useful for few events in the life of the system, and you
> > don't want
> > modify an application.
>
> This is exactly my usecase, a tiny daemon doing basically nothing but
> waiting for a button press once a year or so.
>
> > > Besides: your gpiod uses the well known libgpiod, but is not part of
> > > that project, right? That is a little puzzling, people will mix that
> > > up.
> > >
> > Yes I'm sorry for the name. I wanted to use direct access to the
> > /dev/gpiochip,
> > and after I saw that libgpiod was a kernel.org project. I should change
> the
> > name
> > but it's the right name for its usage, and it uses libgpiod, then the
> > daemon promotes
> > the library. Another name would have been stupid.
> > I will propose the daemon to the libgpiod developer, when I will be
> ready.
>
> Looking forward to that. :-)
>
> Greets
> Alex
>
> --
> /"\ ASCII RIBBON | ?With the first link, the chain is forged. The first
> \ / CAMPAIGN     | speech censured, the first thought forbidden, the
>  X  AGAINST      | first freedom denied, chains us all irrevocably.?
> / \ HTML MAIL    | (Jean-Luc Picard, quoting Judge Aaron Satie)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200620/0dceda13/attachment.html>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
  2020-06-26 11:29 Marc Chalain
@ 2022-01-08 16:07 ` Romain Naour
  0 siblings, 0 replies; 9+ messages in thread
From: Romain Naour @ 2022-01-08 16:07 UTC (permalink / raw)
  To: Marc Chalain, buildroot

Hello Marc,

Le 26/06/2020 à 13:29, Marc Chalain a écrit :
> Gpiod is a little daemon to trig gpio event and launch scripts on level
> changing events.
> As udev or mdev, it reads rules files to attach scripts on events. and
> launch the scripts with environment variables to describe the event.
> It uses libgpiod to monitor the gpio and libconfig to read the rules.
> It is tested on Raspberry Pi (0,3,4) with success.

Did you had some feedback from libgpiod upstream project about merging your work
? [1]

Your gpiod daemon provided by libgpiod would be nice.

[1] http://lists.busybox.net/pipermail/buildroot/2020-June/587769.html

> 
> Signed-off-by: Marc Chalain <marc.chalain@gmail.com>
> ---
>  package/Config.in              |  1 +
>  package/gpiod/Config.in        | 14 +++++++++
>  package/gpiod/S20gpiod.in      | 56 ++++++++++++++++++++++++++++++++++
>  package/gpiod/gpiod.hash       |  2 ++
>  package/gpiod/gpiod.mk         | 52 +++++++++++++++++++++++++++++++
>  package/gpiod/gpiod.service.in | 11 +++++++
>  6 files changed, 136 insertions(+)
>  create mode 100644 package/gpiod/Config.in
>  create mode 100755 package/gpiod/S20gpiod.in
>  create mode 100644 package/gpiod/gpiod.hash
>  create mode 100644 package/gpiod/gpiod.mk
>  create mode 100644 package/gpiod/gpiod.service.in
> 
> diff --git a/package/Config.in b/package/Config.in
> index 6a34a895af..c86315630f 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -458,6 +458,7 @@ endmenu
>  	source "package/freescale-imx/Config.in"
>  	source "package/fxload/Config.in"
>  	source "package/gcnano-binaries/Config.in"
> +	source "package/gpiod/Config.in"
>  	source "package/gpm/Config.in"
>  	source "package/gpsd/Config.in"
>  	source "package/gptfdisk/Config.in"
> diff --git a/package/gpiod/Config.in b/package/gpiod/Config.in
> new file mode 100644
> index 0000000000..e9ba5bdba3
> --- /dev/null
> +++ b/package/gpiod/Config.in
> @@ -0,0 +1,14 @@
> +config BR2_PACKAGE_GPIOD
> +	bool "gpiod: gpio monitor daemon"
> +	depends on BR2_USE_MMU
> +	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8 # libgpiod
> +	select BR2_PACKAGE_LIBGPIOD
> +	select BR2_PACKAGE_LIBCONFIG
> +	help
> +	  GPIOD monitors gpio events and start scripts.
> +	  The daemon loads rules defining a gpio and
> +	  the scripts to launch when the level of gpio changes.

Add the url to the project:
https://github.com/mchalain/gpiod

> +
> +comment "gpiod needs a toolchain w/ kernel headers >= 4.8"
> +	depends on !BR2_USE_MMU
> +	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
> diff --git a/package/gpiod/S20gpiod.in b/package/gpiod/S20gpiod.in
> new file mode 100755
> index 0000000000..2cc77af145
> --- /dev/null
> +++ b/package/gpiod/S20gpiod.in
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +#
> +# Starts gpiod.
> +#
> +
> +DAEMON="gpiod"
> +PIDFILE="/var/run/$DAEMON.pid"
> +
> +OPTIONS=""
> +
> +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
> +
> +start() {
> +	printf 'Starting %s: ' "$DAEMON"
> +	OPTIONS="${OPTIONS} -p ${PIDFILE}"
> +	OPTIONS="${OPTIONS} -D"
> +	start-stop-daemon -S -q -x "@PREFIX@/sbin/$DAEMON" \
> +		-- $OPTIONS
> +	status=$?
> +	if [ "$status" -eq 0 ]; then
> +		echo "OK"
> +	else
> +		echo "FAIL"
> +	fi
> +	return "$status"
> +}
> +
> +stop() {
> +	printf 'Stopping %s: ' "$DAEMON"
> +	start-stop-daemon -K -q -p "$PIDFILE"
> +	status=$?
> +	if [ "$status" -eq 0 ]; then
> +		rm -f "$PIDFILE"
> +		echo "OK"
> +	else
> +		echo "FAIL"
> +	fi
> +	return "$status"
> +}
> +
> +restart() {
> +	stop
> +	sleep 1
> +	start
> +}
> +
> +case "$1" in
> +	start|stop|restart)
> +		"$1";;
> +	reload)
> +		# Restart, since there is no true "reload" feature.
> +		restart;;
> +	*)
> +		echo "Usage: $0 {start|stop|restart|reload}"
> +		exit 1
> +esac
> diff --git a/package/gpiod/gpiod.hash b/package/gpiod/gpiod.hash
> new file mode 100644
> index 0000000000..af0486f792
> --- /dev/null
> +++ b/package/gpiod/gpiod.hash
> @@ -0,0 +1,2 @@
> +sha256 d042c0394071ea8fc7464f02c2e599021d15a9891bd378677b000aa373436c89  gpiod-1.1.tar.gz
> +sha256 dfba39760e099e2a64567309f0c6ceacaf9e6473bf79835fe0f8a8580651ff49  LICENSE
> diff --git a/package/gpiod/gpiod.mk b/package/gpiod/gpiod.mk
> new file mode 100644
> index 0000000000..cef3a58fd5
> --- /dev/null
> +++ b/package/gpiod/gpiod.mk
> @@ -0,0 +1,52 @@
> +################################################################################
> +#
> +# gpiod
> +#
> +################################################################################
> +
> +GPIOD_VERSION = 1.1
> +GPIOD_SITE = $(call github,mchalain,gpiod,$(GPIOD_VERSION))
> +GPIOD_LICENSE = BSD
> +GPIOD_LICENSE_FILES = LICENSE
> +
> +PREFIX=/usr
> +SYSCONFDIR=/etc/gpiod
> +
> +GPIOD_MAKE_OPTS = \
> +	prefix=$(PREFIX) \
> +	sysconfdir=$(SYSCONFDIR)
> +
> +GPIOD_DEPENDENCIES = \
> +	libgpiod \
> +	libconfig
> +
> +define GPIOD_CONFIGURE_CMDS
> +	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
> +		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS) defconfig
> +endef
> +
> +define GPIOD_BUILD_CMDS
> +	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
> +		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS)
> +endef
> +
> +define GPIOD_INSTALL_TARGET_CMDS
> +	$(INSTALL) -d -m 755 $(TARGET_DIR)$(SYSCONFDIR)/rules.d
> +	$(MAKE) -C $(@D) $(GPIOD_MAKE_OPTS) \
> +		DESTDIR="$(TARGET_DIR)" install
> +endef
> +
> +define GPIOD_INSTALL_INIT_SYSTEMD
> +	cp $(GPIOD_PKGDIR)/gpiod.service.in $(@D)/gpiod.service
> +	$(SED) "s,@PREFIX@,$(PREFIX),g" $(@D)/gpiod.service
> +	$(INSTALL) -D -m 644 $(@D)/gpiod.service \
> +		$(TARGET_DIR)/usr/lib/systemd/system/gpiod.service
> +endef
> +define GPIOD_INSTALL_INIT_SYSV
> +	cp $(GPIOD_PKGDIR)/S20gpiod.in $(@D)/S20gpiod
> +	$(SED) "s,@PREFIX@,$(PREFIX),g" $(@D)/S20gpiod
> +	$(INSTALL) -D -m 755 $(@D)/S20gpiod \
> +		$(TARGET_DIR)/etc/init.d/S20gpiod
> +endef
> +
> +$(eval $(generic-package))
> diff --git a/package/gpiod/gpiod.service.in b/package/gpiod/gpiod.service.in
> new file mode 100644
> index 0000000000..38a573ccf4
> --- /dev/null
> +++ b/package/gpiod/gpiod.service.in
> @@ -0,0 +1,11 @@
> +[Unit]
> +Description=GPIO event handler daemon
> +
> +[Service]
> +Type=forking
> +ExecStart=@PREFIX@/sbin/gpiod -D -p /var/run/gpiod.pid
> +ExecStop=@PREFIX@/sbin/gpiod -K -p /var/run/gpiod.pid
> +Restart=always
> +
> +[Install]
> +WantedBy=multi-user.target
> 

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon
@ 2020-06-26 11:29 Marc Chalain
  2022-01-08 16:07 ` Romain Naour
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Chalain @ 2020-06-26 11:29 UTC (permalink / raw)
  To: buildroot

Gpiod is a little daemon to trig gpio event and launch scripts on level
changing events.
As udev or mdev, it reads rules files to attach scripts on events. and
launch the scripts with environment variables to describe the event.
It uses libgpiod to monitor the gpio and libconfig to read the rules.
It is tested on Raspberry Pi (0,3,4) with success.

Signed-off-by: Marc Chalain <marc.chalain@gmail.com>
---
 package/Config.in              |  1 +
 package/gpiod/Config.in        | 14 +++++++++
 package/gpiod/S20gpiod.in      | 56 ++++++++++++++++++++++++++++++++++
 package/gpiod/gpiod.hash       |  2 ++
 package/gpiod/gpiod.mk         | 52 +++++++++++++++++++++++++++++++
 package/gpiod/gpiod.service.in | 11 +++++++
 6 files changed, 136 insertions(+)
 create mode 100644 package/gpiod/Config.in
 create mode 100755 package/gpiod/S20gpiod.in
 create mode 100644 package/gpiod/gpiod.hash
 create mode 100644 package/gpiod/gpiod.mk
 create mode 100644 package/gpiod/gpiod.service.in

diff --git a/package/Config.in b/package/Config.in
index 6a34a895af..c86315630f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -458,6 +458,7 @@ endmenu
 	source "package/freescale-imx/Config.in"
 	source "package/fxload/Config.in"
 	source "package/gcnano-binaries/Config.in"
+	source "package/gpiod/Config.in"
 	source "package/gpm/Config.in"
 	source "package/gpsd/Config.in"
 	source "package/gptfdisk/Config.in"
diff --git a/package/gpiod/Config.in b/package/gpiod/Config.in
new file mode 100644
index 0000000000..e9ba5bdba3
--- /dev/null
+++ b/package/gpiod/Config.in
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_GPIOD
+	bool "gpiod: gpio monitor daemon"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8 # libgpiod
+	select BR2_PACKAGE_LIBGPIOD
+	select BR2_PACKAGE_LIBCONFIG
+	help
+	  GPIOD monitors gpio events and start scripts.
+	  The daemon loads rules defining a gpio and
+	  the scripts to launch when the level of gpio changes.
+
+comment "gpiod needs a toolchain w/ kernel headers >= 4.8"
+	depends on !BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_8
diff --git a/package/gpiod/S20gpiod.in b/package/gpiod/S20gpiod.in
new file mode 100755
index 0000000000..2cc77af145
--- /dev/null
+++ b/package/gpiod/S20gpiod.in
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Starts gpiod.
+#
+
+DAEMON="gpiod"
+PIDFILE="/var/run/$DAEMON.pid"
+
+OPTIONS=""
+
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	OPTIONS="${OPTIONS} -p ${PIDFILE}"
+	OPTIONS="${OPTIONS} -D"
+	start-stop-daemon -S -q -x "@PREFIX@/sbin/$DAEMON" \
+		-- $OPTIONS
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+restart() {
+	stop
+	sleep 1
+	start
+}
+
+case "$1" in
+	start|stop|restart)
+		"$1";;
+	reload)
+		# Restart, since there is no true "reload" feature.
+		restart;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload}"
+		exit 1
+esac
diff --git a/package/gpiod/gpiod.hash b/package/gpiod/gpiod.hash
new file mode 100644
index 0000000000..af0486f792
--- /dev/null
+++ b/package/gpiod/gpiod.hash
@@ -0,0 +1,2 @@
+sha256 d042c0394071ea8fc7464f02c2e599021d15a9891bd378677b000aa373436c89  gpiod-1.1.tar.gz
+sha256 dfba39760e099e2a64567309f0c6ceacaf9e6473bf79835fe0f8a8580651ff49  LICENSE
diff --git a/package/gpiod/gpiod.mk b/package/gpiod/gpiod.mk
new file mode 100644
index 0000000000..cef3a58fd5
--- /dev/null
+++ b/package/gpiod/gpiod.mk
@@ -0,0 +1,52 @@
+################################################################################
+#
+# gpiod
+#
+################################################################################
+
+GPIOD_VERSION = 1.1
+GPIOD_SITE = $(call github,mchalain,gpiod,$(GPIOD_VERSION))
+GPIOD_LICENSE = BSD
+GPIOD_LICENSE_FILES = LICENSE
+
+PREFIX=/usr
+SYSCONFDIR=/etc/gpiod
+
+GPIOD_MAKE_OPTS = \
+	prefix=$(PREFIX) \
+	sysconfdir=$(SYSCONFDIR)
+
+GPIOD_DEPENDENCIES = \
+	libgpiod \
+	libconfig
+
+define GPIOD_CONFIGURE_CMDS
+	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
+		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS) defconfig
+endef
+
+define GPIOD_BUILD_CMDS
+	$(TARGET_CONFIGURE_OPTS) $(TARGET_MAKE_ENV) \
+		$(MAKE1) -C $(@D) $(GPIOD_MAKE_OPTS)
+endef
+
+define GPIOD_INSTALL_TARGET_CMDS
+	$(INSTALL) -d -m 755 $(TARGET_DIR)$(SYSCONFDIR)/rules.d
+	$(MAKE) -C $(@D) $(GPIOD_MAKE_OPTS) \
+		DESTDIR="$(TARGET_DIR)" install
+endef
+
+define GPIOD_INSTALL_INIT_SYSTEMD
+	cp $(GPIOD_PKGDIR)/gpiod.service.in $(@D)/gpiod.service
+	$(SED) "s, at PREFIX@,$(PREFIX),g" $(@D)/gpiod.service
+	$(INSTALL) -D -m 644 $(@D)/gpiod.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/gpiod.service
+endef
+define GPIOD_INSTALL_INIT_SYSV
+	cp $(GPIOD_PKGDIR)/S20gpiod.in $(@D)/S20gpiod
+	$(SED) "s, at PREFIX@,$(PREFIX),g" $(@D)/S20gpiod
+	$(INSTALL) -D -m 755 $(@D)/S20gpiod \
+		$(TARGET_DIR)/etc/init.d/S20gpiod
+endef
+
+$(eval $(generic-package))
diff --git a/package/gpiod/gpiod.service.in b/package/gpiod/gpiod.service.in
new file mode 100644
index 0000000000..38a573ccf4
--- /dev/null
+++ b/package/gpiod/gpiod.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=GPIO event handler daemon
+
+[Service]
+Type=forking
+ExecStart=@PREFIX@/sbin/gpiod -D -p /var/run/gpiod.pid
+ExecStop=@PREFIX@/sbin/gpiod -K -p /var/run/gpiod.pid
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-08 16:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 16:42 [Buildroot] [PATCH 1/1] package/gpiod: add gpiod hardware handling daemon mchalain
2020-06-17 20:38 ` Thomas Petazzoni
2020-06-19 15:37   ` Marc Chalain
2020-06-19 19:39     ` Alexander Dahl
2020-06-19 20:25       ` Marc Chalain
2020-06-20 12:33         ` Alexander Dahl
2020-06-20 17:29           ` Marc Chalain
2020-06-26 11:29 Marc Chalain
2022-01-08 16:07 ` Romain Naour

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.