Skip to content

Commit bc5c3bd

Browse files
authored
feat: support for ipk packages (#818)
Implements #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.
1 parent 45cc1de commit bc5c3bd

28 files changed

+2237
-7
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
acceptance-tests:
6666
strategy:
6767
matrix:
68-
pkgFormat: [deb, rpm, apk, archlinux]
68+
pkgFormat: [deb, rpm, apk, archlinux, ipk]
6969
pkgPlatform: [amd64, arm64, 386, ppc64le, armv6, armv7, s390x]
7070
runs-on: ubuntu-latest
7171
env:

acceptance_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
_ "github.com/goreleaser/nfpm/v2/apk"
1616
_ "github.com/goreleaser/nfpm/v2/arch"
1717
_ "github.com/goreleaser/nfpm/v2/deb"
18+
_ "github.com/goreleaser/nfpm/v2/ipk"
1819
_ "github.com/goreleaser/nfpm/v2/rpm"
1920
"github.com/stretchr/testify/require"
2021
)
@@ -23,6 +24,7 @@ import (
2324
var formatArchs = map[string][]string{
2425
"apk": {"amd64", "arm64", "386", "ppc64le", "armv6", "armv7", "s390x"},
2526
"deb": {"amd64", "arm64", "ppc64le", "armv7", "s390x"},
27+
"ipk": {"x86_64", "aarch64_generic"},
2628
"rpm": {"amd64", "arm64", "ppc64le"},
2729
"archlinux": {"amd64"},
2830
}
@@ -261,6 +263,38 @@ func TestDebSpecific(t *testing.T) {
261263
}
262264
}
263265

266+
func TestIPKSpecific(t *testing.T) {
267+
t.Parallel()
268+
format := "ipk"
269+
testNames := []string{
270+
"alternatives",
271+
"conflicts",
272+
"predepends",
273+
}
274+
for _, name := range testNames {
275+
for _, arch := range formatArchs[format] {
276+
func(t *testing.T, testName, testArch string) {
277+
t.Run(fmt.Sprintf("%s/%s/%s", format, testArch, testName), func(t *testing.T) {
278+
t.Parallel()
279+
if testArch == "ppc64le" && os.Getenv("NO_TEST_PPC64LE") == "true" {
280+
t.Skip("ppc64le arch not supported in pipeline")
281+
}
282+
accept(t, acceptParms{
283+
Name: fmt.Sprintf("%s_%s", testName, testArch),
284+
Conf: fmt.Sprintf("%s.%s.yaml", format, testName),
285+
Format: format,
286+
Docker: dockerParams{
287+
File: fmt.Sprintf("%s.dockerfile", format),
288+
Target: testName,
289+
Arch: testArch,
290+
},
291+
})
292+
})
293+
}(t, name, arch)
294+
}
295+
}
296+
}
297+
264298
func TestRPMSign(t *testing.T) {
265299
t.Parallel()
266300
for _, os := range []string{"centos9", "centos8", "fedora34", "fedora36", "fedora38"} {

cmd/nfpm/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333

3434
func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info {
3535
return goversion.GetVersionInfo(
36-
goversion.WithAppDetails("nfpm", "a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go", website),
36+
goversion.WithAppDetails("nfpm", "a simple and 0-dependencies apk, arch linux, deb, ipk, and rpm packager written in Go", website),
3737
goversion.WithASCIIName(asciiArt),
3838
func(i *goversion.Info) {
3939
if commit != "" {

internal/cmd/package.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"path"
88
"path/filepath"
9+
"strings"
910

1011
"github.com/goreleaser/nfpm/v2"
1112
"github.com/spf13/cobra"
@@ -37,9 +38,12 @@ func newPackageCmd() *packageCmd {
3738
_ = cmd.MarkFlagFilename("config", "yaml", "yml")
3839
cmd.Flags().StringVarP(&root.target, "target", "t", "", "where to save the generated package (filename, folder or empty for current folder)")
3940
_ = cmd.MarkFlagFilename("target")
40-
cmd.Flags().StringVarP(&root.packager, "packager", "p", "", "which packager implementation to use [apk|deb|rpm|archlinux]")
41-
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(
42-
[]string{"apk", "deb", "rpm", "archlinux"},
41+
42+
pkgs := nfpm.Enumerate()
43+
44+
cmd.Flags().StringVarP(&root.packager, "packager", "p", "",
45+
fmt.Sprintf("which packager implementation to use [%s]", strings.Join(pkgs, "|")))
46+
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(pkgs,
4347
cobra.ShellCompDirectiveNoFileComp,
4448
))
4549

internal/cmd/root.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
_ "github.com/goreleaser/nfpm/v2/apk" // apk packager
88
_ "github.com/goreleaser/nfpm/v2/arch" // archlinux packager
99
_ "github.com/goreleaser/nfpm/v2/deb" // deb packager
10+
_ "github.com/goreleaser/nfpm/v2/ipk" // ipk packager
1011
_ "github.com/goreleaser/nfpm/v2/rpm" // rpm packager
1112
"github.com/spf13/cobra"
1213
)
@@ -35,8 +36,8 @@ func newRootCmd(version goversion.Info, exit func(int)) *rootCmd {
3536
}
3637
cmd := &cobra.Command{
3738
Use: "nfpm",
38-
Short: "Packages apps on RPM, Deb, APK and Arch Linux formats based on a YAML configuration file",
39-
Long: `nFPM is a simple and 0-dependencies deb, rpm, apk and arch linux packager written in Go.`,
39+
Short: "Packages apps on RPM, Deb, APK, Arch Linux, and ipk formats based on a YAML configuration file",
40+
Long: `nFPM is a simple and 0-dependencies apk, arch, deb, ipk and rpm linux packager written in Go.`,
4041
Version: version.String(),
4142
SilenceUsage: true,
4243
SilenceErrors: true,

0 commit comments

Comments
 (0)