如何检测.deb包的体系结构?

存储库中有一个.deb包,声明为32位,但安装64位二进制文​​件。 通过apt-get从存储库安装以及下载.deb文件和运行dpkg -i

如果我安装该文件进行尝试,它会以32位升级/覆盖我现有的应用程序,而我无法再运行它(在15.04 32位Ubuntu上)。 当这首先发生时,我搜索了已安装的可执行文件which并用file检查了它的类型,certificate它是64位ELF二进制文件:

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

因此,当我等待维护人员解决问题时,如何确定包(来自存储库或.deb文件)包含哪个体系结构?

我为存储库版本尝试了apt-cache showapt-cache policy ,为.deb文件尝试了dpkg -I ,但是所有这些都报告了32位,这是错误的。

有没有机会找到包含可执行文件的真实体系结构,除非访问包的元信息(我认为这是我尝试过的命令?),这显然不合适。

在我的示例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 

用法

 ./foo  

 % ./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 

DEB包只是一个具有非常具体内容的存档。 您可以在任何您喜欢的存档管理器中打开它(例如File Roller或其他任何存档管理器),并且内容的布局就像将其清空到/ 。 您需要做的就是找到二进制文件并查询其文件类型。 这通常不是必需的 – 如果文件名中包含i386,则应该是i386。 你的情况肯定是不正常的,所以我想知道软件包维护者是如何让这种情况发生的。

每个deb包声明一个架构,例如。 “i386”或“全部”。 然而,这只是一个声明,它可以被声明为错误(故意由于某种原因,或者例如在某些包构建脚本中出错)。

你有什么可以validation真正的包架构:

 # verify, if package supports multiple architectures (and possibly has some bug): dpkg --print-foreign-architectures package.deb # unpack and check executables inside: dpkg --unpack package.deb dpkg --contents package.deb |grep ^-rwxr-xr-x |awk "{ print \$6 }" |grep -v /etc/ # and then check a few random unpacked executables using: file ./usr/bin/some-executable