[Pkg-ceph-commits] [ceph] 01/02: Add fix-init-system-detection.patch
Gaudenz Steinlin
gaudenz at moszumanska.debian.org
Tue May 16 19:13:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
gaudenz pushed a commit to branch jewel
in repository ceph.
commit a12798af80d903bbaa18d174a98ac5c6ae8b1204
Author: Gaudenz Steinlin <gaudenz at debian.org>
Date: Thu May 11 23:09:24 2017 +0200
Add fix-init-system-detection.patch
This replaces the static init system detection by more appropriate
runtime detection which also works if a Debian system is running with
sysvinit.
Closes: #862075
---
debian/patches/fix-init-system-detection.patch | 144 +++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 145 insertions(+)
diff --git a/debian/patches/fix-init-system-detection.patch b/debian/patches/fix-init-system-detection.patch
new file mode 100644
index 0000000..2e250b3
--- /dev/null
+++ b/debian/patches/fix-init-system-detection.patch
@@ -0,0 +1,144 @@
+Last-Update: 2017-05-11
+Bug-Ceph: http://tracker.ceph.com/issues/19884
+Author: Kefu Chai <kchai at redhat.com> and Gaudenz Steinlin <gaudenz at debian.org>
+Description: Replace static init system detection by runtime detection. Modified
+ version of the patch proposed by Kefu Chai upstream.
+
+--- a/src/ceph-detect-init/ceph_detect_init/debian/__init__.py
++++ b/src/ceph-detect-init/ceph_detect_init/debian/__init__.py
+@@ -1,3 +1,6 @@
++import os
++import subprocess
++
+ distro = None
+ release = None
+ codename = None
+@@ -8,14 +11,11 @@
+
+ Returns the name of a init system (upstart, sysvinit ...).
+ """
+- assert(distro and codename)
+- if distro.lower() in ('ubuntu', 'linuxmint'):
+- if codename >= 'vivid':
+- return 'systemd'
+- else:
+- return 'upstart'
+- if distro.lower() == 'debian':
+- if codename in ('squeeze', 'wheezy'):
+- return 'sysvinit'
+- else:
+- return 'systemd'
++ # yes, this is heuristics
++ if os.path.isdir('/run/systemd/system'):
++ return 'systemd'
++ if not subprocess.call('. /lib/lsb/init-functions ; init_is_upstart',
++ shell=True):
++ return 'upstart'
++ elif os.path.isfile('/sbin/init') and not os.path.islink('/sbin/init'):
++ return 'sysvinit'
+--- a/src/ceph-detect-init/tests/test_all.py
++++ b/src/ceph-detect-init/tests/test_all.py
+@@ -44,30 +44,35 @@
+ self.assertEqual('sysvinit', centos.choose_init())
+
+ def test_debian(self):
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='debian',
+- codename='wheezy'):
+- self.assertEqual('sysvinit', debian.choose_init())
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='debian',
+- codename='squeeze'):
+- self.assertEqual('sysvinit', debian.choose_init())
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='debian',
+- codename='jessie'):
++ with mock.patch.multiple('os.path',
++ isdir=lambda x: x == '/run/systemd/system'):
+ self.assertEqual('systemd', debian.choose_init())
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='ubuntu',
+- codename='trusty'):
+- self.assertEqual('upstart', debian.choose_init())
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='ubuntu',
+- codename='vivid'):
+- self.assertEqual('systemd', debian.choose_init())
+- with mock.patch.multiple('ceph_detect_init.debian',
+- distro='not-debian',
+- codename='andy'):
+- self.assertIs(None, debian.choose_init())
++
++ def mock_call_with_upstart(*args, **kwargs):
++ if args[0] == '. /lib/lsb/init-functions ; init_is_upstart' and \
++ kwargs['shell']:
++ return 0
++ else:
++ return 1
++ with mock.patch.multiple('os.path',
++ isdir=lambda x: False,
++ isfile=lambda x: False):
++ with mock.patch.multiple('subprocess',
++ call=mock_call_with_upstart):
++ self.assertEqual('upstart', debian.choose_init())
++ with mock.patch.multiple('os.path',
++ isdir=lambda x: False,
++ isfile=lambda x: x == '/sbin/init',
++ islink=lambda x: x != '/sbin/init'):
++ with mock.patch.multiple('subprocess',
++ call=lambda *args, **kwargs: 1):
++ self.assertEqual('sysvinit', debian.choose_init())
++ with mock.patch.multiple('os.path',
++ isdir=lambda x: False,
++ isfile=lambda x: False):
++ with mock.patch.multiple('subprocess',
++ call=lambda *args, **kwargs: 1):
++ self.assertIs(None, debian.choose_init())
+
+ def test_fedora(self):
+ with mock.patch('ceph_detect_init.fedora.release',
+@@ -115,7 +120,6 @@
+ self.assertEqual(False, distro.is_el)
+ self.assertEqual('6.0', distro.release)
+ self.assertEqual('squeeze', distro.codename)
+- self.assertEqual('sysvinit', distro.init)
+
+ def test_get_distro(self):
+ g = ceph_detect_init._get_distro
+--- a/src/ceph-detect-init/ceph_detect_init/__init__.py
++++ b/src/ceph-detect-init/ceph_detect_init/__init__.py
+@@ -25,7 +25,7 @@
+
+ def get(use_rhceph=False):
+ distro_name, release, codename = platform_information()
+- if not codename or not _get_distro(distro_name):
++ if not _get_distro(distro_name):
+ raise exc.UnsupportedPlatform(
+ distro=distro_name,
+ codename=codename,
+@@ -83,25 +83,6 @@
+ logging.debug('platform_information: linux_distribution = ' +
+ str(platform.linux_distribution()))
+ distro, release, codename = platform.linux_distribution()
+- # this could be an empty string in Debian
+- if not codename and 'debian' in distro.lower():
+- debian_codenames = {
+- '8': 'jessie',
+- '7': 'wheezy',
+- '6': 'squeeze',
+- }
+- major_version = release.split('.')[0]
+- codename = debian_codenames.get(major_version, '')
+-
+- # In order to support newer jessie/sid or wheezy/sid strings
+- # we test this if sid is buried in the minor, we should use
+- # sid anyway.
+- if not codename and '/' in release:
+- major, minor = release.split('/')
+- if minor == 'sid':
+- codename = minor
+- else:
+- codename = major
+
+ return (
+ str(distro).rstrip(),
diff --git a/debian/patches/series b/debian/patches/series
index 506e4a7..c54047d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -16,6 +16,7 @@ tests-disable.patch
# Use correct compiler flags on armel
softfp-armel.patch
mips_mipsel_libatomic.patch
+fix-init-system-detection.patch
## From Ubuntu
fix-cycles-arch.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ceph/ceph.git
More information about the Pkg-ceph-commits
mailing list