osmo-*: Fix systemd services to run against old systemd

Change-Id: I821249615c7bc593cd5a68b1a9c48fe787016e87
Related: SYS#6340
diff --git a/recipes-osmocom/libosmo-sccp/libosmo-sccp.inc b/recipes-osmocom/libosmo-sccp/libosmo-sccp.inc
index 78dd525..0f1f28d 100644
--- a/recipes-osmocom/libosmo-sccp/libosmo-sccp.inc
+++ b/recipes-osmocom/libosmo-sccp/libosmo-sccp.inc
@@ -3,7 +3,7 @@
 HOMEPAGE = "https://osmocom.org/projects/libosmo-sccp"
 LICENSE = "AGPLv3"
 
-INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
 
@@ -18,6 +18,12 @@
 # access symbols not starting with osmo_*
 EXTRA_OECONF_remove = "--disable-static"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/osmo-stp.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/osmo-stp.service"
+}
+
 PACKAGES =+ "osmo-stp"
 SYSTEMD_PACKAGES = "osmo-stp"
 SYSTEMD_SERVICE_osmo-stp = "osmo-stp.service"
diff --git a/recipes-osmocom/osmo-bsc/osmo-bsc.inc b/recipes-osmocom/osmo-bsc/osmo-bsc.inc
index 484a779..50e8f9b 100644
--- a/recipes-osmocom/osmo-bsc/osmo-bsc.inc
+++ b/recipes-osmocom/osmo-bsc/osmo-bsc.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "sqlite3 libpcap libosmocore libosmo-abis libosmo-sccp libosmo-netif osmo-mgw"
 
-INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,12 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 PACKAGES =+ "meas-utils ipaccess-utils bs11-utils abisip-find"
 SYSTEMD_PACKAGES = "osmo-bsc"
 SYSTEMD_SERVICE_osmo-bsc = "osmo-bsc.service"
diff --git a/recipes-osmocom/osmo-gbproxy/osmo-gbproxy.inc b/recipes-osmocom/osmo-gbproxy/osmo-gbproxy.inc
index 1add0b9..aff20fa 100644
--- a/recipes-osmocom/osmo-gbproxy/osmo-gbproxy.inc
+++ b/recipes-osmocom/osmo-gbproxy/osmo-gbproxy.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libosmocore"
 
-INC_PR="r0.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,12 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 SYSTEMD_SERVICE_osmo-gbproxy = "osmo-gbproxy.service"
 
 CONFFILES_osmo-gbproxy = "${sysconfdir}/osmocom/osmo-gbproxy.cfg"
diff --git a/recipes-osmocom/osmo-ggsn/osmo-ggsn.inc b/recipes-osmocom/osmo-ggsn/osmo-ggsn.inc
index 0aaf418..58b93f0 100644
--- a/recipes-osmocom/osmo-ggsn/osmo-ggsn.inc
+++ b/recipes-osmocom/osmo-ggsn/osmo-ggsn.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libosmocore"
 
-INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r3.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,12 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 PACKAGES =+ " libgtp libgtp-dev libgtp-staticdev osmo-sgsnemu"
 RDEPENDS_${PN} += "iptables"
 RRECOMMENDS_${PN} += "kernel-module-ipt-masquerade kernel-module-tun"
diff --git a/recipes-osmocom/osmo-hlr/osmo-hlr.inc b/recipes-osmocom/osmo-hlr/osmo-hlr.inc
index c270746..4229e7b 100644
--- a/recipes-osmocom/osmo-hlr/osmo-hlr.inc
+++ b/recipes-osmocom/osmo-hlr/osmo-hlr.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libtalloc libosmocore libosmo-abis sqlite3 sqlite3-native"
 
-INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r3.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -17,6 +17,10 @@
 do_install_append() {
 	install -d ${D}${localstatedir}/lib/osmocom/
 	install -m 0644 ${WORKDIR}/hlr.db ${D}${localstatedir}/lib/osmocom/hlr.db
+
+	# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
 }
 
 PACKAGECONFIG ??= "\
diff --git a/recipes-osmocom/osmo-hnbgw/osmo-hnbgw.inc b/recipes-osmocom/osmo-hnbgw/osmo-hnbgw.inc
index 696c864..6bf01d3 100644
--- a/recipes-osmocom/osmo-hnbgw/osmo-hnbgw.inc
+++ b/recipes-osmocom/osmo-hnbgw/osmo-hnbgw.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libosmocore libosmo-netif libosmo-sccp osmo-iuh libasn1c lksctp-tools osmo-mgw"
 
-INC_PR="r0.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
 
 # Workaround to oe-core meta/site/* CONFIG_SITE files passed to autoconf forcing unavailability of netinet/sctp.h.
 # Patch fixing issue upstream: https://patchwork.openembedded.org/patch/168892/
@@ -18,6 +18,11 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 SYSTEMD_SERVICE_${PN} = "${PN}.service"
 
 CONFFILES_osmo-hnbgw = "${sysconfdir}/osmocom/osmo-hnbgw.cfg"
diff --git a/recipes-osmocom/osmo-mgw/osmo-mgw.inc b/recipes-osmocom/osmo-mgw/osmo-mgw.inc
index c00f998..a9a60b4 100644
--- a/recipes-osmocom/osmo-mgw/osmo-mgw.inc
+++ b/recipes-osmocom/osmo-mgw/osmo-mgw.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libosmocore libosmo-netif"
 
-INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r3.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,12 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 PACKAGES =+ "libosmo-mgcp libosmo-mgcp-dev libosmo-mgcp-client libosmo-mgcp-client-dev"
 SYSTEMD_SERVICE_osmo-mgw = "osmo-mgw.service"
 
diff --git a/recipes-osmocom/osmo-msc/osmo-msc.inc b/recipes-osmocom/osmo-msc/osmo-msc.inc
index 59280ce..c60fd07 100644
--- a/recipes-osmocom/osmo-msc/osmo-msc.inc
+++ b/recipes-osmocom/osmo-msc/osmo-msc.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libdbi libosmocore libosmo-abis libosmo-sccp libosmo-netif osmo-mgw osmo-hlr"
 
-INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r3.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -18,6 +18,12 @@
 PACKAGECONFIG[iu] = "--enable-iu,--disable-iu,libasn1c osmo-iuh,"
 PACKAGECONFIG[smpp] = "--enable-smpp,--disable-smpp,libsmpp34,"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
+
 RDEPENDS_${PN} = "libdbd-sqlite3"
 
 SYSTEMD_SERVICE_${PN} = "${PN}.service"
diff --git a/recipes-osmocom/osmo-pcap/osmo-pcap.inc b/recipes-osmocom/osmo-pcap/osmo-pcap.inc
index a7d3a60..3f39103 100644
--- a/recipes-osmocom/osmo-pcap/osmo-pcap.inc
+++ b/recipes-osmocom/osmo-pcap/osmo-pcap.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "libosmocore zeromq libpcap gnutls"
 
-INC_PR="r0.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,14 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/osmo-pcap-server.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/osmo-pcap-server.service"
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/osmo-pcap-client.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/osmo-pcap-client.service"
+}
+
 PACKAGES =+ "osmo-pcap-server osmo-pcap-client"
 
 SYSTEMD_PACKAGES = "osmo-pcap-server osmo-pcap-client"
diff --git a/recipes-osmocom/osmo-sgsn/osmo-sgsn.inc b/recipes-osmocom/osmo-sgsn/osmo-sgsn.inc
index 1f6fd7a..9463047 100644
--- a/recipes-osmocom/osmo-sgsn/osmo-sgsn.inc
+++ b/recipes-osmocom/osmo-sgsn/osmo-sgsn.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "c-ares libosmocore libosmo-netif osmo-ggsn osmo-hlr"
 
-INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -16,6 +16,14 @@
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 PACKAGECONFIG[iu] = "--enable-iu,--disable-iu,libasn1c libosmo-sccp osmo-iuh,"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/osmo-sgsn.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/osmo-sgsn.service"
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/osmo-gtphub.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/osmo-gtphub.service"
+}
+
 PACKAGES =+ "osmo-gtphub-doc osmo-gtphub"
 SYSTEMD_PACKAGES = "osmo-sgsn osmo-gtphub"
 SYSTEMD_SERVICE_osmo-sgsn = "osmo-sgsn.service"
diff --git a/recipes-osmocom/osmo-sip-connector/osmo-sip-connector.inc b/recipes-osmocom/osmo-sip-connector/osmo-sip-connector.inc
index 96d3734..7aabf20 100644
--- a/recipes-osmocom/osmo-sip-connector/osmo-sip-connector.inc
+++ b/recipes-osmocom/osmo-sip-connector/osmo-sip-connector.inc
@@ -5,7 +5,7 @@
 
 DEPENDS = "sofia-sip libosmocore"
 
-INC_PR="r1.${META_TELEPHONY_OSMO_INC}"
+INC_PR="r2.${META_TELEPHONY_OSMO_INC}"
 
 inherit autotools pkgconfig systemd
 
@@ -14,6 +14,11 @@
     "
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir},--without-systemdsystemunitdir"
 
+# StateDirectory requires systemd >= v235, but poky pyro ships with v232 (SYS#6340):
+do_install_append() {
+	sed -i '/^StateDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+	sed -i '/^WorkingDirectory=/d' "${D}${systemd_system_unitdir}/${PN}.service"
+}
 
 SYSTEMD_SERVICE_${PN} = "${PN}.service"
 CONFFILES_osmo-sip-connector = "${sysconfdir}/osmocom/osmo-sip-connector.cfg"