3 # rpm query replacement for the Node image without rpmdb
4 # list of RPMs is stored during the image creatation in /rpm-qa.txt
5 # only rpm -q is available, any other option returns error
8 # rpmdb snapshot created during image creation:
9 # rpm -qa --qf '%{NAME}\t%{VERSION}\t%{RELEASE}\t%{BUILDTIME}\n'
11 if [ ! -e $RPMDB ]; then
12 echo "$PROG: $RPMDB not found"
16 OPTS
=$
(getopt
-n $PROG -o qav
--long query
,all
,quiet
,verbose
,qf
:,queryformat
: -- "$@")
24 while [ "$#" -gt 0 ]; do
28 --qf|
--queryformat) qf
="$2"; shift;;
30 -v|
--verbose) verbose
=1;;
32 *) echo "$PROG: invalid option, only --query is available"
38 function print_pkg
() {
49 grep -E -q "$regex" $RPMDB || rc
=1
51 # actual queryformat is ignored
52 if ! grep -E "$regex" $RPMDB; then
53 echo "package $pkg is not installed"
59 match($0,p) { print $1"-"$2"-"$3; rc=0 } END { exit rc }
67 if [ "$#" -eq 0 ]; then
72 echo "$PROG: no arguments given for query"
78 print_pkg
"$pkg" || rc
=1
81 echo "$PROG: invalid option, only --query is available"