Complete uninstall of the RPM software package script
Sometimes when uninstalling a package, there are many other packages that depend on it, forcing the uninstall to make these packages unusable. The following script can unload a package and all the packages that depend on it.
rpm_erase_deps.sh
#!/bin/bash
#######################################################
Package=$1
rpm_ops= "-E"
#######################################################
If ["$" = "]
Then
echo "Usage: $ package--rpmops=[/' opts/'"
echo "Example: $ ant--rpmops= '--test-e '"
Exit 1
Fi
#######################################################
While [! "$" = ""]
Todo
Shift
Arg=$1
if ["${arg:0:8}" = "--rpmops"]
Then
rpm_ops= "${arg:9:100}"
Fi
Done
function Show_depends ()
{
Local _package= "$"
Local _indent= "$"
deps= ' rpm--test-e $_package 2>&1|grep needed|awk ' {print $NF} '
For depends in $DEPS
Todo
echo "$_indent $depends"
Show_depends "$depends" "$_indent" "--"
Done
}
function Rpm_do_erase ()
{
Local _package= "$"
Local _indent= "$"
deps= ' rpm $RPM _ops $_package 2>&1|grep needed|awk ' {print $NF} '
For depends in $DEPS
Todo
echo "Erase $_indent $depends"
Rpm_do_erase "$depends" "$_indent" "--"
if [! "$?" = 0]
Then
echo "Erase $_indent $depends failed."
Fi
Done
}
echo "Show depends graph:"
echo "$PACKAGE"
Show_depends $PACKAGE "--"
echo "Do you want to uninstall $_package (y/n)?"
Read yn
If ["$yn" = "Y"]
Then
Rpm_do_erase $PACKAGE "--"
Else
echo "Cancel Uninstall $PACKAGE"
Fi