5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:13:36 +08:00
wails/v2/internal/system/packagemanager/pm.go
Ian M. Jones 82cc5498f1
Add nixpkgs support to doctor command. (#1551)
* Dependancy => Dependency typo fix.

* Add Nixpkgs support to doctor command.

* Add mention of nixpkgs to linux distro support doc.
2022-07-13 07:29:41 +10:00

63 lines
1.6 KiB
Go

package packagemanager
// Package contains information about a system package
type Package struct {
Name string
Version string
InstallCommand map[string]string
SystemPackage bool
Library bool
Optional bool
}
type packagemap = map[string][]*Package
// PackageManager is a common interface across all package managers
type PackageManager interface {
Name() string
Packages() packagemap
PackageInstalled(*Package) (bool, error)
PackageAvailable(*Package) (bool, error)
InstallCommand(*Package) string
}
// Dependency represents a system package that we require
type Dependency struct {
Name string
PackageName string
Installed bool
InstallCommand string
Version string
Optional bool
External bool
}
// DependencyList is a list of Dependency instances
type DependencyList []*Dependency
// InstallAllRequiredCommand returns the command you need to use to install all required dependencies
func (d DependencyList) InstallAllRequiredCommand() string {
result := ""
for _, dependency := range d {
if !dependency.Installed && !dependency.Optional {
result += " - " + dependency.Name + ": " + dependency.InstallCommand + "\n"
}
}
return result
}
// InstallAllOptionalCommand returns the command you need to use to install all optional dependencies
func (d DependencyList) InstallAllOptionalCommand() string {
result := ""
for _, dependency := range d {
if !dependency.Installed && dependency.Optional {
result += " - " + dependency.Name + ": " + dependency.InstallCommand + "\n"
}
}
return result
}