#!/bin/bash

O1=O
O2=("AVAILABLE RPM-FILES: SEARCH FOR FILE (rpm)")

function available_rpms_search_file {

    [ -f ${CONSTATEDIR}/rpmsearch ] && rm -f ${CONSTATEDIR}/rpmsearch

    choose_wdir

    inputbox "Enter a filename to search for:"

    msgbox "Search for \"$INPUT\". Output will also be written to
\"${CONSTATEDIR}/rpmsearch\" for later examination"

    for FILE in *.${EXT} ; do

	(nice ${NICELEVEL} rpm -qpl "${WDIR}/${FILE}" | grep "${INPUT}" && \
	echo -e "Found \"${INPUT}\" in \"${FILE}\"\n") >> ${CONSTATEDIR}/rpmsearch

    done

    if [ ! -z "`cat ${CONSTATEDIR}/rpmsearch 2> /dev/null`" ]; then

	textbox ${CONSTATEDIR}/rpmsearch

    else

	msgbox "Could not find \"${INPUT}\" in \"${WDIR}\""

    fi

}
