mirror of
https://github.com/taigrr/wails.git
synced 2026-04-04 06:02:43 -07:00
Compare commits
1 Commits
linux-db
...
gitbash-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9164bf17c0 |
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -4,13 +4,6 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
|
||||||
"name": "Test cmd package",
|
|
||||||
"type": "go",
|
|
||||||
"request": "launch",
|
|
||||||
"mode": "test",
|
|
||||||
"program": "${workspaceFolder}/cmd/"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Wails Init",
|
"name": "Wails Init",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -46,7 +46,7 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
#### Debian 9, Ubuntu 18.04, Zorin 15, Parrot 4.7
|
#### Ubuntu 18.04, Debian 9, Zorin 15
|
||||||
|
|
||||||
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
|
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||||
|
|
||||||
@@ -54,17 +54,13 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
|||||||
|
|
||||||
`sudo pacman -S webkit2gtk gtk3`
|
`sudo pacman -S webkit2gtk gtk3`
|
||||||
|
|
||||||
#### Centos 7
|
|
||||||
|
|
||||||
`sudo yum install webkitgtk3-devel gtk3-devel`
|
|
||||||
|
|
||||||
#### Fedora 30
|
#### Fedora 30
|
||||||
|
|
||||||
`sudo yum install webkit2gtk3-devel gtk3-devel`
|
`sudo yum install webkit2gtk3-devel gtk3-devel`
|
||||||
|
|
||||||
#### Gentoo
|
#### Centos 7
|
||||||
|
|
||||||
`sudo emerge gtk+:3 webkit-gtk`
|
`sudo yum install webkitgtk3-devel gtk3-devel`
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
120
cmd/linux.go
120
cmd/linux.go
@@ -17,22 +17,22 @@ type LinuxDistribution int
|
|||||||
const (
|
const (
|
||||||
// Unknown is the catch-all distro
|
// Unknown is the catch-all distro
|
||||||
Unknown LinuxDistribution = iota
|
Unknown LinuxDistribution = iota
|
||||||
// Debian distribution
|
|
||||||
Debian
|
|
||||||
// Ubuntu distribution
|
// Ubuntu distribution
|
||||||
Ubuntu
|
Ubuntu
|
||||||
// Arch linux distribution
|
// Arch linux distribution
|
||||||
Arch
|
Arch
|
||||||
|
// RedHat linux distribution
|
||||||
|
RedHat
|
||||||
// CentOS linux distribution
|
// CentOS linux distribution
|
||||||
CentOS
|
CentOS
|
||||||
// Fedora linux distribution
|
// Fedora linux distribution
|
||||||
Fedora
|
Fedora
|
||||||
|
// Debian distribution
|
||||||
|
Debian
|
||||||
// Gentoo distribution
|
// Gentoo distribution
|
||||||
Gentoo
|
Gentoo
|
||||||
// Zorin distribution
|
// Zorin distribution
|
||||||
Zorin
|
Zorin
|
||||||
// Parrot distribution
|
|
||||||
Parrot
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
@@ -42,77 +42,66 @@ type DistroInfo struct {
|
|||||||
ID string
|
ID string
|
||||||
Description string
|
Description string
|
||||||
Release string
|
Release string
|
||||||
|
DiscoveredBy string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLinuxDistroInfo returns information about the running linux distribution
|
// GetLinuxDistroInfo returns information about the running linux distribution
|
||||||
func GetLinuxDistroInfo() *DistroInfo {
|
func GetLinuxDistroInfo() *DistroInfo {
|
||||||
result := &DistroInfo{
|
|
||||||
Distribution: Unknown,
|
|
||||||
ID: "unknown",
|
|
||||||
Name: "Unknown",
|
|
||||||
}
|
|
||||||
_, err := os.Stat("/etc/os-release")
|
|
||||||
if !os.IsNotExist(err) {
|
|
||||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
|
||||||
result = parseOsRelease(string(osRelease))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseOsRelease parses the given os-release data and returns
|
|
||||||
// a DistroInfo struct with the details
|
|
||||||
func parseOsRelease(osRelease string) *DistroInfo {
|
|
||||||
result := &DistroInfo{Distribution: Unknown}
|
result := &DistroInfo{Distribution: Unknown}
|
||||||
|
|
||||||
// Default value
|
_, err := os.Stat("/etc/os-release")
|
||||||
osID := "unknown"
|
if !os.IsNotExist(err) {
|
||||||
osNAME := "Unknown"
|
// Default value
|
||||||
version := ""
|
osID := "unknown"
|
||||||
|
osNAME := "Unknown"
|
||||||
|
version := ""
|
||||||
|
// read /etc/os-release
|
||||||
|
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||||
|
// Split into lines
|
||||||
|
lines := strings.Split(string(osRelease), "\n")
|
||||||
|
// Iterate lines
|
||||||
|
for _, line := range lines {
|
||||||
|
// Split each line by the equals char
|
||||||
|
splitLine := strings.SplitN(line, "=", 2)
|
||||||
|
// Check we have
|
||||||
|
if len(splitLine) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
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], "\"")
|
||||||
|
}
|
||||||
|
|
||||||
// Split into lines
|
|
||||||
lines := strings.Split(osRelease, "\n")
|
|
||||||
// Iterate lines
|
|
||||||
for _, line := range lines {
|
|
||||||
// Split each line by the equals char
|
|
||||||
splitLine := strings.SplitN(line, "=", 2)
|
|
||||||
// Check we have
|
|
||||||
if len(splitLine) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
switch splitLine[0] {
|
// Check distro name against list of distros
|
||||||
case "ID":
|
result.Release = version
|
||||||
osID = strings.Trim(splitLine[1], "\"")
|
result.DiscoveredBy = "/etc/os-release"
|
||||||
case "NAME":
|
switch osID {
|
||||||
osNAME = strings.Trim(splitLine[1], "\"")
|
case "fedora":
|
||||||
case "VERSION_ID":
|
result.Distribution = Fedora
|
||||||
version = strings.Trim(splitLine[1], "\"")
|
case "centos":
|
||||||
|
result.Distribution = CentOS
|
||||||
|
case "arch":
|
||||||
|
result.Distribution = Arch
|
||||||
|
case "debian":
|
||||||
|
result.Distribution = Debian
|
||||||
|
case "ubuntu":
|
||||||
|
result.Distribution = Ubuntu
|
||||||
|
case "gentoo":
|
||||||
|
result.Distribution = Gentoo
|
||||||
|
case "zorin":
|
||||||
|
result.Distribution = Zorin
|
||||||
|
default:
|
||||||
|
result.Distribution = Unknown
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Check distro name against list of distros
|
|
||||||
result.Release = version
|
|
||||||
switch osID {
|
|
||||||
case "fedora":
|
|
||||||
result.Distribution = Fedora
|
|
||||||
case "centos":
|
|
||||||
result.Distribution = CentOS
|
|
||||||
case "arch":
|
|
||||||
result.Distribution = Arch
|
|
||||||
case "debian":
|
|
||||||
result.Distribution = Debian
|
|
||||||
case "ubuntu":
|
|
||||||
result.Distribution = Ubuntu
|
|
||||||
case "gentoo":
|
|
||||||
result.Distribution = Gentoo
|
|
||||||
case "zorin":
|
|
||||||
result.Distribution = Zorin
|
|
||||||
case "parrot":
|
|
||||||
result.Distribution = Parrot
|
|
||||||
default:
|
|
||||||
result.Distribution = Unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
result.ID = osID
|
result.ID = osID
|
||||||
result.Name = osNAME
|
result.Name = osNAME
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +180,7 @@ func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) e
|
|||||||
str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.ID))
|
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 Name | %s |\n", distroInfo.Name))
|
||||||
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
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.ID, 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?"
|
fullURL := "https://github.com/wailsapp/wails/issues/new?"
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func TestUbuntuDetection(t *testing.T) {
|
|
||||||
osrelease := `
|
|
||||||
NAME="Ubuntu"
|
|
||||||
VERSION="18.04.2 LTS (Bionic Beaver)"
|
|
||||||
ID=ubuntu
|
|
||||||
ID_LIKE=debian
|
|
||||||
PRETTY_NAME="Ubuntu 18.04.2 LTS"
|
|
||||||
VERSION_ID="18.04"
|
|
||||||
HOME_URL="https://www.ubuntu.com/"
|
|
||||||
SUPPORT_URL="https://help.ubuntu.com/"
|
|
||||||
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
|
||||||
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
|
||||||
VERSION_CODENAME=bionic
|
|
||||||
UBUNTU_CODENAME=bionic
|
|
||||||
`
|
|
||||||
|
|
||||||
result := parseOsRelease(osrelease)
|
|
||||||
if result.Distribution != Ubuntu {
|
|
||||||
t.Errorf("expected 'Ubuntu' ID but got '%d'", result.Distribution)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/leaanthony/mewn"
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
)
|
|
||||||
|
|
||||||
// LinuxDB is the database for linux distribution data.
|
|
||||||
type LinuxDB struct {
|
|
||||||
Distributions map[string]*Distribution `yaml:"distributions"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Distribution holds the os-release ID and a map of releases.
|
|
||||||
type Distribution struct {
|
|
||||||
ID string `yaml:"id"`
|
|
||||||
Releases map[string]*Release `yaml:"releases"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRelease attempts to return the specific Release information
|
|
||||||
// for the given release name. If there is no specific match, the
|
|
||||||
// default release data is returned.
|
|
||||||
func (d *Distribution) GetRelease(name string) *Release {
|
|
||||||
result := d.Releases[name]
|
|
||||||
if result == nil {
|
|
||||||
result = d.Releases["default"]
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release holds the name and version of the release as given by
|
|
||||||
// os-release. Programs is a slice of dependant programs required
|
|
||||||
// to be present on the local installation for Wails to function.
|
|
||||||
// Libraries is a slice of libraries that must be present for Wails
|
|
||||||
// applications to compile.
|
|
||||||
type Release struct {
|
|
||||||
Name string `yaml:"name"`
|
|
||||||
Version string `yaml:"version"`
|
|
||||||
GccVersionCommand string `yaml:"gccversioncommand"`
|
|
||||||
Programs []*Prerequisite `yaml:"programs"`
|
|
||||||
Libraries []*Prerequisite `yaml:"libraries"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prerequisite is a simple struct containing a program/library name
|
|
||||||
// plus the distribution specific help text indicating how to install
|
|
||||||
// it.
|
|
||||||
type Prerequisite struct {
|
|
||||||
Name string `yaml:"name"`
|
|
||||||
Help string `yaml:"help,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load will load the given filename from disk and attempt to
|
|
||||||
// import the data into the LinuxDB.
|
|
||||||
func (l *LinuxDB) Load(filename string) error {
|
|
||||||
if fs.FileExists(filename) {
|
|
||||||
data, err := fs.LoadAsBytes(filename)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return l.ImportData(data)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImportData will unmarshal the given YAML formatted data
|
|
||||||
// into the LinuxDB
|
|
||||||
func (l *LinuxDB) ImportData(data []byte) error {
|
|
||||||
return yaml.Unmarshal(data, l)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDistro returns the Distribution information for the
|
|
||||||
// given distribution name. If the distribution is not supported,
|
|
||||||
// nil is returned.
|
|
||||||
func (l *LinuxDB) GetDistro(name string) *Distribution {
|
|
||||||
return l.Distributions[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewLinuxDB creates a new LinuxDB instance from the bundled
|
|
||||||
// linuxdb.yaml file.
|
|
||||||
func NewLinuxDB() *LinuxDB {
|
|
||||||
data := mewn.Bytes("./linuxdb.yaml")
|
|
||||||
result := LinuxDB{
|
|
||||||
Distributions: make(map[string]*Distribution),
|
|
||||||
}
|
|
||||||
err := result.ImportData(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
return &result
|
|
||||||
}
|
|
||||||
124
cmd/linuxdb.yaml
124
cmd/linuxdb.yaml
@@ -1,124 +0,0 @@
|
|||||||
---
|
|
||||||
distributions:
|
|
||||||
ubuntu:
|
|
||||||
id: ubuntu
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
name: Ubuntu
|
|
||||||
version: default
|
|
||||||
gccversioncommand: &gccdumpfullversion -dumpfullversion
|
|
||||||
programs: &ubuntudefaultprograms
|
|
||||||
- name: gcc
|
|
||||||
help: Please install with `sudo apt install build-essential` and try again
|
|
||||||
- name: pkg-config
|
|
||||||
help: Please install with `sudo apt install pkg-config` and try again
|
|
||||||
- name: npm
|
|
||||||
help: Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - && sudo apt-get install -y nodejs` and try again
|
|
||||||
libraries: &ubuntudefaultlibraries
|
|
||||||
- name: libgtk-3-dev
|
|
||||||
help: Please install with `sudo apt install libgtk-3-dev` and try again
|
|
||||||
- name: libwebkit2gtk-4.0-dev
|
|
||||||
help: Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again
|
|
||||||
debian:
|
|
||||||
id: debian
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Debian
|
|
||||||
gccversioncommand: &gccdumpversion -dumpversion
|
|
||||||
programs: *ubuntudefaultprograms
|
|
||||||
libraries: *ubuntudefaultlibraries
|
|
||||||
parrot:
|
|
||||||
id: parrot
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Parrot
|
|
||||||
gccversioncommand: *gccdumpversion
|
|
||||||
programs: *ubuntudefaultprograms
|
|
||||||
libraries: *ubuntudefaultlibraries
|
|
||||||
zorin:
|
|
||||||
id: zorin
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Zorin
|
|
||||||
gccversioncommand: *gccdumpversion
|
|
||||||
programs:
|
|
||||||
- name: gcc
|
|
||||||
help: Please install with `sudo apt install build-essential` and try again
|
|
||||||
- name: pkg-config
|
|
||||||
help: Please install with `sudo apt install pkg-config` and try again
|
|
||||||
- name: npm
|
|
||||||
help: Please install with `sudo snap install node --channel=12/stable --classic` and try again
|
|
||||||
libraries: *ubuntudefaultlibraries
|
|
||||||
centos:
|
|
||||||
id: centos
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: CentOS
|
|
||||||
gccversioncommand: *gccdumpversion
|
|
||||||
programs:
|
|
||||||
- name: gcc
|
|
||||||
help: Please install with `sudo yum install gcc-c++ make` and try again
|
|
||||||
- name: pkg-config
|
|
||||||
help: Please install with `sudo yum install pkgconf-pkg-config` and try again
|
|
||||||
- name: npm
|
|
||||||
help: Please install with `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` and try again
|
|
||||||
libraries: ¢osdefaultlibraries
|
|
||||||
- name: gtk3-devel
|
|
||||||
help: Please install with `sudo yum install gtk3-devel` and try again
|
|
||||||
- name: webkit2gtk3-devel
|
|
||||||
help: Please install with `sudo yum install webkit2gtk3-devel` and try again
|
|
||||||
fedora:
|
|
||||||
id: fedora
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Fedora
|
|
||||||
gccversioncommand: *gccdumpfullversion
|
|
||||||
programs:
|
|
||||||
- name: gcc
|
|
||||||
help: Please install with `sudo yum install gcc-c++ make` and try again
|
|
||||||
- name: pkg-config
|
|
||||||
help: Please install with `sudo yum install pkgconf-pkg-config` and try again
|
|
||||||
- name: npm
|
|
||||||
help: Please install `sudo yum install -y nodejs` and try again
|
|
||||||
libraries: *centosdefaultlibraries
|
|
||||||
arch:
|
|
||||||
id: arch
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Arch Linux
|
|
||||||
gccversioncommand: *gccdumpversion
|
|
||||||
prerequisites:
|
|
||||||
- name: gtk3
|
|
||||||
help: Please install with `sudo pacman -S gtk3` and try again
|
|
||||||
- name: webkit2gtk
|
|
||||||
help: Please install with `sudo pacman -S webkit2gtk` and try again
|
|
||||||
- name: gcc
|
|
||||||
help: Please install with `sudo pacman -S gcc` and try again
|
|
||||||
- name: pkgconf
|
|
||||||
help: Please install with `sudo pacman -S pkgconf` and try again
|
|
||||||
- name: npm
|
|
||||||
help: Please install with `sudo pacman -S npm` and try again
|
|
||||||
gentoo:
|
|
||||||
id: gentoo
|
|
||||||
releases:
|
|
||||||
default:
|
|
||||||
version: default
|
|
||||||
name: Gentoo
|
|
||||||
gccversioncommand: *gccdumpversion
|
|
||||||
prerequisites:
|
|
||||||
- name: gtk+:3
|
|
||||||
help: Please install with `sudo emerge gtk+:3` and try again
|
|
||||||
- name: webkit-gtk
|
|
||||||
help: Please install with `sudo emerge webkit-gtk` and try again
|
|
||||||
- name: gcc
|
|
||||||
help: Please install using your system's package manager
|
|
||||||
- name: pkg-config
|
|
||||||
help: Please install using your system's package manager
|
|
||||||
- name: npm
|
|
||||||
help: Please install using your system's package manager
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func TestNewLinuxDB(t *testing.T) {
|
|
||||||
_ = NewLinuxDB()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestKnownDistro(t *testing.T) {
|
|
||||||
var linuxDB = NewLinuxDB()
|
|
||||||
result := linuxDB.GetDistro("ubuntu")
|
|
||||||
if result == nil {
|
|
||||||
t.Error("Cannot get distro 'ubuntu'")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUnknownDistro(t *testing.T) {
|
|
||||||
var linuxDB = NewLinuxDB()
|
|
||||||
result := linuxDB.GetDistro("unknown")
|
|
||||||
if result != nil {
|
|
||||||
t.Error("Should get nil for distribution 'unknown'")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDefaultRelease(t *testing.T) {
|
|
||||||
var linuxDB = NewLinuxDB()
|
|
||||||
result := linuxDB.GetDistro("ubuntu")
|
|
||||||
if result == nil {
|
|
||||||
t.Error("Cannot get distro 'ubuntu'")
|
|
||||||
}
|
|
||||||
|
|
||||||
release := result.GetRelease("default")
|
|
||||||
if release == nil {
|
|
||||||
t.Error("Cannot get release 'default' for distro 'ubuntu'")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUnknownRelease(t *testing.T) {
|
|
||||||
var linuxDB = NewLinuxDB()
|
|
||||||
result := linuxDB.GetDistro("ubuntu")
|
|
||||||
if result == nil {
|
|
||||||
t.Error("Cannot get distro 'ubuntu'")
|
|
||||||
}
|
|
||||||
|
|
||||||
release := result.GetRelease("16.04")
|
|
||||||
if release == nil {
|
|
||||||
t.Error("Failed to get release 'default' for unknown release version '16.04'")
|
|
||||||
}
|
|
||||||
|
|
||||||
if release.Version != "default" {
|
|
||||||
t.Errorf("Got version '%s' instead of 'default' for unknown release version '16.04'", result.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetPrerequisites(t *testing.T) {
|
|
||||||
var linuxDB = NewLinuxDB()
|
|
||||||
result := linuxDB.GetDistro("debian")
|
|
||||||
if result == nil {
|
|
||||||
t.Error("Cannot get distro 'debian'")
|
|
||||||
}
|
|
||||||
|
|
||||||
release := result.GetRelease("default")
|
|
||||||
if release == nil {
|
|
||||||
t.Error("Failed to get release 'default' for unknown release version '16.04'")
|
|
||||||
}
|
|
||||||
|
|
||||||
if release.Version != "default" {
|
|
||||||
t.Errorf("Got version '%s' instead of 'default' for unknown release version '16.04'", result.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if release.Name != "Debian" {
|
|
||||||
t.Errorf("Got Release Name '%s' instead of 'debian' for unknown release version '16.04'", release.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(release.Programs) != 3 {
|
|
||||||
t.Errorf("Expected %d programs for unknown release version '16.04'", len(release.Programs))
|
|
||||||
}
|
|
||||||
if len(release.Libraries) != 2 {
|
|
||||||
t.Errorf("Expected %d libraries for unknown release version '16.04'", len(release.Libraries))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,13 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Prerequisite defines a Prerequisite!
|
||||||
|
type Prerequisite struct {
|
||||||
|
Name string
|
||||||
|
Help string
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
func newPrerequisite(name, help string) *Prerequisite {
|
func newPrerequisite(name, help string) *Prerequisite {
|
||||||
return &Prerequisite{Name: name, Help: help}
|
return &Prerequisite{Name: name, Help: help}
|
||||||
}
|
}
|
||||||
@@ -41,13 +48,31 @@ func getRequiredProgramsOSX() *Prerequisites {
|
|||||||
func getRequiredProgramsLinux() *Prerequisites {
|
func getRequiredProgramsLinux() *Prerequisites {
|
||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
if distroInfo.Distribution != Unknown {
|
switch distroInfo.Distribution {
|
||||||
var linuxDB = NewLinuxDB()
|
case Debian:
|
||||||
distro := linuxDB.GetDistro(distroInfo.ID)
|
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
||||||
release := distro.GetRelease(distroInfo.Release)
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
||||||
for _, program := range release.Programs {
|
result.Add(newPrerequisite("npm", "Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - && sudo apt-get install -y nodejs` and try again"))
|
||||||
result.Add(program)
|
case Ubuntu:
|
||||||
}
|
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("npm", "Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - && sudo apt-get install -y nodejs` and try again"))
|
||||||
|
case Zorin:
|
||||||
|
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("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
|
||||||
|
case Fedora:
|
||||||
|
result.Add(newPrerequisite("gcc", "Please install with `sudo yum install gcc-c++ make` and try again"))
|
||||||
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo yum install pkgconf-pkg-config` and try again"))
|
||||||
|
result.Add(newPrerequisite("npm", "Please install with `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` and try again"))
|
||||||
|
case CentOS:
|
||||||
|
result.Add(newPrerequisite("gcc", "Please install with `sudo yum install gcc gcc-c++ make` and try again"))
|
||||||
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo yum install pkgconfig` and try again"))
|
||||||
|
result.Add(newPrerequisite("npm", "Please install with `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` and try again"))
|
||||||
|
default:
|
||||||
|
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("npm", "Please install from https://nodejs.org/en/download/ and try again"))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -81,15 +106,32 @@ func getRequiredLibrariesOSX() (*Prerequisites, error) {
|
|||||||
|
|
||||||
func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
// The Linux Distribution DB
|
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
if distroInfo.Distribution != Unknown {
|
switch distroInfo.Distribution {
|
||||||
var linuxDB = NewLinuxDB()
|
case Debian:
|
||||||
distro := linuxDB.GetDistro(distroInfo.ID)
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
release := distro.GetRelease(distroInfo.Release)
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
for _, library := range release.Libraries {
|
case Ubuntu:
|
||||||
result.Add(library)
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
}
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
|
case Zorin:
|
||||||
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
|
case Gentoo:
|
||||||
|
result.Add(newPrerequisite("gtk+:3", "Please install with `sudo emerge gtk+:3` and try again"))
|
||||||
|
result.Add(newPrerequisite("webkit-gtk", "Please install with `sudo emerge webkit-gtk` and try again"))
|
||||||
|
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 Fedora:
|
||||||
|
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"))
|
||||||
|
case CentOS:
|
||||||
|
result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again"))
|
||||||
|
result.Add(newPrerequisite("webkitgtk3-devel", "Please install with `sudo yum install webkitgtk3-devel` and try again"))
|
||||||
|
default:
|
||||||
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with your system package manager and try again"))
|
||||||
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with your system package manager and try again"))
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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, Debian, Zorin, Parrot:
|
case Ubuntu, Zorin, Debian:
|
||||||
installed, err := DpkgInstalled(library.Name)
|
installed, err := DpkgInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -294,7 +294,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
} else {
|
} else {
|
||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
case CentOS, Fedora:
|
case RedHat, Fedora, CentOS:
|
||||||
installed, err := RpmInstalled(library.Name)
|
installed, err := RpmInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v0.17.11-pre"
|
const Version = "v0.17.9-pre"
|
||||||
|
|||||||
@@ -42,12 +42,10 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
|||||||
gomodule = "(Not Set)"
|
gomodule = "(Not Set)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// get version numbers for GCC, node & npm
|
// Get versions for GCC, node & npm
|
||||||
program := cmd.NewProgramHelper()
|
program := cmd.NewProgramHelper()
|
||||||
// string helpers
|
|
||||||
var gccVersion, nodeVersion, npmVersion string
|
var gccVersion, nodeVersion, npmVersion string
|
||||||
|
|
||||||
// choose between OS (mac,linux,win)
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
gcc := program.FindProgram("gcc")
|
gcc := program.FindProgram("gcc")
|
||||||
@@ -56,25 +54,14 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
|||||||
gccVersion = strings.TrimSpace(stdout)
|
gccVersion = strings.TrimSpace(stdout)
|
||||||
}
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
// for linux we have to collect
|
gcc := program.FindProgram("gcc")
|
||||||
// the distribution name
|
if gcc != nil {
|
||||||
distroInfo := cmd.GetLinuxDistroInfo()
|
gccVersion, _, _, _ := gcc.Run("-dumpfullversion")
|
||||||
linuxDB := cmd.NewLinuxDB()
|
gccVersion = gccVersion[:len(gccVersion)-1]
|
||||||
distro := linuxDB.GetDistro(distroInfo.ID)
|
gccVersion = strings.TrimSpace(gccVersion)
|
||||||
release := distro.GetRelease(distroInfo.Release)
|
}
|
||||||
gccVersionCommand := release.GccVersionCommand
|
|
||||||
|
|
||||||
gcc := program.FindProgram("gcc")
|
// TODO: windows support
|
||||||
if gcc != nil {
|
|
||||||
stdout, _, _, _ := gcc.Run(gccVersionCommand)
|
|
||||||
gccVersion = strings.TrimSpace(stdout)
|
|
||||||
}
|
|
||||||
case "windows":
|
|
||||||
gcc := program.FindProgram("gcc")
|
|
||||||
if gcc != nil {
|
|
||||||
stdout, _, _, _ := gcc.Run("-dumpversion")
|
|
||||||
gccVersion = strings.TrimSpace(stdout)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
npm := program.FindProgram("npm")
|
npm := program.FindProgram("npm")
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -27,5 +27,4 @@ require (
|
|||||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
|
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
|
||||||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862
|
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862
|
||||||
gopkg.in/AlecAivazis/survey.v1 v1.8.4
|
gopkg.in/AlecAivazis/survey.v1 v1.8.4
|
||||||
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
|
|
||||||
)
|
)
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -89,7 +89,3 @@ golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
gopkg.in/AlecAivazis/survey.v1 v1.8.4 h1:10xXXN3wgIhPheb5NI58zFgZv32Ana7P3Tl4shW+0Qc=
|
gopkg.in/AlecAivazis/survey.v1 v1.8.4 h1:10xXXN3wgIhPheb5NI58zFgZv32Ana7P3Tl4shW+0Qc=
|
||||||
gopkg.in/AlecAivazis/survey.v1 v1.8.4/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA=
|
gopkg.in/AlecAivazis/survey.v1 v1.8.4/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 h1:0efs3hwEZhFKsCoP8l6dDB1AZWMgnEl3yWXWRZTOaEA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
|||||||
Reference in New Issue
Block a user