All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH 0/3] SystemD service management support
@ 2011-11-04 17:25 Otavio Salvador
  2011-11-04 17:25 ` [meta-oe][PATCH 1/3] systemd-systemctl-native: add a systemctl wrapper Otavio Salvador
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Otavio Salvador @ 2011-11-04 17:25 UTC (permalink / raw)
  To: openembedded-devel

The following changes since commit 120753e7437bc893462356ef153b67d38f7f696e:

  php 5.3.6: import from OE classic (2011-11-03 15:02:20 +0100)

are available in the git repository at:
  git://github.com/OSSystems/meta-oe master
  https://github.com/OSSystems/meta-oe/tree/master

Otavio Salvador (3):
  systemd-systemctl-native: add a systemctl wrapper
  systemd.bbclass: make easier handle service enabling
  connman: refactor systemd packaging

 meta-oe/classes/systemd.bbclass                    |   78 ++++++++++++++++++++
 meta-oe/recipes-connectivity/connman/connman.inc   |   24 +-----
 .../recipes-connectivity/connman/connman_0.77.bb   |    2 +-
 .../systemd/systemd-systemctl-native.bb            |   13 +++
 .../systemd/systemd-systemctl-native/systemctl     |   51 +++++++++++++
 5 files changed, 148 insertions(+), 20 deletions(-)
 create mode 100644 meta-oe/classes/systemd.bbclass
 create mode 100644 meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
 create mode 100755 meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl

-- 
1.7.2.5




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH 1/3] systemd-systemctl-native: add a systemctl wrapper
  2011-11-04 17:25 [meta-oe][PATCH 0/3] SystemD service management support Otavio Salvador
@ 2011-11-04 17:25 ` Otavio Salvador
  2011-11-04 17:25 ` [meta-oe][PATCH 2/3] systemd.bbclass: make easier handle service enabling Otavio Salvador
  2011-11-04 17:26 ` [meta-oe][PATCH 3/3] connman: refactor systemd packaging Otavio Salvador
  2 siblings, 0 replies; 4+ messages in thread
From: Otavio Salvador @ 2011-11-04 17:25 UTC (permalink / raw)
  To: openembedded-devel

The wrapper allows for enabling services at rootfs generation thus
allowing systemd to be used in ready-only filesystems.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 .../systemd/systemd-systemctl-native.bb            |   13 +++++
 .../systemd/systemd-systemctl-native/systemctl     |   51 ++++++++++++++++++++
 2 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
 create mode 100755 meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl

diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb b/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
new file mode 100644
index 0000000..3ee757e
--- /dev/null
+++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native.bb
@@ -0,0 +1,13 @@
+DESCRIPTION = "Wrapper to enable of systemd services"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
+
+inherit native
+
+SRC_URI = "file://systemctl"
+
+do_install() {
+	install -d ${D}${bindir}
+	install -m 0755 ${WORKDIR}/systemctl ${D}${bindir}
+}
diff --git a/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
new file mode 100755
index 0000000..1fc77fd
--- /dev/null
+++ b/meta-oe/recipes-core/systemd/systemd-systemctl-native/systemctl
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+ROOT=
+
+# parse command line params
+while [ $# != 0 ]; do
+	opt="$1"
+
+	case "$opt" in
+		enable)
+			shift
+
+			service="$1"
+			shift
+			;;
+		--root=*)
+			ROOT=${opt##--root=}
+			shift
+			;;
+		*)
+			echo "'$opt' is an unkown option; exiting with error"
+			exit 1
+			;;
+	esac
+done
+
+# find service file
+for p in $ROOT/etc/systemd/system \
+         $ROOT/lib/systemd/system \
+         $ROOT/usr/lib/systemd/system; do
+	if [ -e $p/$service ]; then
+		service_file=$p/$service
+		service_file=${service_file##$ROOT}
+	fi
+done
+if [ -z "$service_file" ]; then
+	echo "'$service' couldn't be found; exiting with error"
+	exit 1
+fi
+
+# create the required symbolic links
+wanted_by=$(grep WantedBy $ROOT/$service_file \
+                | sed 's,WantedBy=,,g' \
+                | tr ',' '\n' \
+                | grep '\.target$')
+
+for r in $wanted_by; do
+	mkdir -p $ROOT/etc/systemd/system/$r.wants
+	ln -s $service_file $ROOT/etc/systemd/system/$r.wants
+	echo "Enabled $service for $wanted_by."
+done
-- 
1.7.2.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH 2/3] systemd.bbclass: make easier handle service enabling
  2011-11-04 17:25 [meta-oe][PATCH 0/3] SystemD service management support Otavio Salvador
  2011-11-04 17:25 ` [meta-oe][PATCH 1/3] systemd-systemctl-native: add a systemctl wrapper Otavio Salvador
@ 2011-11-04 17:25 ` Otavio Salvador
  2011-11-04 17:26 ` [meta-oe][PATCH 3/3] connman: refactor systemd packaging Otavio Salvador
  2 siblings, 0 replies; 4+ messages in thread
From: Otavio Salvador @ 2011-11-04 17:25 UTC (permalink / raw)
  To: openembedded-devel

This generates the postinst/prerm/postrm routines for the package
specified in SYSTEMD_PACKAGES avoding code duplication and
centralizing the handling of it for easy maintainence work.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 meta-oe/classes/systemd.bbclass |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)
 create mode 100644 meta-oe/classes/systemd.bbclass

diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
new file mode 100644
index 0000000..83833db
--- /dev/null
+++ b/meta-oe/classes/systemd.bbclass
@@ -0,0 +1,78 @@
+SYSTEMDPN ?= "${PN}"
+
+DEPENDS_append = " systemd-systemctl-native"
+RDEPENDS_${SYSTEMDPN}_append = " systemd"
+
+systemd_postinst() {
+OPTS=""
+
+if [ -n "$D" ]; then
+    OPTS="--root=$D"
+fi
+
+systemctl $OPTS enable ${SYSTEMD_SERVICE}
+
+if [ -z "$D" ]; then
+    systemctl start ${SYSTEMD_SERVICE}
+fi
+}
+
+systemd_prerm() {
+if [ -z "$D" ]; then
+    systemctl stop ${SYSTEMD_SERVICE}
+fi
+}
+
+systemd_postrm() {
+systemctl disable ${SYSTEMD_SERVICE}
+}
+
+def systemd_after_parse(d):
+    if bb.data.getVar('SYSTEMD_PACKAGES', d) == None:
+        if bb.data.getVar('SYSTEMD_SERVICE', d) == None:
+            raise bb.build.FuncFailed, "%s inherits systemd but doesn't set SYSTEMD_SERVICE" % bb.data.getVar('FILE', d)
+
+python __anonymous() {
+    systemd_after_parse(d)
+}
+
+python populate_packages_prepend () {
+	def systemd_package(pkg):
+		bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg)
+		localdata = bb.data.createCopy(d)
+		overrides = bb.data.getVar("OVERRIDES", localdata, 1)
+		bb.data.setVar("OVERRIDES", "%s:%s" % (pkg, overrides), localdata)
+		bb.data.update_data(localdata)
+
+		"""
+		systemd postinst is appended here because pkg_postinst may require to
+		execute on the target. Not doing so may cause systemd postinst invoked
+		twice to cause unwanted warnings.
+		""" 
+		postinst = bb.data.getVar('pkg_postinst', localdata, 1)
+		if not postinst:
+			postinst = '#!/bin/sh\n'
+		postinst += bb.data.getVar('systemd_postinst', localdata, 1)
+		bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
+
+		prerm = bb.data.getVar('pkg_prerm', localdata, 1)
+		if not prerm:
+			prerm = '#!/bin/sh\n'
+		prerm += bb.data.getVar('systemd_prerm', localdata, 1)
+		bb.data.setVar('pkg_prerm_%s' % pkg, prerm, d)
+
+	        postrm = bb.data.getVar('pkg_postrm', localdata, 1)
+	        if not postrm:
+	                postrm = '#!/bin/sh\n'
+                postrm += bb.data.getVar('systemd_postrm', localdata, 1)
+		bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d)
+
+	pkgs = bb.data.getVar('SYSTEMD_PACKAGES', d, 1)
+	if pkgs == None:
+		pkgs = bb.data.getVar('SYSTEMDPN', d, 1)
+		packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
+		if not pkgs in packages and packages != []:
+			pkgs = packages[0]
+	for pkg in pkgs.split():
+		systemd_package(pkg)
+}
-- 
1.7.2.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [meta-oe][PATCH 3/3] connman: refactor systemd packaging
  2011-11-04 17:25 [meta-oe][PATCH 0/3] SystemD service management support Otavio Salvador
  2011-11-04 17:25 ` [meta-oe][PATCH 1/3] systemd-systemctl-native: add a systemctl wrapper Otavio Salvador
  2011-11-04 17:25 ` [meta-oe][PATCH 2/3] systemd.bbclass: make easier handle service enabling Otavio Salvador
@ 2011-11-04 17:26 ` Otavio Salvador
  2 siblings, 0 replies; 4+ messages in thread
From: Otavio Salvador @ 2011-11-04 17:26 UTC (permalink / raw)
  To: openembedded-devel

This changes the recipe to use systemd.bbclass to avoid duplicating
code and also fix the rdepends of connman-systemd on connman.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 meta-oe/recipes-connectivity/connman/connman.inc   |   24 ++++---------------
 .../recipes-connectivity/connman/connman_0.77.bb   |    2 +-
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/meta-oe/recipes-connectivity/connman/connman.inc b/meta-oe/recipes-connectivity/connman/connman.inc
index 8209502..88b2e51 100644
--- a/meta-oe/recipes-connectivity/connman/connman.inc
+++ b/meta-oe/recipes-connectivity/connman/connman.inc
@@ -31,9 +31,12 @@ EXTRA_OECONF += "\
 INITSCRIPT_NAME = "connman"
 INITSCRIPT_PARAMS = "start 05 5 2 . stop 22 0 1 6 ."
 
+SYSTEMD_PACKAGES = "${PN}-systemd"
+SYSTEMD_SERVICE_${PN}-systemd = "connman.service"
+
 PARALLEL_MAKE = ""
 
-inherit autotools pkgconfig update-rc.d
+inherit autotools pkgconfig update-rc.d systemd
 
 do_configure_append() {
 	ln -sf . include/connman
@@ -84,24 +87,7 @@ FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*.so.* \
 PACKAGES =+ "${PN}-systemd"
 # Package up systemd files
 FILES_${PN}-systemd += "${base_libdir}/systemd"
-
-pkg_postinst_connman-systemd() {
-	# can't do this offline
-	if [ "x$D" != "x" ]; then
-		exit 1
-	fi
-	
-	systemctl enable connman.service
-}
-
-pkg_postrm_connman-systemd() {
-	# can't do this offline
-	if [ "x$D" != "x" ]; then
-		exit 1
-	fi
-
-	systemctl disable connman.service
-}
+RDEPENDS_${PN}-systemd += "${PN}"
 
 # Needed when using DNS proxy feature
 RRECOMMENDS_${PN} += "dnsmasq-dbus"
diff --git a/meta-oe/recipes-connectivity/connman/connman_0.77.bb b/meta-oe/recipes-connectivity/connman/connman_0.77.bb
index 6d9c87c..9c93e51 100644
--- a/meta-oe/recipes-connectivity/connman/connman_0.77.bb
+++ b/meta-oe/recipes-connectivity/connman/connman_0.77.bb
@@ -1,5 +1,5 @@
 require connman.inc
-PR = "r2"
+PR = "r3"
 
 EXTRA_OECONF += "\
   --disable-gtk-doc \
-- 
1.7.2.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-04 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-04 17:25 [meta-oe][PATCH 0/3] SystemD service management support Otavio Salvador
2011-11-04 17:25 ` [meta-oe][PATCH 1/3] systemd-systemctl-native: add a systemctl wrapper Otavio Salvador
2011-11-04 17:25 ` [meta-oe][PATCH 2/3] systemd.bbclass: make easier handle service enabling Otavio Salvador
2011-11-04 17:26 ` [meta-oe][PATCH 3/3] connman: refactor systemd packaging Otavio Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.