如何逃離依賴地獄?

如何逃離依賴地獄?

我有一台沒有網路的 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 檔案轉儲到一個資料夾中以保存我的理智?謝謝!

答案1

看一眼apt-offline,一種(更)用戶友好的管理離線依賴關係的方式。您需要先透過下載 deb 檔案並將其傳輸到離線電腦來安裝它。您可以使用類似的東西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. 將 zip 檔案包移回離線計算機並在其上執行以下命令:

    sudo apt-offline install ndis-ao.zip
    

ndiswrapper-dkms此時您應該已經安裝並且一切都應該很好。


如果您的apt-offline套件安裝失敗,請記下失敗的依賴套件並一一解決(根據需要手動複製)。依賴地獄很煩人,但不幸的是,這是離線系統的問題之一。

你可以嘗試看一下apt-rdepends以及生成一個完全的依賴圖。將此與此結合起來apt download,您可能會找到問題的替代解決方案,儘管我對此進行的測試至少可以說是不確定的。

相關內容