From 188389f6b2c34f56385f7bd7e3a14740906b9811 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Sun, 15 Dec 2024 01:09:38 -0300 Subject: [PATCH] fix: make updateCheck work with bootc and rpm-ostree --- cmd/updateCheck.go | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/cmd/updateCheck.go b/cmd/updateCheck.go index 377d295..b8950b4 100644 --- a/cmd/updateCheck.go +++ b/cmd/updateCheck.go @@ -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