Domanda

So usare rpm per elencare il contenuto di un pacchetto ( rpm -qpil package.rpm ). Tuttavia, ciò richiede la conoscenza della posizione del file .rpm sul filesystem. Una soluzione più elegante sarebbe quella di utilizzare il gestore di pacchetti, che nel mio caso è YUM. Come si può usare YUM per raggiungere questo obiettivo?

È stato utile?

Soluzione

Esiste un pacchetto chiamato yum-utils che si basa su YUM e contiene uno strumento chiamato repoquery che può fare questo.

$ repoquery --help | grep -E "list\ files" 
  -l, --list            list files in this package/group

Combinato in un esempio:

$ repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz

Su almeno un sistema RH, con rpm v4.8.0, yum v3.2.29 e repoquery v0.0.11, repoquery -l rpm non stampa nulla.

Se stai riscontrando questo problema, prova ad aggiungere il --installed flag: repoquery --installed -l rpm .


DNF Aggiornamento:

Per usare dnf invece di yum-utils , usa il seguente comando:

$ dnf repoquery -l time
/usr/bin/time
/usr/share/doc/time-1.7
/usr/share/doc/time-1.7/COPYING
/usr/share/doc/time-1.7/NEWS
/usr/share/doc/time-1.7/README
/usr/share/info/time.info.gz

Altri suggerimenti

rpm -ql [packageName]

Esempio

# rpm -ql php-fpm

/etc/php-fpm.conf
/etc/php-fpm.d
/etc/php-fpm.d/www.conf
/etc/sysconfig/php-fpm
...
/run/php-fpm
/usr/lib/systemd/system/php-fpm.service
/usr/sbin/php-fpm
/usr/share/doc/php-fpm-5.6.0
/usr/share/man/man8/php-fpm.8.gz
...
/var/lib/php/sessions
/var/log/php-fpm

Non è necessario installare yum-utils o conoscere la posizione del file rpm.

$ yum install -y yum-utils

$ repoquery -l packagename

Non penso che tu possa elencare il contenuto di un pacchetto usando yum, ma se hai il file .rpm sul tuo sistema locale (come molto probabilmente sarà il caso di tutti i pacchetti installati), puoi usare rpm comando per elencare il contenuto di quel pacchetto in questo modo:

rpm -qlp /path/to/fileToList.rpm

Se non hai il file del pacchetto (.rpm), ma hai installato il pacchetto, prova questo:

rpm -ql packageName

Ci sono diverse buone risposte qui, quindi lasciatemi fornire una terribile:

: 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

Yum non ha il proprio tipo di pacchetto. Yum opera e aiuta a gestire gli RPM. Quindi, puoi usare yum per elencare gli RPM disponibili e quindi eseguire il comando rpm -qlp per vedere il contenuto di quel pacchetto.

attualmente reopquery è integrato in dnf e yum , quindi digitando:

dnf repoquery -l <pkg-name>

elencherà i contenuti dei pacchetti da un repository remoto (anche per i pacchetti che non sono ancora stati installati)

che significa installare un pacchetto dnf-utils o yum-utils separato non è più richiesto per la funzionalità in quanto ora è supportato in modo nativo.


per elencare i contenuti dei pacchetti installati o locali ( * .rpm ) c'è rpm -ql

non credo sia possibile con yum org dnf (non repoquery sottocomando)

per favore correggimi se sbaglio

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top