mirror of
https://github.com/taigrr/wails.git
synced 2026-04-15 19:30:49 -07:00
Compare commits
9 Commits
123-Unify-
...
135-Add-De
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
105073e412 | ||
|
|
9d1f1fff47 | ||
|
|
08050ec35e | ||
|
|
bd9751d888 | ||
|
|
7d171b0907 | ||
|
|
5b8f311465 | ||
|
|
a84e2ae9b3 | ||
|
|
9496d1d47f | ||
|
|
70ccb8942b |
@@ -46,7 +46,7 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
#### Ubuntu 18.04
|
#### Ubuntu 18.04, Debian 9
|
||||||
|
|
||||||
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||||
|
|
||||||
|
|||||||
89
cmd/linux.go
89
cmd/linux.go
@@ -3,9 +3,12 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/browser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LinuxDistribution is of type int
|
// LinuxDistribution is of type int
|
||||||
@@ -20,6 +23,8 @@ const (
|
|||||||
Arch
|
Arch
|
||||||
// RedHat linux distribution
|
// RedHat linux distribution
|
||||||
RedHat
|
RedHat
|
||||||
|
// Debian distribution
|
||||||
|
Debian
|
||||||
)
|
)
|
||||||
|
|
||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
@@ -29,6 +34,7 @@ type DistroInfo struct {
|
|||||||
Release string
|
Release string
|
||||||
Codename string
|
Codename string
|
||||||
DistributorID string
|
DistributorID string
|
||||||
|
DiscoveredBy string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLinuxDistroInfo returns information about the running linux distribution
|
// GetLinuxDistroInfo returns information about the running linux distribution
|
||||||
@@ -43,7 +49,7 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
result.DiscoveredBy = "lsb"
|
||||||
for _, line := range strings.Split(stdout, "\n") {
|
for _, line := range strings.Split(stdout, "\n") {
|
||||||
if strings.Contains(line, ":") {
|
if strings.Contains(line, ":") {
|
||||||
// Iterate lines a
|
// Iterate lines a
|
||||||
@@ -58,6 +64,8 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Distribution = Ubuntu
|
result.Distribution = Ubuntu
|
||||||
case "Arch", "ManjaroLinux":
|
case "Arch", "ManjaroLinux":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
|
case "Debian":
|
||||||
|
result.Distribution = Debian
|
||||||
}
|
}
|
||||||
case "Description":
|
case "Description":
|
||||||
result.Description = value
|
result.Description = value
|
||||||
@@ -65,21 +73,37 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Release = value
|
result.Release = value
|
||||||
case "Codename":
|
case "Codename":
|
||||||
result.Codename = value
|
result.Codename = value
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if /etc/os-release exists
|
// check if /etc/os-release exists
|
||||||
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
||||||
|
// Default value
|
||||||
|
osName := "Unknown"
|
||||||
|
version := ""
|
||||||
// read /etc/os-release
|
// read /etc/os-release
|
||||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||||
// compile a regex to find NAME=distro
|
// Split into lines
|
||||||
re := regexp.MustCompile(`^NAME=(.*)\n`)
|
lines := strings.Split(string(osRelease), "\n")
|
||||||
// extract the distro name
|
// Iterate lines
|
||||||
osName := string(re.FindSubmatch(osRelease)[1])
|
for _, line := range lines {
|
||||||
// strip quotations
|
// Split each line by the equals char
|
||||||
osName = strings.Trim(osName, "\"")
|
splitLine := strings.SplitN(line, "=", 2)
|
||||||
|
// Check we have
|
||||||
|
if len(splitLine) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch splitLine[0] {
|
||||||
|
case "NAME":
|
||||||
|
osName = strings.Trim(splitLine[1], "\"")
|
||||||
|
case "VERSION_ID":
|
||||||
|
version = strings.Trim(splitLine[1], "\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// Check distro name against list of distros
|
// Check distro name against list of distros
|
||||||
|
result.Release = version
|
||||||
|
result.DiscoveredBy = "os-release"
|
||||||
switch osName {
|
switch osName {
|
||||||
case "Fedora":
|
case "Fedora":
|
||||||
result.Distribution = RedHat
|
result.Distribution = RedHat
|
||||||
@@ -87,6 +111,11 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Distribution = RedHat
|
result.Distribution = RedHat
|
||||||
case "Arch Linux":
|
case "Arch Linux":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
|
case "Debian GNU/Linux":
|
||||||
|
result.Distribution = Debian
|
||||||
|
default:
|
||||||
|
result.Distribution = Unknown
|
||||||
|
result.DistributorID = osName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -124,3 +153,45 @@ func RpmInstalled(packageName string) (bool, error) {
|
|||||||
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
||||||
return exitCode == 0, nil
|
return exitCode == 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RequestSupportForDistribution promts the user to submit a request to support their
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
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)
|
||||||
|
result := Prompt(q, "yes")
|
||||||
|
if strings.ToLower(result) != "yes" {
|
||||||
|
return defaultError
|
||||||
|
}
|
||||||
|
|
||||||
|
title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID)
|
||||||
|
|
||||||
|
var str strings.Builder
|
||||||
|
|
||||||
|
gomodule, exists := os.LookupEnv("GO111MODULE")
|
||||||
|
if !exists {
|
||||||
|
gomodule = "(Not Set)"
|
||||||
|
}
|
||||||
|
|
||||||
|
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
||||||
|
str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", Version))
|
||||||
|
str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version()))
|
||||||
|
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 Version | %s |\n", distroInfo.Release))
|
||||||
|
str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy))
|
||||||
|
|
||||||
|
body := fmt.Sprintf("**Description**\nDistribution '%s' is curently 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())
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,11 +49,10 @@ func getRequiredProgramsLinux() *Prerequisites {
|
|||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu:
|
case Ubuntu, Debian:
|
||||||
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
||||||
result.Add(newPrerequisite("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
|
result.Add(newPrerequisite("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
for _, library := range *requiredLibraries {
|
for _, library := range *requiredLibraries {
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu:
|
case Ubuntu, Debian:
|
||||||
installed, err := DpkgInstalled(library.Name)
|
installed, err := DpkgInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -295,7 +295,6 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
case RedHat:
|
case RedHat:
|
||||||
|
|
||||||
installed, err := RpmInstalled(library.Name)
|
installed, err := RpmInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -307,7 +306,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
|
return false, RequestSupportForDistribution(distroInfo, library.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,11 @@
|
|||||||
"extends": "react-app"
|
"extends": "react-app"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [],
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
"development": [
|
"development": [
|
||||||
"last 1 chrome version",
|
"last 1 chrome version",
|
||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
|
|||||||
@@ -26,22 +26,8 @@ class HelloWorld extends React.Component {
|
|||||||
this.setState({ showModal: false });
|
this.setState({ showModal: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
startAsync() {
|
|
||||||
this.setState({
|
|
||||||
loading: true
|
|
||||||
});
|
|
||||||
|
|
||||||
window.backend.basic().then(result =>
|
|
||||||
this.setState({
|
|
||||||
loading: false,
|
|
||||||
result
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, result } = this.state;
|
const { result } = this.state;
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<button onClick={this.handleOpenModal} type="button">
|
<button onClick={this.handleOpenModal} type="button">
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func checkLibraries() (errors bool, err error) {
|
|||||||
distroInfo := cmd.GetLinuxDistroInfo()
|
distroInfo := cmd.GetLinuxDistroInfo()
|
||||||
for _, library := range *requiredLibraries {
|
for _, library := range *requiredLibraries {
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case cmd.Ubuntu:
|
case cmd.Ubuntu, cmd.Debian:
|
||||||
installed, err := cmd.DpkgInstalled(library.Name)
|
installed, err := cmd.DpkgInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -108,7 +108,7 @@ func checkLibraries() (errors bool, err error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
|
return false, cmd.RequestSupportForDistribution(distroInfo, library.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user