From dbba0d39667032277400ead7e2d08b9caa9ac2c2 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 3 Jan 2019 11:31:45 -0600 Subject: deb: Install policy-rc.d to prevent services from starting Per invoke-rc.d(8), a local policy script can be created at /usr/sbin/policy-rc.d to influence how services are started. When this script exits with code 101, the requested service is not started. This is independent of init system and is respected by all maintainer scripts that comply with debian policy. This is how debootstrap prevents services from running in the chroot. On more recent debian and ubuntu releases where systemd is in use, it will prevent services from starting by detecting that it's in a chroot, but this method works independently of the init system. In our case this fixes builds on Ubuntu Trusty where upstart is init. This change likely makes the hack to replace /sbin/start with a symlink to /sbin/true unnecessary. That hack is not comprehensive since it only handles the start action and not stop, restart, reload, etc. Forwarded: https://github.com/openSUSE/obs-build/pull/484 Applied-upstream: commit:fdb38b34afa8c91eaad37582ab5cedbd06a7817d Gbp-Pq: Name deb-Install-policy-rc.d-to-prevent-services-from-starting.patch --- build-pkg-deb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build-pkg-deb b/build-pkg-deb index c5959c0..4437149 100644 --- a/build-pkg-deb +++ b/build-pkg-deb @@ -48,6 +48,16 @@ deb_setup() { :>> $BUILD_ROOT/var/lib/dpkg/available :>> $BUILD_ROOT/var/log/dpkg.log :>> $BUILD_ROOT/etc/ld.so.conf + + # Install a policy so that services are not started. See + # https://manpages.debian.org/unstable/init-system-helpers/invoke-rc.d.8.en.html + # for details. + mkdir -p $BUILD_ROOT/usr/sbin + cat > $BUILD_ROOT/usr/sbin/policy-rc.d <