5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-05 04:19:45 +08:00

Merge branch 'develop' of github.com:wailsapp/wails into develop

This commit is contained in:
Lea Anthony 2019-08-25 15:59:02 +10:00
commit a5f9688708
3 changed files with 31 additions and 50 deletions

View File

@ -120,6 +120,9 @@ func parseOsRelease(osRelease string) *DistroInfo {
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()
@ -166,9 +169,9 @@ func RpmInstalled(packageName string) (bool, error) {
// RequestSupportForDistribution promts the user to submit a request to support their
// currently unsupported distribution
func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
func RequestSupportForDistribution(distroInfo *DistroInfo) error {
var logger = NewLogger()
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.Name, libraryName)
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)

View File

@ -269,44 +269,25 @@ func CheckDependencies(logger *Logger) (bool, error) {
if err != nil {
return false, err
}
var libraryChecker CheckPkgInstalled
distroInfo := GetLinuxDistroInfo()
for _, library := range *requiredLibraries {
switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint:
installed, err := DpkgInstalled(library.Name)
if err != nil {
return false, err
}
if !installed {
errors = true
logger.Error("Library '%s' not found. %s", library.Name, library.Help)
} else {
logger.Green("Library '%s' installed.", library.Name)
}
libraryChecker = DpkgInstalled
case Arch:
installed, err := PacmanInstalled(library.Name)
if err != nil {
return false, err
}
if !installed {
errors = true
logger.Error("Library '%s' not found. %s", library.Name, library.Help)
} else {
logger.Green("Library '%s' installed.", library.Name)
}
libraryChecker = PacmanInstalled
case CentOS, Fedora:
installed, err := RpmInstalled(library.Name)
if err != nil {
return false, err
}
if !installed {
errors = true
logger.Error("Library '%s' not found. %s", library.Name, library.Help)
} else {
logger.Green("Library '%s' installed.", library.Name)
}
libraryChecker = RpmInstalled
case Gentoo:
installed, err := EqueryInstalled(library.Name)
libraryChecker = EqueryInstalled
default:
return false, RequestSupportForDistribution(distroInfo)
}
for _, library := range *requiredLibraries {
installed, err := libraryChecker(library.Name)
if err != nil {
return false, err
}
@ -316,9 +297,6 @@ func CheckDependencies(logger *Logger) (bool, error) {
} else {
logger.Green("Library '%s' installed.", library.Name)
}
default:
return false, RequestSupportForDistribution(distroInfo, library.Name)
}
}
}
logger.White("")

View File

@ -108,7 +108,7 @@ func checkLibraries() (errors bool, err error) {
logger.Green("Library '%s' installed.", library.Name)
}
default:
return false, cmd.RequestSupportForDistribution(distroInfo, library.Name)
return false, cmd.RequestSupportForDistribution(distroInfo)
}
}
}