mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 22:13:36 +08:00

* Support Distribution 'ArcoLinux' #310 (#312) * Support Distribution 'ArcoLinux' #310 * Vuetify2 support (resurrected from git@github.com:MichaelHipp/wails.git) (#315) * Initial create of vuetify2-basic folder * Change template descr of vuetify-basic to say Vuetify 1.5 * Get vuetify2 template installing vuetify v2.0 (but with styling probs) * Update App.vue, HelloWorld.vue for Vuetify v2 * Remove babel-polyfill, add mdi/font * fix: codacy corrections * fix: babel -> core-js, regenerator-runtime Co-authored-by: Michael Hipp <michael@redmule.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com> * Update Contributors * v1.0.2-pre1 * [313-remote-conn] allow remote connections to the websocket bridge (#314) * [313-remote-conn] feat: compute wsURL based on window.location * [313-remote-conn] feat: allow any host to connect to vue server removing the 'host: "localhost"' specification causes the development server to listen on all interfaces. * [313-remote-conn] feat: allow any host to connect to angular dev server * test: reinject tabs Co-authored-by: Lea Anthony <lea.anthony@gmail.com> * fix: disable host check for vuetify 2 template * v1.0.2-pre2 * fix: shutdown ipcmanager * use channel to trigger shutdown * load linuxdb from relative path * Feat manjaro arm & deepin (#324) * feat: new distros: manjaroARM & Deepin * v1.0.2-pre3 * [326-platform-raspbian] feat: implement raspbian support (#327) * fix: emit arguments (#306) * v1.0.2-pre4 Raspbarian support * Initial support for Typescript decl file (#330) * v1.0.2-pre5 * revert to Go 1.12 * New CI (#331) * prepare * new CI/github actions * Rename later-pre.yml to latest-pre.yml * Update latest-pre.yml * Update README.md * Ensure version in go.mod is up to date (#339) * release v1.0.2-pre6 * Fix typescript generation * Release v1.0.2-pre7 * 316-multi-bridge-conn (#317) * [316-multi-bridge-conn] feat: use callback func for bridge response * [316-multi-bridge-conn] feat: implement multiple session support * split client handling portion into 'session' * keep track of sessions by remote address (ip & port) * notify each of the sessions anytime an event comes across the bus * [316-multi-bridge-conn] chore: move bridge files to package * [316-multi-bridge-conn] chore: remove deprecated Callback function The Callback function is no longer needed for the operation of the frontend callback since the ipc.Dispatch function now requires a callback function to be provided as an argument. This function can be a private function since it is passed by reference. * [316-multi-bridge-conn] chore: make webview.Callback private * [316-multi-bridge-conn] chore: remove unused injectCSS function I believe a slightly better method of doing this might need to be devised if it is needed in the future. I presume it should collect the values into a cache and then inject it into each sesssion as it appears. * [316-multi-bridge-conn] ensure wails:ready event is emitted Event is only emitted for the first session created from the Bridge. * [316-multi-bridge-conn] emit events for session lifecycle Emit an event for each session started and ended. * [316-multi-bridge-conn] fix: session handling fixes Co-authored-by: Lea Anthony <lea.anthony@gmail.com> * Release v1.0.2-pre8 * Release v1.0.2 Co-authored-by: Byron <ktc@protonmail.com> Co-authored-by: Travis McLane <tmclane@gmail.com> Co-authored-by: Michael Hipp <michael@redmule.com>
259 lines
7.1 KiB
Go
259 lines
7.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/url"
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/pkg/browser"
|
|
)
|
|
|
|
// LinuxDistribution is of type int
|
|
type LinuxDistribution int
|
|
|
|
const (
|
|
// Unknown is the catch-all distro
|
|
Unknown LinuxDistribution = iota
|
|
// Debian distribution
|
|
Debian
|
|
// Ubuntu distribution
|
|
Ubuntu
|
|
// Arch linux distribution
|
|
Arch
|
|
// CentOS linux distribution
|
|
CentOS
|
|
// Fedora linux distribution
|
|
Fedora
|
|
// Gentoo distribution
|
|
Gentoo
|
|
// Zorin distribution
|
|
Zorin
|
|
// Parrot distribution
|
|
Parrot
|
|
// Linuxmint distribution
|
|
Linuxmint
|
|
// VoidLinux distribution
|
|
VoidLinux
|
|
// Elementary distribution
|
|
Elementary
|
|
// Kali distribution
|
|
Kali
|
|
// Neon distribution
|
|
Neon
|
|
// ArcoLinux distribution
|
|
ArcoLinux
|
|
// Manjaro distribution
|
|
Manjaro
|
|
// ManjaroARM distribution
|
|
ManjaroARM
|
|
// Deepin distribution
|
|
Deepin
|
|
// Raspbian distribution
|
|
Raspbian
|
|
)
|
|
|
|
// DistroInfo contains all the information relating to a linux distribution
|
|
type DistroInfo struct {
|
|
Distribution LinuxDistribution
|
|
Name string
|
|
ID string
|
|
Description string
|
|
Release string
|
|
}
|
|
|
|
// GetLinuxDistroInfo returns information about the running linux distribution
|
|
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}
|
|
|
|
// Default value
|
|
osID := "unknown"
|
|
osNAME := "Unknown"
|
|
version := ""
|
|
|
|
// 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] {
|
|
case "ID":
|
|
osID = strings.Trim(splitLine[1], "\"")
|
|
case "NAME":
|
|
osNAME = strings.Trim(splitLine[1], "\"")
|
|
case "VERSION_ID":
|
|
version = strings.Trim(splitLine[1], "\"")
|
|
}
|
|
}
|
|
|
|
// Check distro name against list of distros
|
|
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
|
|
case "linuxmint":
|
|
result.Distribution = Linuxmint
|
|
case "void":
|
|
result.Distribution = VoidLinux
|
|
case "elementary":
|
|
result.Distribution = Elementary
|
|
case "kali":
|
|
result.Distribution = Kali
|
|
case "neon":
|
|
result.Distribution = Neon
|
|
case "arcolinux":
|
|
result.Distribution = ArcoLinux
|
|
case "manjaro":
|
|
result.Distribution = Manjaro
|
|
case "manjaro-arm":
|
|
result.Distribution = ManjaroARM
|
|
case "deepin":
|
|
result.Distribution = Deepin
|
|
case "raspbian":
|
|
result.Distribution = Raspbian
|
|
default:
|
|
result.Distribution = Unknown
|
|
}
|
|
|
|
result.Name = osNAME
|
|
result.ID = osID
|
|
result.Release = version
|
|
|
|
return result
|
|
}
|
|
|
|
// CheckPkgInstalled is all functions that use local programs to see if a package is installed
|
|
type CheckPkgInstalled func(string) (bool, error)
|
|
|
|
// EqueryInstalled uses equery to see if a package is installed
|
|
func EqueryInstalled(packageName string) (bool, error) {
|
|
program := NewProgramHelper()
|
|
equery := program.FindProgram("equery")
|
|
if equery == nil {
|
|
return false, fmt.Errorf("cannont check dependencies: equery not found")
|
|
}
|
|
_, _, exitCode, _ := equery.Run("l", packageName)
|
|
return exitCode == 0, nil
|
|
}
|
|
|
|
// DpkgInstalled uses dpkg to see if a package is installed
|
|
func DpkgInstalled(packageName string) (bool, error) {
|
|
program := NewProgramHelper()
|
|
dpkg := program.FindProgram("dpkg")
|
|
if dpkg == nil {
|
|
return false, fmt.Errorf("cannot check dependencies: dpkg not found")
|
|
}
|
|
_, _, exitCode, _ := dpkg.Run("-L", packageName)
|
|
return exitCode == 0, nil
|
|
}
|
|
|
|
// PacmanInstalled uses pacman to see if a package is installed.
|
|
func PacmanInstalled(packageName string) (bool, error) {
|
|
program := NewProgramHelper()
|
|
pacman := program.FindProgram("pacman")
|
|
if pacman == nil {
|
|
return false, fmt.Errorf("cannot check dependencies: pacman not found")
|
|
}
|
|
_, _, exitCode, _ := pacman.Run("-Qs", packageName)
|
|
return exitCode == 0, nil
|
|
}
|
|
|
|
// XbpsInstalled uses pacman to see if a package is installed.
|
|
func XbpsInstalled(packageName string) (bool, error) {
|
|
program := NewProgramHelper()
|
|
xbpsQuery := program.FindProgram("xbps-query")
|
|
if xbpsQuery == nil {
|
|
return false, fmt.Errorf("cannot check dependencies: xbps-query not found")
|
|
}
|
|
_, _, exitCode, _ := xbpsQuery.Run("-S", packageName)
|
|
return exitCode == 0, nil
|
|
}
|
|
|
|
// RpmInstalled uses rpm to see if a package is installed
|
|
func RpmInstalled(packageName string) (bool, error) {
|
|
program := NewProgramHelper()
|
|
rpm := program.FindProgram("rpm")
|
|
if rpm == nil {
|
|
return false, fmt.Errorf("cannot check dependencies: rpm not found")
|
|
}
|
|
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
|
return exitCode == 0, nil
|
|
}
|
|
|
|
// RequestSupportForDistribution promts the user to submit a request to support their
|
|
// currently unsupported distribution
|
|
func RequestSupportForDistribution(distroInfo *DistroInfo) error {
|
|
var logger = NewLogger()
|
|
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'", distroInfo.Name)
|
|
|
|
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.Name)
|
|
|
|
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.ID))
|
|
str.WriteString(fmt.Sprintf("| Distribution Name | %s |\n", distroInfo.Name))
|
|
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
|
|
|
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
|
|
}
|