From 9de2f66f50e9a3e581e0803651988d5e361ee41d Mon Sep 17 00:00:00 2001 From: Chronophylos Date: Sat, 27 Jul 2019 21:26:11 +0200 Subject: [PATCH 1/7] drop lsb_release Signed-off-by: Chronophylos --- cmd/linux.go | 68 +++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index 610902389..5cf3d371c 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -44,52 +44,11 @@ type DistroInfo struct { // 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" version := "" // read /etc/os-release osRelease, _ := ioutil.ReadFile("/etc/os-release") @@ -104,8 +63,8 @@ func GetLinuxDistroInfo() *DistroInfo { continue } switch splitLine[0] { - case "NAME": - osName = strings.Trim(splitLine[1], "\"") + case "ID": + osID = strings.Trim(splitLine[1], "\"") case "VERSION_ID": version = strings.Trim(splitLine[1], "\"") } @@ -114,21 +73,22 @@ func GetLinuxDistroInfo() *DistroInfo { // Check distro name against list of distros result.Release = version result.DiscoveredBy = "os-release" - switch osName { - case "Fedora": + switch osID { + case "fedora": result.Distribution = RedHat - case "CentOS": - result.Distribution = RedHat - case "Arch Linux": + case "arch": result.Distribution = Arch - case "Debian GNU/Linux": + case "debian": result.Distribution = Debian - case "Gentoo/Linux": + case "gentoo": result.Distribution = Gentoo + case "zorin": + result.Distribution = Zorin default: result.Distribution = Unknown - result.DistributorID = osName } + + result.DistributorID = osID } return result } From 67a8ad8e12e123f6c3ee8004f9b3128608bdd19e Mon Sep 17 00:00:00 2001 From: Chronophylos Date: Sun, 28 Jul 2019 00:44:46 +0200 Subject: [PATCH 2/7] change DistributionID to NAME= Signed-off-by: Chronophylos --- cmd/linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/linux.go b/cmd/linux.go index 5cf3d371c..8d70eb9fb 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -49,6 +49,7 @@ func GetLinuxDistroInfo() *DistroInfo { if !os.IsNotExist(err) { // Default value osID := "unknown" + osNAME := "Unknown" version := "" // read /etc/os-release osRelease, _ := ioutil.ReadFile("/etc/os-release") @@ -65,6 +66,8 @@ func GetLinuxDistroInfo() *DistroInfo { switch splitLine[0] { case "ID": osID = strings.Trim(splitLine[1], "\"") + case "NAME": + osNAME = strings.Trim(splitLine[1], "\"") case "VERSION_ID": version = strings.Trim(splitLine[1], "\"") } @@ -88,7 +91,7 @@ func GetLinuxDistroInfo() *DistroInfo { result.Distribution = Unknown } - result.DistributorID = osID + result.DistributorID = osNAME } return result } From 0bac20556506bc9a7451d27b279452a39e1fcbb3 Mon Sep 17 00:00:00 2001 From: Chronophylos Date: Sun, 28 Jul 2019 13:16:56 +0200 Subject: [PATCH 3/7] show distro id when creating a issue Signed-off-by: Chronophylos --- cmd/linux.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index 8d70eb9fb..9e9f34b83 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -33,12 +33,12 @@ 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 @@ -91,7 +91,8 @@ func GetLinuxDistroInfo() *DistroInfo { result.Distribution = Unknown } - result.DistributorID = osNAME + result.ID = osID + result.Name = osNAME } return result } @@ -144,16 +145,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 @@ -168,16 +169,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 - } From b36a3c4abb1320c0f6e3087987d1a591e207d88a Mon Sep 17 00:00:00 2001 From: Chronophylos Date: Sun, 28 Jul 2019 13:39:03 +0200 Subject: [PATCH 4/7] fix assumption Signed-off-by: Chronophylos --- cmd/linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index 9e9f34b83..e5ba768da 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -77,11 +77,11 @@ func GetLinuxDistroInfo() *DistroInfo { result.Release = version result.DiscoveredBy = "os-release" switch osID { - case "fedora": + case "fedora", "centos": result.Distribution = RedHat case "arch": result.Distribution = Arch - case "debian": + case "debian", "ubuntu": result.Distribution = Debian case "gentoo": result.Distribution = Gentoo From 9cac33670895ca888eec2ee1cfc8ab61292de7a4 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 29 Jul 2019 09:03:17 +1000 Subject: [PATCH 5/7] docs: updated contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) 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) From 5e047debfc177fed62963836b863a6e0df9a1f12 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 29 Jul 2019 17:52:22 +1000 Subject: [PATCH 6/7] fix: add support back for ubuntu, redhat --- cmd/linux.go | 14 ++++++++++++-- cmd/prerequisites.go | 2 +- cmd/system.go | 2 +- go.sum | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index e5ba768da..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 @@ -77,12 +81,18 @@ func GetLinuxDistroInfo() *DistroInfo { result.Release = version result.DiscoveredBy = "os-release" switch osID { - case "fedora", "centos": + case "rhel": result.Distribution = RedHat + case "fedora": + result.Distribution = Fedora + case "centos": + result.Distribution = CentOS case "arch": result.Distribution = Arch - case "debian", "ubuntu": + case "debian": result.Distribution = Debian + case "ubuntu": + result.Distribution = Ubuntu case "gentoo": result.Distribution = Gentoo case "zorin": 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/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= From 750a02efc680ca28367e6763d70918e9b7bd25c9 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 29 Jul 2019 17:54:41 +1000 Subject: [PATCH 7/7] chore: version bump --- cmd/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"