mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Gerz Burak LCPF-CH <Burak.Gerz@mt.com>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: barebox hooks in userspace
Date: Tue, 6 Dec 2022 08:18:23 +0100	[thread overview]
Message-ID: <20221206071823.GT29728@pengutronix.de> (raw)
In-Reply-To: <DB3PR0302MB8966A4A44D35F989B46B88B0E7189@DB3PR0302MB8966.eurprd03.prod.outlook.com>

On Mon, Dec 05, 2022 at 04:34:55PM +0000, Gerz Burak LCPF-CH wrote:
> Hi
> 
> I'm thinking of integrating something like a very simple "hook executer" in barebox - so that it can execute scripts which live in the rootfs.
> This would facilitate updating the barebox hooks by a simple RAUC rootfs update.
> Since I have an A/B setup, I do not know which partition will be booted by barebox beforehand - so currently I just execute all scripts twice
> 
> e.g, I have:
> 
> /defaultenv/defaultenv-2-base/init/zzbarebox-hook-exec
> @@ -0,0 +1,18 @@
> #!/bin/sh
> 
> #Execute all scripts found
> #TODO: Get next boot target from bootchooser and execute scripts located
> #      only on one target
> 
> SYSTEM0=${bootsource}${bootsource_instance}.0
> SYSTEM1=${bootsource}${bootsource_instance}.1
> 
> HOOKS_DIR=boot/barebox-hooks/
> 
> for i in /mnt/$SYSTEM0/$HOOKS_DIR/*; do
>         . $i
> done
> 
> for i in /mnt/$SYSTEM1/$HOOKS_DIR/*; do
>         . $i
> done
> 
> I see that bootchooser -i prints the next to be booted system:
> barebox@Juno phyCORE-i.MX6 ULL eMMC SOM:/ bootchooser -i
> Good targets (first will be booted next):
> system0
> ...
> 
> 
> My Question:
> Would it make sense to extend the bootchooser command, e.g. with
> bootchooser -n (get and store next boot target in a global variable),
> so that it can be used by the hush shell?

When do you want to execute the scripts? When you want to execute them
during booting then I think we'll find a better way for this. When you
want to execute them at barebox init time then the way you describe
sounds good to me.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2022-12-06  7:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 16:34 Gerz Burak LCPF-CH
2022-12-06  7:18 ` Sascha Hauer [this message]
2022-12-06 20:17   ` Trent Piepho

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=20221206071823.GT29728@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=Burak.Gerz@mt.com \
    --cc=barebox@lists.infradead.org \
    /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