diff --git a/v3/internal/commands/build_assets/Taskfile.linux.yml b/v3/internal/commands/build_assets/Taskfile.linux.yml index 814ee0ae130..74ae5eaaef6 100644 --- a/v3/internal/commands/build_assets/Taskfile.linux.yml +++ b/v3/internal/commands/build_assets/Taskfile.linux.yml @@ -28,6 +28,9 @@ tasks: PRODUCTION: "true" cmds: - task: create:appimage + - task: create:deb + - task: create:rpm + - task: create:aur create:appimage: summary: Creates an AppImage @@ -48,6 +51,48 @@ tasks: DESKTOP_FILE: '{{.APP_NAME}}.desktop' OUTPUT_DIR: '../../bin' + create:deb: + summary: Creates a deb package + deps: + - task: build + vars: + PRODUCTION: "true" + cmds: + - task: generate:deb + + create:rpm: + summary: Creates a rpm package + deps: + - task: build + vars: + PRODUCTION: "true" + cmds: + - task: generate:rpm + + create:aur: + summary: Creates a arch linux packager package + deps: + - task: build + vars: + PRODUCTION: "true" + cmds: + - task: generate:aur + + generate:deb: + summary: Creates a deb package + cmds: + - nfpm pkg -f ./build/nfpm/nfpm.yaml -p deb -t ./bin/{{.APP_NAME}}.deb + + generate:rpm: + summary: Creates a rpm package + cmds: + - nfpm pkg -f ./build/nfpm/nfpm.yaml -p rpm -t ./bin/{{.APP_NAME}}.rpm + + generate:aur: + summary: Creates a arch linux packager package + cmds: + - nfpm pkg -f ./build/nfpm/nfpm.yaml -p arch -t ./bin/{{.APP_NAME}}.pkg.tar.zst + generate:dotdesktop: summary: Generates a `.desktop` file dir: build diff --git a/v3/internal/commands/updatable_build_assets/nfpm.yaml.tmpl b/v3/internal/commands/updatable_build_assets/nfpm.yaml.tmpl new file mode 100644 index 00000000000..427ffaaaac9 --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm.yaml.tmpl @@ -0,0 +1,20 @@ +name: "{{.BinaryName}}" +arch: "amd64" +platform: "linux" +version: "{{.ProductVersion}}" +section: "default" +priority: "extra" +maintainer: "{{.ProductCompany}}" +description: "{{.ProductDescription}}" +vendor: "{{.ProductCompany}}" +homepage: "https://wails.io" +license: "MIT" +release: "1" + +contents: + - src: "../../bin/{{.BinaryName}}" + dst: "/usr/bin/{{.BinaryName}}" + - src: "../appicon.png" + dst: "/usr/share/icons/hicolor/128x128/apps/{{.BinaryName}}.png" + - src: "{{.BinaryName}}.desktop" + dst: "/usr/share/applications/{{.BinaryName}}.desktop" diff --git a/v3/internal/commands/updatable_build_assets/nfpm/nfpm.yaml.tmpl b/v3/internal/commands/updatable_build_assets/nfpm/nfpm.yaml.tmpl new file mode 100644 index 00000000000..4c37eb6774e --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm/nfpm.yaml.tmpl @@ -0,0 +1,44 @@ +# Feel free to remove those if you don't want/need to use them. +# Make sure to check the documentation at https://nfpm.goreleaser.com +# +# The lines below are called `modelines`. See `:help modeline` + +name: "{{.BinaryName}}" +arch: ${GOARCH} +platform: "linux" +version: "{{.ProductVersion}}" +section: "default" +priority: "extra" +maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}> +description: "{{.ProductDescription}}" +vendor: "{{.ProductCompany}}" +homepage: "https://wails.io" +license: "MIT" +release: "1" + +contents: + - src: "./bin/{{.BinaryName}}" + dst: "/usr/local/bin/{{.BinaryName}}" + - src: "./build/appicon.png" + dst: "/usr/share/icons/hicolor/128x128/apps/{{.BinaryName}}.png" + +# replaces: +# - foobar +# provides: +# - bar +# depends: +# - foo +# - bar +# recommends: +# - whatever +# suggests: +# - something-else +# conflicts: +# - not-foo +# - not-bar +# changelog: "changelog.yaml" +# scripts: +# preinstall: ./build/nfpm/scripts/preinstall.sh +# postinstall: ./build/nfpm/scripts/postinstall.sh +# preremove: ./build/nfpm/scripts/preremove.sh +# postremove: ./build/nfpm/scripts/postremove.sh diff --git a/v3/internal/commands/updatable_build_assets/nfpm/scripts/postinstall.sh b/v3/internal/commands/updatable_build_assets/nfpm/scripts/postinstall.sh new file mode 100644 index 00000000000..a9bf588e2f8 --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm/scripts/postinstall.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/v3/internal/commands/updatable_build_assets/nfpm/scripts/postremove.sh b/v3/internal/commands/updatable_build_assets/nfpm/scripts/postremove.sh new file mode 100644 index 00000000000..a9bf588e2f8 --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm/scripts/postremove.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/v3/internal/commands/updatable_build_assets/nfpm/scripts/preinstall.sh b/v3/internal/commands/updatable_build_assets/nfpm/scripts/preinstall.sh new file mode 100644 index 00000000000..a9bf588e2f8 --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm/scripts/preinstall.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/v3/internal/commands/updatable_build_assets/nfpm/scripts/preremove.sh b/v3/internal/commands/updatable_build_assets/nfpm/scripts/preremove.sh new file mode 100644 index 00000000000..a9bf588e2f8 --- /dev/null +++ b/v3/internal/commands/updatable_build_assets/nfpm/scripts/preremove.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/v3/internal/doctor/doctor.go b/v3/internal/doctor/doctor.go index c6d3c0ca773..3e1fe948df1 100644 --- a/v3/internal/doctor/doctor.go +++ b/v3/internal/doctor/doctor.go @@ -2,7 +2,6 @@ package doctor import ( "fmt" - "github.com/wailsapp/wails/v3/internal/buildinfo" "path/filepath" "runtime" "runtime/debug" @@ -10,6 +9,8 @@ import ( "strconv" "strings" + "github.com/wailsapp/wails/v3/internal/buildinfo" + "github.com/go-git/go-git/v5" "github.com/jaypipes/ghw" "github.com/pterm/pterm" diff --git a/v3/internal/doctor/packagemanager/apt.go b/v3/internal/doctor/packagemanager/apt.go index 1a85b8376be..1f46db46970 100644 --- a/v3/internal/doctor/packagemanager/apt.go +++ b/v3/internal/doctor/packagemanager/apt.go @@ -40,6 +40,9 @@ func (a *Apt) Packages() Packagemap { "npm": []*Package{ {Name: "npm", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -54,7 +57,10 @@ func (a *Apt) listPackage(name string) (string, error) { // PackageInstalled tests if the given package name is installed func (a *Apt) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } output, err := a.listPackage(pkg.Name) @@ -64,8 +70,8 @@ func (a *Apt) PackageInstalled(pkg *Package) (bool, error) { // PackageAvailable tests if the given package is available for installation func (a *Apt) PackageAvailable(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { - return false, nil + if !pkg.SystemPackage { + return true, nil } output, err := a.listPackage(pkg.Name) // We add a space to ensure we get a full match, not partial match @@ -78,8 +84,8 @@ func (a *Apt) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (a *Apt) InstallCommand(pkg *Package) string { - if pkg.SystemPackage == false { - return pkg.InstallCommand[a.osid] + if !pkg.SystemPackage { + return pkg.InstallCommand } return "sudo apt install " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/dnf.go b/v3/internal/doctor/packagemanager/dnf.go index a98ceac7038..223845dd0a6 100644 --- a/v3/internal/doctor/packagemanager/dnf.go +++ b/v3/internal/doctor/packagemanager/dnf.go @@ -43,6 +43,9 @@ func (y *Dnf) Packages() Packagemap { {Name: "npm", SystemPackage: true}, {Name: "nodejs-npm", SystemPackage: true}, }, + "nfpm*": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -53,7 +56,10 @@ func (y *Dnf) Name() string { // PackageInstalled tests if the given package name is installed func (y *Dnf) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } stdout, err := execCmd("dnf", "info", "installed", pkg.Name) @@ -103,7 +109,7 @@ func (y *Dnf) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (y *Dnf) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[y.osid] + return pkg.InstallCommand } return "sudo dnf install " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/emerge.go b/v3/internal/doctor/packagemanager/emerge.go index 5ff21539a9a..aae18e8da06 100644 --- a/v3/internal/doctor/packagemanager/emerge.go +++ b/v3/internal/doctor/packagemanager/emerge.go @@ -41,6 +41,9 @@ func (e *Emerge) Packages() Packagemap { "npm": []*Package{ {Name: "net-libs/nodejs", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -106,7 +109,7 @@ func (e *Emerge) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (e *Emerge) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[e.osid] + return pkg.InstallCommand } return "sudo emerge " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/eopkg.go b/v3/internal/doctor/packagemanager/eopkg.go index a2dc7aa8cac..8f7d0df1d7f 100644 --- a/v3/internal/doctor/packagemanager/eopkg.go +++ b/v3/internal/doctor/packagemanager/eopkg.go @@ -7,7 +7,6 @@ import ( "strings" ) -// Eopkg represents the Eopkg manager type Eopkg struct { name string osid string @@ -42,6 +41,9 @@ func (e *Eopkg) Packages() Packagemap { "npm": []*Package{ {Name: "nodejs", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -52,7 +54,10 @@ func (e *Eopkg) Name() string { // PackageInstalled tests if the given package is installed func (e *Eopkg) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } stdout, err := execCmd("eopkg", "info", pkg.Name) @@ -75,7 +80,7 @@ func (e *Eopkg) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (e *Eopkg) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[e.osid] + return pkg.InstallCommand } return "sudo eopkg it " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/nixpkgs.go b/v3/internal/doctor/packagemanager/nixpkgs.go index 749860eba23..6d39a53a27c 100644 --- a/v3/internal/doctor/packagemanager/nixpkgs.go +++ b/v3/internal/doctor/packagemanager/nixpkgs.go @@ -55,6 +55,9 @@ func (n *Nixpkgs) Packages() Packagemap { "npm": []*Package{ {Name: channel + ".nodejs", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: channel + ".nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -65,7 +68,10 @@ func (n *Nixpkgs) Name() string { // PackageInstalled tests if the given package name is installed func (n *Nixpkgs) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } @@ -142,7 +148,7 @@ func (n *Nixpkgs) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (n *Nixpkgs) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[n.osid] + return pkg.InstallCommand } return "nix-env -iA " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/packagemanager.go b/v3/internal/doctor/packagemanager/packagemanager.go index 800b05f7a93..3d95291613d 100644 --- a/v3/internal/doctor/packagemanager/packagemanager.go +++ b/v3/internal/doctor/packagemanager/packagemanager.go @@ -134,6 +134,10 @@ func AppVersion(name string) string { return npmVersion() } + if name == "nfpm" { + return nfpmVersion() + } + return "" } @@ -167,3 +171,20 @@ func npmVersion() string { version, _ := execCmd("npm", "--version") return strings.TrimSpace(version) } + +func nfpmVersion() string { + output, _ := execCmd("nfpm", "--version") + lines := strings.Split(output, "\n") + for _, line := range lines { + if strings.HasPrefix(line, "GitVersion:") { + version := strings.TrimSpace(strings.TrimPrefix(line, "GitVersion:")) + return version + } + } + return "unknown" +} + +func isNfpmInstalled() bool { + _, err := exec.LookPath("nfpm") + return err == nil +} diff --git a/v3/internal/doctor/packagemanager/pacman.go b/v3/internal/doctor/packagemanager/pacman.go index d585f94f770..131a6a8b685 100644 --- a/v3/internal/doctor/packagemanager/pacman.go +++ b/v3/internal/doctor/packagemanager/pacman.go @@ -41,6 +41,9 @@ func (p *Pacman) Packages() Packagemap { "npm": []*Package{ {Name: "npm", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -51,7 +54,10 @@ func (p *Pacman) Name() string { // PackageInstalled tests if the given package name is installed func (p *Pacman) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } stdout, err := execCmd("pacman", "-Q", pkg.Name) @@ -103,7 +109,7 @@ func (p *Pacman) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (p *Pacman) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[p.osid] + return pkg.InstallCommand } return "sudo pacman -S " + pkg.Name } diff --git a/v3/internal/doctor/packagemanager/pm.go b/v3/internal/doctor/packagemanager/pm.go index 0602e1e03fa..6b6ced9c003 100644 --- a/v3/internal/doctor/packagemanager/pm.go +++ b/v3/internal/doctor/packagemanager/pm.go @@ -6,7 +6,8 @@ package packagemanager type Package struct { Name string Version string - InstallCommand map[string]string + InstallCommand string + InstallCheck func() bool SystemPackage bool Library bool Optional bool diff --git a/v3/internal/doctor/packagemanager/zypper.go b/v3/internal/doctor/packagemanager/zypper.go index dec28acb252..3a350e89578 100644 --- a/v3/internal/doctor/packagemanager/zypper.go +++ b/v3/internal/doctor/packagemanager/zypper.go @@ -44,6 +44,9 @@ func (z *Zypper) Packages() Packagemap { "npm": []*Package{ {Name: "npm10", SystemPackage: true}, }, + "nfpm": []*Package{ + {Name: "nfpm", SystemPackage: false, InstallCheck: isNfpmInstalled, InstallCommand: "go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest", Optional: true}, + }, } } @@ -54,7 +57,10 @@ func (z *Zypper) Name() string { // PackageInstalled tests if the given package name is installed func (z *Zypper) PackageInstalled(pkg *Package) (bool, error) { - if pkg.SystemPackage == false { + if !pkg.SystemPackage { + if pkg.InstallCheck != nil { + return pkg.InstallCheck(), nil + } return false, nil } stdout, err := execCmd("zypper", "info", pkg.Name) @@ -101,7 +107,7 @@ func (z *Zypper) PackageAvailable(pkg *Package) (bool, error) { // InstallCommand returns the package manager specific command to install a package func (z *Zypper) InstallCommand(pkg *Package) string { if pkg.SystemPackage == false { - return pkg.InstallCommand[z.osid] + return pkg.InstallCommand } return "sudo zypper in " + pkg.Name }