add archlinux support

This commit is contained in:
Adrian Lanzafame 2019-05-02 13:35:34 +10:00
commit b015f27e14
No known key found for this signature in database
GPG key ID: 87E40C5D62EAE192
3 changed files with 31 additions and 2 deletions

View file

@ -10,9 +10,11 @@ type LinuxDistribution int
const (
// Unknown is the catch-all distro
Unknown LinuxDistribution = 0
Unknown LinuxDistribution = iota
// Ubuntu distribution
Ubuntu LinuxDistribution = 1
Ubuntu
// Arch linux distribution
Arch
)
// DistroInfo contains all the information relating to a linux distribution
@ -49,6 +51,8 @@ func GetLinuxDistroInfo() *DistroInfo {
switch value {
case "Ubuntu":
result.Distribution = Ubuntu
case "Arch":
result.Distribution = Arch
}
case "Description":
result.Description = value
@ -75,3 +79,14 @@ func DpkgInstalled(packageName string) (bool, error) {
_, _, 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
}

View file

@ -97,6 +97,9 @@ func getRequiredLibrariesLinux() (*Prerequisites, error) {
case Ubuntu:
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 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"))
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"))

View file

@ -272,6 +272,17 @@ func CheckDependencies(logger *Logger) (bool, error) {
} else {
logger.Green("Library '%s' installed.", library.Name)
}
case Arch:
installed, err := PacmanInstalled(library.Name)
if err != nil {
return false, err
}
if !installed {
errors = true
logger.Red("Library '%s' not found. %s", library.Name, library.Help)
} else {
logger.Green("Library '%s' installed.", library.Name)
}
default:
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
}