Issue
I'm automating RPM package building with rpmbuild
. The files end up in the architecture subdirectory under RPMS
.
Question - how do I retrieve, from a shell script, the architecture name of the host that RPM is using? It's not the same as arch
command.
Solution
There's /usr/lib/rpm/rpmrc
that translates known OS-level architecture names into canonical RPM architecture names. The following shell script does the job for me:
ARCH=`arch`
# OS-level architecture name, like 'i686'
ARCH=`cat /usr/lib/rpm/rpmrc | grep "buildarchtranslate: $ARCH" | cut -c21-`
# returns the translate line as "arch-from: arch-to"
ARCH=${ARCH/#*: /}
# strips the prefix up to colon and following space, returns arch-to.
# Assumes just one space after colon. If not, more regex magic is needed.
Answered By - Seva Alekseyev Answer Checked By - Pedro (WPSolving Volunteer)