mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
feat: add linux prereq checking
This commit is contained in:
38
cmd/linux.go
38
cmd/linux.go
@@ -1,6 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// LinuxDistribution is of type int
|
||||
type LinuxDistribution int
|
||||
@@ -12,23 +14,45 @@ const (
|
||||
|
||||
// DistroInfo contains all the information relating to a linux distribution
|
||||
type DistroInfo struct {
|
||||
distribution LinuxDistribution
|
||||
name string
|
||||
release string
|
||||
Distribution LinuxDistribution
|
||||
Description string
|
||||
Release string
|
||||
Codename string
|
||||
DistributorId string
|
||||
}
|
||||
|
||||
func getLinuxDistroInfo() *DistroInfo {
|
||||
func GetLinuxDistroInfo() *DistroInfo {
|
||||
result := &DistroInfo{}
|
||||
program := NewProgramHelper()
|
||||
// Does lsb_release exist?
|
||||
|
||||
lsbRelease := program.FindProgram("lsb_release")
|
||||
if lsbRelease != nil {
|
||||
stdout, _, err := lsbRelease.Run("-a")
|
||||
stdout, _, err, _ := lsbRelease.Run("-a")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
fmt.Println(stdout)
|
||||
|
||||
for _, line := range strings.Split(stdout, "\n") {
|
||||
if strings.Contains(line, ":") {
|
||||
// Iterate lines a
|
||||
details := strings.Split(line, ":")
|
||||
key := strings.TrimSpace(details[0])
|
||||
value := strings.TrimSpace(details[1])
|
||||
switch key {
|
||||
case "Distributor ID":
|
||||
result.DistributorId = value
|
||||
case "Description":
|
||||
result.Description = value
|
||||
case "Release":
|
||||
result.Release = value
|
||||
case "Codename":
|
||||
result.Codename = value
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user