bash-3.2$ pacman -Ql jre jdk | grep "/java$" jre /opt/java/jre/bin/java jdk /opt/java/bin/java
bash-3.2$ ls -l /opt/java/bin/java lrwxrwxrwx 1 root root 15 oct 4 22:59 /opt/java/bin/java -> ../jre/bin/java
bash-3.2$ LANG=C pacman -Qo /opt/java/jre/bin/java /opt/java/jre/bin/java is owned by jdk 6u3-1
The -Qo operation calls realpath on both sides, and realpath(/opt/java/bin/java) = /opt/java/jre/bin/java, so it returns that /opt/java/jre/bin/java is owned by jdk, while in fact, jdk only owns a symlink that points to it.
I think that realpath should only be called on the path (== dirname), not the whole thing (dirname + basename). That is, /opt/java/bin/ should be resolved, but not the java symlink itself.
For implementing that, I would need a dirname function though. For basename, we have a mbasename function that was grabbed from uClibc source. Btw, what is the m for? And could we have mdirname also?