Skip to content

Commit

Permalink
fix: make updateCheck work with bootc and rpm-ostree
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Dec 20, 2024
1 parent 0763cfe commit 188389f
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions cmd/updateCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,41 @@ import (
)

func UpdateCheck(cmd *cobra.Command, args []string) {
systemUpdater, err := drv.SystemUpdater{}.New(drv.UpdaterInitConfiguration{})
var enableUpd bool = true

initConfiguration := drv.UpdaterInitConfiguration{}.New()
rpmOstreeUpdater, err := drv.RpmOstreeUpdater{}.New(*initConfiguration)
if err != nil {
slog.Error("Failed getting system driver", slog.Any("error", err))
return
enableUpd = false
}

systemUpdater, err := drv.SystemUpdater{}.New(*initConfiguration)
if err != nil {
enableUpd = false
}

isBootc, err := drv.BootcCompatible(systemUpdater.BinaryPath)
if err != nil {
isBootc = false
}
updateAvailable, err := systemUpdater.Check()

if !isBootc {
slog.Debug("Using rpm-ostree fallback as system driver")
}

systemUpdater.Config.Enabled = isBootc && enableUpd
rpmOstreeUpdater.Config.Enabled = !isBootc && enableUpd

var mainSystemDriver drv.SystemUpdateDriver
if !isBootc {
slog.Debug("Using the rpm-ostree driver")
mainSystemDriver = &rpmOstreeUpdater
} else {
slog.Debug("Using the bootc driver")
mainSystemDriver = &systemUpdater
}

updateAvailable, err := mainSystemDriver.Check()
if err != nil {
slog.Error("Failed checking for updates", slog.Any("error", err))
return
Expand Down

0 comments on commit 188389f

Please sign in to comment.