Skip to content

Commit

Permalink
feat: support for ipk packages
Browse files Browse the repository at this point in the history
Implements goreleaser#507.

* Adds ipk support for keywords used by OpenWRT and Yocto.
* MD5sum is explicitly excluded due to insecurity.
* SHA256Sum excluded due packages not being individually signed,
  instead, the feed of packages is checksummed and signed externally.
* Adds code to nfpm package to automatically enumerate the supported
  packaging types where possible.
  • Loading branch information
schmidtw committed Apr 29, 2024
1 parent 409b516 commit 675e6f0
Show file tree
Hide file tree
Showing 27 changed files with 2,133 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -65,7 +65,7 @@ jobs:
acceptance-tests:
strategy:
matrix:
pkgFormat: [deb, rpm, apk, archlinux]
pkgFormat: [deb, rpm, apk, archlinux, ipk]
pkgPlatform: [amd64, arm64, 386, ppc64le, armv6, armv7, s390x]
runs-on: ubuntu-latest
env:
Expand Down
34 changes: 34 additions & 0 deletions acceptance_test.go
Expand Up @@ -15,6 +15,7 @@ import (
_ "github.com/goreleaser/nfpm/v2/apk"
_ "github.com/goreleaser/nfpm/v2/arch"
_ "github.com/goreleaser/nfpm/v2/deb"
_ "github.com/goreleaser/nfpm/v2/ipk"
_ "github.com/goreleaser/nfpm/v2/rpm"
"github.com/stretchr/testify/require"
)
Expand All @@ -23,6 +24,7 @@ import (
var formatArchs = map[string][]string{
"apk": {"amd64", "arm64", "386", "ppc64le", "armv6", "armv7", "s390x"},
"deb": {"amd64", "arm64", "ppc64le", "armv7", "s390x"},
"ipk": {"amd64", "aarch64_generic", "i386_pentium4"},
"rpm": {"amd64", "arm64", "ppc64le"},
"archlinux": {"amd64"},
}
Expand Down Expand Up @@ -261,6 +263,38 @@ func TestDebSpecific(t *testing.T) {
}
}

func TestIPKSpecific(t *testing.T) {
t.Parallel()
format := "ipk"
testNames := []string{
"alternatives",
"conflicts",
"predepends",
}
for _, name := range testNames {
for _, arch := range formatArchs[format] {
func(t *testing.T, testName, testArch string) {
t.Run(fmt.Sprintf("%s/%s/%s", format, testArch, testName), func(t *testing.T) {
t.Parallel()
if testArch == "ppc64le" && os.Getenv("NO_TEST_PPC64LE") == "true" {
t.Skip("ppc64le arch not supported in pipeline")
}
accept(t, acceptParms{
Name: fmt.Sprintf("%s_%s", testName, testArch),
Conf: fmt.Sprintf("%s.%s.yaml", format, testName),
Format: format,
Docker: dockerParams{
File: fmt.Sprintf("%s.dockerfile", format),
Target: testName,
Arch: testArch,
},
})
})
}(t, name, arch)
}
}
}

func TestRPMSign(t *testing.T) {
t.Parallel()
for _, os := range []string{"centos9", "centos8", "fedora34", "fedora36", "fedora38"} {
Expand Down
2 changes: 1 addition & 1 deletion cmd/nfpm/main.go
Expand Up @@ -33,7 +33,7 @@ func main() {

func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info {
return goversion.GetVersionInfo(
goversion.WithAppDetails("nfpm", "a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go", website),
goversion.WithAppDetails("nfpm", "a simple and 0-dependencies apk, arch linux, deb, ipk, and rpm packager written in Go", website),
goversion.WithASCIIName(asciiArt),
func(i *goversion.Info) {
if commit != "" {
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/package.go
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path"
"path/filepath"
"strings"

"github.com/goreleaser/nfpm/v2"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -37,9 +38,12 @@ func newPackageCmd() *packageCmd {
_ = cmd.MarkFlagFilename("config", "yaml", "yml")
cmd.Flags().StringVarP(&root.target, "target", "t", "", "where to save the generated package (filename, folder or empty for current folder)")
_ = cmd.MarkFlagFilename("target")
cmd.Flags().StringVarP(&root.packager, "packager", "p", "", "which packager implementation to use [apk|deb|rpm|archlinux]")
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(
[]string{"apk", "deb", "rpm", "archlinux"},

pkgs := nfpm.Enumerate()

cmd.Flags().StringVarP(&root.packager, "packager", "p", "",
fmt.Sprintf("which packager implementation to use [%s]", strings.Join(pkgs, "|")))
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(pkgs,
cobra.ShellCompDirectiveNoFileComp,
))

Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/root.go
Expand Up @@ -7,6 +7,7 @@ import (
_ "github.com/goreleaser/nfpm/v2/apk" // apk packager
_ "github.com/goreleaser/nfpm/v2/arch" // archlinux packager
_ "github.com/goreleaser/nfpm/v2/deb" // deb packager
_ "github.com/goreleaser/nfpm/v2/ipk" // ipk packager
_ "github.com/goreleaser/nfpm/v2/rpm" // rpm packager
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -35,8 +36,8 @@ func newRootCmd(version goversion.Info, exit func(int)) *rootCmd {
}
cmd := &cobra.Command{
Use: "nfpm",
Short: "Packages apps on RPM, Deb, APK and Arch Linux formats based on a YAML configuration file",
Long: `nFPM is a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go.`,
Short: "Packages apps on RPM, Deb, APK, Arch Linux, and ipk formats based on a YAML configuration file",
Long: `nFPM is a simple and 0-dependencies apk, arch, deb, ipk and rpm linux packager written in Go.`,
Version: version.String(),
SilenceUsage: true,
SilenceErrors: true,
Expand Down

0 comments on commit 675e6f0

Please sign in to comment.