[7/7] systemd: do not pre-enable services, rely on presets

Submitted by Jonas Bonn on Dec. 31, 2018, 12:05 p.m. | Patch ID: 157498

Details

Message ID 20181231120559.25470-8-jonas@norrbonn.se
State New
Headers show

Commit Message

Jonas Bonn Dec. 31, 2018, 12:05 p.m.
At installation, systemd _both_ installs preset files for its services
and enables the services accordingly (effectively, calling 'systemctl
preset-all' on its own services).  As we now rely on systemd calling
preset-all at first boot, there's no need to carry the pre-populated
/etc/systemd/system directory in the package.

This gets us a step closer to en empty /etc which is a requirement for
running a "stateless system".
---
 meta/recipes-core/systemd/systemd_239.bb | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/systemd/systemd_239.bb b/meta/recipes-core/systemd/systemd_239.bb
index 70e687c92e..7b4c5c56aa 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -298,6 +298,8 @@  do_install() {
 	# duplicate udevadm for postinst script
 	install -d ${D}${libexecdir}
 	ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
+
+	rm -rf ${D}${sysconfdir}/systemd/system
 }
 
 

Comments

Alexander Kanavin Jan. 2, 2019, 12:06 p.m.
On Mon, 31 Dec 2018 at 13:07, Jonas Bonn <jonas@norrbonn.se> wrote:
> diff --git a/meta/recipes-core/systemd/systemd_239.bb b/meta/recipes-core/systemd/systemd_239.bb
> index 70e687c92e..7b4c5c56aa 100644
> --- a/meta/recipes-core/systemd/systemd_239.bb
> +++ b/meta/recipes-core/systemd/systemd_239.bb
> @@ -298,6 +298,8 @@ do_install() {
>         # duplicate udevadm for postinst script
>         install -d ${D}${libexecdir}
>         ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
> +
> +       rm -rf ${D}${sysconfdir}/systemd/system
>  }

Apologies, but this is a hack. You need to tell systemd to not install
the files in the first place, if they are unneeded, instead of
removing them after the fact, which is a maintainability issue
(specifically, anyone looking at the recipe would be totally puzzled
by this removal).

If systemd always installs the files, you should add a configure
option, and send the patch upstream *first*.

Alex
Jonas Bonn Jan. 2, 2019, 2:32 p.m.
Hi Alex,

On 02/01/2019 13:06, Alexander Kanavin wrote:
> On Mon, 31 Dec 2018 at 13:07, Jonas Bonn <jonas@norrbonn.se> wrote:
>> diff --git a/meta/recipes-core/systemd/systemd_239.bb b/meta/recipes-core/systemd/systemd_239.bb
>> index 70e687c92e..7b4c5c56aa 100644
>> --- a/meta/recipes-core/systemd/systemd_239.bb
>> +++ b/meta/recipes-core/systemd/systemd_239.bb
>> @@ -298,6 +298,8 @@ do_install() {
>>          # duplicate udevadm for postinst script
>>          install -d ${D}${libexecdir}
>>          ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
>> +
>> +       rm -rf ${D}${sysconfdir}/systemd/system
>>   }
> 
> Apologies, but this is a hack. You need to tell systemd to not install
> the files in the first place, if they are unneeded, instead of
> removing them after the fact, which is a maintainability issue
> (specifically, anyone looking at the recipe would be totally puzzled
> by this removal).
> 
> If systemd always installs the files, you should add a configure
> option, and send the patch upstream *first*.

Leaving these installed is not a big deal, either.  It's just inelegant 
to leave them there if one is over-mounting /etc with a tmpfs at runtime.

I think this patch is wrong for other reasons, however.  Since there are 
no SYSTEMD_SERVICE_ entries for these .service files in the recipe, they 
probably won't be handled correctly if the systemd package is 
upgraded... the implications are a bit fuzzy, whether or not it matters.

Thanks for looking at this.

/Jonas


> 
> Alex
>