Hello,
'Federico Sauter' via swupdate wrote on Thu, Apr 15, 2021 at 04:17:42AM -0700:
> I would like to inquire whether this is the intended behavior. If so, what
> is the rationale behind it, as this makes preinstall scripts less useful at
> least for my use case.
Unfortunately yes (I'm in the same case), this is a limitation of the
streaming interface used for installed-directly.
I just had brought it up to the list so if you have a bit of time could
you please read (and comment!) on:
- a patch I sent earlier this week to try to clarify docs about it[1]
[1]
https://groups.google.com/g/swupdate/c/pnuKcKd0YaI/m/5KOarUDjBwAJ
- and the discussion as a whole that prompted it[2]; although it went a
bit off topic at times.
[2]
https://groups.google.com/g/swupdate/c/Ih6Co_4CCq8/m/FmhCRWZtCQAJ
Long story short, you only have two ways of executing code before
installed-directly images:
- the preupdatecmd that has to reside on the device before the install
starts
- embedded lua code (and its hooks) that is part of sw-description and
is guaranteed to be downloaded first, so present before other entries in
the cpio archive, and thus executed first.
It's technically possible to thus embed a base64 tar in the
sw-decription and execute scripts from it from lua but lua process
handling is suboptimal so after quite some testing while I got such a
hack to work I wouldn't recommend it (lua5.1 io.popen doesn't even have
a way of checking return code!! and even newer versions which do can't
handle stdout/stderr nicely)
There's a third way I haven't tried yet which would be to have the
preinstall script handle installed-directly, and just have it run your
pre-script before other installed-directly images by placing the scripts
earlier in the image.
That's the direction I'm looking at right now, but I haven't started
yet, and I'm not sure Stefano would be interested in such a feature so
would probably want to discuss first.
--
Dominique