1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-27 00:36:10 +02:00

feat: test os ppc64le too

This commit is contained in:
Carlos Alexandro Becker 2019-03-19 21:34:06 -03:00
parent c97639b107
commit 26a86166dc
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
9 changed files with 61 additions and 39 deletions

View File

@ -39,6 +39,15 @@ func TestSimple(t *testing.T) {
Dockerfile: fmt.Sprintf("%s.386.dockerfile", format),
})
})
t.Run("ppc64le", func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("simple_%s_ppc64le", format),
Conf: "simple.ppc64le.yaml",
Format: format,
Dockerfile: fmt.Sprintf("%s.ppc64le.dockerfile", format),
})
})
}
}

View File

@ -0,0 +1,10 @@
FROM ppc64le/ubuntu
ARG package
COPY ${package} /tmp/foo.deb
RUN dpkg -i /tmp/foo.deb
RUN test -e /usr/local/bin/fake
RUN test -f /etc/foo/whatever.conf
RUN echo wat >> /etc/foo/whatever.conf
RUN dpkg -r foo
RUN test -f /etc/foo/whatever.conf
RUN test ! -f /usr/local/bin/fake

View File

@ -1,4 +1,4 @@
FROM i386/centos:6
FROM i386/centos
ARG package
COPY ${package} /tmp/foo.rpm
RUN rpm -ivh /tmp/foo.rpm

View File

@ -1,4 +1,4 @@
FROM i386/centos:6
FROM i386/centos
ARG package
COPY ${package} /tmp/foo.rpm
RUN rpm -ivh /tmp/foo.rpm

View File

@ -0,0 +1,10 @@
FROM ppc64le/centos
ARG package
COPY ${package} /tmp/foo.rpm
RUN rpm -ivh /tmp/foo.rpm
RUN test -e /usr/local/bin/fake
RUN test -f /etc/foo/whatever.conf
RUN echo wat >> /etc/foo/whatever.conf
RUN rpm -e foo
RUN test -f /etc/foo/whatever.conf.rpmsave
RUN test ! -f /usr/local/bin/fake

15
acceptance/testdata/simple.ppc64le.yaml vendored Normal file
View File

@ -0,0 +1,15 @@
name: "foo"
arch: "ppc64le"
platform: "linux"
version: "v1.2.3"
maintainer: "Foo Bar"
description: |
Foo bar
Multiple lines
vendor: "foobar"
homepage: "https://foobar.org"
license: "MIT"
files:
../testdata/fake: "/usr/local/bin/fake"
config_files:
../testdata/whatever.conf: "/etc/foo/whatever.conf"

View File

@ -27,12 +27,13 @@ func init() {
}
// nolint: gochecknoglobals
var goarchToDebian = map[string]string{
"386": "i386",
"arm": "armhf",
"arm6": "armel",
"arm7": "armhf",
"mipsle": "mipsel",
var archToDebian = map[string]string{
"386": "i386",
"arm": "armhf",
"arm6": "armel",
"arm7": "armhf",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
}
// Default deb packager
@ -44,7 +45,7 @@ type Deb struct{}
// Package writes a new deb package to the given writer using the given info
func (*Deb) Package(info nfpm.Info, deb io.Writer) (err error) {
arch, ok := goarchToDebian[info.Arch]
arch, ok := archToDebian[info.Arch]
if ok {
info.Arch = arch
}

View File

@ -33,24 +33,17 @@ var Default = &RPM{}
// RPM is a RPM packager implementation
type RPM struct{}
// GoArchToRpm converts a goarch to an RPM compatible arch
func GoArchToRpm(goArch string) string {
switch {
case strings.Contains(goArch, "amd64"):
return "x86_64"
case strings.Contains(goArch, "386"):
return "i386"
case strings.Contains(goArch, "ppc64le"):
return "ppc64le"
case strings.Contains(goArch, "ppc64"):
return "ppc64"
}
return goArch
var archToRPM = map[string]string{
"amd64": "x86_64",
"386": "i386",
}
// Package writes a new RPM package to the given writer using the given info
func (*RPM) Package(info nfpm.Info, w io.Writer) error {
info.Arch = GoArchToRpm(info.Arch)
arch, ok := archToRPM[info.Arch]
if ok {
info.Arch = arch
}
info.Version = strings.Replace(info.Version, "-", "_", -1)
_, err := exec.LookPath("rpmbuild")
if err != nil {

View File

@ -94,22 +94,6 @@ func TestRPM(t *testing.T) {
assert.NoError(t, err)
}
func TestArchitectureMappings(t *testing.T) {
for fromArch, toArch := range map[string]string{
"amd64": "x86_64",
"386": "i386",
"linuxppc64": "ppc64",
"linuxppc64le": "ppc64le",
} {
// Check the mapping
assert.Equal(t, toArch, GoArchToRpm(fromArch))
// Verify the build actually works
info := exampleInfo(fromArch)
var err = Default.Package(info, ioutil.Discard)
assert.NoError(t, err)
}
}
func TestRPMVersionWithDash(t *testing.T) {
info := exampleInfo("amd64")
info.Version = "1.0.0-beta"