我有一個大約 30 個「不需要的」軟體包的列表,我總是在新安裝的基於 RPM 的 Linux 系統上刪除/刪除/刪除這些軟體包。
但是,當我嘗試--erase
命令時,例如(故意縮短)
# rpm -e sos abrt abrt-libs abrt-python abrt-dbus abrt-addon-xorg abrt-tui abrt-addon-ccpp abrt-cli abrt-console-notification abrt-addon-kerneloops abrt-retrace-client abrt-addon-vmcore abrt-addon-pstoreoops abrt-addon-python
error: package abrt is not installed
error: package abrt-libs is not installed
error: package abrt-python is not installed
error: package abrt-dbus is not installed
error: package abrt-addon-xorg is not installed
error: package abrt-tui is not installed
error: package abrt-addon-ccpp is not installed
error: package abrt-cli is not installed
error: package abrt-console-notification is not installed
error: package abrt-addon-kerneloops is not installed
error: package abrt-retrace-client is not installed
error: package abrt-addon-vmcore is not installed
error: package abrt-addon-pstoreoops is not installed
error: package abrt-addon-python is not installed
Exit 14
有些包(sos
只有我猜?)顯然確實存在,但沒有被刪除。當然,我不想匹配兩個包列表(我的包列表和錯誤訊息)並編輯命令行,因為即使在這個簡短的範例中,它也需要太長的時間。
所以我當然可以嘗試解決這個問題
echo sos abrt abrt-libs abrt-python abrt-dbus abrt-addon-xorg abrt-tui abrt-addon-ccpp abrt-cli abrt-console-notification abrt-addon-kerneloops abrt-retrace-client abrt-addon-vmcore abrt-addon-pstoreoops abrt-addon-python | xargs --max-args=1 rpm -e
但我寧願忽略不存在的包包。
我怎麼做? --force
不適用於擦除:
# rpm -e --force sos abrt abrt-libs abrt-python abrt-dbus abrt-addon-xorg abrt-tui abrt-addon-ccpp abrt-cli abrt-console-notification abrt-addon-kerneloops abrt-retrace-client abrt-addon-vmcore abrt-addon-pstoreoops abrt-addon-python
rpm: only installation and upgrading may be forced
Exit 1
答案1
我想這就是你正在尋找的。此版本僅輸出與已安裝內容相符的軟體包清單。
#- for pkg in sos abrt abrt-libs abrt-python abrt-dbus abrt-addon-xorg abrt-tui abrt-addon-ccpp abrt-cli abrt-console-notification abrt-addon-kerneloops abrt-retrace-client abrt-addon-vmcore abrt-addon-pstoreoops abrt-addon-python; do rpm --quiet -q "$pkg" && echo "$pkg"; done
abrt
abrt-libs
abrt-dbus
abrt-addon-xorg
abrt-tui
abrt-addon-ccpp
abrt-cli
abrt-console-notification
abrt-addon-kerneloops
abrt-retrace-client
abrt-addon-vmcore
abrt-addon-pstoreoops
您可以使用上面的內容產生包名稱列表,然後可以將其反饋到rpm
擦除(也稱為刪除):
#- rpm -e --nodeps $(for pkg in sos abrt abrt-libs abrt-python abrt-dbus abrt-addon-xorg abrt-tui abrt-addon-ccpp abrt-cli abrt-console-notification abrt-addon-kerneloops abrt-retrace-client abrt-addon-vmcore abrt-addon-pstoreoops abrt-addon-python; do rpm --quiet -q "$pkg" && echo "$pkg"; done)
Removed /etc/systemd/system/multi-user.target.wants/abrt-journal-core.service.
Removed /etc/systemd/system/multi-user.target.wants/abrt-xorg.service.
Removed /etc/systemd/system/multi-user.target.wants/abrt-vmcore.service.
Removed /etc/systemd/system/multi-user.target.wants/abrt-oops.service.
Removed /etc/systemd/system/multi-user.target.wants/abrtd.service.
請注意,這個簡單版本不處理依賴關係處理。如果您需要處理依賴關係,您可能應該切換到 DNF(或 YUM),因為這就是建立這些工具的目的。