Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: James Knight <james.d.knight@live.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 2/2] package/skeleton-init-systemd: flexible reinstalls
Date: Sun, 1 Oct 2023 18:05:59 +0200	[thread overview]
Message-ID: <20231001160559.GM2579@scaer> (raw)
In-Reply-To: <SN4P221MB06825C5F564A59CA4DE16C09A0729@SN4P221MB0682.NAMP221.PROD.OUTLOOK.COM>

James, All,

On 2023-05-05 00:30 -0400, James Knight spake thusly:
> The following commit tweaks the `skeleton-init-systemd` package to
> gracefully handle if a user invokes a reinstall for the package (e.g.
> when performing development tweaks to the initial skeleton).
> 
> Signed-off-by: James Knight <james.d.knight@live.com>
> ---
> Only a suggestion; feel free to drop.

I've spent a bit of time on this, and was about to apply...

However, there are a few "issues" I noticed with it, mostly that
/etc/fstab should not be used with systemd, but mount units should be
used, and so /etc/fstab should only contain this one line, so it does
not make much sense to have it "reinstallable".

Also, with BR2_PER_PACKAGE_DIRECTORIES=y, when the "final" target is
aggregated there is no guarantee that the modified file gets used in
this case. Indeed, assuming the following dependency chain (simplified
for the sake of the explanation):

    S <-- A <-- target/
     `<-- Z <--'

I.e. A depends on S (the skeleton), Z also depends on S, and the target
is aggreagated from A and Z, and S. When you first build, Z inherits the
fstab from S, and because it sorts after S, that the one that gets used.

If you rebuild S, Z will not get rebuild, so will not get the new fstab.
And thus when you assemble target after the rebuild, you still get the
old file from Z, not the new one from S.

(there are more complex cases, the above is just a trivial example).

Finally, the only guarantee Buildroot really offers is fof a full build
from scratch.

And last, reinstalling a skeleton package is very rare, so fixing it is
not worth the effort, considering all the above.

So I just decided to drop it.

Regards,
Yann E. MORIN.

> ---
>  .../skeleton-init-systemd.mk                   | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/package/skeleton-init-systemd/skeleton-init-systemd.mk b/package/skeleton-init-systemd/skeleton-init-systemd.mk
> index 4076821c0c0429cf90681f4b16be114c44bde282..18ae91f2eea30277805ee82791c62d53f24dca1e 100644
> --- a/package/skeleton-init-systemd/skeleton-init-systemd.mk
> +++ b/package/skeleton-init-systemd/skeleton-init-systemd.mk
> @@ -18,13 +18,23 @@ SKELETON_INIT_SYSTEMD_PROVIDES = skeleton
>  ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
>  
>  define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
> -	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
> +	if ! grep -q "/dev/root" $(TARGET_DIR)/etc/fstab; then \
> +		echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab; \
> +	else \
> +		sed -i "s|/dev/root.*|/dev/root / auto rw 0 1|g" \
> +			$(TARGET_DIR)/etc/fstab; \
> +	fi
>  endef
>  
>  else
>  
>  define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
> -	echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
> +	if ! grep -q "/dev/root" $(TARGET_DIR)/etc/fstab; then \
> +		echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab; \
> +	else \
> +		sed -i "s|/dev/root.*|/dev/root / auto ro 0 1|g" \
> +			$(TARGET_DIR)/etc/fstab; \
> +	fi
>  endef
>  
>  # On a R/O rootfs, /var is a tmpfs filesystem. So, at build time, we
> @@ -78,9 +88,9 @@ define SKELETON_INIT_SYSTEMD_INSTALL_TARGET_CMDS
>  	mkdir -p $(TARGET_DIR)/home
>  	mkdir -p $(TARGET_DIR)/srv
>  	mkdir -p $(TARGET_DIR)/var
> -	ln -s ../run $(TARGET_DIR)/var/run
> +	ln -sf ../run $(TARGET_DIR)/var/run
>  	# prevent install scripts to create var/lock as directory
> -	ln -s ../run/lock $(TARGET_DIR)/var/lock
> +	ln -sf ../run/lock $(TARGET_DIR)/var/lock
>  	install -D -m644 $(SKELETON_INIT_SYSTEMD_PKGDIR)/legacy.conf $(TARGET_DIR)/usr/lib/tmpfiles.d/legacy.conf
>  	$(SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW)
>  endef
> -- 
> 2.40.1.windows.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2023-10-01 16:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230505043002.1956-1-james.d.knight@live.com>
2023-05-05  4:30 ` [Buildroot] [PATCH 2/2] package/skeleton-init-systemd: flexible reinstalls James Knight
2023-10-01 16:05   ` Yann E. MORIN [this message]
2023-10-05 20:07     ` Arnout Vandecappelle via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231001160559.GM2579@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=james.d.knight@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox