4b0a6e6d59
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 ```
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package packagemanager
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
// AURPackageInfo represents the package information from the AUR
|
|
type AURPackageInfo struct {
|
|
Version string `json:"Version"`
|
|
// Add other relevant fields
|
|
}
|
|
|
|
// UpdateAURPackages updates specified AUR packages or all if no specific package is provided
|
|
func UpdateAURPackages(packageNames ...string) error {
|
|
pkgList, err := ReadPackageList()
|
|
if err != nil {
|
|
return fmt.Errorf("error reading package list: %v", err)
|
|
}
|
|
|
|
for _, packageName := range packageNames {
|
|
aurInfo, err := fetchAURPackageInfo(packageName)
|
|
if err != nil {
|
|
return fmt.Errorf("error fetching AUR package info for %s: %v", packageName, err)
|
|
}
|
|
|
|
installedInfo, ok := pkgList[packageName]
|
|
if !ok || installedInfo.Version != aurInfo.Version {
|
|
_, err := CloneAndInstallFromAUR("https://aur.archlinux.org/" + packageName + ".git", true)
|
|
if err != nil {
|
|
return fmt.Errorf("error updating AUR package %s: %v", packageName, err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// UninstallAURPackage uninstalls a specified AUR package
|
|
func UninstallAURPackage(packageName string) error {
|
|
// Uninstalling an AUR package is typically done with pacman
|
|
cmd := exec.Command("sudo", "pacman", "-Rns", "--noconfirm", packageName)
|
|
if output, err := cmd.CombinedOutput(); err != nil {
|
|
return fmt.Errorf("error uninstalling AUR package: %s, %v", output, err)
|
|
}
|
|
return nil
|
|
}
|