From f4f01ec146d91cb6943828851d98eee6a1ad4dd9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 2 Jul 2014 22:00:00 +0200 Subject: sysv-generator: Skip init scripts for existing native services This avoids taking the SysV init script enablement state into account if we have native units. Otherwise systemctl disable on native unit would not be respected in the presence of an enabled SysV script. Also, there's no need to do all the parsing and creation of service files if we already have a native systemd unit for the processed SysV init script. --- test/sysv-generator-test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/sysv-generator-test.py b/test/sysv-generator-test.py index 5098519073..09f5c01762 100644 --- a/test/sysv-generator-test.py +++ b/test/sysv-generator-test.py @@ -367,6 +367,18 @@ class SysvGeneratorTest(unittest.TestCase): self.assert_enabled('foo.bak.service', []) self.assert_enabled('foo.old.service', []) + def test_existing_native_unit(self): + '''existing native unit''' + + with open(os.path.join(self.unit_dir, 'foo.service'), 'w') as f: + f.write('[Unit]\n') + + self.add_sysv('foo.sh', {'Provides': 'foo bar'}, enable=True) + err, results = self.run_generator() + self.assertEqual(list(results), []) + # no enablement or alias links, as native unit is disabled + self.assertEqual(os.listdir(self.out_dir), []) + if __name__ == '__main__': unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2)) -- cgit v1.2.3-54-g00ecf