Reputation: 1698
How you can check what dependencies will be removed before doing yum remove? I just found some difference between two packages so asking your help.
JDK example (no dependencies when doing yum, but repoquery shows the dependencies - why there is difference?)
root@server DEV # yum remove jdk-1.7.0_101-fcs.x86_64
. . .
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Removing:
jdk x86_64 2000:1.7.0_101-fcs @rhel6-x86_64-660-barclays-custom 209 M
Transaction Summary
=================================================================================================================================================
Remove 1 Package(s)
Installed size: 209 M
Is this ok [y/N]: ^CExiting on user Command
root@server DEV # repoquery --whatrequires --installed jdk-1.7.0_101-fcs.x86_64
jdk-2000:1.7.0_101-fcs.x86_64
axis-0:1.2.1-7.5.el6_5.noarch
log4j-0:1.2.14-6.4.el6.x86_64
mx4j-1:3.0.1-9.13.el6.noarch
wsdl4j-0:1.5.2-7.8.el6.noarch
xml-commons-resolver-0:1.1-4.18.el6.x86_64
root@server DEV #
java gcj works fine in this case:
root@server DEV # repoquery --whatrequires --installed java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
java-1.5.0-gcj-0:1.5.0.0-29.1.el6.x86_64
axis-0:1.2.1-7.5.el6_5.noarch
bcel-0:5.2-7.2.el6.x86_64
classpathx-jaf-0:1.0-15.4.el6.x86_64
classpathx-mail-0:1.1.1-9.4.el6.noarch
ecj-1:3.4.2-6.el6.x86_64
jakarta-commons-daemon-1:1.0.1-8.9.el6.x86_64
jakarta-commons-httpclient-1:3.1-0.9.el6_5.x86_64
jakarta-commons-pool-0:1.3-12.7.el6.x86_64
java-1.5.0-gcj-0:1.5.0.0-29.1.el6.x86_64
java_cup-1:0.10k-5.el6.x86_64
log4j-0:1.2.14-6.4.el6.x86_64
mx4j-1:3.0.1-9.13.el6.noarch
regexp-0:1.5-4.4.el6.x86_64
sinjdoc-0:0.5-9.1.el6.x86_64
tomcat6-0:6.0.24-80.el6.x86_64
wsdl4j-0:1.5.2-7.8.el6.noarch
xml-commons-apis-0:1.3.04-3.6.el6.x86_64
xml-commons-resolver-0:1.1-4.18.el6.x86_64
root@server DEV # yum remove java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
. . .
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Removing:
java-1.5.0-gcj x86_64 1.5.0.0-29.1.el6 @rhel6-x86_64-660 150 k
Removing for dependencies:
axis noarch 1.2.1-7.5.el6_5 @rhel6-x86_64-660 1.6 M
bcel x86_64 5.2-7.2.el6 @rhel6-x86_64-660 16 M
classpathx-jaf x86_64 1.0-15.4.el6 @rhel6-x86_64-660 240 k
classpathx-mail noarch 1.1.1-9.4.el6 @rhel6-x86_64-660 822 k
ecj x86_64 1:3.4.2-6.el6 @rhel6-x86_64-660 7.3 M
jakarta-commons-daemon x86_64 1:1.0.1-8.9.el6 @rhel6-x86_64-660 121 k
jakarta-commons-dbcp noarch 1.2.1-13.8.el6 @rhel6-x86_64-660 125 k
jakarta-commons-httpclient x86_64 1:3.1-0.9.el6_5 @rhel6-x86_64-660 1.8 M
jakarta-commons-pool x86_64 1.3-12.7.el6 @rhel6-x86_64-660 368 k
java_cup x86_64 1:0.10k-5.el6 @rhel6-x86_64-660 544 k
log4j x86_64 1.2.14-6.4.el6 @rhel6-x86_64-660 2.0 M
mx4j noarch 1:3.0.1-9.13.el6 @rhel6-x86_64-660 1.7 M
regexp x86_64 1.5-4.4.el6 @rhel6-x86_64-660 248 k
sinjdoc x86_64 0.5-9.1.el6 @rhel6-x86_64-660 2.3 M
tomcat6 x86_64 6.0.24-80.el6 @rhel6-x86_64-660 189 k
tomcat6-lib x86_64 6.0.24-80.el6 @rhel6-x86_64-660 3.2 M
wsdl4j noarch 1.5.2-7.8.el6 @rhel6-x86_64-660 339 k
xml-commons-apis x86_64 1.3.04-3.6.el6 @rhel6-x86_64-660 1.6 M
xml-commons-resolver x86_64 1.1-4.18.el6 @rhel6-x86_64-660 416 k
Transaction Summary
=================================================================================================================================================
Remove 20 Package(s)
Installed size: 41 M
Is this ok [y/N]: ^CExiting on user Command
root@serverDEV #
I even tried repoquery --whatrequires --installed --exactdeps <package>
. This will not show dependencies for java gcj which is not right.
Upvotes: 1
Views: 1700
Reputation: 1698
I found the solution to list exactly the same dependency list as yum remove
does before removal.
So you can take proper pre-removal actions and understand what will be removed.
Just as a starter I have written this in bash, but this can be easily transformed into Puppet script, Chef recipe or any automation tool. The main command is sudo -u nobody rpm -e --test
which has two protection gates to make sure this is a read-only command.
The script to print the full dependency list:
#!/bin/bash
LEVEL="$1"
LEVEL=`rpm -q $LEVEL`
if [ "$?" == "0" ]
then
ALL=$LEVEL
time while :
do
OLD_DEP_COUNT=`echo $ALL| wc -w`
LEVEL=`sudo -u nobody rpm -e --test $LEVEL 2>&1 | grep -v 'Failed dependencies' | awk -F " " '{print $NF}' | sed -e s/[0-9]://g`
ALL="`echo "$LEVEL $ALL" | xargs -n1 | sort -u | xargs`"
NEW_DEP_COUNT=`echo $ALL | wc -w`
if [ "$OLD_DEP_COUNT" == "$NEW_DEP_COUNT" ]
then
for i in $ALL; do echo $i; done
echo "The count of dependencies:"
echo $ALL | wc -w
break
fi
done
else
echo "Cannot find the package"
fi
Usage:
./script package_name
Upvotes: 1