| 1 | #!/bin/bash |
| 2 | # rpm-check.sh |
| 3 | |
| 4 | # Queries an rpm file for description, listing, |
| 5 | #+ and whether it can be installed. |
| 6 | # Saves output to a file. |
| 7 | # |
| 8 | # This script illustrates using a code block. |
| 9 | |
| 10 | SUCCESS=0 |
| 11 | E_NOARGS=65 |
| 12 | |
| 13 | if [ -z "$1" ] |
| 14 | then |
| 15 | echo "Usage: `basename $0` rpm-file" |
| 16 | exit $E_NOARGS |
| 17 | fi |
| 18 | |
| 19 | { # Begin code block. |
| 20 | echo |
| 21 | echo "Archive Description:" |
| 22 | rpm -qpi $1 # Query description. |
| 23 | echo |
| 24 | echo "Archive Listing:" |
| 25 | rpm -qpl $1 # Query listing. |
| 26 | echo |
| 27 | rpm -i --test $1 # Query whether rpm file can be installed. |
| 28 | if [ "$?" -eq $SUCCESS ] |
| 29 | then |
| 30 | echo "$1 can be installed." |
| 31 | else |
| 32 | echo "$1 cannot be installed." |
| 33 | fi |
| 34 | echo # End code block. |
| 35 | } > "$1.test" # Redirects output of everything in block to file. |
| 36 | |
| 37 | echo "Results of rpm test in file $1.test" |
| 38 | |
| 39 | # See rpm man page for explanation of options. |
| 40 | |
| 41 | exit 0 |