qfile man page on Gentoo

Man page or keyword search:  
man Server   6889 pages
apropos Keyword Search (all sections)
Output format
Gentoo logo
[printable version]

qfile(1)			     qfile			      qfile(1)

NAME
       qfile - list all pkgs owning files

SYNOPSIS
       qfile <opts> <filename>

DESCRIPTION
OPTIONS
       -S, --slots
	      Display installed packages with slots

       -R, --root-prefix
	      Assume arguments are already prefixed by $ROOT

       -f <arg>, --from <arg>
	      Read arguments from file <arg> ("-" for stdin)

       -m <arg>, --max-args <arg>
	      Treat from file arguments by groups of <arg> (defaults to 5000)

       -b, --basename
	      Match any component of the path

       -o, --orphans
	      List orphan files

       -x <arg>, --exclude <arg>
	      Don't look in package <arg> (used with --orphans)

       -e, --exact
	      Exact match (used with --exclude)

       --root <arg>
	      Set the ROOT env var

       -v, --verbose
	      Make a lot of noise

       -q, --quiet
	      Tighter output; suppress warnings

       -C, --nocolor
	      Don't output color

       -h, --help
	      Print this help and exit

       -V, --version
	      Print version and exit

FINDING FILES OWNERS
       This is the default behavior of qfile.  It will list the packages which
       own the files (or directories, or symlinks, or  anything	 else  Portage
       can install) you are querying.  Query items may be file paths or simple
       file names.  By default, output includes packages names	and  the  com‐
       plete  paths  to the matching files.  If using --exact, versions of the
       packages will also be shown.  At the contrary, when using --quiet, only
       package	names  are listed, without files paths.	 Finally, --verbose is
       similar to --exact, but may adds a few warnings.	 The return status  of
       qfile  will be 0 as soon as an owning package has been found for one of
       the query items.

       Find names of package(s) owning "/bin/bash":
	    $ qfile -q /bin/bash
	    app-shells/bash

       Find package(s) owning any file named "bash", and show  paths  of  this
       files:
	    $ qfile bash
	    app-shells/bash (/bin/bash)
	    app-shells/bash (/etc/bash)

       Find packages(s) owning the file named "bash" in the current directory.
       Also display their exact version:
	    $ cd /bin
	    $ qfile -e ./bash
	    app-shells/bash-3.1_p17 (/bin/bash)

       Find the package(s) owning the libraries needed by the Bash binary:
	    $ qfile $(scanelf -nq -F%n#F /bin/bash | tr , '\n')
	    sys-libs/ncurses (/lib/libncurses.so.5)
	    sys-libs/glibc (/lib/libdl.so.2)
	    sys-libs/glibc (/lib/libc.so.6)

FINDING ORPHAN FILES
       qfile can also, with the --orphans option, find	files  which  are  not
       owned  by any package.  This behavior is the opposite of the usual file
       owner search: the output is the list of query items for which no refer‐
       ence  has  been found in your installed packages database.  The --exact
       option has no effect in this mode, whereas  --verbose  may  add	a  few
       warning	messages.  As for --quiet, it will completly turn off the out‐
       put, leaving just a silent test command, which returns 0 if and only if
       there was no orphan in your query items.

       Find the orphan libtool files of your system:
	    $ qfile -o $(find /lib /usr/lib -name "*.la")
	    /usr/lib/libGL.la

       Find  the  libraries  needed  by	 the  binary "foo" which have not been
       installed by any package:
	    $ qfile -o $(scanelf -nq -F%n#F /path/to/foo | tr , '\n')
	    libinstalledmanually.so.2

$ROOT HANDLING
       By setting the ROOT environment variable, you can force qfile  to  work
       in  the	sytem  of your choice. This example shows queries for owner of
       "/bin/sh", first on your main system, and then on a system  mounted  on
       "/mnt":
	    $ qfile -q /bin/sh
	    app-shells/bash
	    $ ROOT=/mnt qfile -q /bin/sh
	    sys-apps/busybox

       Note  that  the	query  item is "/bin/sh" in both commands: by default,
       what qfile looks for is file paths as they are recorded in the packages
       database of the target system, and this paths don't include $ROOT.  If,
       at the contrary, you want to query  files  with	their  current	actual
       paths  (including  the  mount  point), you should add the --root-prefix
       (-R) option:
	    $ ROOT=/mnt qfile -Rq /mnt/bin/sh
	    sys-apps/busybox

       The other difference beetween defaults and -R queries is the output  of
       files  paths.   The  former  doesn't  include the $ROOT prefix, and the
       later does:
	    $ ROOT=/mnt qfile sh
	    sys-apps/busybox (/bin/sh)
	    $ ROOT=/mnt qfile -R sh
	    sys-apps/busybox (/mnt/bin/sh)

       Sure, the same differences hold when querying for orphan files:
	    $ ROOT=/mnt qfile -o $(ls /mnt/bin/ | sed 's:^/mnt::')
	    /bin/dostuff.sh
	    $ ROOT=/mnt qfile -Ro /mnt/bin/*
	    /mnt/bin/dostuff.sh

READING ARGUMENTS FROM A FILE/STDIN
       When you try to launch qfile with a large number of arguments, you  may
       hit the following shell error:
	    $ qfile -o $(find /usr/lib)
	    bash: ./qfile: Argument list too long

       To  avoid that, you must use the --from (-f) option, which allows read‐
       ing your arguments list in a file:
	    $ find /usr/lib > ~/usr-lib.list
	    $ qfile -o -f ~/usr-lib.list
	    /usr/lib/libMagick-5.5.7-Q16.so.0.0.0
	    /usr/lib/libGL.so
	    ...

       Your arguments list must be formatted with one file per line, and with‐
       out  any	 kind of garbage (no leading or trailing space, no empty line,
       etc.).  The default find output format is just fine in general.

       You can also read the arguments list from standard input with  the  "-"
       pseudo filename, which is useful with shell pipes:
	    $ find /usr/lib | qfile -o -f -
	    /usr/lib/libMagick-5.5.7-Q16.so.0.0.0
	    /usr/lib/libGL.so
	    ...

       Here  is	 an  other example of use.  This script lists some files which
       may be orphan config files left behind by Portage after	uninstallation
       or upgrade of some packages:
	    #!/bin/bash
	    SEARCH_PATHS="$(portageq envvar CONFIG_PROTECT)"
	    SEARCH_MASK="$(portageq envvar CONFIG_PROTECT_MASK) \
		 /etc/runlevels /etc/portage \
		 /etc/ssl/certs /etc/ssh \
		 /etc/bash_completion.d /etc/cups"
	    for path in ${SEARCH_MASK} ; do
		 EXCLUDE="${EXCLUDE} -not -path ${path}/*"
	    done
	    set -f
	    find ${SEARCH_PATHS} ${EXCLUDE} | qfile -o -f -

       IMPORTANT:  this script is just a quick example.	 Do not blindly delete
       the files it will list!

       When reading arguments from a file or from stdin, qfile will, for  per‐
       formances  reasons,  treat then by groups of 5000 (search owners of the
       5000 first files, then of the 5000 following ones, etc.).   This	 magic
       value should be fine in most cases, but you can change it if you really
       want, using the --max-args option (-m).	Using a greater value will eat
       a  bit more memory, but may be a bit faster for really big queries.  Be
       careful though, using some stupidly high or  low	 value	can  completly
       kill the performances.  In short, you probably don't want to touch this
       option.

SEARCHING FOR FILE COLLISIONS
       A last option of qfile is --exclude (-x), which will makes it skip  one
       particular  package  when  doing	 its files owners search.  This option
       takes  one  argument,  which  can  be   a   package   name   (bash   or
       app-shells/bash),   or	a   versioned	package	  (bash-3.2_p9-r1   or
       app-shells/bash-3.2_p9-r1),   or	  a   slotted	package	  (bash:0   or
       app-shells/bash:0).  It	is useful for finding file collisions beetween
       packages (ie., comparing the contents of one package with the  contents
       of all the others).

       For  example,  the following script will search collisions beetween all
       your installed packages. Be careful, this will takes time:
	    #!/bin/bash
	    cd $(portageq vdb_path)
	    for pkg in *-*/*-* ; do
		 [[ -f ${pkg}/CONTENTS ]] || continue
		 collisions=$(sed -n \
			   '/^obj\|^sym/s:^... \([^ ]\+\).*:1:p' \
			   ${pkg}/CONTENTS \
		      | qfile -e -x ${pkg} -f -)
		 [[ -n ${collisions} ]] \
		      && echo ">>> ${pkg}:" \
		      && echo "${collisions}"
	    done

       An other example is the following script, which can be  used  to	 check
       that  a	binary	package	 (.tbz2)  has  no  conflict  with  any of your
       installed packages, but the one it may replace (same name and slot), if
       any:
       #!/bin/bash
       pkgver=$(basename "${1}")
       pkgver=${pkgver%%.tbz2}
       pn=$(qatom ${pkgver} | cut -d\  -f2)
       tmpdir=$(mktemp -t -d) || exit 1
       tarbz2=${tmpdir}/${pkgver}.tar.bz2
       xpak=${tmpdir}/${pkgver}.xpak
       qtbz2 -s "${1}" "${tarbz2}" "${xpak}"
       categ=$(qxpak -O -x "${xpak}" CATEGORY)
       slot=$(qxpak -O -x "${xpak}" SLOT)
       tar tjf "${tarbz2}" \
	    | sed -e 's:^\./:/:' -e '\:/$:d' \
	    | qfile -e -f - -x ${categ}/${pn}:${slot}
       rm -rf "${tmpdir}"

ADDITIONAL CONTRIBUTORS
       TGL degrenier[at]easyconnect.fr

REPORTING BUGS
       Please report bugs via http://bugs.gentoo.org/
       Product: Portage Development; Component: Tools

AUTHORS
       Ned Ludd <solar@gentoo.org>
       Mike Frysinger <vapier@gentoo.org>

SEE ALSO
       q(1),  qatom(1), qcache(1), qcheck(1), qdepends(1), qgrep(1), qlist(1),
       qlop(1), qmerge(1), qpkg(1), qsearch(1), qsize(1),  qtbz2(1),  quse(1),
       qxpak(1)

Gentoo Foundation		   Mar 2014			      qfile(1)
[top]

List of man pages available for Gentoo

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net