chiark / gitweb /
sysv-generator: Replace Provides: symlinks with real units
authorMartin Pitt <martin.pitt@ubuntu.com>
Wed, 21 Jan 2015 09:25:14 +0000 (10:25 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Wed, 21 Jan 2015 16:01:00 +0000 (17:01 +0100)
commit77354c7e6f096a447245a8781c1eaa4acbe67089
treedc42596ea5bb9a7053b22aca78da4c083fb3b024
parentd816e2b7909e50ee887e1a0a825db760cf6fd3b0
sysv-generator: Replace Provides: symlinks with real units

Since commit b7e7184 the SysV generator creates symlinks for all "Provides:" in
the LSB header. However, this is too greedy; there are cases where the
creation of a unit .service file fails because of an already existing
symlink with the same name:

 - Backup files such as /etc/init.d/foo.bak still have "Provides: foo", and
   thus get a foo.service -> foo.bak.service link. foo.bak would not be enabled
   in rcN.d/, but we (deliberately) create units for all executables in init.d/
   so that a manual "systemctl start" works. If foo.bak is processed before,
   the symlink already exists.

 - init.d/bar has "Provides: foo", while there also is a real init.d/foo. The
   former would create a link foo.service -> bar.service, while the latter
   would fail to create the real foo.service.

If we encounter an existing symlink, just remove it before writing a real unit.

Note that two init.d scripts "foo" and "bar" which both provide the same name
"common" already work. The first processed init script wins and creates the
"common.service" symlink, and the second just fails to create the symlink
again. Thus create an additional test case for this to ensure that it keeps
working sensibly.

https://bugs.debian.org/775404
src/sysv-generator/sysv-generator.c
test/sysv-generator-test.py