如何摆脱依赖地狱?


21

我有一台没有互联网的Ubuntu计算机和一台有互联网的Ubuntu计算机。没有互联网的人需要通过ndiswrapper安装驱动程序。问题在于,这ndiswrapper-dkms取决于dkms哪几件事,而这几件事又取决于很多事,等等。到目前为止,我已经手动下载了92个依赖项,但我仍然需要更多。我一直在使用代码

for i in $(apt-cache depends <package> | grep -E 'Depends|Recommends|Suggests' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/); do sudo apt-get download $i 2>>errors.txt; done

这样就完成了工作,但仅完成了一个程序包的依赖关系,而不是程序包的依赖关系等等。为了获得所有软件包,这已经变成了数小时的战斗,这确实很乏味。我一直在运行此代码,以将.deb文件下载到在线计算机上的USB驱动器中,然后移至脱机计算机以插入驱动器,然后sudo apt install ./*在该文件夹中运行并希望达到最佳效果。通常会吐出这样的内容:

...
The following packages have unmet dependencies:
 binutils : Depends: binutils-common (= 2.30-21ubuntu1~18.04.1) but 2.30-21ubuntu1~18.04 is to be installed
            Depends: libbinutils (= 2.30-21ubuntu1~18.04.1) but 2.30-21ubuntu1~18.04 is to be installed
            Depends: binutils-x86-64-linux-gnu (= 2.30-21ubuntu1~18.04.1) but 2.30-21ubuntu1~18.04 is to be installed
 cpp-doc : Depends: cpp-7-doc (>= 7.4.0-1~) but it is not installable
 file : Depends: libmagic1 (= 1:5.32-2ubuntu0.2) but 1:5.32-2ubuntu0.1 is to be installed
 g++-7 : Depends: libstdc++-7-dev (= 7.4.0-1ubuntu1~18.04) but it is not installable
 g++-multilib : Depends: g++-7-multilib (>= 7.4.0-1~) but it is not installable
 gcc-7-multilib : Depends: lib32gcc-7-dev (= 7.4.0-1ubuntu1~18.04) but it is not installable
                  Depends: libx32gcc-7-dev (= 7.4.0-1ubuntu1~18.04) but it is not installable
 gfortran : Depends: gfortran-7 (>= 7.4.0-1~) but it is not installable
 glibc-doc : Depends: glibc-doc-reference (>= 2.18) but it is not installable
 libasan4-dbg : Depends: libasan4 (= 7.4.0-1ubuntu1~18.04) but it is not installable
 libatomic1-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
                  Depends: libatomic1 (= 8.3.0-6ubuntu1~18.04) but it is not installable
 libbabeltrace1 : Depends: libdw1 (>= 0.126) but it is not installable
 libcc1-0 : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libcilkrts5-dbg : Depends: libcilkrts5 (= 7.4.0-1ubuntu1~18.04) but it is not installable
 libfl-dev : Depends: libfl2 (= 2.6.4-6) but it is not installable
 libgcc-7-dev : Depends: libitm1 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libatomic1 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libasan4 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: liblsan0 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libtsan0 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libubsan0 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libcilkrts5 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
                Depends: libmpx2 (>= 7.4.0-1ubuntu1~18.04) but it is not installable
 libgcc1 : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libgcc1-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libgomp1-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
                Depends: libgomp1 (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libitm1-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
               Depends: libitm1 (= 8.3.0-6ubuntu1~18.04) but it is not installable
 liblsan0-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
                Depends: liblsan0 (= 8.3.0-6ubuntu1~18.04) but it is not installable
 libmpx2-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
               Depends: libmpx2 (= 8.3.0-6ubuntu1~18.04) but it is not installable
 libquadmath0-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
                    Depends: libquadmath0 (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libstdc++6 : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
 libtsan0-dbg : Depends: gcc-8-base (= 8.3.0-6ubuntu1~18.04) but 8.2.0-1ubuntu2~18.04 is to be installed
                Depends: libtsan0 (= 8.3.0-6ubuntu1~18.04) but it is not installable
 libubsan0-dbg : Depends: libubsan0 (= 7.4.0-1ubuntu1~18.04) but it is not installable
 libumfpack5 : Depends: libcholmod3 (>= 1:4.5.2) but it is not going to be installed
 m4 : Depends: libsigsegv2 (>= 2.9) but it is not installable
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

有谁知道一种仅将包依赖项和所有子依赖项的所有.deb文件转储到单个文件夹中的方法,以节省我的理智?谢谢!



您可能还可以通过以太网直接将两台计算机联网,以便脱机计算机使用在线计算机连接。我记得,apt-offline的过程听起来要简单得多。但这答案是“即插即用”。
pbhj

1
只要您使用RecommendsSuggests不是Depends我希望,无论您从哪个软件包开始,都将最终安装整个Internet。

1
@ N0rbert我从未发现这些答案令人满意。我知道那不是重复系统的重点。
wizzwizz4

@ N0rbert对于解决依赖地狱情况,这不是一个显而易见的问题。两者之间的任何重复都在答案中,而不是问题中
Rich

Answers:


27

查看apt-offline一种(更)用户友好的方式管理脱机依赖关系的方法。您需要先通过下载debfile并将其传输到离线计算机来进行安装。您可以使用类似的方法sudo apt download apt-offline来处理下载。可以sudo dpkg -i /path/to/your/debfile.deb在离线计算机上和sudo apt install在线计算机上进行安装。

完成后,您需要为实际安装准备一堆东西。

  1. 首先创建脱机系统的签名,要求安装ndiswrapper软件包:

    sudo apt-offline set offline.sig --install-packages ndiswrapper-dkms
    
  2. 将文件复制到您的在线计算机上,然后在在线计算机上运行以下命令以下载所有必需的文件:

    apt-offline get offline.sig --bundle ndis-ao.zip
    
  3. 将zipfile捆绑包移回离线计算机,并在其上运行以下命令:

    sudo apt-offline install ndis-ao.zip
    

此时您应该已经ndiswrapper-dkms安装了,一切都应该很好。


如果您的apt-offline软件包无法安装,请记下失败的相关软件包,并一一解决(根据需要手动复制)。依赖地狱很烦人,但是不幸的是,这是离线系统的问题之一。

您也可以尝试查看apt-rdepends以生成完整的依赖关系图。结合使用apt download,您可能会找到解决该问题的替代方案,尽管至少可以说,我对此的测试尚无定论。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.