On 07/01/2008, Robert Wuest <rwuestfc@xxxxxxxxx> wrote: > This brings to mind a problem I had to deal with not too long ago. > > How does one find the spec file a package is built from? > > Is there a more reliable / faster way than something like this? > > rpm -qlp package.src.rpm | egrep '\.spec$' Faster? No. More reliable? Yes, but only with more complex code. Although it might be that nowadays no src.rpm contains more than one spec file anymore, and the complexity would not be worth the effort. In theory, you could verify that no Source/Patch file ends with ".spec". The spec filename must not be found in the arrays "[%{source}\n]" and "[%{patch}\n]", but is included in "[%{filenames}\n]" (which is the same as the -qlp output). Example: $ for f in $(rpm -qp sylpheed-2.3.1-0.1.3.EL.src.rpm --qf "[%{patch}\n]") ; do echo $f ; done sylpheed-2.3.1-CVE-2007-2958.patch sylpheed-2.3.1-escaped-quotes.patch sylpheed-2.3.1-pgpmime-signed-compose.patch sylpheed-2.3.1-apop-cve-2007-1558.patch sylpheed-2.2.5-prefs_common.patch sylpheed-2.3.1-certsdir-rhel.patch sylpheed-2.2.7-desktop.patch sylpheed-2.2.3-defs.h.patch $ for f in $(rpm -qp sylpheed-2.3.1-0.1.3.EL.src.rpm --qf "[%{source}\n]") ; do echo $f ; done sylpheed.1 sylpheed-2.3.1.tar.bz2 But: $ for f in $(rpm -qp sylpheed-2.3.1-0.1.3.EL.src.rpm --qf "[%{filenames}\n]"); do echo $f ; done sylpheed-2.2.3-defs.h.patch sylpheed-2.2.5-prefs_common.patch sylpheed-2.2.7-desktop.patch sylpheed-2.3.1-CVE-2007-2958.patch sylpheed-2.3.1-apop-cve-2007-1558.patch sylpheed-2.3.1-certsdir-rhel.patch sylpheed-2.3.1-escaped-quotes.patch sylpheed-2.3.1-pgpmime-signed-compose.patch sylpheed-2.3.1.tar.bz2 sylpheed.1 sylpheed.spec