Thoroughly uninstall the RPM package script
When you detach a software package, you find that many other software packages depend on it. Force detach may make these software packages unusable. The following script can uninstall a software package and all software packages dependent on it.
Rpm_erase_deps.sh
#! /Bin/bash
######################################## ###############
Package = $1
Rpm_ops = "-e"
######################################## ###############
If ["$1" = ""]
Then
Echo "Usage: $0 package -- rpmops = [/'opts/']"
Echo "Example: $0 ant -- rpmops = '-- Test-E '"
Exit 1
Fi
######################################## ###############
While [! "$1" = ""]
Do
Shift
Arg = $1
If ["$ {Arg: 0: 8}" = "-- rpmops"]
Then
Rpm_ops = "$ {Arg: 9: 100 }"
Fi
Done
Function show_depends ()
{
Local _ package = "$1"
Local _ indent = "$2"
Deps = 'rpm -- Test-e $ _ package 2> & 1 | grep needed | awk '{print $ NF }''
For depends in $ deps
Do
Echo "$ _ indent $ depends"
Show_depends "$ depends" "$ _ indent ""--"
Done
}
Function rpm_do_erase ()
{
Local _ package = "$1"
Local _ indent = "$2"
Deps = 'rpm $ rpm_ops $ _ package 2> & 1 | grep needed | awk '{print $ NF }''
For depends in $ deps
Do
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