我有一个大约 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),因为这就是创建这些工具的目的。