[2/7] systemd-conf: simplify creation of configuration

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

Details

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

Commit Message

Jonas Bonn Dec. 31, 2018, 12:05 p.m.
The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The base configuration files have the lowest priority; they will always
be overridden by any snippets.  As such, it's probably best to not
provide them at all.  This also moves us a step closer to an empty /etc
which is should be a long term goal in order to allow running OE as a
"stateless system".

This patch moves the systemd configuration to snippets in
/usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
just sets up a couple of text files and doesn't even need access to the
systemd source anymore.
---
 meta/recipes-core/systemd/systemd-conf.bb | 34 +++++++++--------------
 1 file changed, 13 insertions(+), 21 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/systemd/systemd-conf.bb b/meta/recipes-core/systemd/systemd-conf.bb
index 7fe2e1105b..a504afe3e7 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,9 +1,8 @@ 
-require systemd.inc
-
 SUMMARY = "Systemd system configuration"
 DESCRIPTION = "Systemd may require slightly different configuration for \
 different machines.  For example, qemu machines require a longer \
 DefaultTimeoutStartSec setting."
+LICENSE = "GPLv2"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
@@ -13,36 +12,29 @@  ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+/usr/lib/logind.conf.d/* \
+/usr/lib/system.conf.d/* \
+"
 
 do_install() {
-	rm -rf ${D}/${sysconfdir}/systemd
-	install -d ${D}/${sysconfdir}/systemd
-
-	install -m 0644 ${S}/src/coredump/coredump.conf ${D}${sysconfdir}/systemd/coredump.conf
-
-	install -m 0644 ${S}/src/journal/journald.conf ${D}${sysconfdir}/systemd/journald.conf
+	install -d ${D}/usr/lib/journald.conf.d
 	# Enable journal to forward message to syslog daemon
-	sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
+	echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
 	# Set the maximium size of runtime journal to 64M as default
-	sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' ${D}${sysconfdir}/systemd/journald.conf
+	echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
 
-	install -m 0644 ${S}/src/login/logind.conf.in ${D}${sysconfdir}/systemd/logind.conf
+	install -d ${D}/usr/lib/logind.conf.d
 	# Set KILL_USER_PROCESSES to yes
-	sed -i -e 's/@KILL_USER_PROCESSES@/yes/' ${D}${sysconfdir}/systemd/logind.conf
+	echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/${PN}.conf
 
-	install -m 0644 ${S}/src/core/system.conf.in ${D}${sysconfdir}/systemd/system.conf
+	install -d ${D}/usr/lib/system.conf.d
 	# Set MEMORY_ACCOUNTING_DEFAULT to yes
-	sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' ${D}${sysconfdir}/systemd/system.conf
-
-	install -m 0644 ${S}/src/core/user.conf ${D}${sysconfdir}/systemd/user.conf
+	echo "DefaultMemoryAccounting=yes" >> ${D}/usr/lib/system.conf.d/${PN}.conf
 }
 
 # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
 do_install_append_qemuall() {
 	# Change DefaultTimeoutStartSec from 90s to 240s
-	echo "DefaultTimeoutStartSec = 240s" >> ${D}${sysconfdir}/systemd/system.conf
+	echo "DefaultTimeoutStartSec = 240s" >> ${D}/usr/lib/system.conf.d/${PN}.conf
 }

Comments

Randy MacLeod Jan. 1, 2019, 3:29 p.m.
On 12/31/18 7:05 AM, Jonas Bonn wrote:
> The configuration files that systemd installs are just skeletons
> detailing the available options and their default values.  The
> recommended means of changing the configuration is to provide snippets
> in configuration directories.  For example, journald.conf settings are
> best set in /usr/lib/journald.conf.d/ and can be overridden by the user
> by providing overriding snippets in /etc/systemd/journald.conf.d/.
> 
> The base configuration files have the lowest priority; they will always
> be overridden by any snippets.  As such, it's probably best to not
> provide them at all.  This also moves us a step closer to an empty /etc
> which is should be a long term goal in order to allow running OE as a
> "stateless system".
> 
> This patch moves the systemd configuration to snippets in
> /usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
> just sets up a couple of text files and doesn't even need access to the
> systemd source anymore.
> ---
>   meta/recipes-core/systemd/systemd-conf.bb | 34 +++++++++--------------
>   1 file changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/meta/recipes-core/systemd/systemd-conf.bb b/meta/recipes-core/systemd/systemd-conf.bb
> index 7fe2e1105b..a504afe3e7 100644
> --- a/meta/recipes-core/systemd/systemd-conf.bb
> +++ b/meta/recipes-core/systemd/systemd-conf.bb
> @@ -1,9 +1,8 @@
> -require systemd.inc
> -
>   SUMMARY = "Systemd system configuration"
>   DESCRIPTION = "Systemd may require slightly different configuration for \
>   different machines.  For example, qemu machines require a longer \
>   DefaultTimeoutStartSec setting."
> +LICENSE = "GPLv2"

Systemd claims that these conf files are: LGPLv2.1+ licensed.

https://github.com/systemd/systemd/blob/master/sysusers.d/systemd.conf.m4

https://github.com/systemd/systemd/blob/master/modprobe.d/systemd.conf

>   
>   PACKAGE_ARCH = "${MACHINE_ARCH}"
>   
> @@ -13,36 +12,29 @@ ${sysconfdir}/systemd/logind.conf \
>   ${sysconfdir}/systemd/system.conf \
>   ${sysconfdir}/systemd/user.conf"
>   
> -FILES_${PN} = "${sysconfdir}/systemd"
> -
> -do_configure[noexec] = '1'
> -do_compile[noexec] = '1'
> +FILES_${PN} = "/usr/lib/journald.conf.d/* \
> +/usr/lib/logind.conf.d/* \
> +/usr/lib/system.conf.d/* \
> +"
>   
>   do_install() {
> -	rm -rf ${D}/${sysconfdir}/systemd
> -	install -d ${D}/${sysconfdir}/systemd
> -
> -	install -m 0644 ${S}/src/coredump/coredump.conf ${D}${sysconfdir}/systemd/coredump.conf
> -
> -	install -m 0644 ${S}/src/journal/journald.conf ${D}${sysconfdir}/systemd/journald.conf
> +	install -d ${D}/usr/lib/journald.conf.d

Should the recipe use /usr/lib or is / should there be a
'systemdconfdir' var?

Otherwise, LGTM.
../Randy

>   	# Enable journal to forward message to syslog daemon
> -	sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
> +	echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
>   	# Set the maximium size of runtime journal to 64M as default
> -	sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' ${D}${sysconfdir}/systemd/journald.conf
> +	echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
>   
> -	install -m 0644 ${S}/src/login/logind.conf.in ${D}${sysconfdir}/systemd/logind.conf
> +	install -d ${D}/usr/lib/logind.conf.d
>   	# Set KILL_USER_PROCESSES to yes
> -	sed -i -e 's/@KILL_USER_PROCESSES@/yes/' ${D}${sysconfdir}/systemd/logind.conf
> +	echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/${PN}.conf
>   
> -	install -m 0644 ${S}/src/core/system.conf.in ${D}${sysconfdir}/systemd/system.conf
> +	install -d ${D}/usr/lib/system.conf.d
>   	# Set MEMORY_ACCOUNTING_DEFAULT to yes
> -	sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' ${D}${sysconfdir}/systemd/system.conf
> -
> -	install -m 0644 ${S}/src/core/user.conf ${D}${sysconfdir}/systemd/user.conf
> +	echo "DefaultMemoryAccounting=yes" >> ${D}/usr/lib/system.conf.d/${PN}.conf
>   }
>   
>   # Based on change from YP bug 8141, OE commit 5196d7bacaef1076c361adaa2867be31759c1b52
>   do_install_append_qemuall() {
>   	# Change DefaultTimeoutStartSec from 90s to 240s
> -	echo "DefaultTimeoutStartSec = 240s" >> ${D}${sysconfdir}/systemd/system.conf
> +	echo "DefaultTimeoutStartSec = 240s" >> ${D}/usr/lib/system.conf.d/${PN}.conf
>   }
>
Jonas Bonn Jan. 1, 2019, 5:03 p.m.
Hi Randy,

Thanks for looking at this.

On 01/01/2019 16:29, Randy MacLeod wrote:
> On 12/31/18 7:05 AM, Jonas Bonn wrote:
>> The configuration files that systemd installs are just skeletons
>> detailing the available options and their default values.  The
>> recommended means of changing the configuration is to provide snippets
>> in configuration directories.  For example, journald.conf settings are
>> best set in /usr/lib/journald.conf.d/ and can be overridden by the user
>> by providing overriding snippets in /etc/systemd/journald.conf.d/.
>>
>> The base configuration files have the lowest priority; they will always
>> be overridden by any snippets.  As such, it's probably best to not
>> provide them at all.  This also moves us a step closer to an empty /etc
>> which is should be a long term goal in order to allow running OE as a
>> "stateless system".
>>
>> This patch moves the systemd configuration to snippets in
>> /usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
>> just sets up a couple of text files and doesn't even need access to the
>> systemd source anymore.
>> ---
>>   meta/recipes-core/systemd/systemd-conf.bb | 34 +++++++++--------------
>>   1 file changed, 13 insertions(+), 21 deletions(-)
>>
>> diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
>> b/meta/recipes-core/systemd/systemd-conf.bb
>> index 7fe2e1105b..a504afe3e7 100644
>> --- a/meta/recipes-core/systemd/systemd-conf.bb
>> +++ b/meta/recipes-core/systemd/systemd-conf.bb
>> @@ -1,9 +1,8 @@
>> -require systemd.inc
>> -
>>   SUMMARY = "Systemd system configuration"
>>   DESCRIPTION = "Systemd may require slightly different configuration 
>> for \
>>   different machines.  For example, qemu machines require a longer \
>>   DefaultTimeoutStartSec setting."
>> +LICENSE = "GPLv2"
> 
> Systemd claims that these conf files are: LGPLv2.1+ licensed.

The configuration files from systemd may be LGPLv2 licensed, but this 
package now only creates some configuration snippets which are 
independent of systemd (it's just data, now).  As such, one could 
certainly put whatever license one wanted on this.  Honestly, GPLv2 is 
probably a stretch... I can hardly see that any license applies to this, 
to be honest.  Consider that:

/usr/lib/journald.conf.d/systemd-conf.conf

contains

ForwardToSyslog=yes
RuntimeMaxUse=64M

Just configuration data that the package creates dynamically.

> 
> https://github.com/systemd/systemd/blob/master/sysusers.d/systemd.conf.m4
> 
> https://github.com/systemd/systemd/blob/master/modprobe.d/systemd.conf
> 
>>   PACKAGE_ARCH = "${MACHINE_ARCH}"
>> @@ -13,36 +12,29 @@ ${sysconfdir}/systemd/logind.conf \
>>   ${sysconfdir}/systemd/system.conf \
>>   ${sysconfdir}/systemd/user.conf"
>> -FILES_${PN} = "${sysconfdir}/systemd"
>> -
>> -do_configure[noexec] = '1'
>> -do_compile[noexec] = '1'
>> +FILES_${PN} = "/usr/lib/journald.conf.d/* \
>> +/usr/lib/logind.conf.d/* \
>> +/usr/lib/system.conf.d/* \
>> +"
>>   do_install() {
>> -    rm -rf ${D}/${sysconfdir}/systemd
>> -    install -d ${D}/${sysconfdir}/systemd
>> -
>> -    install -m 0644 ${S}/src/coredump/coredump.conf 
>> ${D}${sysconfdir}/systemd/coredump.conf
>> -
>> -    install -m 0644 ${S}/src/journal/journald.conf 
>> ${D}${sysconfdir}/systemd/journald.conf
>> +    install -d ${D}/usr/lib/journald.conf.d
> 
> Should the recipe use /usr/lib or is / should there be a
> 'systemdconfdir' var?

So, I looked into the systemd source and, as far as I can see, it seems 
that systemd hardcodes the paths to configuration files, tmpfiles, 
presets, etc.  It's all really /usr/lib/... with no method of specifying 
any other location.  For this reason, I've used these explicit paths 
above, strange though it may appear...

/Jonas
Randy MacLeod Jan. 1, 2019, 8:17 p.m.
On 1/1/19 12:03 PM, Jonas Bonn wrote:
> Hi Randy,
> 
> Thanks for looking at this.
> 
> On 01/01/2019 16:29, Randy MacLeod wrote:
>> On 12/31/18 7:05 AM, Jonas Bonn wrote:
>>> The configuration files that systemd installs are just skeletons
>>> detailing the available options and their default values.  The
>>> recommended means of changing the configuration is to provide snippets
>>> in configuration directories.  For example, journald.conf settings are
>>> best set in /usr/lib/journald.conf.d/ and can be overridden by the user
>>> by providing overriding snippets in /etc/systemd/journald.conf.d/.
>>>
>>> The base configuration files have the lowest priority; they will always
>>> be overridden by any snippets.  As such, it's probably best to not
>>> provide them at all.  This also moves us a step closer to an empty /etc
>>> which is should be a long term goal in order to allow running OE as a
>>> "stateless system".
>>>
>>> This patch moves the systemd configuration to snippets in
>>> /usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
>>> just sets up a couple of text files and doesn't even need access to the
>>> systemd source anymore.
>>> ---
>>>   meta/recipes-core/systemd/systemd-conf.bb | 34 +++++++++--------------
>>>   1 file changed, 13 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
>>> b/meta/recipes-core/systemd/systemd-conf.bb
>>> index 7fe2e1105b..a504afe3e7 100644
>>> --- a/meta/recipes-core/systemd/systemd-conf.bb
>>> +++ b/meta/recipes-core/systemd/systemd-conf.bb
>>> @@ -1,9 +1,8 @@
>>> -require systemd.inc
>>> -
>>>   SUMMARY = "Systemd system configuration"
>>>   DESCRIPTION = "Systemd may require slightly different configuration 
>>> for \
>>>   different machines.  For example, qemu machines require a longer \
>>>   DefaultTimeoutStartSec setting."
>>> +LICENSE = "GPLv2"
>>
>> Systemd claims that these conf files are: LGPLv2.1+ licensed.
> 
> The configuration files from systemd may be LGPLv2 licensed, but this 
> package now only creates some configuration snippets which are 
> independent of systemd (it's just data, now).  As such, one could 
> certainly put whatever license one wanted on this.  Honestly, GPLv2 is 
> probably a stretch... I can hardly see that any license applies to this, 
> to be honest.  Consider that:
> 
> /usr/lib/journald.conf.d/systemd-conf.conf
> 
> contains
> 
> ForwardToSyslog=yes
> RuntimeMaxUse=64M
> 
> Just configuration data that the package creates dynamically.

I agree, maybe it's best to just use:
LICENSE = "MIT"
or as you say, no license tag at all.

> 
>>
>> https://github.com/systemd/systemd/blob/master/sysusers.d/systemd.conf.m4
>>
>> https://github.com/systemd/systemd/blob/master/modprobe.d/systemd.conf
>>
>>>   PACKAGE_ARCH = "${MACHINE_ARCH}"
>>> @@ -13,36 +12,29 @@ ${sysconfdir}/systemd/logind.conf \
>>>   ${sysconfdir}/systemd/system.conf \
>>>   ${sysconfdir}/systemd/user.conf"
>>> -FILES_${PN} = "${sysconfdir}/systemd"
>>> -
>>> -do_configure[noexec] = '1'
>>> -do_compile[noexec] = '1'
>>> +FILES_${PN} = "/usr/lib/journald.conf.d/* \
>>> +/usr/lib/logind.conf.d/* \
>>> +/usr/lib/system.conf.d/* \
>>> +"
>>>   do_install() {
>>> -    rm -rf ${D}/${sysconfdir}/systemd
>>> -    install -d ${D}/${sysconfdir}/systemd
>>> -
>>> -    install -m 0644 ${S}/src/coredump/coredump.conf 
>>> ${D}${sysconfdir}/systemd/coredump.conf
>>> -
>>> -    install -m 0644 ${S}/src/journal/journald.conf 
>>> ${D}${sysconfdir}/systemd/journald.conf
>>> +    install -d ${D}/usr/lib/journald.conf.d
>>
>> Should the recipe use /usr/lib or is / should there be a
>> 'systemdconfdir' var?
> 
> So, I looked into the systemd source and, as far as I can see, it seems 
> that systemd hardcodes the paths to configuration files, tmpfiles, 
> presets, etc.  It's all really /usr/lib/... with no method of specifying 
> any other location.  For this reason, I've used these explicit paths 
> above, strange though it may appear...

I thought that might be the case. Thanks for looking into it.

Some people might want to use a variable name for the path so
that it's uniquely identified should they want to patch systemd's
definition but I don't think that's required.

../Randy

> 
> /Jonas