goreleaser / nfpm

nFPM is Not FPM - a simple deb, rpm, apk, ipk, and arch linux packager written in Go
https://nfpm.goreleaser.com/
MIT License
2.15k stars 157 forks source link

Add AIX platform capability to rpm builds #821

Closed Dylan-M closed 4 months ago

Dylan-M commented 4 months ago

Is your feature request related to a problem? Please describe.

I need to support AIX, and currently I can only do this by using tar packages. Goreleaser supports building AIX binaries, so it would be nice to be able to make their RPM files using nfpm/goreleaser

Describe the solution you'd like

Add AIX as a supported platform for nfpm's rpm packager.

Describe alternatives you've considered

None, we use goreleaser exclusively, so nfpm is a perfect fit.

Search

Code of Conduct

Additional context

I did try this very simple nfpm configuration as a test:

# nfpm example configuration file
#
# check https://nfpm.goreleaser.com/configuration for detailed usage
#
name: "aix-somefile"
arch: "ppc64"
platform: "aix"
version: "1.0.0"
maintainer: "Fake Guy"
contents:
  - src: someFile
    dst: /usr/lib/someFile
    type: config|noreplace
    file_info:
      mode: 0644
      owner: root
      group: root

However, this was the result:

-bash-5.1# rpm -U /tmp/aix-somefile-1.0.0-1.ppc64.rpm 
        package aix-somefile-1.0.0-1.ppc64 is intended for a different architecture
        package aix-somefile-1.0.0-1.ppc64 is intended for a different operating system

The os error makes sense, but the arch error doesn't.

Dylan-M commented 4 months ago

Documentation from IBM that may be useful: https://developer.ibm.com/articles/au-aix-build-open-source-rpm-packages/

djgilcrease commented 4 months ago

You may need to map the ppc64 to something else for the RPM similar to https://github.com/goreleaser/nfpm/blob/main/rpm/rpm.go#L57 when it is AIX

According to https://developer.ibm.com/articles/configure-yum-on-aix/ it could be ppc, ppc-6.1, ppc-7.1, or ppc-7.2

I would try setting the info.RPM.Arch as ppc and see if that works

djgilcrease commented 4 months ago

Same is true for the OS error

https://www.unix.com/aix/266963-tip-problem-rpm-different-operating-system.html

Looks like it needs to be aix#.#

Dylan-M commented 4 months ago

You may need to map the ppc64 to something else for the RPM similar to https://github.com/goreleaser/nfpm/blob/main/rpm/rpm.go#L57 when it is AIX

According to https://developer.ibm.com/articles/configure-yum-on-aix/ it could be ppc, ppc-6.1, ppc-7.1, or ppc-7.2

I would try setting the info.RPM.Arch as ppc and see if that works

I'm not sure that will help. It is building PPC for Linux just fine. It seems to just be ignoring it for AIX period. It isn't that they fail to work, it is that they just don't get generated at all.

Dylan-M commented 4 months ago

I forgot to come back to this, but the rpm it generates is empty. I guess that is more accurate than it doesn't get generated at all.

djgilcrease commented 4 months ago

when I used

# nfpm example configuration file
#
# check https://nfpm.goreleaser.com/configuration for detailed usage
#
name: "aix-somefile"
arch: "ppc64"
platform: "aix6.1"
version: "1.0.0"
maintainer: "Fake Guy"
rpm:
  arch: ppc
contents:
  - src: someFile
    dst: /usr/lib/someFile
    type: config|noreplace
    file_info:
      mode: 0644
      owner: root
      group: root

and had someFile populated with the string boo the resulting rpm was 1.4k in size. When I populated someFile with 10MB of random data the resulting RPM was 11MB in size, so the RPM is not empty. I do not have access to an IBM AIX system to test, but it did build the RPM

Dylan-M commented 4 months ago

Okay, I'll go over my config again (I only included a stripped down version here as an example, our production config is very large covering many OSes), as it sounds like I may have screwed something else up somewhere.

Then I'll try your other suggestions. Thank you.

Assuming your other suggestions work, it would just be a simple PR to add the mapping to nfpm it looks like. I'm happy to make that.

Dylan-M commented 4 months ago

So, a mapping in the code you linked wont work, because it only applies to AIX (Linux builds are correctly ppc for 32bit and ppc64 for 64 bit).

That said, overriding them manually like you did in your example, worked perfectly as far as I can tell.

However, this doesn't work for goreleaser itself, because it isn't aware of the platform and rpm/arch fields. We can address those in goreleaser/goreleaser#4853