dpkg-query 查询的数据库文件在哪里?

dpkg-query 查询的数据库文件在哪里?

我没有dpkg-query -S在手册页中看到检查的数据库文件在哪里。有人能告诉我它在哪里吗?谢谢。

答案1

这取决于您执行的具体查询类型,但所有的dpkg数据库文件都在 下/var/lib/dpkg。它们通常是纯文本文件。

例如,一个简单的方法dpkg-query -l可以在其中找到它所需要的内容/var/lib/dpkg/status

$ strace -e trace=open,openat dpkg-query -l base-files
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/var/lib/dpkg/arch", O_RDONLY) = 3
openat(AT_FDCWD, "/var/lib/dpkg/status", O_RDONLY) = 3
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/share/locale/en_GB/LC_MESSAGES/dpkg.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/dpkg.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_GB/LC_MESSAGES/dpkg.mo", O_RDONLY) = 4
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/dpkg.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/var/lib/dpkg/updates/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/var/lib/dpkg/triggers/File", O_RDONLY) = 3
openat(AT_FDCWD, "/var/lib/dpkg/triggers/Unincorp", O_RDONLY) = 3
openat(AT_FDCWD, "/dev/tty", O_RDONLY)  = 4
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY) = 4
||/ Name              Version       Architecture  Description
+++-=================-=============-=============-=======================================
ii  base-files        10.1ubuntu2.1 amd64         Debian base system miscellaneous files
+++ exited with 0 +++

更新:问题已从简单更改dpkg-query为具体dpkg-query -S.那么回答一下:

如上所述,具体dpkg-query查找的位置取决于您执行的查询类型,但其所有信息都位于下方/var/lib/dpkg/dpkg-query -S例如,对于查询,它会检查以下*.list文件中的每个文件/var/lib/dpkg/info/

$ strace -e trace=open,openat dpkg-query -S /bin/ls 
[…]
openat(AT_FDCWD, "/var/lib/dpkg/info/fonts-sil-abyssinica.list", O_RDONLY) = 4
openat(AT_FDCWD, "/var/lib/dpkg/info/libatk-adaptor:amd64.list", O_RDONLY) = 4
openat(AT_FDCWD, "/var/lib/dpkg/info/libvorbisfile3:amd64.list", O_RDONLY) = 4
openat(AT_FDCWD, "/var/lib/dpkg/info/libquadmath0:amd64.list", O_RDONLY) = 4
[…]
openat(AT_FDCWD, "/var/lib/dpkg/info/tzdata.list", O_RDONLY) = 4                             
openat(AT_FDCWD, "/var/lib/dpkg/diversions", O_RDONLY) = 4                                   
coreutils: /bin/ls                                                                           
+++ exited with 0 +++

相关内容