How to Detect Architecture of a .deb Package

Architecturedpkgpackage-managementpackaging

There is a .deb package in a repository which is declared to be 32bit, but installs 64bit binaries. This is the case for both installing through apt-get from the repository as well as with downloading the .deb file and running dpkg -i.

If I install the file to try, it upgrades/overwrites my existing application in 32bit, and I can't run it any more (on 15.04 32bit Ubuntu). When this happened first, I searched the installed executable with which and checked it's type with file, that proved it to be a 64bit ELF binary:

$ file qtox
qtox: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped

So while I wait for the maintainers to fix the issue, how can I determine which architecture a package (from repository or .deb file) contains?

I tried both apt-cache show and apt-cache policy for the repository version and dpkg -I for the .deb file, but all of them report 32bit, which is wrong.

Is there any chance to find the real architecture the contained executables are made for out, except by accessing the package's meta information (I think this is what the commands I tried did?) which does obviously not fit.

Best Answer

Create a script, in my example foo

#!/bin/bash

# Create a temporary folder in /tmp
dir=$(mktemp -d)

# Extract the deb file
dpkg -x "$1" "$dir"

printf "\n%s\n\n" "$1"

# Show the package architecture information
dpkg --info $1 | \
    awk '/Architecture/ {printf "defined dpkg architecture is:\t%s\n", $2}'

# Show the executable format via find and awk for ELF
find $dir -type f -exec file -b {} \; | \
        sort -u | \
        awk '/ELF/ {printf "executable format is: \t\t%s\n", $0}'

rm -rf "$dir"

exit 0

Usage

./foo <deb_file>

Example

% ./foo qtox_1.1\~git20150707.cfeeb03-97_i386.deb

qtox_1.1~git20150707.cfeeb03-97_i386.deb

defined dpkg architecture is:   i386
executable format is :          ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped
Related Question