2025-02-03 15:52:19 +01:00
|
|
|
package spm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
|
|
|
// persistSystemEnvVar sets a persistent environment variable on Windows using the `setx` command.
|
2025-02-04 17:11:27 +01:00
|
|
|
// 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.
|
2025-02-03 15:52:19 +01:00
|
|
|
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
|
|
|
|
}
|