diff mbox

[16/20] system: separate sysv and systemd parts of the skeleton

Message ID f797589346d85a6ebba86bb418d6b818051d0da7.1500398733.git.yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN July 18, 2017, 5:25 p.m. UTC
systems does not like that the content of /var be symlinks to /tmp,
especially journald that starts before /tmp is mounted, and thus the
journal files are hidden from view, which causes wuite a bit if fuss...

Instead, move the current /var to a sysv-only skeleton.

systemd at install time will create the /var content it needs, so we
just create an empty /var for systemd. Yet, systemd really requires a
bunch of extra directories to exist, so we also create those.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>

---
Note: /home and /srv will be created at runtime if missing, but it is
better to create them right now, to simplify supporting systemd on a
RO filesystem in the (near) future.
---
 package/skeleton-systemd/skeleton-systemd.mk              | 7 +++++++
 package/skeleton-sysv/skeleton-sysv.mk                    | 4 ++++
 {system => package/skeleton-sysv}/skeleton/dev/log        | 0
 {system => package/skeleton-sysv}/skeleton/dev/pts/.empty | 0
 {system => package/skeleton-sysv}/skeleton/dev/shm/.empty | 0
 {system => package/skeleton-sysv}/skeleton/etc/fstab      | 0
 {system => package/skeleton-sysv}/skeleton/var/cache      | 0
 {system => package/skeleton-sysv}/skeleton/var/lib/misc   | 0
 {system => package/skeleton-sysv}/skeleton/var/lock       | 0
 {system => package/skeleton-sysv}/skeleton/var/log        | 0
 {system => package/skeleton-sysv}/skeleton/var/run        | 0
 {system => package/skeleton-sysv}/skeleton/var/spool      | 0
 {system => package/skeleton-sysv}/skeleton/var/tmp        | 0
 system/skeleton/dev/.empty                                | 0
 14 files changed, 11 insertions(+)
 rename {system => package/skeleton-sysv}/skeleton/dev/log (100%)
 rename {system => package/skeleton-sysv}/skeleton/dev/pts/.empty (100%)
 rename {system => package/skeleton-sysv}/skeleton/dev/shm/.empty (100%)
 rename {system => package/skeleton-sysv}/skeleton/etc/fstab (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/cache (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/lib/misc (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/lock (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/log (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/run (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/spool (100%)
 rename {system => package/skeleton-sysv}/skeleton/var/tmp (100%)
 create mode 100644 system/skeleton/dev/.empty

diff --git a/system/skeleton/dev/.empty b/system/skeleton/dev/.empty
new file mode 100644
index 0000000000..e69de29bb2

Comments

Arnout Vandecappelle July 23, 2017, 12:08 a.m. UTC | #1
On 18-07-17 19:25, Yann E. MORIN wrote:
> systems does not like that the content of /var be symlinks to /tmp,
  systemd

> especially journald that starts before /tmp is mounted, and thus the
> journal files are hidden from view, which causes wuite a bit if fuss...
                                                   quite
> 
> Instead, move the current /var to a sysv-only skeleton.
> 
> systemd at install time will create the /var content it needs, so we

 I guess systemd will also create a tmpfs on /var?

> just create an empty /var for systemd. Yet, systemd really requires a
> bunch of extra directories to exist, so we also create those.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>

 Commit message needs to be improved (see also below), but with that
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

> 
> ---
> Note: /home and /srv will be created at runtime if missing, but it is
> better to create them right now, to simplify supporting systemd on a
> RO filesystem in the (near) future.
> ---
>  package/skeleton-systemd/skeleton-systemd.mk              | 7 +++++++
>  package/skeleton-sysv/skeleton-sysv.mk                    | 4 ++++
>  {system => package/skeleton-sysv}/skeleton/dev/log        | 0
>  {system => package/skeleton-sysv}/skeleton/dev/pts/.empty | 0
>  {system => package/skeleton-sysv}/skeleton/dev/shm/.empty | 0

 I guess indeed the /dev stuff is not needed for systemd because there is anyway
a devtmpfs mounted over it. Which makes me wonder: shouldn't these be moved to
the device-table? Only the static devices case needs these to be present... Of
course, such a change is not for this patch, but I'd say that we can just leave
this /dev stuff in the common part - systemd has no less use of it than sysv.

>  {system => package/skeleton-sysv}/skeleton/etc/fstab      | 0

 Why? systemd does use fstab, so it seems weird not to have an fstab in the
systemd case. Well, I guess our skeleton fstab doesn't contain anything relevant
for systemd because all of that is handled already by tmpfiles.
But the commit log should at least explain this.


 Regards,
 Arnout


[snip]
Arnout Vandecappelle July 23, 2017, 12:13 a.m. UTC | #2
On 23-07-17 02:08, Arnout Vandecappelle wrote:
> 
> On 18-07-17 19:25, Yann E. MORIN wrote:
>> systems does not like that the content of /var be symlinks to /tmp,
>   systemd
> 
>> especially journald that starts before /tmp is mounted, and thus the
>> journal files are hidden from view, which causes wuite a bit if fuss...
>                                                    quite
>> Instead, move the current /var to a sysv-only skeleton.
>>
>> systemd at install time will create the /var content it needs, so we
>  I guess systemd will also create a tmpfs on /var?

 Seems the following sentence got dropped:

What happens when a package installs something in /var?


 Regards,
 Arnout
Yann E. MORIN July 23, 2017, 10:24 a.m. UTC | #3
Arnout, All,

On 2017-07-23 02:08 +0200, Arnout Vandecappelle spake thusly:
> On 18-07-17 19:25, Yann E. MORIN wrote:
> > systems does not like that the content of /var be symlinks to /tmp,
>   systemd
> 
> > especially journald that starts before /tmp is mounted, and thus the
> > journal files are hidden from view, which causes wuite a bit if fuss...
>                                                    quite
> > 
> > Instead, move the current /var to a sysv-only skeleton.
> > 
> > systemd at install time will create the /var content it needs, so we
> 
>  I guess systemd will also create a tmpfs on /var?

No it does not. But so far we do not support systemd on a read-only
root filesystem anyway (see the depends on for systemd).

In a later patch, we add support for a read-only rootfs, and then we add
an explicit tmpfs mont on /var, which systemd does not do on its own,
which is the reason for 886f3109bc (system: systemd only really supports
a R/W rootfs)

> > just create an empty /var for systemd. Yet, systemd really requires a
> > bunch of extra directories to exist, so we also create those.
> > 
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
> 
>  Commit message needs to be improved (see also below), but with that
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> 
> > 
> > ---
> > Note: /home and /srv will be created at runtime if missing, but it is
> > better to create them right now, to simplify supporting systemd on a
> > RO filesystem in the (near) future.
> > ---
> >  package/skeleton-systemd/skeleton-systemd.mk              | 7 +++++++
> >  package/skeleton-sysv/skeleton-sysv.mk                    | 4 ++++
> >  {system => package/skeleton-sysv}/skeleton/dev/log        | 0
> >  {system => package/skeleton-sysv}/skeleton/dev/pts/.empty | 0
> >  {system => package/skeleton-sysv}/skeleton/dev/shm/.empty | 0
> 
>  I guess indeed the /dev stuff is not needed for systemd because there is anyway
> a devtmpfs mounted over it. Which makes me wonder: shouldn't these be moved to
> the device-table? Only the static devices case needs these to be present... Of
> course, such a change is not for this patch, but I'd say that we can just leave
> this /dev stuff in the common part - systemd has no less use of it than sysv.
> 
> >  {system => package/skeleton-sysv}/skeleton/etc/fstab      | 0
> 
>  Why? systemd does use fstab, so it seems weird not to have an fstab in the
> systemd case.

We do have one, it is created in the skeleton-systemd.mk file:

    define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
            mkdir -p $(TARGET_DIR)/home
            mkdir -p $(TARGET_DIR)/srv
            mkdir -p $(TARGET_DIR)/var
            echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
    endef

> Well, I guess our skeleton fstab doesn't contain anything relevant
> for systemd because all of that is handled already by tmpfiles.

Exactly.

> But the commit log should at least explain this.

Like so, maybe?

    For systemd, we only ever need an entry for /, because all the rest
    is totally irrelevant for systemd (it automatically mounts what it
    needs where it needs it).

Regards,
Yann E. MORIN.
Yann E. MORIN July 23, 2017, 10:31 a.m. UTC | #4
On 2017-07-23 02:13 +0200, Arnout Vandecappelle spake thusly:
> 
> 
> On 23-07-17 02:08, Arnout Vandecappelle wrote:
> > 
> > On 18-07-17 19:25, Yann E. MORIN wrote:
> >> systems does not like that the content of /var be symlinks to /tmp,
> >   systemd
> > 
> >> especially journald that starts before /tmp is mounted, and thus the
> >> journal files are hidden from view, which causes wuite a bit if fuss...
> >                                                    quite
> >> Instead, move the current /var to a sysv-only skeleton.
> >>
> >> systemd at install time will create the /var content it needs, so we
> >  I guess systemd will also create a tmpfs on /var?
> 
>  Seems the following sentence got dropped:
> 
> What happens when a package installs something in /var?

Since we do not (yet) support a read-only root filesystem for systemd,
and that systemd does _not_ automatically mount anything on /var, we
always have /var that is writable, and thus whatever a package installs
in /var at build time is in /var at runtime.

Now, see the followup patches, that add support for a read-only rootfs
with systemd:

    fs: add pre- and post-command hooks
    system: make systemd work on a read-only rootfs

Even though the code for each is relatively simple, there is a *lot* of
explanations in there about /var handling on a read-only rootfs with
systemd.

But again, so far, we only ever supported systemd on a read-write rootfs.

Regards,
Yann E. MORIN.
Arnout Vandecappelle July 23, 2017, 1:32 p.m. UTC | #5
On 23-07-17 12:24, Yann E. MORIN wrote:
> Arnout, All,
> 
> On 2017-07-23 02:08 +0200, Arnout Vandecappelle spake thusly:

[snip]
>> But the commit log should at least explain this.
> 
> Like so, maybe?
> 
>     For systemd, we only ever need an entry for /, because all the rest
>     is totally irrelevant for systemd (it automatically mounts what it
>     needs where it needs it).

 But... skeleton-common installs a lot more than just /, no? It installs
/etc/stuff, and a bunch of top-level directories...

 Regards,
 Arnout
Arnout Vandecappelle July 23, 2017, 1:39 p.m. UTC | #6
On 23-07-17 15:32, Arnout Vandecappelle wrote:
> 
> 
> On 23-07-17 12:24, Yann E. MORIN wrote:
>> Arnout, All,
>>
>> On 2017-07-23 02:08 +0200, Arnout Vandecappelle spake thusly:
> 
> [snip]
>>> But the commit log should at least explain this.
>>
>> Like so, maybe?
>>
>>     For systemd, we only ever need an entry for /, because all the rest
>>     is totally irrelevant for systemd (it automatically mounts what it
>>     needs where it needs it).
> 
>  But... skeleton-common installs a lot more than just /, no? It installs
> /etc/stuff, and a bunch of top-level directories...

 Sorry, I missed that this was about fstab, I thought it was about the skeleton
itself.

 fstab is not yet mentioned at all in the commit message, so this should be
rephrased a little. But content-wise this is indeed what I wanted.

 Regards,
 Arnout
Yann E. MORIN July 23, 2017, 1:41 p.m. UTC | #7
Arnout, All,

On 2017-07-23 15:39 +0200, Arnout Vandecappelle spake thusly:
> On 23-07-17 15:32, Arnout Vandecappelle wrote:
> > On 23-07-17 12:24, Yann E. MORIN wrote:
> >> Arnout, All,
> >>
> >> On 2017-07-23 02:08 +0200, Arnout Vandecappelle spake thusly:
> > 
> > [snip]
> >>> But the commit log should at least explain this.
> >>
> >> Like so, maybe?
> >>
> >>     For systemd, we only ever need an entry for /, because all the rest
> >>     is totally irrelevant for systemd (it automatically mounts what it
> >>     needs where it needs it).
> > 
> >  But... skeleton-common installs a lot more than just /, no? It installs
> > /etc/stuff, and a bunch of top-level directories...
> 
>  Sorry, I missed that this was about fstab, I thought it was about the skeleton
> itself.
> 
>  fstab is not yet mentioned at all in the commit message, so this should be
> rephrased a little. But content-wise this is indeed what I wanted.

Ok, good. Thanks!

Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/package/skeleton-systemd/skeleton-systemd.mk b/package/skeleton-systemd/skeleton-systemd.mk
index cec6359007..384715e1c9 100644
--- a/package/skeleton-systemd/skeleton-systemd.mk
+++ b/package/skeleton-systemd/skeleton-systemd.mk
@@ -15,4 +15,11 @@  SKELETON_SYSTEMD_DEPENDENCIES = skeleton-common
 
 SKELETON_SYSTEMD_PROVIDES = skeleton
 
+define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
+	mkdir -p $(TARGET_DIR)/home
+	mkdir -p $(TARGET_DIR)/srv
+	mkdir -p $(TARGET_DIR)/var
+	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+endef
+
 $(eval $(generic-package))
diff --git a/package/skeleton-sysv/skeleton-sysv.mk b/package/skeleton-sysv/skeleton-sysv.mk
index b0c2b6bac1..b5fa396ac2 100644
--- a/package/skeleton-sysv/skeleton-sysv.mk
+++ b/package/skeleton-sysv/skeleton-sysv.mk
@@ -15,4 +15,8 @@  SKELETON_SYSV_DEPENDENCIES = skeleton-common
 
 SKELETON_SYSV_PROVIDES = skeleton
 
+define SKELETON_SYSV_INSTALL_TARGET_CMDS
+	$(call SYSTEM_RSYNC,$(SKELETON_SYSV_PKGDIR)/skeleton,$(TARGET_DIR))
+endef
+
 $(eval $(generic-package))
diff --git a/system/skeleton/dev/log b/package/skeleton-sysv/skeleton/dev/log
similarity index 100%
rename from system/skeleton/dev/log
rename to package/skeleton-sysv/skeleton/dev/log
diff --git a/system/skeleton/dev/pts/.empty b/package/skeleton-sysv/skeleton/dev/pts/.empty
similarity index 100%
rename from system/skeleton/dev/pts/.empty
rename to package/skeleton-sysv/skeleton/dev/pts/.empty
diff --git a/system/skeleton/dev/shm/.empty b/package/skeleton-sysv/skeleton/dev/shm/.empty
similarity index 100%
rename from system/skeleton/dev/shm/.empty
rename to package/skeleton-sysv/skeleton/dev/shm/.empty
diff --git a/system/skeleton/etc/fstab b/package/skeleton-sysv/skeleton/etc/fstab
similarity index 100%
rename from system/skeleton/etc/fstab
rename to package/skeleton-sysv/skeleton/etc/fstab
diff --git a/system/skeleton/var/cache b/package/skeleton-sysv/skeleton/var/cache
similarity index 100%
rename from system/skeleton/var/cache
rename to package/skeleton-sysv/skeleton/var/cache
diff --git a/system/skeleton/var/lib/misc b/package/skeleton-sysv/skeleton/var/lib/misc
similarity index 100%
rename from system/skeleton/var/lib/misc
rename to package/skeleton-sysv/skeleton/var/lib/misc
diff --git a/system/skeleton/var/lock b/package/skeleton-sysv/skeleton/var/lock
similarity index 100%
rename from system/skeleton/var/lock
rename to package/skeleton-sysv/skeleton/var/lock
diff --git a/system/skeleton/var/log b/package/skeleton-sysv/skeleton/var/log
similarity index 100%
rename from system/skeleton/var/log
rename to package/skeleton-sysv/skeleton/var/log
diff --git a/system/skeleton/var/run b/package/skeleton-sysv/skeleton/var/run
similarity index 100%
rename from system/skeleton/var/run
rename to package/skeleton-sysv/skeleton/var/run
diff --git a/system/skeleton/var/spool b/package/skeleton-sysv/skeleton/var/spool
similarity index 100%
rename from system/skeleton/var/spool
rename to package/skeleton-sysv/skeleton/var/spool
diff --git a/system/skeleton/var/tmp b/package/skeleton-sysv/skeleton/var/tmp
similarity index 100%
rename from system/skeleton/var/tmp
rename to package/skeleton-sysv/skeleton/var/tmp