mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-23 12:18:50 +02:00
feat: termux.deb (#3333)
termux support, built from #3258 : minor code changes support for 386 as well docs tests closes #3118 closes #3258 Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> Co-authored-by: rsteube <rsteube@users.noreply.github.com>
This commit is contained in:
parent
3729f1ee2b
commit
a7c6b14cbf
@ -121,11 +121,39 @@ func mergeOverrides(fpm config.NFPM, format string) (*config.NFPMOverridables, e
|
|||||||
return &overridden, nil
|
return &overridden, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const termuxFormat = "termux.deb"
|
||||||
|
|
||||||
|
func isSupportedTermuxArch(arch string) bool {
|
||||||
|
for _, a := range []string{"amd64", "arm64", "386"} {
|
||||||
|
if strings.HasPrefix(arch, a) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*artifact.Artifact) error {
|
func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*artifact.Artifact) error {
|
||||||
// TODO: improve mips handling on nfpm
|
// TODO: improve mips handling on nfpm
|
||||||
infoArch := binaries[0].Goarch + binaries[0].Goarm + binaries[0].Gomips // key used for the ConventionalFileName et al
|
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
|
arch := infoArch + binaries[0].Goamd64 // unique arch key
|
||||||
|
|
||||||
|
bindDir := fpm.Bindir
|
||||||
|
if format == termuxFormat {
|
||||||
|
if !isSupportedTermuxArch(arch) {
|
||||||
|
log.Debugf("skipping termux.deb for %s as its not supported by termux", arch)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
replacer := strings.NewReplacer(
|
||||||
|
"386", "i686",
|
||||||
|
"amd64", "x86_64",
|
||||||
|
"arm64", "aarch64",
|
||||||
|
)
|
||||||
|
infoArch = replacer.Replace(infoArch)
|
||||||
|
arch = replacer.Replace(arch)
|
||||||
|
bindDir = filepath.Join("/data/data/com.termux/files", bindDir)
|
||||||
|
}
|
||||||
|
|
||||||
overridden, err := mergeOverrides(fpm, format)
|
overridden, err := mergeOverrides(fpm, format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -138,7 +166,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
|
|||||||
"PackageName": fpm.PackageName,
|
"PackageName": fpm.PackageName,
|
||||||
})
|
})
|
||||||
|
|
||||||
binDir, err := t.Apply(fpm.Bindir)
|
binDir, err := t.Apply(bindDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -326,7 +354,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
|
|||||||
info.Deb.Signature = nfpm.DebSignature{}
|
info.Deb.Signature = nfpm.DebSignature{}
|
||||||
}
|
}
|
||||||
|
|
||||||
packager, err := nfpm.Get(format)
|
packager, err := nfpm.Get(strings.Replace(format, "termux.", "", 1))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
ID: "someid",
|
ID: "someid",
|
||||||
Bindir: "/usr/bin",
|
Bindir: "/usr/bin",
|
||||||
Builds: []string{"default"},
|
Builds: []string{"default"},
|
||||||
Formats: []string{"deb", "rpm", "apk"},
|
Formats: []string{"deb", "rpm", "apk", "termux.deb"},
|
||||||
Section: "somesection",
|
Section: "somesection",
|
||||||
Priority: "standard",
|
Priority: "standard",
|
||||||
Description: "Some description with {{ .Env.DESC }}",
|
Description: "Some description with {{ .Env.DESC }}",
|
||||||
@ -220,7 +220,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.NoError(t, Pipe{}.Run(ctx))
|
require.NoError(t, Pipe{}.Run(ctx))
|
||||||
packages := ctx.Artifacts.Filter(artifact.ByType(artifact.LinuxPackage)).List()
|
packages := ctx.Artifacts.Filter(artifact.ByType(artifact.LinuxPackage)).List()
|
||||||
require.Len(t, packages, 30)
|
require.Len(t, packages, 36)
|
||||||
for _, pkg := range packages {
|
for _, pkg := range packages {
|
||||||
format := pkg.Format()
|
format := pkg.Format()
|
||||||
require.NotEmpty(t, format)
|
require.NotEmpty(t, format)
|
||||||
@ -245,6 +245,12 @@ func TestRunPipe(t *testing.T) {
|
|||||||
"./testdata/testfile-" + pkg.Goarch + pkg.Goamd64 + pkg.Goarm + pkg.Gomips + ".txt",
|
"./testdata/testfile-" + pkg.Goarch + pkg.Goamd64 + pkg.Goarm + pkg.Gomips + ".txt",
|
||||||
binPath,
|
binPath,
|
||||||
}, sources(artifact.ExtraOr(*pkg, extraFiles, files.Contents{})))
|
}, sources(artifact.ExtraOr(*pkg, extraFiles, files.Contents{})))
|
||||||
|
|
||||||
|
bin := "/usr/bin/subdir/"
|
||||||
|
if format == termuxFormat {
|
||||||
|
bin = filepath.Join("/data/data/com.termux/files", bin)
|
||||||
|
}
|
||||||
|
bin = filepath.Join(bin, "mybin")
|
||||||
require.ElementsMatch(t, []string{
|
require.ElementsMatch(t, []string{
|
||||||
"/var/log/foobar",
|
"/var/log/foobar",
|
||||||
"/usr/share/testfile.txt",
|
"/usr/share/testfile.txt",
|
||||||
@ -254,7 +260,7 @@ func TestRunPipe(t *testing.T) {
|
|||||||
"/etc/nope2.conf",
|
"/etc/nope2.conf",
|
||||||
"/etc/nope3_mybin.conf",
|
"/etc/nope3_mybin.conf",
|
||||||
"/etc/folder",
|
"/etc/folder",
|
||||||
"/usr/bin/subdir/mybin",
|
bin,
|
||||||
}, destinations(artifact.ExtraOr(*pkg, extraFiles, files.Contents{})))
|
}, destinations(artifact.ExtraOr(*pkg, extraFiles, files.Contents{})))
|
||||||
}
|
}
|
||||||
require.Len(t, ctx.Config.NFPMs[0].Contents, 8, "should not modify the config file list")
|
require.Len(t, ctx.Config.NFPMs[0].Contents, 8, "should not modify the config file list")
|
||||||
|
@ -66,6 +66,7 @@ nfpms:
|
|||||||
- apk
|
- apk
|
||||||
- deb
|
- deb
|
||||||
- rpm
|
- rpm
|
||||||
|
- termux.deb
|
||||||
|
|
||||||
# Packages your package depends on. (overridable)
|
# Packages your package depends on. (overridable)
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -378,3 +379,10 @@ nfpms:
|
|||||||
|
|
||||||
!!! info
|
!!! info
|
||||||
Fields marked with "overridable" can be overriden for any format.
|
Fields marked with "overridable" can be overriden for any format.
|
||||||
|
|
||||||
|
## A note about Termux
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user