mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
fix(nfpm): termux platform (#4812)
closes #4810 closes #4809 --------- Co-authored-by: rsteube <rsteube@users.noreply.github.com>
This commit is contained in:
parent
c052ccc691
commit
bf31227b4e
@ -103,6 +103,7 @@ func doRun(ctx *context.Context, fpm config.NFPM) error {
|
||||
artifact.Or(
|
||||
artifact.ByGoos("linux"),
|
||||
artifact.ByGoos("ios"),
|
||||
artifact.ByGoos("android"),
|
||||
),
|
||||
}
|
||||
if len(fpm.Builds) > 0 {
|
||||
@ -144,9 +145,12 @@ func mergeOverrides(fpm config.NFPM, format string) (*config.NFPMOverridables, e
|
||||
|
||||
const termuxFormat = "termux.deb"
|
||||
|
||||
func isSupportedTermuxArch(arch string) bool {
|
||||
for _, a := range []string{"amd64", "arm64", "386"} {
|
||||
if strings.HasPrefix(arch, a) {
|
||||
func isSupportedTermuxArch(goos, goarch string) bool {
|
||||
if goos != "android" {
|
||||
return false
|
||||
}
|
||||
for _, arch := range []string{"amd64", "arm64", "386"} {
|
||||
if strings.HasPrefix(goarch, arch) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -155,12 +159,12 @@ func isSupportedTermuxArch(arch string) bool {
|
||||
|
||||
// arch officially only supports x86_64.
|
||||
// however, there are unofficial ports for 686, arm64, and armv7
|
||||
func isSupportedArchlinuxArch(arch, arm string) bool {
|
||||
if arch == "arm" && arm == "7" {
|
||||
func isSupportedArchlinuxArch(goarch, goarm string) bool {
|
||||
if goarch == "arm" && goarm == "7" {
|
||||
return true
|
||||
}
|
||||
for _, a := range []string{"amd64", "arm64", "386"} {
|
||||
if strings.HasPrefix(arch, a) {
|
||||
for _, arch := range []string{"amd64", "arm64", "386"} {
|
||||
if strings.HasPrefix(goarch, arch) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -194,19 +198,25 @@ func create(ctx *context.Context, fpm config.NFPM, format string, artifacts []*a
|
||||
return nil
|
||||
}
|
||||
case termuxFormat:
|
||||
if !isSupportedTermuxArch(artifacts[0].Goarch) {
|
||||
if !isSupportedTermuxArch(artifacts[0].Goos, artifacts[0].Goarch) {
|
||||
log.Debugf("skipping termux.deb for %s as its not supported by termux", arch)
|
||||
return nil
|
||||
}
|
||||
|
||||
infoArch = termuxArchReplacer.Replace(infoArch)
|
||||
arch = termuxArchReplacer.Replace(arch)
|
||||
infoPlatform = "linux"
|
||||
fpm.Bindir = termuxPrefixedDir(fpm.Bindir)
|
||||
fpm.Libdirs.Header = termuxPrefixedDir(fpm.Libdirs.Header)
|
||||
fpm.Libdirs.CArchive = termuxPrefixedDir(fpm.Libdirs.CArchive)
|
||||
fpm.Libdirs.CShared = termuxPrefixedDir(fpm.Libdirs.CShared)
|
||||
}
|
||||
|
||||
if artifacts[0].Goos == "android" && format != termuxFormat {
|
||||
log.Debugf("skipping android packaging as its not supported by %s", format)
|
||||
return nil
|
||||
}
|
||||
|
||||
overridden, err := mergeOverrides(fpm, format)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -196,7 +196,7 @@ func TestRunPipe(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, testctx.WithVersion("1.0.0"), testctx.WithCurrentTag("v1.0.0"))
|
||||
for _, goos := range []string{"linux", "darwin", "ios"} {
|
||||
for _, goos := range []string{"linux", "darwin", "ios", "android"} {
|
||||
for _, goarch := range []string{"amd64", "386", "arm64", "arm", "mips"} {
|
||||
if goos == "ios" && goarch != "arm64" {
|
||||
continue
|
||||
@ -415,9 +415,12 @@ func TestRunPipe(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if pkg.Goos == "linux" {
|
||||
switch pkg.Goos {
|
||||
case "linux":
|
||||
require.Equal(t, "foo_1.0.0_linux_"+arch+"-10-20"+ext, pkg.Name)
|
||||
} else {
|
||||
case "android":
|
||||
require.Equal(t, "foo_1.0.0_android_"+arch+"-10-20"+ext, pkg.Name)
|
||||
default:
|
||||
require.Equal(t, "foo_1.0.0_ios_arm64-10-20"+ext, pkg.Name)
|
||||
}
|
||||
require.Equal(t, "someid", pkg.ID())
|
||||
@ -961,7 +964,7 @@ func TestDebSpecificConfig(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, testctx.WithVersion("1.0.0"), testctx.WithCurrentTag("v1.0.0"))
|
||||
for _, goos := range []string{"linux", "darwin"} {
|
||||
for _, goos := range []string{"linux", "darwin", "android"} {
|
||||
for _, goarch := range []string{"amd64", "386"} {
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: "mybin",
|
||||
@ -1619,6 +1622,15 @@ func TestTemplateExt(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: "mybin",
|
||||
Goos: "android",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.Binary,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraID: "default",
|
||||
},
|
||||
})
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Name: "mybin",
|
||||
Goos: "linux",
|
||||
|
@ -498,6 +498,7 @@ Termux is the same format as `deb`, the differences are:
|
||||
|
||||
- it uses a different `bindir` (prefixed with `/data/data/com.termux/files/`)
|
||||
- it uses slightly different architecture names than Debian
|
||||
- it will only package binaries built for Android
|
||||
|
||||
## Conventional file names, Debian, and ARMv6
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user