Skip to content

Commit

Permalink
feat: nfpm for ios
Browse files Browse the repository at this point in the history
Jailbroken iOS can install deb packages, and it seems the only change
needed is to set the OS to `ios` instead of `linux`.

Closes #3410
  • Loading branch information
caarlos0 committed Oct 5, 2022
1 parent 4a51099 commit fd8d0a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions internal/pipe/nfpm/nfpm.go
Expand Up @@ -82,7 +82,10 @@ func (Pipe) Run(ctx *context.Context) error {
func doRun(ctx *context.Context, fpm config.NFPM) error {
filters := []artifact.Filter{
artifact.ByType(artifact.Binary),
artifact.ByGoos("linux"),
artifact.Or(
artifact.ByGoos("linux"),
artifact.ByGoos("ios"),
),
}
if len(fpm.Builds) > 0 {
filters = append(filters, artifact.ByIDs(fpm.Builds...))
Expand Down Expand Up @@ -266,7 +269,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar

info := &nfpm.Info{
Arch: infoArch,
Platform: "linux",
Platform: binaries[0].Goos,
Name: fpm.PackageName,
Version: ctx.Version,
Section: fpm.Section,
Expand Down
13 changes: 10 additions & 3 deletions internal/pipe/nfpm/nfpm_test.go
Expand Up @@ -159,8 +159,11 @@ func TestRunPipe(t *testing.T) {
})
ctx.Version = "1.0.0"
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
for _, goos := range []string{"linux", "darwin"} {
for _, goos := range []string{"linux", "darwin", "ios"} {
for _, goarch := range []string{"amd64", "386", "arm64", "arm", "mips"} {
if goos == "ios" && goarch != "arm64" {
continue
}
switch goarch {
case "arm":
for _, goarm := range []string{"6", "7"} {
Expand Down Expand Up @@ -220,7 +223,7 @@ func TestRunPipe(t *testing.T) {
}
require.NoError(t, Pipe{}.Run(ctx))
packages := ctx.Artifacts.Filter(artifact.ByType(artifact.LinuxPackage)).List()
require.Len(t, packages, 36)
require.Len(t, packages, 40)
for _, pkg := range packages {
format := pkg.Format()
require.NotEmpty(t, format)
Expand All @@ -234,7 +237,11 @@ func TestRunPipe(t *testing.T) {
if pkg.Gomips != "" {
arch += "_" + pkg.Gomips
}
require.Equal(t, "foo_1.0.0_Tux_"+arch+"-10-20."+format, pkg.Name)
if pkg.Goos == "linux" {
require.Equal(t, "foo_1.0.0_Tux_"+arch+"-10-20."+format, pkg.Name)
} else {
require.Equal(t, "foo_1.0.0_ios_arm64-10-20."+format, pkg.Name)
}
require.Equal(t, "someid", pkg.ID())
require.ElementsMatch(t, []string{
"./testdata/testfile.txt",
Expand Down

0 comments on commit fd8d0a5

Please sign in to comment.