How to list the contents of a package using YUM?

后端 未结 7 688
野趣味
野趣味 2020-12-07 06:55

I know how to use rpm to list the contents of a package (rpm -qpil package.rpm). However, this requires knowing the location of the .rpm file on the filesystem.

相关标签:
7条回答
  • 2020-12-07 07:43

    There are several good answers here, so let me provide a terrible one:

    : you can type in anything below, doesnt have to match anything
    
    yum whatprovides "me with a life"
    
    : result of the above (some liberties taken with spacing):
    
    Loaded plugins: fastestmirror
    base | 3.6 kB 00:00 
    extras | 3.4 kB 00:00 
    updates | 3.4 kB 00:00 
    (1/4): extras/7/x86_64/primary_db | 166 kB 00:00 
    (2/4): base/7/x86_64/group_gz | 155 kB 00:00 
    (3/4): updates/7/x86_64/primary_db | 9.1 MB 00:04 
    (4/4): base/7/x86_64/primary_db | 5.3 MB 00:05 
    Determining fastest mirrors
     * base: mirrors.xmission.com
     * extras: mirrors.xmission.com
     * updates: mirrors.xmission.com
    base/7/x86_64/filelists_db | 6.2 MB 00:02 
    extras/7/x86_64/filelists_db | 468 kB 00:00 
    updates/7/x86_64/filelists_db | 5.3 MB 00:01 
    No matches found
    
    : the key result above is that "primary_db" files were downloaded
    
    : filelists are downloaded EVEN IF you have keepcache=0 in your yum.conf
    
    : note you can limit this to "primary_db.sqlite" if you really want
    
    find /var/cache/yum -name '*.sqlite'
    
    : if you download/install a new repo, run the exact same command again
    : to get the databases for the new repo
    
    : if you know sqlite you can stop reading here
    
    : if not heres a sample command to dump the contents
    
    echo 'SELECT packages.name, GROUP_CONCAT(files.name, ", ") AS files FROM files JOIN packages ON (files.pkgKey = packages.pkgKey) GROUP BY packages.name LIMIT 10;' | sqlite3 -line /var/cache/yum/x86_64/7/base/gen/primary_db.sqlite 
    
    : remove "LIMIT 10" above for the whole list
    
    : format chosen for proof-of-concept purposes, probably can be improved a lot
    0 讨论(0)
提交回复
热议问题