Installer/spm/utils.go

27 lines
812 B
Go
Raw Normal View History

2025-02-04 17:14:00 +01:00
package spm
import (
"os/exec"
)
// persistSystemEnvVar sets a persistent environment variable on Windows using the `setx` command.
// Perhaps support for other systems would be needed, but all of this "Launcher" thingy is probably going to end up
// being Windows-specific, as other superior systems have their own package managers.
func persistSystemEnvVar(key, value string) error {
cmd := exec.Command("cmd", "/C", "setx", key, value)
err := cmd.Run()
if err != nil {
return err
}
return nil
}
// IsMatchingEntry checks if a package entry matches the requested specs
func IsMatchingEntry(e AppIndexEntry, name, release, arch, osName, pkgType string) bool {
return e.Name == name &&
e.Release == release &&
e.Arch == arch &&
e.OS == osName &&
e.Type == pkgType
}