When to use arch vs. noarch when building RPMs?

8,482

In practice, it doesn't really matter whether you build it from source or package some pre-existing archive.

noarch RPMs are meant to be architecture-neutral, i.e., they must contain no (native) binaries.
If the package is comprised of interpreted scripts (Bash, Python, etc.), documentation, headers, media files, etc, even compiled Java classes, then it can be noarch. The same package will work on any hardware architecture because it contains no code built specifically for a given architecture.

On the other hand, if the package contains binaries that are compiled to native machine code (e.g. programs written in C, C++, Pascal, etc.), no matter what else they contain, they must be tied to an architecture. A program compiled for x86_64 can't be run on a ppc host OS, for instance.

As for being compatible with different OS versions, that will vary with dependencies, and can't be generalised easily. For example, if a package depends on a minimum version of a given library, then obviously it won't be guaranteed to work on systems with older versions of such library (or systems with no such library at all). If it has no dependencies or very generic ones then it's likely to work.
Also, strictly speaking, this applies to both arch and noarch packages.

Share:
8,482

Related videos on Youtube

Ram Eswar
Author by

Ram Eswar

Updated on September 18, 2022

Comments

  • Ram Eswar
    Ram Eswar over 1 year

    Preface

    By building RPMs I do not mean compiling from source code. I purely mean taking a tar or a 'zip' file with source code or binaries and repackaging it as a RPM.

    I've been building RPMs from source code for a while now as noarch RPMs. Recently I've had to build RPMs that contain binaries which has raised some concerns:

    1. Is there a best practice on determining facters between arch and noarch RPMs? Specially in the event of building RPM from binary files. I understand that for pure source code where there is no compilation and only extracting files on install of RPM, noarch is acceptable however as mentioned above, I've got some doubt when it comes to packaging binaries.
    2. Are arch RPMs compatible with different OS versions? (This is in the context of the preface above) Just to elaborate can I build a arch RPM on RedHat 6 and then install it in RedHat 5 and vice versa?
  • Ram Eswar
    Ram Eswar almost 9 years
    Thanks. When you say compiled java classes, are you referring to jar files as well?
  • Evan Nudd
    Evan Nudd almost 9 years
    @aspiringCodeArtisan Yes, jars contain class files and accompanying data (and are actually zip files), so they are no different than those files on their own.