When to use arch vs. noarch when building RPMs?
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.
Related videos on Youtube
Ram Eswar
Updated on September 18, 2022Comments
-
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:- Is there a best practice on determining facters between
arch
andnoarch
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. - Are
arch
RPMs compatible with different OS versions? (This is in the context of the preface above) Just to elaborate can I build aarch
RPM on RedHat 6 and then install it in RedHat 5 and vice versa?
- Is there a best practice on determining facters between
-
Ram Eswar almost 9 yearsThanks. When you say compiled java classes, are you referring to jar files as well?
-
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.