• Bug#1076155: dpkg-query --search does not use partial pathnames as patt

    From js@1:229/2 to All on Thu Jul 11 18:40:01 2024
    XPost: linux.debian.bugs.dist
    From: em2jacks@yahoo.com

    Package: dpkg
    Version: 1.22.6
    Severity: minor

    Dear Maintainer,

    ===========================================================================

    dpkg-query does not use a partial pathname as a pattern to search.

    Example:
    => which exiftool
    /bin/exiftool
    => dpkg-query --search `which exiftool`
    dpkg-query: no path found matching pattern /bin/exiftool
    => dlocate `which exiftool`
    libimage-exiftool-perl: /usr/bin/exiftool
    => dpkg-query --search /usr/bin/exiftool
    libimage-exiftool-perl: /usr/bin/exiftool
    => /bin/ls -lt /usr/bin/exiftool /bin/exiftool
    -rwxr-xr-x 1 root root 320936 Feb 2 19:43 /bin/exiftool
    -rwxr-xr-x 1 root root 320936 Feb 2 19:43 /usr/bin/exiftool

    The behavior of dlocate, which takes "/bin/exiftool" as an argument and
    returns the package containing /usr/bin/exiftool is more useful.

    ===========================================================================


    -- Package-specific info:

    -- System Information:
    Debian Release: trixie/sid
    APT prefers testing
    APT policy: (500, 'testing')
    Architecture: amd64 (x86_64)

    Kernel: Linux 6.5.0-5-amd64 (SMP w/12 CPU threads; PREEMPT)
    Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
    Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to C.UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)

    Versions of packages dpkg depends on:
    ii libbz2-1.0 1.0.8-5.1
    ii libc6 2.38-11
    ii liblzma5 5.4.5-0.3
    ii libmd0 1.1.0-2
    ii libselinux1 3.5-2+b2
    ii libzstd1 1.5.5+dfsg2-2
    ii tar 1.35+dfsg-3
    ii zlib1g 1:1.3.dfsg+really1.3.1-1

    dpkg recommends no packages.

    Versions of packages dpkg suggests:
    ii apt 2.9.5
    ii debsig-verify 0.30

    -- Configuration Files:
    /etc/dpkg/dpkg.cfg changed:
    refuse-downgrade
    no-debsig
    log /var/log/dpkg.log


    -- no debconf information

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Vincent Lefevre@1:229/2 to All on Wed May 7 11:50:01 2025
    XPost: linux.debian.bugs.dist
    From: vincent@vinc17.net

    On 2024-07-11 12:32:44 -0400, js wrote:
    dpkg-query does not use a partial pathname as a pattern to search.

    Example:
    => which exiftool
    /bin/exiftool
    => dpkg-query --search `which exiftool`
    dpkg-query: no path found matching pattern /bin/exiftool
    => dlocate `which exiftool`
    libimage-exiftool-perl: /usr/bin/exiftool
    => dpkg-query --search /usr/bin/exiftool
    libimage-exiftool-perl: /usr/bin/exiftool
    => /bin/ls -lt /usr/bin/exiftool /bin/exiftool
    -rwxr-xr-x 1 root root 320936 Feb 2 19:43 /bin/exiftool
    -rwxr-xr-x 1 root root 320936 Feb 2 19:43 /usr/bin/exiftool

    This seems to be the intended behavior. In the dpkg-query(1) man page:

    -S, --search filename-search-pattern...
    [...]
    If the first character in the filename-search-pattern is
    none of ‘*[?/’ then it will be considered a substring match
    and will be implicitly surrounded by ‘*’ (as in
    *filename-search-pattern*).

    Since your searches start with "/", you are requesting an exact match.

    Using realpath solves the issue:

    $ dpkg-query --search $(realpath /bin/exiftool)
    libimage-exiftool-perl: /usr/bin/exiftool

    You could write a small script that does what you want.

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)