[Buildroot] [PATCH 1/6 v3] package/skeleton-systemd: move /var factory tmpfiles out of /etc

Norbert Lange nolange79 at gmail.com
Mon Nov 7 13:32:27 UTC 2022


Am So., 6. Nov. 2022 um 16:58 Uhr schrieb Yann E. MORIN
<yann.morin.1998 at free.fr>:
>
> Norbert, All,
>
> On 2022-11-06 16:40 +0100, Norbert Lange spake thusly:
> > Am Di., 18. Okt. 2022 um 21:43 Uhr schrieb <yann.morin at orange.com>:
> [--SNIP--]
> > > diff --git a/package/skeleton-init-systemd/skeleton-init-systemd.mk b/package/skeleton-init-systemd/skeleton-init-systemd.mk
> > > index 795a171809..7b66732ef4 100644
> > > --- a/package/skeleton-init-systemd/skeleton-init-systemd.mk
> > > +++ b/package/skeleton-init-systemd/skeleton-init-systemd.mk
> > > @@ -29,7 +29,6 @@ else
> > >  # a real (but empty) directory, and the "factory files" will be copied
> > >  # back there by the tmpfiles.d mechanism.
> > >  define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
> > > -       mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
> > >         echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
> > >         echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
> > >  endef
> > > @@ -38,6 +37,7 @@ define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
> > >         rm -rf $(TARGET_DIR)/usr/share/factory/var
> > >         mv $(TARGET_DIR)/var $(TARGET_DIR)/usr/share/factory/var
> > >         mkdir -p $(TARGET_DIR)/var
> > > +       mkdir -p $(TARGET_DIR)/usr/lib/tmpfiles.d
> > >         for i in $(TARGET_DIR)/usr/share/factory/var/* \
> > >                  $(TARGET_DIR)/usr/share/factory/var/lib/* \
> > >                  $(TARGET_DIR)/usr/share/factory/var/lib/systemd/*; do \
> > > @@ -51,7 +51,7 @@ define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
> > >                         printf "C! %s - - - -\n" "$${j}" \
> > >                         || exit 1; \
> > >                 fi; \
> >
> > From tmpfiles.d docs: "C ... Recursively copy a file or directory, if
> > the destination files or directories do not
> >   exist yet or the destination directory is empty. Note that this
> > command will not descend into subdirectories
> >   if the destination directory already exists and is not empty.
> > Instead, the entire copy operation is skipped."
> >
> > So all the drama could be just replaced with "C! /var - - - -\n" imho.
> >
> > (non standard permissions/owner are probably gone either way)
>
> I do remember that I had to explicitly register individual entries
> rather than the directory alone, as that did not work. That was 5+
> years ago (commit 26085bbbd500), and I did not write it down in the
> commit log...
>
> However, it looks like we hit this issue, as hinted in commit
> 7e811708f31c (package/skeleton-init-systemd: work around for /var/lib
> not populating), which states:
>
>     It turns out /var/lib will exist, because some part of systemd creates
>     /var/lib/systemd/catalog on boot before tmpfiles runs.
>
> So, we do have a chicken-n-eggs issue, that registering /var as a whole
> does not work.

I guess thats the logging service, systemd-tmpfiles-setup.service already
requires some stuff running and other stuff is able to run and freely access
/var aswell.

The clean way would be to be done with "migrating" /var before local-fs.target
is reached.

Regards, Norbert



More information about the buildroot mailing list