Aptitude - 刪除 X11 類別中的所有包,特定包的依賴項除外

Aptitude - 刪除 X11 類別中的所有包,特定包的依賴項除外

我想從我的系統中刪除 X11 類別中的大部分軟體包。然而,其中一些軟體包依賴“beaglebone”軟體包。我怎麼能要求 aptitude 刪除 X11 類別中的所有內容,除了「beaglebone」依賴的軟體包之外?

您可以在下面看到它建議將“beaglebone”作為應該卸載的軟體包之一,以免被破壞。

    aptitude 建議刪除。包括 Beaglebone。

如何確保刪除後保留該套件及其相依性?

答案1

簡短的回答是:

aptitude remove '~sX11 ! ~Rbeaglebone'

然而在這種情況下(有一個很多依賴 X11 的東西!要執行此操作,請將選項--schedule-only添加到上面,然後在aptitude不帶參數的情況下再次運行。-o Aptitude::Auto-Fix-Broken=false它我可以看到只有當您g按下介面。

執行 ncurses 介面後,按e檢查第一個解決方案並查看其他刪除內容。如果您看到任何不想要的內容,請使用箭頭鍵選擇它,然後按r拒絕該操作。按.加載下一個解決方案,它現在應該提供一個不包含任何您拒絕的解決方案。根據需要重複並按!接受解決方案並正常繼續。

答案2

我相信您可以使用以下方法之一來“排除”套件“beaglebone”,這將強制保留其任何依賴項。

$ sudo apt-mark hold <package>

或者

$ echo <package> hold | sudo dpkg --set-selections

第一個利用apt-markhold特點。

   hold
        hold is used to mark a package as held back, which will prevent the 
        package from being automatically installed, upgraded or removed. The 
        command is only a wrapper around dpkg --set-selections and the state 
        is therefore maintained by dpkg(1) and not affected by the --file 
        option.

第二個用於dpkg將包標記為“保留”。

   --set-selections
        Set package selections using file read from stdin. This file should 
        be in the format 'package state', where state is one of install, 
        hold,  deinstall  or purge. Blank lines and comment lines beginning 
        with '#' are also permitted.

相關內容