我有一台使用 armhf(准确地说是 armv7l,Cortex A9 ARMv7)CPU 架构的服务器。
我一直尝试在其上安装某个包,但没有成功。
首先,APT 提到它根本不支持该架构:
N: Skipping acquire of configured file 'main/binary-armhf/Packages' as repository 'http://repo.r1soft.com/apt stable InRelease' doesn't support architecture 'armhf'
我接下来所做的就是更改存储库使用的体系结构。我发现存储库支持amd64
。
我将其改为/etc/apt/sources.list
:
deb [arch=amd64] http://repo.r1soft.com/apt stable main
这导致 APT 错误消失:
root@host:~# apt-get update
Get:1 http://last.public.ovh.hdaas.snap.mirrors.ovh.net/ubuntu xenial InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports xenial InRelease
Ign:3 http://repo.r1soft.com/apt stable InRelease
Hit:4 http://repo.r1soft.com/apt stable Release
Get:6 http://repo.r1soft.com/apt stable/main amd64 Packages [3633 B]
Fetched 6325 B in 1s (3953 B/s)
Reading package lists... Done
W: http://repo.r1soft.com/apt/dists/stable/Release.gpg: Signature by key 8954063F882837AE08F8D2CB1BF3530AA40384ED uses weak digest algorithm (SHA1)
然而,在实际安装软件包时,APT 出现错误:
root@host:~# apt-get install serverbackup-enterprise
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package serverbackup-enterprise
当然,这不起作用,因为我们仍在从存储库安装包,而没有指定体系结构。执行此操作后:
root@host:~# apt-get install serverbackup-enterprise:amd64
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
r1soft-docstore:amd64 r1soft-getmodule:amd64 serverbackup-manager:amd64
serverbackup-setup:amd64
The following NEW packages will be installed:
r1soft-docstore:amd64 r1soft-getmodule:amd64 serverbackup-enterprise:amd64
serverbackup-manager:amd64 serverbackup-setup:amd64
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 348 MB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://repo.r1soft.com/apt stable/main amd64 r1soft-docstore amd64 6.2.2-78 [2110 kB]
Get:2 http://repo.r1soft.com/apt stable/main amd64 r1soft-getmodule amd64 1.0.0-51 [1860 kB]
Get:3 http://repo.r1soft.com/apt stable/main amd64 serverbackup-setup amd64 6.2.2-78 [2740 kB]
Get:4 http://repo.r1soft.com/apt stable/main amd64 serverbackup-manager amd64 6.2.2-78 [341 MB]
Get:5 http://repo.r1soft.com/apt stable/main amd64 serverbackup-enterprise amd64 6.2.2-78 [71.7 kB]
Fetched 348 MB in 2min 46s (2092 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "C.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: error processing archive /var/cache/apt/archives/r1soft-docstore_6.2.2-78_amd64.deb (--unpack):
package architecture (amd64) does not match system (armhf)
dpkg: error processing archive /var/cache/apt/archives/r1soft-getmodule_1.0.0-51_amd64.deb (--unpack):
package architecture (amd64) does not match system (armhf)
dpkg: error processing archive /var/cache/apt/archives/serverbackup-setup_6.2.2-78_amd64.deb (--unpack):
package architecture (amd64) does not match system (armhf)
dpkg: error processing archive /var/cache/apt/archives/serverbackup-manager_6.2.2-78_amd64.deb (--unpack):
package architecture (amd64) does not match system (armhf)
dpkg: error processing archive /var/cache/apt/archives/serverbackup-enterprise_6.2.2-78_amd64.deb (--unpack):
package architecture (amd64) does not match system (armhf)
Errors were encountered while processing:
/var/cache/apt/archives/r1soft-docstore_6.2.2-78_amd64.deb
/var/cache/apt/archives/r1soft-getmodule_1.0.0-51_amd64.deb
/var/cache/apt/archives/serverbackup-setup_6.2.2-78_amd64.deb
/var/cache/apt/archives/serverbackup-manager_6.2.2-78_amd64.deb
/var/cache/apt/archives/serverbackup-enterprise_6.2.2-78_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
所以我在想...应用程序本身支持架构——那里不会出错。
有没有办法“伪造” CPU 架构?
我尝试这样做,希望 APT 能够从命令的输出中收集信息uname
,但我对此表示怀疑。但我还是尝试了:
alias UNAME="echo Linux host 4.9.2-armada375 #1 SMP Mon Jan 23 16:52:54 CET 2017 amd64 amd64 amd64 GNU/Linux"
代替:
alias UNAME="echo Linux host 4.9.2-armada375 #1 SMP Mon Jan 23 16:52:54 CET 2017 armv7l armv7l armv7l GNU/Linux"
答案1
您需要在 ARM 设置中模拟 AMD64 / x86 处理器,以便执行为 AMD64 / x86 设计的二进制文件。
虽然从技术上来说,模拟是可行的,但速度会比较慢。需要使用软件执行二进制文件中的每条指令,软件会将每条指令转换为 ARM 架构。这意味着 ARM 端需要多条指令才能执行一条 AMD64 / x86 指令。
可能还需要模拟内存子系统等。
我不知道是否已经进行过这样的模拟,而且即使已经进行过,我怀疑它在任何实际用例中是否可用。
您唯一的选择是获取该软件的 AMD64 / x64 硬件,或者询问软件提供商是否可以提供它的 ARM 版本。