Small Mosaic


Categories:

/books
/career
/codinghorrors
/events
/geekstuff
/justdont
/languages
/languages/bash
/linkshot
/magazines
/meta
/misctech
/movies
/nottech
/operatingsystems
/operatingsystems/linux
/operatingsystems/linux/debian
/operatingsystems/solaris
/perl
/presentations
/programming
/python
/ruby
/security
/security/apache
/security/tools
/serversmells
/services
/services/dns
/sites
/specifications
/sysadmin
/testing
/tools
/tools/commandline
/tools/firefox
/tools/gui
/tools/network
/tools/online
/tools/online/greasemonkey
/tools/puppet
/unixdaemon

Archives:

July 20111
June 20112
May 20113
April 20112
March 20117
January 20111
December 20103
November 20103
August 20101
July 20101
June 20104
May 20102
April 20101
March 20108
February 20101
January 20102
Full Archives

Fri, 18 Mar 2005

Which package owns this file?
Filepkg.sh is another one of those scripts borne of a personal itch. I'm spending a fair amount of time cleaning up both Redhat and Debian boxes which have custom software installed, some of it by hand and some via the package management system (we build the packages ourselves).

One of the annoyances I've come across while determining which files are managed and which were left by us is that while both dpkg and rpm will tell you the package that owns a file, you need to provide the full path of the file you're asking about to get the information out. Well no more!

filepkg.sh takes a file name as an argument and tries to do a 'which' command on it. If this works then the full path is passed to the native package manager (filepkg.sh currently supports Redhat and Debian) and the owning package, if there is one, is returned. If filepkg.sh is called with a '-l' as the first argument or 'which' doesn't find a file with that name ('which' doesn't deal with config files for example) then the file is passed to 'locate'; it then looks up the file and passes it to the package manager to get a package name back.

The idea is simple, the code's easy to read and it works how I want it so feel free to do what you want with this little chunk of GPL'd code.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2005/03/18 00:22 | /unixdaemon | Permanent link to this entry | This entry and same date


books career codinghorrors events geekstuff justdont magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl programming python ruby security security/apache security/tools serversmells services/dns sites sysadmin testing tools tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey tools/puppet unixdaemon

Copyright © 2000-2010 Dean Wilson XML feed logo