package/collectd: add init script for SysV
PATCH v2 1/1 package/collectd: add init script for SysV
---v1->v2: use start-stop-daemon
--- package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++ package/collectd/collectd.mk | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 package/collectd/S90collectd
package/collectd/S90collectd new file +36 -0
@@ -0,0 +1,36 @@ +#!/bin/sh + +DAEMON="collectd" +PIDFILE="/var/run/$DAEMON.pid" + +start() { + printf "Starting collectd... " + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON" + [ $? = 0 ] && echo "OK" || echo "FAIL" +} +stop() { + printf "Stopping collectd... " + start-stop-daemon -K -q -p $PIDFILE + [ $? = 0 ] && echo "OK" || echo "FAIL" +} +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?
package/collectd/collectd.mk +5 -0
@@ -218,4 +218,9 @@ define COLLECTD_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/collectd.service endef +define COLLECTD_INSTALL_INIT_SYSV + $(INSTALL) -D -m 0755 package/collectd/S90collectd \ + $(TARGET_DIR)/etc/init.d/S90collectd +endef + $(eval $(autotools-package))
Signature · 1 line
2.20.1
PATCH v2 1/1 package/uvw: new package
A header-only libuv wrapper in C++.
A patch is added to enable in-tree build, which is checked and prevented by the package and fails the build.
---v1->v2: add missing entry in DEVELOPERS
--- DEVELOPERS | 1 + package/Config.in | 1 + ...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++ package/uvw/Config.in | 16 ++++++++++ package/uvw/uvw.hash | 3 ++ package/uvw/uvw.mk | 15 +++++++++ 6 files changed, 68 insertions(+) create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch create mode 100644 package/uvw/Config.in create mode 100644 package/uvw/uvw.hash create mode 100644 package/uvw/uvw.mk
DEVELOPERS +1 -0
@@ -239,6 +239,7 @@ F: package/python* F: package/snmpclitools/ F: package/spdlog/ F: package/uftp/ +F: package/uvw/ F: package/zeromq/ N: Ash Charles <[email protected]>
package/Config.in +1 -0
@@ -1805,6 +1805,7 @@ endif source "package/tinycbor/Config.in" source "package/tz/Config.in" source "package/tzdata/Config.in" + source "package/uvw/Config.in" source "package/xapian/Config.in" endmenu
package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch new file +32 -0
@@ -0,0 +1,32 @@ +From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001 +From: Asaf Kahlon <[email protected]> +Date: Fri, 25 Oct 2019 19:09:14 +0300 +Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build + +Signed-off-by: Asaf Kahlon <[email protected]> +--- + CMakeLists.txt | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9fc5538..4aaabf7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,14 +4,6 @@ + + cmake_minimum_required(VERSION 3.2) + +-# +-# Building in-tree is not allowed (we take care of your craziness). +-# +- +-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) +- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.") +-endif() +- + # + # Project configuration + # +-- +2.20.1 +
package/uvw/Config.in new file +16 -0
@@ -0,0 +1,16 @@ +config BR2_PACKAGE_UVW + bool "uvw" + depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuv + depends on BR2_USE_MMU # libuv + depends on !BR2_STATIC_LIBS # libuv + depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv + help + Header-only, event based, tiny and easy to use + libuv wrapper in modern C++. + + https://github.com/skypjack/uvw + +comment "uvw needs a toolchain w/ NPTL, dynamic library" + depends on !BR2_TOOLCHAIN_HAS_THREADS_NPTL || BR2_STATIC_LIBS + depends on BR2_USE_MMU + depends on BR2_TOOLCHAIN_HAS_SYNC_4
package/uvw/uvw.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally calculated +sha256 266a354f0c64a8e85f29b10f20f4d08a35bc1e8caa7cc94a8afecf9ca43f4442 uvw-2.2.0_libuv-v1.33.tar.gz +sha256 ea786619b4d1b2ba0a188e923111122dfefea1d01c86e37f9e8c80bdbc3ea400 LICENSE
package/uvw/uvw.mk new file +15 -0
@@ -0,0 +1,15 @@ +################################################################################ +# +# uvw +# +################################################################################ + +UVW_VERSION = 2.2.0_libuv-v1.33 +UVW_SITE = $(call github,skypjack,uvw,v$(UVW_VERSION)) +UVW_INSTALL_STAGING = YES +UVW_INSTALL_TARGET = NO +UVW_DEPENDENCIES = libuv +UVW_LICENSE = MIT +UVW_LICENSE_FILES = LICENSE + +$(eval $(cmake-package))
Signature · 1 line
2.20.1
PATCH v2 1/1 package/uvw: new package
Hello Asaf,
thanks for your contribution. A few comments below.
Le sam. 26 oct. 2019 ? 09:19, Asaf Kahlon <[email protected]> a ?crit :
Quoted 90 lines
A header-only libuv wrapper in C++.
A patch is added to enable in-tree build, which is checked and prevented by the package and fails the build.
Signed-off-by Asaf Kahlon <[email protected]>---
v1->v2: add missing entry in DEVELOPERS--- DEVELOPERS | 1 + package/Config.in | 1 + ...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++ package/uvw/Config.in | 16 ++++++++++ package/uvw/uvw.hash | 3 ++ package/uvw/uvw.mk | 15 +++++++++ 6 files changed, 68 insertions(+) create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch create mode 100644 package/uvw/Config.in create mode 100644 package/uvw/uvw.hash create mode 100644 package/uvw/uvw.mkDEVELOPERS +1
-0@@ -239,6 +239,7 @@ F: package/python* F: package/snmpclitools/ F: package/spdlog/ F: package/uftp/ +F: package/uvw/ F: package/zeromq/ N: Ash Charles <[email protected]>package/Config.in +1
-0@@ -1805,6 +1805,7 @@ endif source "package/tinycbor/Config.in" source "package/tz/Config.in" source "package/tzdata/Config.in" + source "package/uvw/Config.in" source "package/xapian/Config.in" endmenupackage/uvw/0001-CMakeLists.txt-allow-in-place-build.patch new file +32
-0@@ -0,0 +1,32 @@ +From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001 +From: Asaf Kahlon <[email protected]> +Date: Fri, 25 Oct 2019 19:09:14 +0300 +Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build + +Signed-off-by: Asaf Kahlon <[email protected]> +--- + CMakeLists.txt | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9fc5538..4aaabf7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,14 +4,6 @@ + + cmake_minimum_required(VERSION 3.2) + +-# +-# Building in-tree is not allowed (we take care of your craziness). +-# +- +-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) +- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.") +-endif() +- + # + # Project configuration + # +-- +2.20.1 +package/uvw/Config.in new file +0
-0
package/uvw/Config.in line 3
Quoted 3 lines
package/uvw/Config.in new file +3
-0@@ -0,0 +1,16 @@ +config BR2_PACKAGE_UVW + bool "uvw" + depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuv
There's also a dependendy on the toolchain version. The package author mentioned "a compiler that supports at least C++17"
package/uvw/Config.in line 6
Quoted 3 lines
package/uvw/Config.in new file +3
-0+ depends on BR2_USE_MMU # libuv + depends on !BR2_STATIC_LIBS # libuv + depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv
What about selecting libuv here? I think this would be convenient for the user to enable libuv through uvw.
Also, as there's seems to be such a dependency between this package and libuv, I would add a comment in package/libuv/libuv.mk to instruct the developer to bump uvw along with libuv.
thanks
regards
Gilles.
PATCH v2 1/1 package/uvw: new package
Hello Gilles.
Quoted 105 lines · Gilles Talis
Hello Asaf,
thanks for your contribution. A few comments below.
Le sam. 26 oct. 2019 ? 09:19, Asaf Kahlon <[email protected]> a ?crit :
Quoted 90 lines
A header-only libuv wrapper in C++.
A patch is added to enable in-tree build, which is checked and prevented by the package and fails the build.
Signed-off-by Asaf Kahlon <[email protected]>---
v1->v2: add missing entry in DEVELOPERS--- DEVELOPERS | 1 + package/Config.in | 1 + ...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++ package/uvw/Config.in | 16 ++++++++++ package/uvw/uvw.hash | 3 ++ package/uvw/uvw.mk | 15 +++++++++ 6 files changed, 68 insertions(+) create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch create mode 100644 package/uvw/Config.in create mode 100644 package/uvw/uvw.hash create mode 100644 package/uvw/uvw.mkDEVELOPERS +1
-0@@ -239,6 +239,7 @@ F: package/python* F: package/snmpclitools/ F: package/spdlog/ F: package/uftp/ +F: package/uvw/ F: package/zeromq/ N: Ash Charles <[email protected]>package/Config.in +1
-0@@ -1805,6 +1805,7 @@ endif source "package/tinycbor/Config.in" source "package/tz/Config.in" source "package/tzdata/Config.in" + source "package/uvw/Config.in" source "package/xapian/Config.in" endmenupackage/uvw/0001-CMakeLists.txt-allow-in-place-build.patch new file +32
-0@@ -0,0 +1,32 @@ +From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001 +From: Asaf Kahlon <[email protected]> +Date: Fri, 25 Oct 2019 19:09:14 +0300 +Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build + +Signed-off-by: Asaf Kahlon <[email protected]> +--- + CMakeLists.txt | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9fc5538..4aaabf7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,14 +4,6 @@ + + cmake_minimum_required(VERSION 3.2) + +-# +-# Building in-tree is not allowed (we take care of your craziness). +-# +- +-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) +- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.") +-endif() +- + # + # Project configuration + # +-- +2.20.1 +package/uvw/Config.in new file +0
-0package/uvw/Config.in line 3
Quoted 3 lines
package/uvw/Config.in new file +3
-0@@ -0,0 +1,16 @@ +config BR2_PACKAGE_UVW + bool "uvw" + depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuvThere's also a dependendy on the toolchain version. The package author mentioned "a compiler that supports at least C++17"
package/uvw/Config.in line 6
Quoted 3 lines
package/uvw/Config.in new file +3
-0+ depends on BR2_USE_MMU # libuv + depends on !BR2_STATIC_LIBS # libuv + depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv
Quoted 7 lines
What about selecting libuv here? I think this would be convenient for the user to enable libuv through uvw.
Also, as there's seems to be such a dependency between this package and libuv, I would add a comment in
package/libuv/libuv.mkto instruct the developer to bump uvw along with libuv.
Thanks for the review!
I sent a v3.
Quoted 3 lines
thanks
regards
Gilles.
Regards,
Asaf.
PATCH v2 1/1 package/collectd: add init script for SysV
In reply to Asaf KahlonHello Asaf,
Quoted 15 lines · On Sat, 26 Oct 2019 10:19:04 +0300 Asaf Kahlon <[email protected]> wrote:
Signed-off-by Asaf Kahlon <[email protected]>---
v1->v2: use start-stop-daemon--- package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++ package/collectd/collectd.mk | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 package/collectd/S90collectdpackage/collectd/S90collectd new file +0
-0
package/collectd/S90collectd line 8
Quoted 8 lines
package/collectd/S90collectd new file +8
-0@@ -0,0 +1,36 @@ +#!/bin/sh + +DAEMON="collectd" +PIDFILE="/var/run/$DAEMON.pid" + +start() { + printf "Starting collectd... " + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
Does this actually works? In your v1, you were just starting the collectd daemon, without anything to put it in the background, so it suppose it would automatically fork itself and go in the background. This would not play very well with start-stop-daemon, so I was assuming you would need to pass some collectd option to keep it in the foreground, and let start-stop-daemon do the daemonization.
Did you test your v2 on the target ? Does the pidfile really contains the PID of the daemon that is running ? Does the stop action actually works ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 package/collectd: add init script for SysV
Hello,
Quoted 37 lines · Thomas Petazzoni
Hello Asaf,
Quoted 15 lines · On Sat, 26 Oct 2019 10:19:04 +0300 Asaf Kahlon <[email protected]> wrote:
Signed-off-by Asaf Kahlon <[email protected]>---
v1->v2: use start-stop-daemon--- package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++ package/collectd/collectd.mk | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 package/collectd/S90collectdpackage/collectd/S90collectd new file +0
-0package/collectd/S90collectd line 8
Quoted 8 lines
package/collectd/S90collectd new file +8
-0@@ -0,0 +1,36 @@ +#!/bin/sh + +DAEMON="collectd" +PIDFILE="/var/run/$DAEMON.pid" + +start() { + printf "Starting collectd... " + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"Does this actually works? In your v1, you were just starting the collectd daemon, without anything to put it in the background, so it suppose it would automatically fork itself and go in the background. This would not play very well with start-stop-daemon, so I was assuming you would need to pass some collectd option to keep it in the foreground, and let start-stop-daemon do the daemonization.
Quoted 3 lines
Did you test your v2 on the target ? Does the pidfile really contains the PID of the daemon that is running ? Does the stop action actually works ?
Yes, I loaded the image with qemu and the daemon was started.
The pid on /var/run/collectd.pid was the pid of collectd. After that, I manually run "/etc/init.d/S90collectd stop", made sure the process died and the /var/run/collectd.pid file was removed. The logs also looked fine and stated normal
start/stop of the daemon.
Quoted 8 lines
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Asaf.
PATCH v2 1/1 package/collectd: add init script for SysV
In reply to Asaf KahlonQuoted 16 lines · Asaf Kahlon
Signed-off-by Asaf Kahlon <[email protected]>---
v1->v2: use start-stop-daemon--- package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++ package/collectd/collectd.mk | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 package/collectd/S90collectdpackage/collectd/S90collectd new file +0
-0
package/collectd/S90collectd line 3
Quoted 3 lines
package/collectd/S90collectd new file +3
-0@@ -0,0 +1,36 @@ +#!/bin/sh + +DAEMON="collectd"
EXEC="/usr/sbin/$DAEMON"
package/collectd/S90collectd line 5
Quoted 2 lines
package/collectd/S90collectd new file +2
-0+PIDFILE="/var/run/$DAEMON.pid" +
Leave room to user customizations
COLLECTD_ARGS=""
# shellcheck source=/dev/null [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
package/collectd/S90collectd line 8
Quoted 3 lines
package/collectd/S90collectd new file +3
-0+start() { + printf "Starting collectd... " + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
The -b and -m are not necessary here, since collectd daemonizes by default. The only reason why it "works" is because collectd takes a few milliseconds to daemonize and override the /var/run/collectd.pid that was written by start-stop-daemon. Replacing $PIDFILE by $PIDFILE.x in the line above will show the truth:
# /etc/init.d/S90collectd stop
Stopping collectd... OK
# /etc/init.d/S90collectd start
Starting collectd... OK
# pidof collectd 161 # ls -ltr /var/run/collectd.pid* -rw-r--r-- 1 root root 4 Oct 28 18:15 /var/run/collectd.pid.x <<-- written by start-stop-daemon -rw-r--r-- 1 root root 4 Oct 28 18:15 /var/run/collectd.pid <<-- written by collectd ==> /var/run/collectd.pid <== 161 <<-- daemonized correctd
==> /var/run/collectd.pid.x <==
160 <<-- initial collectd process
package/collectd/S90collectd line 9
Quoted 1 line
package/collectd/S90collectd new file +1
-0+ [ $? = 0 ] && echo "OK" || echo "FAIL"]
This leads the function to result the result of the "echo" command on failure, which will be zero. Use this construction, instead
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -p "$PIDFILE" -x "$EXEC" \
-- $COLLECTD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}package/collectd/S90collectd line 15
Quoted 6 lines
package/collectd/S90collectd new file +6
-0+} +stop() { + printf "Stopping collectd... " + start-stop-daemon -K -q -p $PIDFILE + [ $? = 0 ] && echo "OK" || echo "FAIL" +}
Leave a blank line between each function to improve readability
package/collectd/S90collectd line 17
Quoted 2 lines
package/collectd/S90collectd new file +2
-0+restart() { + stop
Put a one-second pause here, giving time for the daemon to stop.
Quoted 7 lines
package/collectd/S90collectd new file +7
-0+ start +} + +case "$1" in + start) + start + ;;
package/collectd/S90collectd line 34
Quoted 10 lines
package/collectd/S90collectd new file +10
-0+ stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac
case "$1" in
start|stop|restart)
"$1";;
reload)
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1esac
package/collectd/S90collectd line 36
Quoted 1 line
package/collectd/S90collectd new file +1
-0+exit $?
This is not required. A Shell script exit status is by default the the same one of the last command.
Quoted 17 lines
package/collectd/collectd.mk +5
-1@@ -218,4 +218,9 @@ define COLLECTD_INSTALL_INIT_SYSTEMD $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/collectd.service endef +define COLLECTD_INSTALL_INIT_SYSV + $(INSTALL) -D -m 0755 package/collectd/S90collectd \ + $(TARGET_DIR)/etc/init.d/S90collectd +endef + $(eval $(autotools-package)) --2.20.1
Quoted 4 lines
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Refer to package/sysklogd/S01syslogd and package/acpid/S02acpid for examples.
Signature · 1 line
Carlos Santos <[email protected]>