Complete uninstall of the RPM software package script

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.