测试是否可以安装一个rpm包

[root@station shell]# cat 5.sh
#!/bin/bash
SUCCESS=0
ERROR_NARGS=65

if [ -z $1 ]
then
        echo "usage: `basename $0` rpm-file"
        exit $ERROR_NARGS
fi

{
        echo
        echo "Achive Description"
        rpm -qpi $1
        echo
        echo "Achive Listing"
        rpm -qpl $1
        echo
        rpm -i --test $1
        if [[ "$?" -eq "$SUCCESS" ]]
        then
        echo "$1 can be installed"
        else
        echo "$1 can not be installed"
        fi
        echo
} > "/root/shell/$1.test"
echo "result of rpm test in file $1.test"
exit 0

 

本文出自 “风继续吹” 博客,谢绝转载!

你可能感兴趣的:(安装,职场,rpm,休闲,RPM包)