AllPac/pkg/packagemanager/all_updater.go
VetheonGames 4b0a6e6d59 Major Update 3
changes to main.go:
```
- rough write main.go
```

changes to install package:
```
- merged install package with packagemanager package
```

changes to packagemanager package:
```
- merged search and install packages into this one
- write all_updater.go in rough form, this will handle when the user wants to update all the packages across all backends
- rough write all of aur.go, this will handle AUR package update logic, and AUR package uninstall logic
- add a function to flatpak.go to retrieve a packages version
- move utility functions out of install.go and into installer_utils.go
- add a function to pacman.go to fetch a programs version from pacman
- add a function to snap.go to fetch a programs version from pacman
```

changes to toolcheck package:
```
- change toolcheck.go to import the packagemanager instead of install, since we merged the two
```
2024-01-04 13:08:32 -07:00

47 lines
1.3 KiB
Go

package packagemanager
import (
"fmt"
"sync"
)
// UpdateAllPackages updates all packages on the system
func UpdateAllPackages() error {
pkgList, err := readPackageList()
if err != nil {
return fmt.Errorf("error reading package list: %v", err)
}
var wg sync.WaitGroup
for pkgName, pkgInfo := range pkgList {
wg.Add(1)
go func(name string, info PackageInfo) {
defer wg.Done()
if err := checkAndUpdatePackage(name, info); err != nil {
fmt.Printf("Error updating package %s: %v\n", name, err)
}
}(pkgName, pkgInfo)
}
wg.Wait()
fmt.Println("All packages have been updated.")
return nil
}
// checkAndUpdatePackage checks if an update is available for the package and updates it
func checkAndUpdatePackage(name string, info PackageInfo) error {
// Implement logic to check for the latest version and update
return nil
}
// functions to get the latest version for each package manager
func getLatestPacmanVersion(packageName string) (string, error) {
// Use SearchPacman to get the latest version
// Parse the output to extract the version
// Return the version
// ...
return "", nil
}
// Similar implementations for getLatestAURVersion, getLatestSnapVersion, getLatestFlatpakVersion