Skip to content

Allow to install default configuration into /usr/share/factory#17501

Closed
Mic92 wants to merge 1 commit intosystemd:masterfrom
Mic92:factory-config-dir
Closed

Allow to install default configuration into /usr/share/factory#17501
Mic92 wants to merge 1 commit intosystemd:masterfrom
Mic92:factory-config-dir

Conversation

@Mic92
Copy link
Copy Markdown
Contributor

@Mic92 Mic92 commented Nov 1, 2020

With this meson option it allows distributions to install systemd in a
stateless way as described in http://0pointer.net/blog/projects/stateless.html

For backwards compatibility the build would still install all
configuration files to /etc/systemd and /etc unless specified otherwise.

We use this option in NixOS.

@Mic92 Mic92 marked this pull request as draft November 1, 2020 14:44
@Mic92 Mic92 force-pushed the factory-config-dir branch from c7a51c3 to dd2fc25 Compare November 1, 2020 14:56
With this meson option it allows distributions to install systemd in a
stateless way as described in http://0pointer.net/blog/projects/stateless.html

For backwards compatibility the build would still install all
configuration files to /etc/systemd and /etc unless specified otherwise.

We use this option in NixOS.
@Mic92 Mic92 force-pushed the factory-config-dir branch from dd2fc25 to 92c4575 Compare November 1, 2020 15:17
@Mic92 Mic92 marked this pull request as ready for review November 1, 2020 15:21
@poettering
Copy link
Copy Markdown
Member

Not sure I grok this. These config files are redundant, we install them as commentary only, they generally contain not a single uncommented line. They exist only to help admins a bit when they want to edit them.

On a stateless system you really shouldn't bother with them. Copying them in has no benefit really. They are NOPs

@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Nov 4, 2020

Not sure I grok this. These config files are redundant, we install them as commentary only, they generally contain not a single uncommented line. They exist only to help admins a bit when they want to edit them.

On a stateless system you really shouldn't bother with them. Copying them in has no benefit really. They are NOPs

We do something like meson --prefix $out in our package build and than installation fails due to permission problems because it also installs stuff /etc with no way to overwrite it. It might be possible to workaround that by installing everything first to $DESTDIR before moving files to its final installation directory, but having support for this in the systemd build system is easier to maintain.

@poettering
Copy link
Copy Markdown
Member

hmm, what? Your build system doesn't use $DESTDIR? that's super strange.

@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Nov 5, 2020

Let's say we don't need DESTDIR in the normal case if packages stick to directories given by configure flags. Our package manager computes a unique installation directory per package based on the build plan and all dependencies (/nix/store/$SHA256-$PACKAGENAME), which makes DESTDIR unnecessary and it does not not allow files to be installed outside of this directory. It would be still possible to use DESTDIR on a temporary directory and than filter out files that are not installed to /nix/store/$SHA256-$PACKAGENAME. In this case we need to add some tests that make sure we don't miss important files on a systemd upgrades that by pass our specified installation directory, which is why I thought this variant is nicer in general.

@poettering
Copy link
Copy Markdown
Member

Not getting what that has to do with the configuration stuff and the factory dir though?

@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Nov 5, 2020

Not getting what that has to do with the configuration stuff and the factory dir though?

My intention was that distributions that want to provide these templates in etc would use systemd-tmpfiles to populate /etc on boot after a factory reset. Would it be an option more acceptable that skips installing these files to /etc?

@keszybz
Copy link
Copy Markdown
Member

keszybz commented Nov 11, 2020

Would it be an option more acceptable that skips installing these files to /etc?

It would be welcome. In particular, when developing on a "live" machine, installing any configuration files is problematic and I think many developers would find it useful to disable.

@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Nov 11, 2020

Ok. I am going to make a new PR for this.

@Mic92 Mic92 closed this Nov 11, 2020
Mic92 added a commit to Mic92/systemd that referenced this pull request Nov 12, 2020
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to systemd#17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
@Mic92
Copy link
Copy Markdown
Contributor Author

Mic92 commented Nov 12, 2020

Follow up: #17580

@Mic92 Mic92 deleted the factory-config-dir branch November 12, 2020 07:33
keszybz pushed a commit that referenced this pull request Nov 12, 2020
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to #17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
fbuihuu pushed a commit to openSUSE/systemd that referenced this pull request Nov 23, 2020
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to systemd/systemd#17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install

(cherry picked from commit d7aa78c)

[fbui: adjust context]
Yamakuzure pushed a commit to elogind/elogind that referenced this pull request Aug 10, 2021
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to systemd/systemd#17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants