Thanks for the quick reply
Stefano Babic wrote on Fri, Apr 02, 2021 at 12:08:28PM +0200:
> > - other handlers (sw->images so image, file or partition)
> > - postinstall scripts
> > - postupdatecmd if requested (swupdate-client -p or network update
> > only)
>
> Or swupdate started with -p or postinstall command defined in configuration
> file.
That doesn't always work in my tests.
With a postinstall command defined in configuration config (or -p
somescript, I had similar behaviour), this triggered the post script:
swupdate -d '-u
http://someurl/test.swu'
But this did not:
swupdate -i test.swu
I don't have the code open right now but I think this comes from the
fact that the precommand runs from stream extractor so always runs, but
postupdate runs from an explicit rpc request in either swupdate-client
(so swupdate-client -p test.swu works) or the downloader part of the
code, but not local install.
> > So first that means if I want to run before installed-directly images I
> > need to use either preupdatecmd or lua hooks;
>
> Use Lua Hooks. This was already discussed on the ML, and it is the safer
> place to do something before installing.
If lua hooks could call external lua scripts I wouldn't mind so much,
but managing code in sw-description is really not something I want to
do right now.
I also don't like the dissymmetry that would come from "pre" stuff being
in embed script while the post part would be separate; I'd rather have
things simple for others to pick up and having a single logic is better
for that.
Anyway, once I finally figured how the post command was triggered that
works for me.
> > while I can work with that
> > it's not strictly obvious and might be simpler if installed-directly
> > images were run in a separate step with other normal handlers.
>
> I do not understand this.
>
> If this is nmot strictly obvious, it could be better documented.
for example swupdate.rst states "- Support for preinstall scripts. They
run before updating the images" but if there are items with
installed-directly that is no longer true.
Looking further below there is a note about using embedded script:
---
- runs pre-install scripts, if any. Please note: if artifacts are
streamed, a preinstall script cannot be executed because it depends on
the order the artifact (including the script) are packed into the CPIO
archive. In this case, please use the "embedded-script" feature in
sw-description to execute functions before any installation takes place.
---
but the whole section is still before the extract/installed-directly
step in the list so it wasn't really clear to me what order would be
expected from pre-install scripts.
Maybe the two could be rephrased a bit, I don't know.
> > [ERROR] : SWUPDATE failed [0] ERROR : Found nothing to install
> > [ERROR] : SWUPDATE failed [0] ERROR : JSON File corrupted
> > [ERROR] : SWUPDATE failed [0] ERROR : no parser available to parse sw-description!
> > [ERROR] : SWUPDATE failed [0] ERROR : Compatible SW not found
> > [ERROR] : SWUPDATE failed [0] ERROR : Writing into SWUpdate IPC stream failed.
> > [ERROR] : SWUPDATE failed [0] ERROR : Channel operation returned error (23): 'Failed writing received data to disk/application'
> > [ERROR] : SWUPDATE failed [1] Image invalid or corrupted. Not installing...
> >
> >
> > But the file is perfectly valid so I don't think that's an error.
>
> This was a neverending discussion in the Mailing list and it is more a
> philosophical as technical discussion. If there is nothing to install, we
> can say that SWUpdate has successfully installed "nothing". This was also
> the old behavior. Anyway, if SWUpdate is successful, one can interprete this
> as a successful update and a toglle / reboot is triggered. The failure (even
> if it is not a strict failure) stops any attempt to toggle (if done
> externally) and reboot.
Ok, I wasn't aware of the past discussion as I subscribed just recently,
sorry for that. I think both point of views are valid here.
My problem is that error log level will be written in a rather small
syslog so if possible I don't want to repeat these error lines everytime
we check if there was a new update.
I guess I can wrap the swupdate execution around a separate poll that
checks for the http date but I'm not sure how reliable that would really
be compared to just reading the sw-description part of the cpio and
checking versions there... So I'll be more inclined towards adding an
empty shell script just to make the update non-empty.
Well, I'll think about it a bit more.
> > (speaking of error messages I see everytime, I also get an error on ubi
> > partition scan:
> > [ERROR] : SWUPDATE failed [0] ERROR : cannot attach mtd0 - maybe not a NAND or raw device
> >
> > since nothing in the sw-description requires it it's a bit annoying as
> > well, but I'll just remove CONFIG_UBIATTACH from our builds as a
> > workaround)
>
> No, you have to add you own UBIWHITELIST and mtd0 should not be part of it.
> This is normal when UBI is used, and not all MTD devices must be scanned.
Hm, these are still config options and I won't use the handler at all,
so it's probably best to just disable. In general security practice
would be to disable everything we don't use anyway, I just had created a
swupdate package with all handlers enabled to test things (and
potentially package it for alpine linux like debian did), but I think
it's best if people compile something for their own needs ultimately.
Thanks,
--
Dominique