summaryrefslogtreecommitdiff
path: root/apt_macos.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-02 10:53:50 -0600
committerJeff Carr <[email protected]>2024-12-02 10:53:50 -0600
commit1c18f171c1bc9f6de5f7ce3d781e342ee85fe62c (patch)
tree6afd49fd3c0c77827c4bfd6574385420ced4034d /apt_macos.go
parentba5c32d24465b1d958b20d9dba62fd2b7b2d0df1 (diff)
stub in windows and darwin files. golang is neatv0.0.15v0.0.14
Diffstat (limited to 'apt_macos.go')
-rw-r--r--apt_macos.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/apt_macos.go b/apt_macos.go
deleted file mode 100644
index 3e71d1a..0000000
--- a/apt_macos.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package zoopb
-
-import (
- "bufio"
- "fmt"
- "os/exec"
- "strings"
-
- "go.wit.com/log"
-)
-
-// getPackageList returns the list of installed packages based on the distro
-func getPackageList(distro string) (map[string]string, error) {
- var cmd *exec.Cmd
-
- // Run the appropriate command based on the detected distribution
- switch distro {
- case "ubuntu", "debian":
- return dpkgQuery()
- case "fedora", "centos", "rhel":
- cmd = exec.Command("rpm", "-qa")
- case "arch", "manjaro":
- cmd = exec.Command("pacman", "-Q")
- default:
- return nil, fmt.Errorf("unsupported distribution: %s", distro)
- }
-
- // Capture the command's output
- output, err := cmd.CombinedOutput()
- if err != nil {
- return nil, fmt.Errorf("error running command: %v", err)
- }
-
- // todo: Split the output into lines and return
- lines := strings.Split(string(output), "\n")
- log.Info("output had", len(lines), "lines")
- return nil, nil
-}
-
-func dpkgQuery() (map[string]string, error) {
- // Run the dpkg-query command to list installed packages and versions
- cmd := exec.Command("dpkg-query", "-W", "-f=${Package} ${Version}\n")
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return nil, err
- }
-
- // Start the command execution
- if err := cmd.Start(); err != nil {
- return nil, err
- }
- defer cmd.Wait()
-
- // Create a map to store package names and versions
- installedPackages := make(map[string]string)
-
- // Use a scanner to read the output of the command line by line
- scanner := bufio.NewScanner(stdout)
- for scanner.Scan() {
- line := scanner.Text()
- // Split each line into package name and version
- parts := strings.SplitN(line, " ", 2)
- if len(parts) == 2 {
- packageName := parts[0]
- version := parts[1]
- installedPackages[packageName] = version
- }
- }
-
- // Return the map with package names and versions
- return installedPackages, scanner.Err()
-}