Advertisement
Guest User

Untitled

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