Skip to contentSkip to conversation

bump smcroute and add start script

PATCH In review Joachim Wiberg 2 participants 7 messages Aug 30, 2021 – Sep 28, 2021

lore
Share & tools
lore
#0 lore raw

v2 cover bump smcroute and add start script

Hi everyone!

This is the third version of the patch to update SMCRoute to the latest version. Previous versions were audited by Yegor and Thomas, thank you for that! There is a fresh bug fix release upstream and this patch set has been updated to reflect that.

Also, there is now a SysV start script included, installed when a SysV init is used. The upstream systemd unit file was already instaled when systemd is used. Both of them support an optional /etc/default/smcroute environment file that is sourced before starting smcrouted, for site local cmdline options.

Basic tests pass:

    $ ./utils/check-package package/smcroute/*
    56 lines processed
    0 warnings generated
    $ ./utils/test-pkg -c smcroute.config -p smcroute
                        bootlin-armv5-uclibc [1/6]: OK
                         bootlin-armv7-glibc [2/6]: OK
                       bootlin-armv7m-uclibc [3/6]: SKIPPED
                         bootlin-x86-64-musl [4/6]: OK
                          br-arm-full-static [5/6]: OK
                                sourcery-arm [6/6]: OK
    6 builds, 1 skipped, 0 build failed, 0 legal-info failed

To verify the integration, manual testing from a clean master branch, has been performed in Qemu (Aarch64) using with both BusyBox init and systemd.

Best regards
/Joachim

---
v2:
- fixed incorrect use of global CFLAGS in .mk (Thomas)
- bump to latest upstream, v2.5.2
- add sysv init script with optional /etc/default/smcroute
- clean up compat script wrapper post-install

Joachim Wiberg (3):
package/smcroute: bump version to v2.5.2 package/smcroute: add sysv init script package/smcroute: prune old smcroute compat script

 package/smcroute/S41smcroute   | 48 ++++++++++++++++++++++++++++++++++
 package/smcroute/smcroute.hash |  7 ++---
 package/smcroute/smcroute.mk   | 18 +++++++++----
 3 files changed, 65 insertions(+), 8 deletions(-)
 create mode 100755 package/smcroute/S41smcroute
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 1/3 package/smcroute: bump version to v2.5.2

- Upstream has changed to tar.gz
- Drop _SOURCE, fixes check-package warning
- setpgrp not used anymore, no need to override configure cache
- Makefile no longer uses CC?=, drop comment
- Enable MRDISC build option, must be activated per phyint in smcroute.conf, so safe to enable as a default build option

---
 package/smcroute/smcroute.hash | 7 ++++---
 package/smcroute/smcroute.mk   | 7 ++-----
 2 files changed, 6 insertions(+), 8 deletions(-)
package/smcroute/smcroute.hash +4 -3
index f79ce167ed..62b72239cc 100644
@@ -1,5 +1,6 @@
+# Upstream .md5 and .sha256 from GitHub
+sha256	7eca88389cc08cbfe75f787e02ab32a390ef806555069a08abe8d7fa925ed094  smcroute-2.5.2.tar.gz
+md5	dc29e6bd3024a1ad3dd0f2d8c2aed16e  smcroute-2.5.2.tar.gz
+
 # Locally generated
-sha256	431be94c46646767f69c85fee445277b7e765a55177d3ee29522416cfe2cc067  smcroute-2.4.4.tar.xz
 sha256	ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6  COPYING
-# From https://github.com/troglobit/smcroute/releases/download/2.4.4/smcroute-2.4.4.tar.xz.md5
-md5	a1dc8c54c684e8c8de139444f73a0ba3  smcroute-2.4.4.tar.xz
package/smcroute/smcroute.mk +2 -5
index 0db0e084f6..e4ee81db6f 100644
@@ -4,16 +4,13 @@
 #
 ################################################################################
 
-SMCROUTE_VERSION = 2.4.4
-SMCROUTE_SOURCE = smcroute-$(SMCROUTE_VERSION).tar.xz
+SMCROUTE_VERSION = 2.5.2
 SMCROUTE_SITE = https://github.com/troglobit/smcroute/releases/download/$(SMCROUTE_VERSION)
 SMCROUTE_LICENSE = GPL-2.0+
 SMCROUTE_LICENSE_FILES = COPYING
 SMCROUTE_CPE_ID_VENDOR = troglobit
 
-SMCROUTE_CONF_OPTS = ac_cv_func_setpgrp_void=yes
-#BUG:The package Makefile uses CC?= even though the package is autotools based
-SMCROUTE_MAKE_ENV = $(TARGET_CONFIGURE_OPTS)
+SMCROUTE_CONF_OPTS = --enable-mrdisc
 
 ifeq ($(BR2_PACKAGE_LIBCAP),y)
 SMCROUTE_DEPENDENCIES = libcap
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH v2 1/3] package/smcroute: bump version to v2.5.2

Quoted 8 lines · Joachim Wiberg

- Upstream has changed to tar.gz
- Drop _SOURCE, fixes check-package warning
- setpgrp not used anymore, no need to override configure cache
- Makefile no longer uses CC?=, drop comment
- Enable MRDISC build option, must be activated per phyint in smcroute.conf, so safe to enable as a default build option

All three applied to master, thanks.

Regards,
Arnout

Quoted 33 lines
---
 package/smcroute/smcroute.hash | 7 ++++---
 package/smcroute/smcroute.mk   | 7 ++-----
 2 files changed, 6 insertions(+), 8 deletions(-)
package/smcroute/smcroute.hash +4 -3
index f79ce167ed..62b72239cc 100644
@@ -1,5 +1,6 @@
+# Upstream .md5 and .sha256 from GitHub
+sha256	7eca88389cc08cbfe75f787e02ab32a390ef806555069a08abe8d7fa925ed094  smcroute-2.5.2.tar.gz
+md5	dc29e6bd3024a1ad3dd0f2d8c2aed16e  smcroute-2.5.2.tar.gz
+
 # Locally generated
-sha256	431be94c46646767f69c85fee445277b7e765a55177d3ee29522416cfe2cc067  smcroute-2.4.4.tar.xz
 sha256	ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6  COPYING
-# From https://github.com/troglobit/smcroute/releases/download/2.4.4/smcroute-2.4.4.tar.xz.md5
-md5	a1dc8c54c684e8c8de139444f73a0ba3  smcroute-2.4.4.tar.xz
package/smcroute/smcroute.mk +1 -2
index 0db0e084f6..e4ee81db6f 100644
@@ -4,16 +4,13 @@
 #
 ################################################################################
 
-SMCROUTE_VERSION = 2.4.4
-SMCROUTE_SOURCE = smcroute-$(SMCROUTE_VERSION).tar.xz
+SMCROUTE_VERSION = 2.5.2
 SMCROUTE_SITE = https://github.com/troglobit/smcroute/releases/download/$(SMCROUTE_VERSION)
 SMCROUTE_LICENSE = GPL-2.0+

package/smcroute/smcroute.mk line 16

Quoted 10 lines
package/smcroute/smcroute.mk +1 -3
 SMCROUTE_LICENSE_FILES = COPYING
 SMCROUTE_CPE_ID_VENDOR = troglobit
 
-SMCROUTE_CONF_OPTS = ac_cv_func_setpgrp_void=yes
-#BUG:The package Makefile uses CC?= even though the package is autotools based
-SMCROUTE_MAKE_ENV = $(TARGET_CONFIGURE_OPTS)
+SMCROUTE_CONF_OPTS = --enable-mrdisc
 
 ifeq ($(BR2_PACKAGE_LIBCAP),y)
 SMCROUTE_DEPENDENCIES = libcap

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

PATCH v2 2/3 package/smcroute: add sysv init script

In reply to Joachim Wiberg

Same start order as mrouted, start after networking is up.

Custom command line options, like startup delay, or disable multicast routing by default, can be added to the optional /etc/default/smcroute env. file.

---
 package/smcroute/S41smcroute | 48 ++++++++++++++++++++++++++++++++++++
 package/smcroute/smcroute.mk |  5 ++++
 2 files changed, 53 insertions(+)
 create mode 100755 package/smcroute/S41smcroute
package/smcroute/S41smcroute new file +48 -0
new file mode 100755
index 0000000000..bdc0f87645
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+NAME="smcroute"
+DAEMON="smcrouted"
+PIDFILE="/var/run/$NAME.pid"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"
+
+cmd()
+{
+    start-stop-daemon -q -p "$PIDFILE" "$@"
+    status=$?
+    if [ $status -eq 0 ]; then
+	echo "OK"
+    else
+	echo "FAIL"
+    fi
+    return $status
+}
+
+case "$1" in
+    start)
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	cmd -S -x "/usr/sbin/$DAEMON" -- $SMCROUTED_ARGS
+	;;
+
+    stop)
+	printf 'Stopping %s: ' "$DAEMON"
+	cmd -K
+	;;
+
+    restart)
+	$0 stop
+	sleep 1
+	$0 start
+	;;
+
+    reload)
+	printf 'Reloading %s: ' "$DAEMON"
+	cmd -K -s HUP
+	;;
+
+    *)
+	echo "Usage: $0 {start|stop|restart|reload}"
+	exit 1
+esac
package/smcroute/smcroute.mk +5 -0
index e4ee81db6f..9cce0acbbc 100644
@@ -19,4 +19,9 @@ else
 SMCROUTE_CONF_OPTS += --without-libcap
 endif
 
+define SMCROUTE_INSTALL_INIT_SYSV
+	$(INSTALL) -m 755 -D package/smcroute/S41smcroute \
+		$(TARGET_DIR)/etc/init.d/S41smcroute
+endef
+
 $(eval $(autotools-package))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH v2 2/3] package/smcroute: add sysv init script

Quoted 19 lines · Joachim Wiberg

Same start order as mrouted, start after networking is up.

Custom command line options, like startup delay, or disable multicast routing by default, can be added to the optional /etc/default/smcroute env. file.

---
 package/smcroute/S41smcroute | 48 ++++++++++++++++++++++++++++++++++++
 package/smcroute/smcroute.mk |  5 ++++
 2 files changed, 53 insertions(+)
 create mode 100755 package/smcroute/S41smcroute
package/smcroute/S41smcroute new file +0 -0
new file mode 100755
index 0000000000..bdc0f87645

package/smcroute/S41smcroute line 10

Quoted 10 lines
package/smcroute/S41smcroute new file +10 -0
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+NAME="smcroute"
+DAEMON="smcrouted"
+PIDFILE="/var/run/$NAME.pid"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"
+
+cmd()

This is not how we usually write our start scripts, but I like it!

package/smcroute/S41smcroute line 12

Quoted 2 lines
package/smcroute/S41smcroute new file +2 -0
+{
+    start-stop-daemon -q -p "$PIDFILE" "$@"

Can't you pass the -x here as well (which makes sure that you actually kill the
intended daemon in stop() and not some other random process that happens to have the same PID)?

Anyway, I applied as is.

Regards,
Arnout

Quoted 42 lines
package/smcroute/S41smcroute new file +36 -0
+    status=$?
+    if [ $status -eq 0 ]; then
+	echo "OK"
+    else
+	echo "FAIL"
+    fi
+    return $status
+}
+
+case "$1" in
+    start)
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	cmd -S -x "/usr/sbin/$DAEMON" -- $SMCROUTED_ARGS
+	;;
+
+    stop)
+	printf 'Stopping %s: ' "$DAEMON"
+	cmd -K
+	;;
+
+    restart)
+	$0 stop
+	sleep 1
+	$0 start
+	;;
+
+    reload)
+	printf 'Reloading %s: ' "$DAEMON"
+	cmd -K -s HUP
+	;;
+
+    *)
+	echo "Usage: $0 {start|stop|restart|reload}"
+	exit 1
+esac
package/smcroute/smcroute.mk +0 -0
index e4ee81db6f..9cce0acbbc 100644

package/smcroute/smcroute.mk else · line 27

Quoted 9 lines
package/smcroute/smcroute.mk +5 -0
@@ -19,4 +19,9 @@ else
 SMCROUTE_CONF_OPTS += --without-libcap
 endif
 
+define SMCROUTE_INSTALL_INIT_SYSV
+	$(INSTALL) -m 755 -D package/smcroute/S41smcroute \
+		$(TARGET_DIR)/etc/init.d/S41smcroute
+endef
+
 $(eval $(autotools-package))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

Re: [Buildroot] [PATCH v2 2/3] package/smcroute: add sysv init script

Quoted 2 lines · Arnout Vandecappelle

On 30/08/2021 17:30, Joachim Wiberg wrote:
This is not how we usually write our start scripts, but I like it!

Thank you, I wasn't sure it would pass inspection :)

Quoted 5 lines

package/smcroute/S41smcroute line 12

Quoted 2 lines
package/smcroute/S41smcroute new file +2 -0
+{
+    start-stop-daemon -q -p "$PIDFILE" "$@"

Can't you pass the -x here as well (which makes sure that you actually kill the
intended daemon in stop() and not some other random process that happens to have the same PID)?

Huh, from the usage text of start-stop-daemon it wasn't clear to me if -x was reserved only for starting. Thanks for alerting me to this!

Quoted 1 line

Anyway, I applied as is.

Thanks, I'll push another bump later today, for the v2.5.3 release, which will include a fix for -x as well.

Cheers
/Joachim

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw

PATCH v2 3/3 package/smcroute: prune old smcroute compat script

In reply to Joachim Wiberg

Long ago, before SMCRoute had yet become a proper daemon and standalone control tool, it was both. After the metamorphosis commands and options had changed, a compat script was added to provide a smooth transition.

The compat script is still shipped in the tarball, and installed, but only Debian still relies on it, so we prune it here to keep confusion to a minimum, hopefully.

---
 package/smcroute/smcroute.mk | 6 ++++++
 1 file changed, 6 insertions(+)
package/smcroute/smcroute.mk +6 -0
index 9cce0acbbc..e8fc54bb42 100644
@@ -24,4 +24,10 @@ define SMCROUTE_INSTALL_INIT_SYSV
 		$(TARGET_DIR)/etc/init.d/S41smcroute
 endef
 
+define SMCROUTE_PRUNE_COMPAT_SCRIPT
+	rm -f $(TARGET_DIR)/usr/sbin/smcroute
+endef
+
+SMCROUTE_POST_INSTALL_TARGET_HOOKS += SMCROUTE_PRUNE_COMPAT_SCRIPT
+
 $(eval $(autotools-package))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot