@@ -8,9 +8,17 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3"
inherit cml1 update-rc.d systemd pkgconfig
SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
- file://defconfig \
- file://swupdate \
- "
+ file://defconfig \
+ file://swupdate \
+ file://swupdate.sh \
+ file://swupdate.service \
+ file://swupdate.socket.tmpl \
+ file://swupdate-usb.rules \
+ file://swupdate-usb@.service \
+ file://swupdate-progress.service \
+ file://tmpfiles-swupdate.conf \
+ file://10-mongoose-args \
+"
PACKAGES =+ " \
${PN}-client \
@@ -137,12 +145,32 @@ python () {
depends = d.getVar('DEPENDS', False)
d.setVar('DEPENDS', depends + ' librsync')
+ if 'CONFIG_MONGOOSE=y\n' in features:
+ d.setVar('SWUPDATE_MONGOOSE', 'true')
+ else:
+ d.setVar('SWUPDATE_MONGOOSE', 'false')
+
if 'CONFIG_MONGOOSE_WEB_API_V2=y\n' in features:
d.setVar('SWUPDATE_WWW', 'webapp')
if 'CONFIG_BOOTLOADER_EBG=y\n' in features:
depends = d.getVar('DEPENDS', False)
d.setVar('DEPENDS', depends + ' efibootguard')
+
+ # Values not used here might be used in a bbappend
+ for feature in features:
+ if feature.startswith('CONFIG_SOCKET_CTRL_PATH='):
+ ctrl_path = feature.split('=')[1].strip()
+ d.setVar('SWUPDATE_SOCKET_CTRL_PATH', ctrl_path)
+ elif feature.startswith('CONFIG_SOCKET_PROGRESS_PATH='):
+ prog_path = feature.split('=')[1].strip()
+ d.setVar('SWUPDATE_SOCKET_PROGRESS_PATH', prog_path)
+ elif feature.startswith('CONFIG_HW_COMPATIBILITY_FILE='):
+ hwrev_file = feature.split('=')[1].strip()
+ d.setVar('SWUPDATE_HW_COMPATIBILITY_FILE', hwrev_file)
+ elif feature.startswith('CONFIG_SW_VERSIONS_FILE='):
+ swver_file = feature.split('=')[1].strip()
+ d.setVar('SWUPDATE_SW_VERSIONS_FILE', swver_file)
}
do_configure () {
@@ -152,29 +180,50 @@ do_configure () {
}
do_compile() {
- unset LDFLAGS
- oe_runmake
+ unset LDFLAGS
+ oe_runmake
}
do_install () {
-
- oe_runmake install
-
- install -m 0755 -d ${D}/www
- if [ -d ${S}/web-app ];then
- cp -R --no-dereference --preserve=mode,links -v ${S}/examples/www/v2/* ${D}/www
- else
- install -m 0755 ${S}/www/* ${D}/www
- fi
-
- install -d ${D}${sysconfdir}/init.d
- install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
+ oe_runmake install
+
+ install -m 0755 -d ${D}/www
+ if [ -d ${S}/web-app ];then
+ cp -R --no-dereference --preserve=mode,links -v ${S}/examples/www/v2/* ${D}/www
+ else
+ install -m 0755 ${S}/www/* ${D}/www
+ fi
+
+ install -d ${D}${sysconfdir}/init.d
+ install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
+
+ # shell based configuration loader allows to place code snippets into this folder
+ install -d ${D}${libdir}/swupdate/conf.d
+ install -m 755 ${WORKDIR}/swupdate.sh ${D}${libdir}/swupdate
+ if ${SWUPDATE_MONGOOSE}; then
+ install -m 644 ${WORKDIR}/10-mongoose-args ${D}${libdir}/swupdate/conf.d/
+ fi
+ install -d ${D}${systemd_unitdir}/system
+ install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_system_unitdir}
+ install -m 644 ${WORKDIR}/swupdate.socket.tmpl ${D}${systemd_system_unitdir}/swupdate.socket
+ sed -e "s,@@SWUPDATE_SOCKET_CTRL_PATH@@,${SWUPDATE_SOCKET_CTRL_PATH},g" \
+ -e "s,@@SWUPDATE_SOCKET_PROGRESS_PATH@@,${SWUPDATE_SOCKET_PROGRESS_PATH},g" \
+ -i ${D}${systemd_system_unitdir}/swupdate.socket
+ install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_system_unitdir}
+ install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_system_unitdir}
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${libdir}/tmpfiles.d
+ install -m 0644 ${WORKDIR}/tmpfiles-swupdate.conf ${D}${libdir}/tmpfiles.d/swupdate.conf
+ install -d ${D}${sysconfdir}/udev/rules.d
+ install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/
+ fi
}
INITSCRIPT_NAME = "swupdate"
INITSCRIPT_PARAMS = "defaults 70"
SYSTEMD_PACKAGES = "${PN} ${PN}-progress ${PN}-usb"
-SYSTEMD_SERVICE_${PN} = "swupdate.service"
+SYSTEMD_SERVICE_${PN} = "swupdate.service swupdate.socket"
SYSTEMD_SERVICE_${PN}-progress = "swupdate-progress.service"
SYSTEMD_SERVICE_${PN}-usb = "swupdate-usb@.service"
new file mode 100644
@@ -0,0 +1 @@
+SWUPDATE_WEBSERVER_ARGS="-r /www ${SWUPDATE_MONGOOSE_EXTRA_ARGS:--p 8080}"
@@ -30,7 +30,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="swupdate"
NAME="swupdate"
-DAEMON=/usr/bin/swupdate
+DAEMON=/usr/lib/swupdate/swupdate.sh
PIDFILE=/var/run/$NAME.pid
. /etc/init.d/functions || exit 1
@@ -57,7 +57,7 @@ do_start() {
*)
echo "Starting $DESC ..."
cd /home/root
- exec $DAEMON -v -w "-r /www $SWUPDATE_MONGOOSE_EXTRA_ARGS" $SWUPDATE_EXTRA_ARGS &
+ exec $DAEMON &
exit 0
;;
esac
similarity index 61%
rename from recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
rename to recipes-support/swupdate/swupdate/swupdate-progress.service
@@ -1,6 +1,9 @@
[Unit]
Description=swupdate progress service
-Requires=swupdate.service
+Before=swupdate.service
[Service]
ExecStart=/usr/bin/swupdate-progress -r -w
+
+[Install]
+WantedBy=swupdate.service
similarity index 100%
rename from recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
rename to recipes-support/swupdate/swupdate/swupdate-usb.rules
similarity index 100%
rename from recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
rename to recipes-support/swupdate/swupdate/swupdate-usb@.service
similarity index 59%
rename from recipes-support/swupdate/swupdate-2019.04/swupdate.service
rename to recipes-support/swupdate/swupdate/swupdate.service
@@ -4,9 +4,7 @@ Documentation=https://github.com/sbabic/swupdate
Documentation=https://sbabic.github.io/swupdate
[Service]
-ExecStartPre=-/usr/bin/swupdate-env
-EnvironmentFile=-/tmp/swupdate.env
-ExecStart=/usr/bin/swupdate -v -w "-r /www" $SWUPDATE_EXTRA_ARGS
+ExecStart=/usr/lib/swupdate/swupdate.sh
KillMode=mixed
[Install]
new file mode 100644
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Override these variables in sourced script(s) located
+# in /usr/lib/swupdate/conf.d or /etc/swupdate/conf.d
+SWUPDATE_ARGS="-v ${SWUPDATE_EXTRA_ARGS}"
+SWUPDATE_WEBSERVER_ARGS=""
+SWUPDATE_DOWNLOAD_ARGS=""
+
+# source all files from /etc/swupdate/conf.d and /usr/lib/swupdate/conf.d/
+# A file found in /etc replaces the same file in /usr
+for f in `(test -d /usr/lib/swupdate/conf.d/ && ls -1 /usr/lib/swupdate/conf.d/; test -d /etc/swupdate/conf.d && ls -1 /etc/swupdate/conf.d) | sort -u`; do
+ if [ -f /etc/swupdate/conf.d/$f ]; then
+ . /etc/swupdate/conf.d/$f
+ else
+ . /usr/lib/swupdate/conf.d/$f
+ fi
+done
+
+# handle variable escaping in a simmple way. Use exec to forward open filedescriptors from systemd open.
+if [ "$SWUPDATE_WEBSERVER_ARGS" != "" -a "$SWUPDATE_DOWNLOAD_ARGS" != "" ]; then
+ exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS" -u "$SWUPDATE_DOWNLOAD_ARGS"
+elif [ "$SWUPDATE_WEBSERVER_ARGS" != "" ]; then
+ exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS"
+elif [ "$SWUPDATE_DOWNLOAD_ARGS" != "" ]; then
+ exec /usr/bin/swupdate $SWUPDATE_ARGS -d "$SWUPDATE_DOWNLOAD_ARGS"
+else
+ exec /usr/bin/swupdate $SWUPDATE_ARGS
+fi
new file mode 100644
@@ -0,0 +1,11 @@
+[Unit]
+Description=SWUpdate socket listener
+Documentation=https://github.com/sbabic/swupdate
+Documentation=https://sbabic.github.io/swupdate
+
+[Socket]
+ListenStream=@@SWUPDATE_SOCKET_CTRL_PATH@@
+ListenStream=@@SWUPDATE_SOCKET_PROGRESS_PATH@@
+
+[Install]
+WantedBy=sockets.target
similarity index 60%
rename from recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
rename to recipes-support/swupdate/swupdate/tmpfiles-swupdate.conf
@@ -1,3 +1,2 @@
X /tmp/datadst
X /tmp/scripts
-X /tmp/swupdate.env
@@ -1,13 +1,5 @@
require swupdate.inc
-SRC_URI += " \
- file://swupdate.service \
- file://swupdate-usb.rules \
- file://swupdate-usb@.service \
- file://swupdate-progress.service \
- file://systemd-tmpfiles-swupdate.conf \
- "
-
SRCREV = "d39f4b8e00ef1929545b66158e45b82ea922bf81"
do_install_append () {
@@ -16,15 +8,4 @@ do_install_append () {
test -f ${D}${bindir}/client && mv ${D}${bindir}/client ${D}${bindir}/swupdate-client
test -f ${D}${bindir}/hawkbitcfg && mv ${D}${bindir}/hawkbitcfg ${D}${bindir}/swupdate-hawkbitcfg
test -f ${D}${bindir}/sendtohawkbit && mv ${D}${bindir}/sendtohawkbit ${D}${bindir}/swupdate-sendtohawkbit
-
- install -d ${D}${systemd_system_unitdir}
- install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_system_unitdir}
- install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_system_unitdir}
- install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_system_unitdir}
- if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
- install -d ${D}${libdir}/tmpfiles.d
- install -m 0644 ${WORKDIR}/systemd-tmpfiles-swupdate.conf ${D}${libdir}/tmpfiles.d/swupdate.conf
- install -d ${D}${sysconfdir}/udev/rules.d
- install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/
- fi
}
@@ -4,7 +4,3 @@ DEFAULT_PREFERENCE = "-1"
SRCREV ?= "045a618a725d0a2fce64161f10101c0004ac5d85"
PV = "2019.04+git${SRCPV}"
-
-SYSTEMD_SERVICE_${PN} += " \
- swupdate.socket \
-"
This is a followup for: 135d46bc1446b49971f8f153c3cc55c2fec1e52f Adding the systemd service files and the init scripts back to this repository resolves the circular dependencies between menuconfig and the Yocto build-system. In addition the conf.d folder is now also supported for sysv init based systems. Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> --- recipes-support/swupdate/swupdate.inc | 85 +++++++++++++++++----- recipes-support/swupdate/swupdate/10-mongoose-args | 1 + recipes-support/swupdate/swupdate/swupdate | 4 +- .../swupdate-progress.service | 5 +- .../swupdate-usb.rules | 0 .../swupdate-usb@.service | 0 .../swupdate.service | 4 +- recipes-support/swupdate/swupdate/swupdate.sh | 28 +++++++ .../swupdate/swupdate/swupdate.socket.tmpl | 11 +++ .../tmpfiles-swupdate.conf} | 1 - recipes-support/swupdate/swupdate_2019.04.bb | 19 ----- recipes-support/swupdate/swupdate_git.bb | 4 - 12 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 recipes-support/swupdate/swupdate/10-mongoose-args rename recipes-support/swupdate/{swupdate-2019.04 => swupdate}/swupdate-progress.service (61%) rename recipes-support/swupdate/{swupdate-2019.04 => swupdate}/swupdate-usb.rules (100%) rename recipes-support/swupdate/{swupdate-2019.04 => swupdate}/swupdate-usb@.service (100%) rename recipes-support/swupdate/{swupdate-2019.04 => swupdate}/swupdate.service (59%) create mode 100644 recipes-support/swupdate/swupdate/swupdate.sh create mode 100644 recipes-support/swupdate/swupdate/swupdate.socket.tmpl rename recipes-support/swupdate/{swupdate-2019.04/systemd-tmpfiles-swupdate.conf => swupdate/tmpfiles-swupdate.conf} (60%)