Commit 11ee2cd2 authored by Adrian Freihofer's avatar Adrian Freihofer Committed by Stefano Babic
Browse files

swupdate: config via conf.d folder

This is a followup for: 135d46bc



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: default avatarAdrian Freihofer <adrian.freihofer@siemens.com>
parent 8320f340
......@@ -8,9 +8,18 @@ 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 \
file://90-start-progress \
"
PACKAGES =+ " \
${PN}-client \
......@@ -30,6 +39,7 @@ FILES_${PN}-lua += "${libdir}/lua/"
FILES_${PN}-progress = " \
${bindir}/swupdate-progress \
${systemd_system_unitdir}/swupdate-progress.service \
${libdir}/swupdate/conf.d/90-start-progress \
"
FILES_${PN}-usb = " \
${sysconfdir}/udev/rules.d/swupdate-usb.rules \
......@@ -54,8 +64,9 @@ FILES_${PN}-www = " \
RDEPENDS_${PN}-usb += "${PN}-client"
# The tools package is deprecated, it is an empty meta package for backward compatibility
RDEPENDS_${PN}-tools += "${PN}-client ${PN}-progress ${PN}-tools-hawkbit ${PN}-usb"
RDEPENDS_${PN}-tools += "${PN}-client ${PN}-progress ${PN}-tools-hawkbit \
${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}-usb','',d)} \
"
S = "${WORKDIR}/git/"
......@@ -140,12 +151,36 @@ 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
d.setVar('SWUPDATE_SOCKET_CTRL_PATH', '/tmp/sockinstctrl')
d.setVar('SWUPDATE_SOCKET_PROGRESS_PATH', '/tmp/swupdateprog')
d.setVar('SWUPDATE_HW_COMPATIBILITY_FILE', '/etc/hwrevision')
d.setVar('SWUPDATE_SW_VERSIONS_FILE', '/etc/sw-versions')
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 () {
......@@ -155,29 +190,53 @@ 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/
else
# in case of systemd there is a service file, for sysv init we need to start it as well
install -m 0644 ${WORKDIR}/90-start-progress ${D}${libdir}/swupdate/conf.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"
SWUPDATE_WEBSERVER_ARGS="-r /www ${SWUPDATE_MONGOOSE_EXTRA_ARGS:--p 8080}"
exec /usr/bin/swupdate-progress -w -p -r &
......@@ -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
......
[Unit]
Description=swupdate progress service
Requires=swupdate.service
Before=swupdate.service
[Service]
ExecStart=/usr/bin/swupdate-progress -r -w
[Install]
WantedBy=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]
......
#!/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_SURICATTA_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_SURICATTA_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS" -u "$SWUPDATE_SURICATTA_ARGS"
elif [ "$SWUPDATE_WEBSERVER_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS"
elif [ "$SWUPDATE_SURICATTA_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -u "$SWUPDATE_SURICATTA_ARGS"
else
exec /usr/bin/swupdate $SWUPDATE_ARGS
fi
[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
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 \
"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment