Feature/linux v2 beta (#1171)

* Update docusaurus version

* Add install instructions

* Add Linus Distro Support Page

* Update Linus Distro Support Page

* v2.0.0-beta.30

* image

* update blog

* Update blog

* Remove exp tag

* Update banner

* Update banner

* [linux] Fix warning
This commit is contained in:
Lea Anthony
2022-02-22 21:35:03 +11:00
committed by GitHub
parent fff838d7c6
commit a445db1b7b
11 changed files with 236 additions and 19 deletions
+5 -1
View File
@@ -58,7 +58,11 @@ import TabItem from "@theme/TabItem";
runtime is installed. Some Windows installations will already have this installed. You can check using the{" "}
<code>wails doctor</code> command (see below).
</TabItem>
<TabItem value="Linux">Coming Soon...</TabItem>
<TabItem value="Linux">Linux required the standard <code>gcc</code> build tools plus <code>libgtk3</code> and <code>libwebkit</code>.
Rather than list a ton of commands for different distros, Wails can try to determine
what the installation commands are for your specific distribution. Run <code>wails doctor</code> after installation
to be shown how to install the dependencies. If your distro/package manager is not supported, please consult the
<a href="/docs/guides/linux-distro-support"> Add Linux Distro</a> guide.</TabItem>
</Tabs>
## Optional Dependencies
@@ -0,0 +1,107 @@
# Linux Distro Support
## Overview
Wails offers Linux support but providing installation instructions for all available distributions is an impossible task.
Instead, Wails tries to determine if the packages you need to develop applications are available via your system's package
manager. Currently, we support the following package managers:
- apt
- dnf
- emerge
- eopkg
- pacman
- zypper
## Adding package names
There may be circumstances where your distro uses one of the supported package managers but the package name
is different. For example, you may use an Ubuntu derivative, but the package name for gtk may be different. Wails
attempts to find the correct package by iterating through a list of package names.
The list of packages are stored in the packagemanager specific file in the `v2/internal/system/packagemanager`
directory. In our example, this would be `v2/internal/system/packagemanager/apt.go`.
In this file, the list of packages are defined by the `Packages()` method:
```go
func (a *Apt) Packages() packagemap {
return packagemap{
"libgtk-3": []*Package{
{Name: "libgtk-3-dev", SystemPackage: true, Library: true},
},
"libwebkit": []*Package{
{Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true},
},
"gcc": []*Package{
{Name: "build-essential", SystemPackage: true},
},
"pkg-config": []*Package{
{Name: "pkg-config", SystemPackage: true},
},
"npm": []*Package{
{Name: "npm", SystemPackage: true},
},
"docker": []*Package{
{Name: "docker.io", SystemPackage: true, Optional: true},
},
}
}
```
Let's assume that in our linux distro, `libgtk-3` is packaged under the name `lib-gtk3-dev`.
We could add support for this by adding the following line:
```go {5}
func (a *Apt) Packages() packagemap {
return packagemap{
"libgtk-3": []*Package{
{Name: "libgtk-3-dev", SystemPackage: true, Library: true},
{Name: "lib-gtk3-dev", SystemPackage: true, Library: true},
},
"libwebkit": []*Package{
{Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true},
},
"gcc": []*Package{
{Name: "build-essential", SystemPackage: true},
},
"pkg-config": []*Package{
{Name: "pkg-config", SystemPackage: true},
},
"npm": []*Package{
{Name: "npm", SystemPackage: true},
},
"docker": []*Package{
{Name: "docker.io", SystemPackage: true, Optional: true},
},
}
}
```
## Adding new package managers
To add a new package manager, perform the following steps:
- Create a new file in `v2/internal/system/packagemanager` called `<pm>.go`, where `<pm>` is the name of the package manager.
- Define a struct that conforms to the package manager interface defined in `pm.go`:
```go
type PackageManager interface {
Name() string
Packages() packagemap
PackageInstalled(*Package) (bool, error)
PackageAvailable(*Package) (bool, error)
InstallCommand(*Package) string
}
```
- `Name()` should return the name of the package manager
- `Packages()` should return a `packagemap`, that provides candidate filenames for dependencies
- `PackageInstalled()` should return `true` if the given package is installed
- `PackageAvailable()` should return `true` if the given package is not installed but available for installation
- `InstallCommand()` should return the exact command to install the given package name
Take a look at the other package managers code to get an idea how this works.
:::info Remember
If you add support for a new package manager, don't forget to also update this page!
:::