mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Linux db (#182)
* feat: refactor linux distro detection * linux db updates * feat: add gccversioncommand + windows support * fix: build-essential
This commit is contained in:
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -4,6 +4,13 @@
|
|||||||
// 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",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
40
cmd/linux.go
40
cmd/linux.go
@@ -42,23 +42,35 @@ 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}
|
result := &DistroInfo{
|
||||||
|
Distribution: Unknown,
|
||||||
|
ID: "unknown",
|
||||||
|
Name: "Unknown",
|
||||||
|
}
|
||||||
_, err := os.Stat("/etc/os-release")
|
_, err := os.Stat("/etc/os-release")
|
||||||
if !os.IsNotExist(err) {
|
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}
|
||||||
|
|
||||||
// Default value
|
// Default value
|
||||||
osID := "unknown"
|
osID := "unknown"
|
||||||
osNAME := "Unknown"
|
osNAME := "Unknown"
|
||||||
version := ""
|
version := ""
|
||||||
// read /etc/os-release
|
|
||||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
|
||||||
// Split into lines
|
// Split into lines
|
||||||
lines := strings.Split(string(osRelease), "\n")
|
lines := strings.Split(osRelease, "\n")
|
||||||
// Iterate lines
|
// Iterate lines
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
// Split each line by the equals char
|
// Split each line by the equals char
|
||||||
@@ -75,22 +87,20 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
case "VERSION_ID":
|
case "VERSION_ID":
|
||||||
version = strings.Trim(splitLine[1], "\"")
|
version = strings.Trim(splitLine[1], "\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Check distro name against list of distros
|
// Check distro name against list of distros
|
||||||
result.Release = version
|
result.Release = version
|
||||||
result.DiscoveredBy = "/etc/os-release"
|
|
||||||
switch osID {
|
switch osID {
|
||||||
case "debian":
|
|
||||||
result.Distribution = Debian
|
|
||||||
case "ubuntu":
|
|
||||||
result.Distribution = Ubuntu
|
|
||||||
case "arch":
|
|
||||||
result.Distribution = Arch
|
|
||||||
case "fedora":
|
case "fedora":
|
||||||
result.Distribution = Fedora
|
result.Distribution = Fedora
|
||||||
case "centos":
|
case "centos":
|
||||||
result.Distribution = CentOS
|
result.Distribution = CentOS
|
||||||
|
case "arch":
|
||||||
|
result.Distribution = Arch
|
||||||
|
case "debian":
|
||||||
|
result.Distribution = Debian
|
||||||
|
case "ubuntu":
|
||||||
|
result.Distribution = Ubuntu
|
||||||
case "gentoo":
|
case "gentoo":
|
||||||
result.Distribution = Gentoo
|
result.Distribution = Gentoo
|
||||||
case "zorin":
|
case "zorin":
|
||||||
@@ -103,7 +113,6 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
|
|
||||||
result.ID = osID
|
result.ID = osID
|
||||||
result.Name = osNAME
|
result.Name = osNAME
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +191,6 @@ 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?"
|
||||||
|
|||||||
26
cmd/linux_test.go
Normal file
26
cmd/linux_test.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
91
cmd/linuxdb.go
Normal file
91
cmd/linuxdb.go
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
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
Normal file
124
cmd/linuxdb.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
---
|
||||||
|
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
|
||||||
81
cmd/linuxdb_test.go
Normal file
81
cmd/linuxdb_test.go
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
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,13 +5,6 @@ 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}
|
||||||
}
|
}
|
||||||
@@ -48,43 +41,13 @@ func getRequiredProgramsOSX() *Prerequisites {
|
|||||||
func getRequiredProgramsLinux() *Prerequisites {
|
func getRequiredProgramsLinux() *Prerequisites {
|
||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
if distroInfo.Distribution != Unknown {
|
||||||
case Debian:
|
var linuxDB = NewLinuxDB()
|
||||||
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
distro := linuxDB.GetDistro(distroInfo.ID)
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
release := distro.GetRelease(distroInfo.Release)
|
||||||
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"))
|
for _, program := range release.Programs {
|
||||||
case Ubuntu:
|
result.Add(program)
|
||||||
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 Arch:
|
|
||||||
result.Add(newPrerequisite("gcc", "Please install with `sudo pacman -S base-devel` and try again"))
|
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with `sudo pacman -S base-devel` and try again"))
|
|
||||||
result.Add(newPrerequisite("npm", "Please install with `pacman -S npm 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"))
|
|
||||||
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 Gentoo:
|
|
||||||
result.Add(newPrerequisite("gcc", "Please install with `sudo emerge gcc make` and try again"))
|
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with `sudo emerge pkg-config` and try again"))
|
|
||||||
result.Add(newPrerequisite("npm", "Please install with `sudo emerge 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 Parrot:
|
|
||||||
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 apt install npm 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
|
||||||
}
|
}
|
||||||
@@ -118,35 +81,15 @@ func getRequiredLibrariesOSX() (*Prerequisites, error) {
|
|||||||
|
|
||||||
func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
|
// The Linux Distribution DB
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
if distroInfo.Distribution != Unknown {
|
||||||
case Debian:
|
var linuxDB = NewLinuxDB()
|
||||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
distro := linuxDB.GetDistro(distroInfo.ID)
|
||||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
release := distro.GetRelease(distroInfo.Release)
|
||||||
case Ubuntu:
|
for _, library := range release.Libraries {
|
||||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
result.Add(library)
|
||||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` 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 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"))
|
|
||||||
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 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 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 Parrot:
|
|
||||||
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"))
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,24 +58,23 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
|||||||
case "linux":
|
case "linux":
|
||||||
// for linux we have to collect
|
// for linux we have to collect
|
||||||
// the distribution name
|
// the distribution name
|
||||||
distro := cmd.GetLinuxDistroInfo()
|
distroInfo := cmd.GetLinuxDistroInfo()
|
||||||
// and use it as nested switch
|
linuxDB := cmd.NewLinuxDB()
|
||||||
switch distro.ID {
|
distro := linuxDB.GetDistro(distroInfo.ID)
|
||||||
default: // most supported distros are printing the right result with just 'gcc -dumpversion'
|
release := distro.GetRelease(distroInfo.Release)
|
||||||
|
gccVersionCommand := release.GccVersionCommand
|
||||||
|
|
||||||
|
gcc := program.FindProgram("gcc")
|
||||||
|
if gcc != nil {
|
||||||
|
stdout, _, _, _ := gcc.Run(gccVersionCommand)
|
||||||
|
gccVersion = strings.TrimSpace(stdout)
|
||||||
|
}
|
||||||
|
case "windows":
|
||||||
gcc := program.FindProgram("gcc")
|
gcc := program.FindProgram("gcc")
|
||||||
if gcc != nil {
|
if gcc != nil {
|
||||||
stdout, _, _, _ := gcc.Run("-dumpversion")
|
stdout, _, _, _ := gcc.Run("-dumpversion")
|
||||||
gccVersion = strings.TrimSpace(stdout)
|
gccVersion = strings.TrimSpace(stdout)
|
||||||
}
|
}
|
||||||
case "fedora", "ubuntu": // except fedora & ubuntu that require 'gcc -dumpfullversion'
|
|
||||||
gcc := program.FindProgram("gcc")
|
|
||||||
if gcc != nil {
|
|
||||||
stdout, _, _, _ := gcc.Run("-dumpfullversion")
|
|
||||||
gccVersion = strings.TrimSpace(stdout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: windows support
|
|
||||||
}
|
}
|
||||||
|
|
||||||
npm := program.FindProgram("npm")
|
npm := program.FindProgram("npm")
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -27,4 +27,5 @@ 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,3 +89,7 @@ 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