Permalink
Browse files

- Add proper 'arch' support for rpm.

  • Loading branch information...
jordansissel committed Jan 22, 2011
1 parent 05ae0b7 commit 6a8692a6e497a3f2239d13bb47760f310e6d47ac
Showing with 2 additions and 0 deletions.
  1. +1 −0 lib/fpm/builder.rb
  2. +1 −0 templates/rpm.erb
View
@@ -41,6 +41,7 @@ def initialize(settings, paths=[])
@package = package_class_for(settings.package_type).new(@source)
# Append dependencies given from settings (-d flag for fpm)
@package.dependencies += settings.dependencies if settings.dependencies
+ @package.architecture = settings.architecture if settings.architecture
@output = settings.package_path
@recurse_dependencies = settings.recurse_dependencies
View
@@ -2,6 +2,7 @@ Name: <%= @name %>
Version: <%= @version %>
Release: <%= @iteration %>
Summary: <%= @summary %>
+BuildArch: <%= architecture %>
Group: <%= @category %>
<%#

11 comments on commit 6a8692a

@glensc

This comment has been minimized.

Show comment Hide comment
@glensc

glensc Jun 18, 2013

Contributor

ee, wth? what are you fixing here?
only valid value for BuildArch is noarch

otherwise rpmbuild will give you an error:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

if you wanted to limit build architecture (x86_64 vs i686, i585), then the tag is ExclusiveArch: x86_64

if you wanted to build for different target, then you should use --target x86_64 rpmbuild commandline option

i would propose PR, but i'm not sure what are you you fixing here

Contributor

glensc replied Jun 18, 2013

ee, wth? what are you fixing here?
only valid value for BuildArch is noarch

otherwise rpmbuild will give you an error:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

if you wanted to limit build architecture (x86_64 vs i686, i585), then the tag is ExclusiveArch: x86_64

if you wanted to build for different target, then you should use --target x86_64 rpmbuild commandline option

i would propose PR, but i'm not sure what are you you fixing here

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 18, 2013

Owner

This commit is 2 years old and nobody's complained yet that this causes problems. All fpm tests are passing, including ones that verify rpms.

What are you claiming is broken by this? I am confused :)

Owner

jordansissel replied Jun 18, 2013

This commit is 2 years old and nobody's complained yet that this causes problems. All fpm tests are passing, including ones that verify rpms.

What are you claiming is broken by this? I am confused :)

@glensc

This comment has been minimized.

Show comment Hide comment
@glensc

glensc Jun 18, 2013

Contributor

rpm5 (from rpm5.org) is crying on this:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

because only valid value for "BuildArch" is "noarch" to specify that you want architecture independent package instead of default binary package.

what are you trying to achieve here?

Contributor

glensc replied Jun 18, 2013

rpm5 (from rpm5.org) is crying on this:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

because only valid value for "BuildArch" is "noarch" to specify that you want architecture independent package instead of default binary package.

what are you trying to achieve here?

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 18, 2013

Owner

On rpm5:

You're the first person I've ever seen use rpm5 or mention it in the wild. FPM is only tested on rpm of redhat origin (rpm 4.8/4.10 in most cases. For example CentOS/RHEL 4, 5, and 6, SLES 10&11 I think, fedora 15-19, etc. As for your shock that rpm5 causes problems: nobody's asked for rpm5 support in the entire life of fpm (2.5 years). It is not surprising to me that rpm5 doesn't work with fpm, today, because nobody's asked for it and nobody's testing for it.

what are you trying to achieve here?

The BuildArch label sets the ARCH tag in the rpm (and probably some other stuff I'm forgetting).

Regarding "the only valid value for BuildArch is noarch" - this is demonstrably false. See below for an example:

# fpm convers the arch string "native" to whatever the native arch is.
% fpm -fs dir -t rpm -n example -a native ~/.zshrc
# noarch is supported
% fpm -fs dir -t rpm -n example -a noarch ~/.zshrc
# as is other architectures that are not "the native" one.
% fpm -fs dir -t rpm -n example -a i686 ~/.zshrc

% ls *.rpm
example-1.0-1.i686.rpm  example-1.0-1.noarch.rpm  example-1.0-1.x86_64.rpm
% rpm --qf "%{ARCH}\n" -qp *.rpm
i686
noarch
x86_64

This allows you to build rpms with specific architecture tags and not just against whatever the default one happens to be for the process doing the build.

It's worth also pointing out that in my grand plan, I'll be removing rpmbuild as a dependency. At some point in the future, fpm will no longer invoke rpmbuild (or any rpm tool) to build rpms - the plan is to implement all of this in https://github.com/jordansissel/ruby-arr-pm - but it's waiting until I have time to do so ;)

In summary:

  • BuildArch can basically be any text, though rpmbuild (rpm 4.x) has some policies enforcing which ones are valid.
  • You're the first to even mention rpm5 in the context of fpm. fpm can support it, but hasn't yet because of the previous sentence.

Does this help answer your questions?

Owner

jordansissel replied Jun 18, 2013

On rpm5:

You're the first person I've ever seen use rpm5 or mention it in the wild. FPM is only tested on rpm of redhat origin (rpm 4.8/4.10 in most cases. For example CentOS/RHEL 4, 5, and 6, SLES 10&11 I think, fedora 15-19, etc. As for your shock that rpm5 causes problems: nobody's asked for rpm5 support in the entire life of fpm (2.5 years). It is not surprising to me that rpm5 doesn't work with fpm, today, because nobody's asked for it and nobody's testing for it.

what are you trying to achieve here?

The BuildArch label sets the ARCH tag in the rpm (and probably some other stuff I'm forgetting).

Regarding "the only valid value for BuildArch is noarch" - this is demonstrably false. See below for an example:

# fpm convers the arch string "native" to whatever the native arch is.
% fpm -fs dir -t rpm -n example -a native ~/.zshrc
# noarch is supported
% fpm -fs dir -t rpm -n example -a noarch ~/.zshrc
# as is other architectures that are not "the native" one.
% fpm -fs dir -t rpm -n example -a i686 ~/.zshrc

% ls *.rpm
example-1.0-1.i686.rpm  example-1.0-1.noarch.rpm  example-1.0-1.x86_64.rpm
% rpm --qf "%{ARCH}\n" -qp *.rpm
i686
noarch
x86_64

This allows you to build rpms with specific architecture tags and not just against whatever the default one happens to be for the process doing the build.

It's worth also pointing out that in my grand plan, I'll be removing rpmbuild as a dependency. At some point in the future, fpm will no longer invoke rpmbuild (or any rpm tool) to build rpms - the plan is to implement all of this in https://github.com/jordansissel/ruby-arr-pm - but it's waiting until I have time to do so ;)

In summary:

  • BuildArch can basically be any text, though rpmbuild (rpm 4.x) has some policies enforcing which ones are valid.
  • You're the first to even mention rpm5 in the context of fpm. fpm can support it, but hasn't yet because of the previous sentence.

Does this help answer your questions?

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 19, 2013

Owner

Just did some digging to confirm for myself that BuildArch can be any text in the rpm file itself the 'arch' tag (tag code 1022, RPMTAG_ARCH in rpmtag.h) is a string.

# an rpm built by fpm
% ruby printrpm.rb ../fpm/example-1.0-1.x86_64.rpm  |grep arch
[:arch, 1022, :string, 1, "x86_64"]

# An rpm provided by the jenkins project
% ruby printrpm.rb jenkins-1.519-1.1.noarch.rpm |grep :arch
[:arch, 1022, :string, 1, "noarch"]

Owner

jordansissel replied Jun 19, 2013

Just did some digging to confirm for myself that BuildArch can be any text in the rpm file itself the 'arch' tag (tag code 1022, RPMTAG_ARCH in rpmtag.h) is a string.

# an rpm built by fpm
% ruby printrpm.rb ../fpm/example-1.0-1.x86_64.rpm  |grep arch
[:arch, 1022, :string, 1, "x86_64"]

# An rpm provided by the jenkins project
% ruby printrpm.rb jenkins-1.519-1.1.noarch.rpm |grep :arch
[:arch, 1022, :string, 1, "noarch"]

@glensc

This comment has been minimized.

Show comment Hide comment
@glensc

glensc Jun 19, 2013

Contributor

how about using --target x86_64 commandline option to produce valid rpm for that arch?

Contributor

glensc replied Jun 19, 2013

how about using --target x86_64 commandline option to produce valid rpm for that arch?

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 19, 2013

Owner

what about today's implementation causes it to create an invalid rpm? How can I verify that it is invalid so that I can write a test to ensure valiity?

Owner

jordansissel replied Jun 19, 2013

what about today's implementation causes it to create an invalid rpm? How can I verify that it is invalid so that I can write a test to ensure valiity?

@glensc

This comment has been minimized.

Show comment Hide comment
@glensc

glensc Jun 19, 2013

Contributor

bad wording. it doesn't build at all, exits with error giving the error:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

i think you need to get rpm5 binary somehow to be able to test it...

Contributor

glensc replied Jun 19, 2013

bad wording. it doesn't build at all, exits with error giving the error:

error: line 12: Only "noarch" sub-packages are supported: BuildArch: x86_64

i think you need to get rpm5 binary somehow to be able to test it...

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 19, 2013

Owner

Anyway, to work around the problem yourself, you should just set the -a flag. If your rpm implementation only supports noarch, that's fine, and you can specify noarch:

fpm -s whatever -t rpm -a noarch ...

Owner

jordansissel replied Jun 19, 2013

Anyway, to work around the problem yourself, you should just set the -a flag. If your rpm implementation only supports noarch, that's fine, and you can specify noarch:

fpm -s whatever -t rpm -a noarch ...

@jordansissel

This comment has been minimized.

Show comment Hide comment
@jordansissel

jordansissel Jun 19, 2013

Owner

(It just happens that fpm uses the current system architecture as the default architecture value)

Owner

jordansissel replied Jun 19, 2013

(It just happens that fpm uses the current system architecture as the default architecture value)

@glensc

This comment has been minimized.

Show comment Hide comment
@glensc

glensc Jun 20, 2013

Contributor

i don't use fpm directly, it's invoked via omnibus-ruby when building omnibus-chef-server

workaround for myself was just to comment out "BuildArch" line in the rpm .spec template.

also, my resulting rpm is binary, aka archidecture dependant, so "-a noarch" would be wrong.

but really, --target x86_64, --target noarch commandline option for rpmbuild, should work for both rpm4 and rpm5, can't you take that path?

Contributor

glensc replied Jun 20, 2013

i don't use fpm directly, it's invoked via omnibus-ruby when building omnibus-chef-server

workaround for myself was just to comment out "BuildArch" line in the rpm .spec template.

also, my resulting rpm is binary, aka archidecture dependant, so "-a noarch" would be wrong.

but really, --target x86_64, --target noarch commandline option for rpmbuild, should work for both rpm4 and rpm5, can't you take that path?

Please sign in to comment.