From fca1b92a9f1cc61d56a666cc71983700747bb49a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 15 Apr 2018 22:32:34 +0000 Subject: [PATCH] The postinst script now checks /usr/sbin/policy-rc.d Some complicated service dependencies will fail to configure under normal circumstances because invoke-rc.d will kill service start based on policy-rc.d but this is not taken into account when configuring services that are dependent on that service. The dependency check fails prior to the policy-rc.d check and as a result some packages will remain unconfigured after we have finished constructing the root filesystem. This is ok for most cases but precludes dynamic modification of that filesystem post-creation and will even cause those unconfigured services to be restarted the first time a new package is installed. Checking policy-rc.d first in the postinst script allows the configuration step to complete for all services and their dependents to fix these problems. --- tools/onlpm.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index 523287f0..4784fb79 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -69,10 +69,17 @@ class OnlPackageServiceScript(object): class OnlPackageAfterInstallScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh -set -e if [ -x "/etc/init.d/%(service)s" ]; then - update-rc.d %(service)s defaults >/dev/null - invoke-rc.d %(service)s start || exit $? + if [ -x "/usr/sbin/policy-rc.d" ]; then + /usr/sbin/policy-rc.d + if [ $? -eq 101 ]; then + echo "warning: service %(service)s: postinst: ignored due to policy-rc.d" + exit 0; + fi + fi + set -e + update-rc.d %(service)s defaults >/dev/null + invoke-rc.d %(service)s start || exit $? fi """ @@ -80,7 +87,7 @@ class OnlPackageBeforeRemoveScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh set -e if [ -x "/etc/init.d/%(service)s" ]; then - invoke-rc.d %(service)s stop || exit $? + invoke-rc.d %(service)s stop || exit $? fi """ @@ -88,7 +95,7 @@ class OnlPackageAfterRemoveScript(OnlPackageServiceScript): SCRIPT = """#!/bin/sh set -e if [ "$1" = "purge" ] ; then - update-rc.d %(service)s remove >/dev/null + update-rc.d %(service)s remove >/dev/null fi """