lk2nd handling improvements
Currently pmbootstrap flasher flash_lk2nd
action is not completely thought through and is applied a bit inconsistently especially regarding how the correct lk2nd package from pmaports is installed (device package dependency, manually?)
CC @alikates @minlexx @ollieparanoid @Ultra-azu
Quotes from Matrix chat:
@z3ntu:
Regarding pmbootstrap flasher flash_lk2nd, how do you think it would be best for the correct lk2nd package to be installed when running this action? Currently a few device packages (8974, 8953) have a dependency on the lk2nd package which would mean if you have the device selected (and I guess pmbootstrap install'ed) then you can run flash_lk2nd and it has the correct image. However you really only need this at flashing time so it's not super fitting as dependency. Another way we discussed in the team meeting is adding a deviceinfo variable that contains the lk2nd package name so that flash_lk2nd just installs the package when needed but it doesn't have to be there at device runtime. What do you think? Or I'm open to any other way too really, just want to have some unified way to use this action
@minlexx
well, boot.img is also present at device runtime, but only needed during flashing (and kernel upgrades)? lk2nd.img can also be "flashed" during package upgrade, so maybe having it as package is not bad idea?
I don't think adding more and more deviceinfo variables is good..
@alikates
Like Alexey Min said, I also think it would be nice to have some install hook to have it flashed on package upgrade. One concern I have though is people smashing their current boot partition when trying to upgrade from their PCs, because now flash_lk2nd doesn't distinguish between the stock bootloader or lk2nd and flashing to the boot partition from lk2nd erases it (for upgrading lk2nd from itself you can run fastboot flash lk2nd lk2nd.img)
Regarding keeping lk2nd as a dependency, one way can be creating some kind of package that handles flashing and upgrading from the chroot. Then unify both lk2nd packages and have that new flashing package manage a compatibility list for the supported devices.
if it is used only at "pmbootstrap flasher" time and not after postmarketOS is installed, then I would handle it in a deviceinfo variable (just like we decide based on deviceinfo variables whether to install fastboot/heimdall etc. for flashing). If there will be code to upgrade it from the package after installing postmarketOS, it makes sense to add the dependency. We should also consider upgrading it from fwupd.
@z3ntu
This could be solved I think by a simple fastboot getvar something and check if it's lk2nd running, then use flash lk2nd, otherwise flash boot? One thing I didn't check is whether flash_lk2nd works without having done pmbootstrap install before, so just pmbootstrap init with the correct device and then pmbootstrap flasher flash_lk2nd, maybe not since the device package + dependencies will not be installed?