From 8d7f7630950a42bf81e73faf9acba6729472b81d Mon Sep 17 00:00:00 2001 From: atterpac Date: Sat, 23 Nov 2024 19:44:05 -0700 Subject: [PATCH] package tool fixes and add bundle name field empty name guard --- .../commands/build_assets/Taskfile.linux.yml | 28 ++++--------------- v3/internal/commands/tool_package.go | 10 ++++++- v3/internal/flags/package.go | 5 ++-- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/v3/internal/commands/build_assets/Taskfile.linux.yml b/v3/internal/commands/build_assets/Taskfile.linux.yml index bfd0250be04..2b2a46a81e6 100644 --- a/v3/internal/commands/build_assets/Taskfile.linux.yml +++ b/v3/internal/commands/build_assets/Taskfile.linux.yml @@ -28,10 +28,9 @@ tasks: PRODUCTION: "true" cmds: - task: create:appimage - # Requires nfpm to be installed - # - task: create:deb - # - task: create:rpm - # - task: create:aur + - task: create:deb + - task: create:rpm + - task: create:aur create:appimage: summary: Creates an AppImage @@ -81,33 +80,18 @@ tasks: generate:deb: summary: Creates a deb package - preconditions: - - sh: nfpm --version - msg: It appears nfpm is not installed. Please install using `go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest` cmds: - - nfpm pkg -f ./build/nfpm/nfpm.yaml -p deb -t ./bin/{{.APP_NAME}}.deb - env: - GOARCH: '{{.ARCH | default ARCH}}' + - wails3 tool package -name {{.APP_NAME}} -format deb -config ./build/nfpm/nfpm.yaml generate:rpm: summary: Creates a rpm package - preconditions: - - sh: nfpm --version - msg: It appears nfpm is not installed. Please install using `go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest` cmds: - - nfpm pkg -f ./build/nfpm/nfpm.yaml -p rpm -t ./bin/{{.APP_NAME}}.rpm - env: - GOARCH: '{{.ARCH | default ARCH}}' + - wails3 tool package -name {{.APP_NAME}} -format rpm -config ./build/nfpm/nfpm.yaml generate:aur: summary: Creates a arch linux packager package - preconditions: - - sh: nfpm --version - msg: It appears nfpm is not installed. Please install using `go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest` cmds: - - nfpm pkg -f ./build/nfpm/nfpm.yaml -p arch -t ./bin/{{.APP_NAME}}.pkg.tar.zst - env: - GOARCH: '{{.ARCH | default ARCH}}' + - wails3 tool package -name {{.APP_NAME}} -format arch -config ./build/nfpm/nfpm.yaml generate:dotdesktop: summary: Generates a `.desktop` file diff --git a/v3/internal/commands/tool_package.go b/v3/internal/commands/tool_package.go index 66f3d2d251c..0ea07e79691 100644 --- a/v3/internal/commands/tool_package.go +++ b/v3/internal/commands/tool_package.go @@ -18,6 +18,10 @@ func ToolPackage(options *flags.ToolPackage) error { return fmt.Errorf("please provide a config file using the -config flag") } + if options.ExecutableName == "" { + return fmt.Errorf("please provide an executable name using the -name flag") + } + // Validate format var pkgType packager.PackageType switch strings.ToLower(options.Format) { @@ -43,7 +47,11 @@ func ToolPackage(options *flags.ToolPackage) error { } // Generate output filename based on format - outputFile := fmt.Sprintf("package.%s", options.Format) + if options.Format == "archlinux" { + // Arch linux packages are not .archlinux files, they are .pkg.tar.zst + options.Format = "pkg.tar.zst" + } + outputFile := fmt.Sprintf("./bin/%s.%s", options.ExecutableName, options.Format) // Create the package err = packager.CreatePackageFromConfig(pkgType, configPath, outputFile) diff --git a/v3/internal/flags/package.go b/v3/internal/flags/package.go index dfc8fb9debd..f4ffb99ebd8 100644 --- a/v3/internal/flags/package.go +++ b/v3/internal/flags/package.go @@ -4,6 +4,7 @@ package flags type ToolPackage struct { Common - Format string `name:"format" description:"Package format to generate (deb, rpm, archlinux)" default:"deb"` - ConfigPath string `name:"config" description:"Path to the package configuration file" default:""` + Format string `name:"format" description:"Package format to generate (deb, rpm, archlinux)" default:"deb"` + ExecutableName string `name:"name" description:"Name of the executable to package" default:"myapp"` + ConfigPath string `name:"config" description:"Path to the package configuration file" default:""` }