You are not logged in.
Pages: 1
I have found pacman -Qo <filename> to often return no or incorrect results, (or maybe I misunderstand its function), so here is a simple bash script that takes a filename as argument and tells you which package installed that file. It's quite slow, but it works. Hope you find it useful.
#!/bin/sh
get_full_path()
{
# arg1: filename
# arg2: name of return variable
if [ $# -lt 2 ]
then
return
fi
_PWD=`pwd`
_DIR=`dirname $1`
_FILE=`basename $1`
cd $_DIR
eval "$2=`pwd`/${_FILE}"
cd $_PWD
}
###############
# main
if [ $# != 1 ]
then
echo
echo "Usage: findfileowner <file>"
exit 2
fi
FILE=""
get_full_path $1 FILE
if [ ! -f $FILE ]
then
echo
echo "File does not exist"
exit 2
fi
count=0
for P in `pacman -Q`
do
if [ $count = 0 ]
then
OWNER=`pacman -Ql $P | grep $FILE`
if [ $? = 0 ]
then
OWNER=`echo $OWNER | cut -d " " -f 1`
echo
echo "$FILE was installed by $OWNER"
exit 0
fi
count=1
else
count=0
fi
done
echo
echo "File not found"
exit 1
Offline
I don't think I understand what's going on - you say "pacman -Qo" returns nothing, but you're still using pacman to determine the owner...
pacman -Qo works fine for me...
Offline
I'm still using pacman to find the file, but what I've found is that pacman -Qo and pacman -Ql don't always agree, at least not on my system. Or, as I said in the original post, maybe I misunderstand what "owner" of a file means. But here is an example:
[username@hostname:~]
[1]% pacman -Qo /etc/zsh/zprofile
/etc/zsh/zprofile is owned by bash 3.0-6
[username@hostname:~]
[2]% pacman -Ql bash | grep "/etc/zsh/zprofile"
[username@hostname:~]
[3]% pacman -Ql zsh | grep "/etc/zsh/zprofile"
zsh /etc/zsh/zprofile
Offline
huh, I've never come across something like that... I'd submit a bug report...
nice script though!
Offline
Pages: 1