Skip to content

Commit

Permalink
feat: nfpm for ios (#3436)
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

cc/ @blacktop

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Oct 13, 2022
1 parent 13bb053 commit 080ccff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 9 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 @@ -136,6 +139,10 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
// TODO: improve mips handling on nfpm
infoArch := binaries[0].Goarch + binaries[0].Goarm + binaries[0].Gomips // key used for the ConventionalFileName et al
arch := infoArch + binaries[0].Goamd64 // unique arch key
infoPlatform := binaries[0].Goos
if infoPlatform == "ios" {
infoPlatform = "iphoneos-arm64"
}

bindDir := fpm.Bindir
if format == termuxFormat {
Expand Down Expand Up @@ -266,7 +273,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar

info := &nfpm.Info{
Arch: infoArch,
Platform: "linux",
Platform: infoPlatform,
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 080ccff

Please sign in to comment.