This is a discussion on script: whichpkg - which package installed that file? within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Every so often the question comes up, "which package installed that file?" This little script tries to answer that ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Every so often the question comes up, "which package installed that file?" This little script tries to answer that question as concisely as possible, accepting input in several forms. Enjoy! ----- snip here ---------------------------------------- #!/bin/bash # whichpkg - list the slackware package(s) which installed # the given file or directory; # syntax: whichpkg name [...] # # starts with strict tests: full match on file or directory; # if nothing found, try full match on .new or in; # if nothing found, try substring match; # multiple arguments are handled recursively. # # copyright 2004 by William Hunt, all rights reserved. # distributed under terms of the Gnu Public License, version 2 or later. # master distribution at ftp://prv8.net/slackstuff/ DATA=/var/log/packages/* [ "$1" = . ] || [ "$1" = .. ] && shift # skip if given [ "${1:0:2}" = ./ ] && F=${1:2} || F=$1 # trim relative root if given [ "${1:0:1}" = / ] && F=${1:1} # trim absolute root if given [ -z $F ] && exit # argument required x=$( grep ^$F$ ${DATA} ) [ -z "$x" ] && x=$( grep ^$F/$ ${DATA} ) [ -z "$x" ] && x=$( grep ^$F.new$ ${DATA} ) [ -z "$x" ] && x=$( grep ^$F.in$ ${DATA} ) [ -z "$x" ] && x=$( grep /$F/$ ${DATA} | grep -v ":.*:" ) [ -z "$x" ] && x=$( grep /$F.new$ ${DATA} | grep -v ":.*:" ) [ -z "$x" ] && x=$( grep /$F.in$ ${DATA} | grep -v ":.*:" ) [ -z "$x" ] && x=$( grep /$F$ ${DATA} | grep -v ":.*:" ) for a in $x ; do b=${a%:*} ; echo ${b##*/} ; done | uniq shift ; $0 $* # recursion. # tha-tha-tha-that's all, folks! ----- snip here ---------------------------------------- -- William Hunt, Portland Oregon USA |
| |||
| William Hunt wrote: > Every so often the question comes up, > "which package installed that file?" > > This little script tries to answer that question as > concisely as possible, accepting input in several forms. > > Enjoy! > > ----- snip here ---------------------------------------- > #!/bin/bash > # whichpkg - list the slackware package(s) which installed > # the given file or directory; > # syntax: whichpkg name [...] > # > # starts with strict tests: full match on file or directory; > # if nothing found, try full match on .new or in; > # if nothing found, try substring match; > # multiple arguments are handled recursively. > # > # copyright 2004 by William Hunt, all rights reserved. > # distributed under terms of the Gnu Public License, version 2 or later. > # master distribution at ftp://prv8.net/slackstuff/ > DATA=/var/log/packages/* > [ "$1" = . ] || [ "$1" = .. ] && shift # skip if given > [ "${1:0:2}" = ./ ] && F=${1:2} || F=$1 # trim relative root if given > [ "${1:0:1}" = / ] && F=${1:1} # trim absolute root if given > [ -z $F ] && exit # argument required > x=$( grep ^$F$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F/$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F.new$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F.in$ ${DATA} ) > [ -z "$x" ] && x=$( grep /$F/$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F.new$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F.in$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F$ ${DATA} | grep -v ":.*:" ) > for a in $x ; do b=${a%:*} ; echo ${b##*/} ; done | uniq > shift ; $0 $* # recursion. > # tha-tha-tha-that's all, folks! > ----- snip here ---------------------------------------- > You know what would be good is a program that hunts through your hard drive and looks for files that do not come from a package. Of course it would skip home directories and /dev and /tmp etc. Then it would allow you to group those files so you can create packages. From those loose files. Also another good program would be one that looks at a file in /var/log/packages and recreates that package from the files listed. Unfortunatley it wouldn't get thinks like symlinks. Richard |
| |||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 William Hunt <wjh@huntbros.net> wrote: > DATA=/var/log/packages/* > [ "$1" = . ] || [ "$1" = .. ] && shift # skip if given > [ "${1:0:2}" = ./ ] && F=${1:2} || F=$1 # trim relative root if given > [ "${1:0:1}" = / ] && F=${1:1} # trim absolute root if given > [ -z $F ] && exit # argument required > x=$( grep ^$F$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F/$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F.new$ ${DATA} ) > [ -z "$x" ] && x=$( grep ^$F.in$ ${DATA} ) > [ -z "$x" ] && x=$( grep /$F/$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F.new$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F.in$ ${DATA} | grep -v ":.*:" ) > [ -z "$x" ] && x=$( grep /$F$ ${DATA} | grep -v ":.*:" ) > for a in $x ; do b=${a%:*} ; echo ${b##*/} ; done | uniq > shift ; $0 $* # recursion. Heh. A similar concept with this script snippet (extracted from my old workhorse, checkpkg. Old code, but it still works for me): #!/bin/sh cd /var/log/packages/ ; SEARCH=`grep "/$1"$ * | grep -v " " | \ grep -v "doc" | awk '{print $1}' | sed -e s/"\:"/" "/g` [ ! "$SEARCH" ] && (cd /var/log/packages/ ; SEARCH=`grep "/$1\.new"$ * | grep -v " " |\ grep -v "doc" | awk '{print $1}' | sed -e s/"\:"/" "/g`) echo "$SEARCH" Only checks for .new suffixes, though. - -- George Georgakis-geeg AT tripleg net au-http://www.tripleg.net.au/ SlackBuild Central - http://slackpack.tripleg.net.au/ -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com> iQA/AwUBQDQvlklp3nJf7PixEQIWMwCfQV/vbL16oCZ/KlEQJ7AM5uXqmaAAni6l LUZQhWq7CDmFGafeWQ0gTUvK =Tt5N -----END PGP SIGNATURE----- |
| ||||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 richard <c@dog.bird.eu> wrote: > You know what would be good is a program that hunts through your hard > drive and looks for files that do not come from a package. Of course it > would skip home directories and /dev and /tmp etc. Then it would allow > you to group those files so you can create packages. From those loose > files. Too tricky, too many variables involved. Especially on multi-user machines. > Also another good program would be one that looks at a file in > /var/log/packages and recreates that package from the files listed. > Unfortunatley it wouldn't get thinks like symlinks. That's different -- /var/log/scripts/ contains a list of symlinks created by a package. - -- George Georgakis-geeg AT tripleg net au-http://www.tripleg.net.au/ SlackBuild Central - http://slackpack.tripleg.net.au/ -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com> iQA/AwUBQDQwwklp3nJf7PixEQJTPQCgq9LKifKaDCrSB4aq+ENb83 wBT8YAoIyw 2C3jtbW3JOowCq/dfcgcSu83 =1Ytj -----END PGP SIGNATURE----- |
| Thread Tools | |
| Display Modes | |
|
|