rpmqf 785 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#!/bin/sh
# 2003-2006 (c) Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
#
# ,      ,   which
# :
# -  
# TODO not -i only, we need any key

if [ "$1" = "-h" ]; then
	echo "rpmqf - the same as rpm -qf"
	exit 0
fi

if [ "$1" = "-i" ]; then
	ARG=$1
	shift
fi

TOFILE=`which $1 2>/dev/null`

if [ -z "$TOFILE" ] ; then
	#echo "$1 is missed in PATH"
	#exit 1
	TOFILE=$1
fi

if [ -L "$TOFILE" ] ; then
	LINKTO=`readlink "$TOFILE"`
	if [ -L "$LINKTO" ] ; then
		LINKTO1=`readlink "$LINKTO"`
		echo "Note: $TOFILE is link to $LINKTO, that is link to $LINKTO1"
		TOFILE="$LINKTO1"
	else
		echo "Note: $TOFILE is link to $LINKTO"
		TOFILE="$LINKTO"
	fi
fi

rpm -qf $ARG "$TOFILE"