]> code.ossystems Code Review - openembedded-core.git/commitdiff
opkg: Use systemd service for first boot configuration
authorMuhammad Shakeel <muhammad_shakeel@mentor.com>
Fri, 27 Sep 2013 18:14:15 +0000 (18:14 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 30 Sep 2013 21:02:09 +0000 (22:02 +0100)
Currently opkg uses a script to configure packages during first time boot.
This script is present in rcS.d and when 'sysvinit' is disabled this
script doesn't execute. For systemd only distros this newly added service
will run the opkg configure during first boot only.

Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/opkg/opkg.inc
meta/recipes-devtools/opkg/opkg/opkg-configure.service [new file with mode: 0644]
meta/recipes-devtools/opkg/opkg_svn.bb

index afe6cb0ce607104256157b4568a2d979d7aef536..3d568867d4b9468096ff8660b3d18443c35d8d41 100644 (file)
@@ -16,7 +16,13 @@ do_configure_prepend() {
        sed -i -e s:-Werror::g ${S}/libopkg/Makefile.am
 }
 
-inherit autotools pkgconfig
+inherit autotools pkgconfig systemd
+
+python () {
+    if 'sysvinit' not in d.getVar("DISTRO_FEATURES", True).split():
+        pn = d.getVar('PN', True)
+        d.setVar('SYSTEMD_SERVICE_%s' % (pn), 'opkg-configure.service')
+}
 
 target_localstatedir := "${localstatedir}"
 OPKGLIBDIR = "${target_localstatedir}/lib"
@@ -49,6 +55,16 @@ FILES_libopkg = "${libdir}/*.so.* ${OPKGLIBDIR}/opkg/"
 do_install_append() {
        # We need to create the lock directory
        install -d ${D}${OPKGLIBDIR}/opkg
+
+       if ${@base_contains('DISTRO_FEATURES','sysvinit','false','true',d)};then
+               install -d ${D}${systemd_unitdir}/system
+               install -m 0644 ${WORKDIR}/opkg-configure.service ${D}${systemd_unitdir}/system/
+               sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
+                       -e 's,@SYSCONFDIR@,${sysconfdir},g' \
+                       -e 's,@BINDIR@,${bindir},g' \
+                       -e 's,@SYSTEMD_UNITDIR@,${systemd_unitdir},g' \
+                       ${D}${systemd_unitdir}/system/opkg-configure.service
+       fi
 }
 
 do_install_append_class-native() {
@@ -59,7 +75,8 @@ do_install_append_class-native() {
 
 pkg_postinst_${PN} () {
 #!/bin/sh
-if [ "x$D" != "x" ] && [ -f $D${OPKGLIBDIR}/opkg/status ]; then
+if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)} && \
+       [ "x$D" != "x" ] && [ -f $D${OPKGLIBDIR}/opkg/status ]; then
        install -d $D${sysconfdir}/rcS.d
 
        # this happens at S98 where our good 'ole packages script used to run
diff --git a/meta/recipes-devtools/opkg/opkg/opkg-configure.service b/meta/recipes-devtools/opkg/opkg/opkg-configure.service
new file mode 100644 (file)
index 0000000..a1c3a31
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=Opkg first boot configure
+DefaultDependencies=no
+After=systemd-remount-fs.service systemd-tmpfiles-setup.service tmp.mount
+Before=sysinit.target
+
+[Service]
+Type=oneshot
+EnvironmentFile=-@SYSCONFDIR@/default/postinst
+ExecStart=@BASE_BINDIR@/sh -c " if [ $POSTINST_LOGGING = '1' ]; then @BINDIR@/opkg-cl configure > $LOGFILE 2>&1; else @BINDIR@/opkg-cl configure; fi"
+ExecStartPost=@BASE_BINDIR@/systemctl disable opkg-configure.service
+StandardOutput=syslog
+RemainAfterExit=No
+
+[Install]
+WantedBy=basic.target
+WantedBy=sysinit.target
index bc10491030ec9b42143ad01604cf17d829193023..cd0485fe38a5aec2bca39d324e91ca446bfe8bda 100644 (file)
@@ -3,6 +3,7 @@ require opkg.inc
 SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;protocol=http \
            file://no-install-recommends.patch \
            file://add-exclude.patch \
+           file://opkg-configure.service \
 "
 
 S = "${WORKDIR}/trunk"