diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 63094efbf..2a2f19e76 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -15,3 +15,4 @@ Wails is what it is because of the time and effort given by these great people. * [iceleo-com](https://github.com/iceleo-com) * [fallendusk](https://github.com/fallendusk) * [Florian Didran](https://github.com/fdidron) +* [Nikolai Zimmermann](https://github.com/Chronophylos) diff --git a/cmd/linux.go b/cmd/linux.go index 610902389..9a1e55ae9 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -23,6 +23,10 @@ const ( Arch // RedHat linux distribution RedHat + // CentOS linux distribution + CentOS + // Fedora linux distribution + Fedora // Debian distribution Debian // Gentoo distribution @@ -33,63 +37,23 @@ const ( // DistroInfo contains all the information relating to a linux distribution type DistroInfo struct { - Distribution LinuxDistribution - Description string - Release string - Codename string - DistributorID string - DiscoveredBy string + Distribution LinuxDistribution + Name string + ID string + Description string + Release string + DiscoveredBy string } // GetLinuxDistroInfo returns information about the running linux distribution func GetLinuxDistroInfo() *DistroInfo { result := &DistroInfo{Distribution: Unknown} - program := NewProgramHelper() - // Does lsb_release exist? - lsbRelease := program.FindProgram("lsb_release") - if lsbRelease != nil { - stdout, _, _, err := lsbRelease.Run("-a") - if err != nil { - return result - } - result.DiscoveredBy = "lsb" - 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 - switch value { - case "Ubuntu": - result.Distribution = Ubuntu - case "Arch", "ManjaroLinux": - result.Distribution = Arch - case "Debian": - result.Distribution = Debian - case "Gentoo": - result.Distribution = Gentoo - case "Zorin": - result.Distribution = Zorin - case "Fedora": - result.Distribution = RedHat - } - case "Description": - result.Description = value - case "Release": - result.Release = value - case "Codename": - result.Codename = value - } - } - } - // check if /etc/os-release exists - } else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) { + _, err := os.Stat("/etc/os-release") + if !os.IsNotExist(err) { // Default value - osName := "Unknown" + osID := "unknown" + osNAME := "Unknown" version := "" // read /etc/os-release osRelease, _ := ioutil.ReadFile("/etc/os-release") @@ -104,8 +68,10 @@ func GetLinuxDistroInfo() *DistroInfo { continue } switch splitLine[0] { + case "ID": + osID = strings.Trim(splitLine[1], "\"") case "NAME": - osName = strings.Trim(splitLine[1], "\"") + osNAME = strings.Trim(splitLine[1], "\"") case "VERSION_ID": version = strings.Trim(splitLine[1], "\"") } @@ -114,21 +80,29 @@ func GetLinuxDistroInfo() *DistroInfo { // Check distro name against list of distros result.Release = version result.DiscoveredBy = "os-release" - switch osName { - case "Fedora": + switch osID { + case "rhel": result.Distribution = RedHat - case "CentOS": - result.Distribution = RedHat - case "Arch Linux": + case "fedora": + result.Distribution = Fedora + case "centos": + result.Distribution = CentOS + case "arch": result.Distribution = Arch - case "Debian GNU/Linux": + case "debian": result.Distribution = Debian - case "Gentoo/Linux": + case "ubuntu": + result.Distribution = Ubuntu + case "gentoo": result.Distribution = Gentoo + case "zorin": + result.Distribution = Zorin default: result.Distribution = Unknown - result.DistributorID = osName } + + result.ID = osID + result.Name = osNAME } return result } @@ -181,16 +155,16 @@ func RpmInstalled(packageName string) (bool, error) { // currently unsupported distribution func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error { var logger = NewLogger() - defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, libraryName) + defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.Name, libraryName) - logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.DistributorID) - q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.DistributorID) + logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.Name) + q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.Name) result := Prompt(q, "yes") if strings.ToLower(result) != "yes" { return defaultError } - title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID) + title := fmt.Sprintf("Support Distribution '%s'", distroInfo.Name) var str strings.Builder @@ -205,16 +179,16 @@ func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) e str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS)) str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH)) str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule)) - str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.DistributorID)) + str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.ID)) + str.WriteString(fmt.Sprintf("| Distribution Name | %s |\n", distroInfo.Name)) str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release)) str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy)) - body := fmt.Sprintf("**Description**\nDistribution '%s' is currently unsupported.\n\n**Further Information**\n\n%s\n\n*Please add any extra information here, EG: libraries that are needed to make the distribution work, or commands to install them*", distroInfo.DistributorID, str.String()) + body := fmt.Sprintf("**Description**\nDistribution '%s' is currently unsupported.\n\n**Further Information**\n\n%s\n\n*Please add any extra information here, EG: libraries that are needed to make the distribution work, or commands to install them*", distroInfo.ID, str.String()) fullURL := "https://github.com/wailsapp/wails/issues/new?" params := "title=" + title + "&body=" + body fmt.Println("Opening browser to file request.") browser.OpenURL(fullURL + url.PathEscape(params)) return nil - } diff --git a/cmd/prerequisites.go b/cmd/prerequisites.go index 51ad778c1..affe16b0f 100644 --- a/cmd/prerequisites.go +++ b/cmd/prerequisites.go @@ -102,7 +102,7 @@ func getRequiredLibrariesLinux() (*Prerequisites, error) { case Arch: result.Add(newPrerequisite("gtk3", "Please install with `sudo pacman -S gtk3` and try again")) result.Add(newPrerequisite("webkit2gtk", "Please install with `sudo pacman -S webkit2gtk` and try again")) - case RedHat: + case RedHat, Fedora, CentOS: result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again")) result.Add(newPrerequisite("webkit2gtk3-devel", "Please install with `sudo yum install webkit2gtk3-devel` and try again")) default: diff --git a/cmd/system.go b/cmd/system.go index 57bb104d8..f607a9243 100644 --- a/cmd/system.go +++ b/cmd/system.go @@ -294,7 +294,7 @@ func CheckDependencies(logger *Logger) (bool, error) { } else { logger.Green("Library '%s' installed.", library.Name) } - case RedHat: + case RedHat, Fedora, CentOS: installed, err := RpmInstalled(library.Name) if err != nil { return false, err diff --git a/cmd/version.go b/cmd/version.go index dd98c36c7..6e06c26da 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -1,4 +1,4 @@ package cmd // Version - Wails version -const Version = "v0.17.6-pre" +const Version = "v0.17.7-pre" diff --git a/go.sum b/go.sum index 54caca56e..d67835ac2 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,8 @@ github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/wailsapp/webview v0.2.7 h1:fN5L5H9Oivg9IJPk7uaXQnjqB68Fny11ZWkIaTIZHmk= +github.com/wailsapp/webview v0.2.7/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY= github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4= golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=