Search code examples
rpmrpm-spec

Using rpm specfile to get files to be installed


I'm looking for a solution to query an RPM spec file to get the lists of files it installs, preferably without building the package(s). I've tried rpmspec --queryformat '%{filenames}' but it only results in (none)

Example test.spec:

Name:           test
Version:        1
Release:        1%{?dist}
Summary:        test
License:        bsd
URL:            http://localhost
Source0:        test.tgz
%description
%install
%files
/usr/foo.txt

Test run:

$ rpmspec --builtrpms -q --qf 'name: %{name}\nfiles: %{filenames}\n\n' test.spec
name: test
files: (none)

Expected result:

name: test
files: /usr/foo.txt

Solution

  • The spec file doesn't know how many files are being installed.

    If it had something like this:

    %files
    /path/to/a/ton/of/files/
    

    there's no way for it to know how many files would be in that directory after building the software.

    If you've built the RPM, you can use rpm -qlp <rpmfile> to see the files it would install without doing the actual installation. But again, you need a built RPM.