* [meta-oe][PATCH] volatile-binds: Calculate the name of the /var/lib service
@ 2023-08-27 16:49 Stéphane Veyret
2023-08-27 21:22 ` [OE-core] " Peter Kjellerstedt
0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Veyret @ 2023-08-27 16:49 UTC (permalink / raw)
To: openembedded-core; +Cc: Stéphane Veyret
By default, /var/lib is bind mounted on /var/volatile/lib. If this is
the case, the recipe adds conditions on systemd-random-seed in the
service file mounting it. But as the VOLATILE_BINDS may be modified,
/var/lib may be mounted elsewhere, for example in /persistent/var/lib.
In this case, the conditions are not set because the service file name
does not match expected one.
This patch automatically records the name of the service mounting
/var/lib, if any, in order to set the condition in the appropriate file.
Signed-off-by: Stéphane Veyret <sveyret@gmail.com>
---
meta/recipes-core/volatile-binds/volatile-binds.bb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/meta/recipes-core/volatile-binds/volatile-binds.bb b/meta/recipes-core/volatile-binds/volatile-binds.bb
index 3fefa9abde..7a3f53c3ed 100644
--- a/meta/recipes-core/volatile-binds/volatile-binds.bb
+++ b/meta/recipes-core/volatile-binds/volatile-binds.bb
@@ -48,6 +48,7 @@ do_compile () {
servicefile="${spec#/}"
servicefile="$(echo "$servicefile" | tr / -).service"
+ [ "${mountpoint}" = /var/lib ] && var_lib_servicefile=$servicefile
sed -e "s#@what@#$spec#g; s#@where@#$mountpoint#g" \
-e "s#@whatparent@#${spec%/*}#g; s#@whereparent@#${mountpoint%/*}#g" \
-e "s#@avoid_overlayfs@#${@d.getVar('AVOID_OVERLAYFS')}#g" \
@@ -56,12 +57,12 @@ do_compile () {
${@d.getVar('VOLATILE_BINDS').replace("\\n", "\n")}
END
- if [ -e var-volatile-lib.service ]; then
+ if [ -n ${var_lib_servicefile} ] && [ -e ${var_lib_servicefile} ]; then
# As the seed is stored under /var/lib, ensure that this service runs
# after the volatile /var/lib is mounted.
sed -i -e "/^Before=/s/\$/ systemd-random-seed.service/" \
-e "/^WantedBy=/s/\$/ systemd-random-seed.service/" \
- var-volatile-lib.service
+ ${var_lib_servicefile}
fi
}
do_compile[dirs] = "${WORKDIR}"
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [OE-core] [meta-oe][PATCH] volatile-binds: Calculate the name of the /var/lib service
2023-08-27 16:49 [meta-oe][PATCH] volatile-binds: Calculate the name of the /var/lib service Stéphane Veyret
@ 2023-08-27 21:22 ` Peter Kjellerstedt
2023-08-28 17:55 ` Stéphane Veyret
0 siblings, 1 reply; 3+ messages in thread
From: Peter Kjellerstedt @ 2023-08-27 21:22 UTC (permalink / raw)
To: Stéphane Veyret, openembedded-core@lists.openembedded.org
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Stéphane Veyret
> Sent: den 27 augusti 2023 18:49
> To: openembedded-core@lists.openembedded.org
> Cc: Stéphane Veyret <sveyret@gmail.com>
> Subject: [OE-core] [meta-oe][PATCH] volatile-binds: Calculate the name of the /var/lib service
>
> By default, /var/lib is bind mounted on /var/volatile/lib. If this is
> the case, the recipe adds conditions on systemd-random-seed in the
> service file mounting it. But as the VOLATILE_BINDS may be modified,
> /var/lib may be mounted elsewhere, for example in /persistent/var/lib.
> In this case, the conditions are not set because the service file name
> does not match expected one.
> This patch automatically records the name of the service mounting
> /var/lib, if any, in order to set the condition in the appropriate file.
>
> Signed-off-by: Stéphane Veyret <sveyret@gmail.com>
> ---
> meta/recipes-core/volatile-binds/volatile-binds.bb | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/meta/recipes-core/volatile-binds/volatile-binds.bb b/meta/recipes-core/volatile-binds/volatile-binds.bb
> index 3fefa9abde..7a3f53c3ed 100644
> --- a/meta/recipes-core/volatile-binds/volatile-binds.bb
> +++ b/meta/recipes-core/volatile-binds/volatile-binds.bb
> @@ -48,6 +48,7 @@ do_compile () {
>
> servicefile="${spec#/}"
> servicefile="$(echo "$servicefile" | tr / -).service"
Those two line can be simplified to:
servicefile="$(echo ${spec#/} | tr / -).service"
> + [ "${mountpoint}" = /var/lib ] && var_lib_servicefile=$servicefile
You should use "${localstatedir}/lib" instead of "/var/lib". Actually
${localstatedir} should be used instead of /var throughout the recipe).
It is also a good idea to avoid && in constructs like the one above
due to how shell evaluates and sets the exit status. Also avoid ${...}
for shell variables in bitbake recipes where possible as they will
otherwise be included in the task hash. All taken together:
[ "$mountpoint" != ${localstatedir}/lib ] || var_lib_servicefile=$servicefile
> sed -e "s#@what@#$spec#g; s#@where@#$mountpoint#g" \
> -e "s#@whatparent@#${spec%/*}#g; s#@whereparent@#${mountpoint%/*}#g" \
> -e "s#@avoid_overlayfs@#${@d.getVar('AVOID_OVERLAYFS')}#g" \
> @@ -56,12 +57,12 @@ do_compile () {
> ${@d.getVar('VOLATILE_BINDS').replace("\\n", "\n")}
> END
>
> - if [ -e var-volatile-lib.service ]; then
> + if [ -n ${var_lib_servicefile} ] && [ -e ${var_lib_servicefile} ]; then
Variables that may be empty shall always be quoted. And when they are,
you do not need to test that they have a value before using the -e test:
if [ -e "$var_lib_servicefile" ]; then
> # As the seed is stored under /var/lib, ensure that this service runs
> # after the volatile /var/lib is mounted.
> sed -i -e "/^Before=/s/\$/ systemd-random-seed.service/" \
> -e "/^WantedBy=/s/\$/ systemd-random-seed.service/" \
> - var-volatile-lib.service
> + ${var_lib_servicefile}
Here too:
"$var_lib_servicefile"
> fi
> }
> do_compile[dirs] = "${WORKDIR}"
> --
> 2.41.0
//Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-28 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-27 16:49 [meta-oe][PATCH] volatile-binds: Calculate the name of the /var/lib service Stéphane Veyret
2023-08-27 21:22 ` [OE-core] " Peter Kjellerstedt
2023-08-28 17:55 ` Stéphane Veyret
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox