From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from song.cn.fujitsu.com (unknown [222.73.24.84]) by mail.openembedded.org (Postfix) with ESMTP id E35726D12A for ; Tue, 5 Nov 2013 10:14:23 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.93,638,1378828800"; d="scan'208";a="8951823" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 05 Nov 2013 18:11:02 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rA5AEOQC015639 for ; Tue, 5 Nov 2013 18:14:24 +0800 Received: from [127.0.0.1] ([10.167.226.56]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013110518123347-2776635 ; Tue, 5 Nov 2013 18:12:33 +0800 Message-ID: <5278C502.1080100@cn.fujitsu.com> Date: Tue, 05 Nov 2013 18:14:26 +0800 From: Li Zhijian Organization: fnst-ulinux User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Patches and discussions about the oe-core layer X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/05 18:12:33, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/05 18:12:33, Serialize complete at 2013/11/05 18:12:33 Subject: [PATCH v2] systemd.bbclass: only restart the service when it is active at systemd_postinst X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Nov 2013 10:14:24 -0000 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=GB2312 From: Li Zhijian If systemd_postinst is installed as a delayed package scriptlet (installed to /etc/rpm-postints/${PN}) which would be executed at the first time of OS startup. And then this script would block when it is trying to call systemctl to restart service. It seems that it is not a good timing to restart service at run-postinsts. I test serval services which has supported systemd(uuidd/avahi-daemon), all of them will block the startup. Steps to reproduce: 1) Installed systemd_postinst as a delayed package scriptlet i.e. Append Following lines to meta/recipes-core/busybox/busybox.inc pkg_postinst_${PN}-syslog () { if [ "x$D" != "x" ] ; then exit 1 fi } 2) build a rootfs $ bitbake core-image-minimal 3) startup this rootfs OS would block at /etc/rpm-postinsts/busybox-syslog, like follows [ ***] A start job is running ro Run pending postinsts This patch can fix the block problem, and make the service is consistent with the original status Signed-off-by: Li Zhijian --- meta/classes/systemd.bbclass | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass index 3700b2e..1feac06 100644 --- a/meta/classes/systemd.bbclass +++ b/meta/classes/systemd.bbclass @@ -32,7 +32,8 @@ fi if type systemctl >/dev/null 2>/dev/null; then systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} - if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then + if [ -z "$D" ] && systemctl is-active ${SYSTEMD_SERVICE} &>/dev/null; then + # if service is active, restart it systemctl restart ${SYSTEMD_SERVICE} fi fi -- 1.7.1