From 75232878d1ce01c9c533b6ff2d1a29e616969ed2 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 10 Jul 2015 16:31:12 -0500 Subject: [PATCH] Patch init grain --- salt-2015.5.3-tests.patch | 54 +++++++++++++++++++++++++++++++++++++++ salt.spec | 5 +++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/salt-2015.5.3-tests.patch b/salt-2015.5.3-tests.patch index a4bb953..3a591de 100644 --- a/salt-2015.5.3-tests.patch +++ b/salt-2015.5.3-tests.patch @@ -1,3 +1,57 @@ +diff -ur a/salt/grains/core.py b/salt/grains/core.py +--- a/salt/grains/core.py 2015-07-07 15:42:37.000000000 -0500 ++++ b/salt/grains/core.py 2015-07-10 16:24:29.097483841 -0500 +@@ -1042,28 +1042,29 @@ + with salt.utils.fopen('/proc/1/cmdline') as fhr: + init_cmdline = fhr.read().replace('\x00', ' ').split() + init_bin = salt.utils.which(init_cmdline[0]) +- supported_inits = ('upstart', 'sysvinit', 'systemd') +- edge_len = max(len(x) for x in supported_inits) - 1 +- buf_size = __opts__['file_buffer_size'] +- try: +- with open(init_bin, 'rb') as fp_: +- buf = True +- edge = '' +- buf = fp_.read(buf_size).lower() +- while buf: +- buf = edge + buf +- for item in supported_inits: +- if item in buf: +- grains['init'] = item +- buf = '' +- break +- edge = buf[-edge_len:] ++ if init_bin: ++ supported_inits = ('upstart', 'sysvinit', 'systemd') ++ edge_len = max(len(x) for x in supported_inits) - 1 ++ buf_size = __opts__['file_buffer_size'] ++ try: ++ with open(init_bin, 'rb') as fp_: ++ buf = True ++ edge = '' + buf = fp_.read(buf_size).lower() +- except (IOError, OSError) as exc: +- log.error( +- 'Unable to read from init_bin ({0}): {1}' +- .format(init_bin, exc) +- ) ++ while buf: ++ buf = edge + buf ++ for item in supported_inits: ++ if item in buf: ++ grains['init'] = item ++ buf = '' ++ break ++ edge = buf[-edge_len:] ++ buf = fp_.read(buf_size).lower() ++ except (IOError, OSError) as exc: ++ log.error( ++ 'Unable to read from init_bin ({0}): {1}' ++ .format(init_bin, exc) ++ ) + + # Add lsb grains on any distro with lsb-release + try: diff -ur a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/artifactory_test.py --- a/tests/unit/modules/artifactory_test.py 2015-07-07 15:42:37.000000000 -0500 +++ b/tests/unit/modules/artifactory_test.py 2015-07-10 12:11:33.942671443 -0500 diff --git a/salt.spec b/salt.spec index 8f6ccff..b280e56 100644 --- a/salt.spec +++ b/salt.spec @@ -455,7 +455,10 @@ rm -rf %{buildroot} %endif %changelog -* Mon Jun 4 2015 Erik Johnson - 2015.5.3-2 +* Fri Jul 10 2015 Erik Johnson - 2015.5.3-3 +- Patch init grain + +* Fri Jul 10 2015 Erik Johnson - 2015.5.3-2 - Update to bugfix release 2015.5.3, add bash completion * Fri Jun 19 2015 Fedora Release Engineering - 2015.5.2-4