Skip to content

Commit

Permalink
fix: make updates work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Dec 4, 2024
1 parent 5423cb4 commit 7bfb0ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ func Update(cmd *cobra.Command, args []string) {
if err != nil {
systemUpdater.Config.Enabled = false
} else {
systemUpdater.Check()
enableUpd, err := systemUpdater.Check()
if err != nil {
slog.Error("Failed checking for updates")
}
systemUpdater.Config.Enabled = enableUpd
}

brewUpdater, err := drv.BrewUpdater{}.New(*initConfiguration)
Expand Down
8 changes: 4 additions & 4 deletions drv/brew.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ type BrewUpdater struct {

func (up BrewUpdater) New(config UpdaterInitConfiguration) (BrewUpdater, error) {
brewPrefix, empty := os.LookupEnv("HOMEBREW_PREFIX")
if empty {
if empty || brewPrefix == "" {
brewPrefix = "/home/linuxbrew/.linuxbrew"
}
brewRepo, empty := os.LookupEnv("HOMEBREW_REPOSITORY")
if empty {
if empty || brewRepo == "" {
brewRepo = fmt.Sprintf("%s/Homebrew", brewPrefix)
}
brewCellar, empty := os.LookupEnv("HOMEBREW_CELLAR")
if empty {
if empty || brewCellar == "" {
brewCellar = fmt.Sprintf("%s/Cellar", brewPrefix)
}
brewPath, empty := os.LookupEnv("HOMEBREW_PATH")
if empty {
if empty || brewPath == "" {
brewPath = fmt.Sprintf("%s/bin/brew", brewPrefix)
}

Expand Down
2 changes: 1 addition & 1 deletion drv/distrobox.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (up *DistroboxUpdater) Update() (*[]CommandOutput, error) {
for _, user := range up.users {
up.Tracker.Tracker.IncrementSection(err)
lib.ChangeTrackerMessageFancy(*up.Tracker.Writer, up.Tracker.Tracker, up.Tracker.Progress, lib.TrackerMessage{Title: up.Config.Title, Description: *up.Config.UserDescription + " " + user.Name})
out, err := lib.RunUID(user.UID, []string{"/usr/bin/flatpak", "update", "-y"}, nil)
out, err := lib.RunUID(user.UID, []string{"/usr/bin/distrobox", "upgrade", "-a"}, nil)
tmpout = CommandOutput{}.New(out, err)
if err != nil {
tmpout.SetFailureContext(fmt.Sprintf("Distroboxes for User: %s", user.Name))
Expand Down
2 changes: 1 addition & 1 deletion drv/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (up SystemUpdater) New(initconfig UpdaterInitConfiguration) (SystemUpdater,
}

func (up *SystemUpdater) Check() (bool, error) {
if up.Config.DryRun || !up.Config.Enabled {
if up.Config.DryRun {
return true, nil
}
updateAvailable, err := up.SystemDriver.UpdateAvailable()
Expand Down

0 comments on commit 7bfb0ee

Please sign in to comment.