kwindrem / SetupHelper

Helper functions to simplify writing setup scripts that modify VenusOs functionality. The package includes automatic reinstallation of the package after a VenusOs update.
153 stars 18 forks source link

Package update reboot #79

Closed drtinaz closed 1 month ago

drtinaz commented 1 month ago

Not sure if this is an issue or my failure to understand. When pushing a new release for a package, what is the sequence of events that takes place in setuphelper? Reason I ask is if I push a new release that has an update to the driver in the package, a reboot is not occuring. I have to manually reboot, or stop/restart the driver. The package is leveraging the auto install files resources. Should this occur automatically, or do I need to add a reboot required to the setup script?

kwindrem commented 1 month ago

When you publish a new release to GitHub, the version for the selected branch will EVENTUALLY change. In some cases, I've seen it take 30 minutes for PackageManager to see the change! I believe this has to do with caching in the internet somewhere.

With automatic downloads enabled, PackageManager compares the GitHub version differs with the "Stored "version. That's what is in the package's version file. If they differ, PackageManager begins a download.

After the download is complete and if auto install is enabled, PackageManager compares the Stored version with the Installed version. If the branch specifies a specific version (starts with v), then an install is started. If the branch is any thing else (eg 'latest', 'main', 'beta'), the Stored version must be newer than the installed one. If so, an install is started.

PackageManager schedules a reboot or GUI restart based on what the setup script returns. Automatically, reboots are scheduled if a Raspberry PI overlay, config.txt, anything in /etc/udev/rules.d or /etc/venus/gpio_list are changed.

For other changes that require a reboot, the setup script must set rebootNeeded=true.

If there other areas of the system that I can check for automatic reboots, let me know and I'll add it to updateRestartFlags() in CommonResources.

drtinaz commented 1 month ago

I would think any package that installs/runs a service should at the very least restart the service when the package updates?

kwindrem commented 1 month ago

Yes, that is true. It does.

However, there is no way for the service to tell PackageManager a reboot is needed. Services can generally just be restarted svc -t /service/< service name >

It would be possible to include a REBOOT flag file in the service directory that the setup script could then look for and deal with the reboot in the same way reboots for files are handled.

drtinaz commented 1 month ago

Can I just add svc -t /service/< service name > before the end script? Or would reboot required be better? What would you suggest?

kwindrem commented 1 month ago

ServiceResources should already be restarting the service if is is running. You should see a log entry if this happens.

A newly installed service should start on its own and I do not attempt to start it.

If this is not happening, let me know and I'll check my code

I would only request a reboot if there is something that is only checked or used in the boot process (like udev rules or gpio_list or config.txt changes )

drtinaz commented 1 month ago

I was pushing updates to the driver in the package. The package updates automatically but I have been rebooting to start the driver with the changes.

kwindrem commented 1 month ago

PackageManager does not check modification dates so won't see your changes.

If you run the package setup script it will restart your driver service:

drtinaz commented 1 month ago

I was pushing releases thru GitHub.

kwindrem commented 1 month ago

Should work if you have auto downloads and auto installs turned on AND you change the version number.

If the version number in the branch/tag at GitHub doesn't change then PackageManager won't know there's anything to do.

You can trick PackageManager to download by removing the version file in the package directory.

You can trick PackagerManager to install by removing /etc/venus/installedVersion-< package name >