#!/bin/bash # find what package a file comes from # if bare filename, uses either current directory or # executable path for full path name if echo $1 | grep -q '/'; then target=$1 else target=`which $1` || target=`pwd`/$1 fi # we want link target target=`ls -l $target 2>/dev/null | sed 's/.* //' ` # of course it has to exist... if [ -e "$target" ]; then # lists may not have install target in the path name target=`echo $target | sed 's|/mnt/card/||;s|/mnt/cf/||' ` # It's called parametric substitution package=`grep -l "$target$" {,/mnt/cf,/mnt/card}/usr/lib/ipkg/info/*.list` || echo "no package found" if [ -n "$package" ]; then [[ $package == */mnt/cf/* ]] && { from=`basename $package`; from=${from%%.list}; where=CF; } [[ $package == */mnt/card/* ]] && { from=`basename $package`; from=${from%%.list}; where=SD; } [[ $package != */mnt* ]] && { from=`basename $package`; from=${from%%.list}; where=RAM; } echo $from in $where fi else target=${target:-$1} echo no such file, \"$target\" fi