I was wondering the possible best time case solutions to extract each RPM files from a list of TAR bundle and get the package information from those files.
So, I have a list of tar bundles in a directory, containing at least one RPM. For these, I have tried the simplest solution to loop over, extract and then peak into each RPM package using a bash script, which is taking a significant amount of time given the TAR bundles are over 20+.
I also tried bulk extraction using cat *.tar | tar -xvf - -i
, then rpm -qp #list of files
to get the package names which gave me an improvement over my last approach.
I know that I could peek into TAR bundle and get the .rpm file name, but since the name of the file containing a package has nothing to do with the name of the package, I need to check the RPM package as well.
The closest solution I could attempt was:
# given tarball-containing-wget-rpm-package.tar.gz contains wget.rpm
bash$ time (cat tarball-containing-wget-rpm-package.tar.gz|gunzip|tar --wildcards --extract '*.rpm' --to-stdout|rpm -qp /dev/stdin)
wget-1.11.4-1.40.1
real 0m0.049s
user 0m0.044s
sys 0m0.004s
which is pretty quick, but doesn't give right info if a TAR bundle contains more than one RPM files.
So, what I’m asking is:
- Can I bulk extract all TAR file to stdout and peek in the RPM files then?
- Can I perform this operation without extracting the files from TAR bundle?
- How can I modify the above command to work with a single TAR bundle containing multiple RPM?
-p
option expects a single package file, so I don't think you'll be able to use this approach. As a side note, you can replacecat filename|gunzip|tar
withtar -z -f filename
if you have GNU tar.rpm -qp --queryformat '%{NAME}\t%{VERSION}\t%{RELEASE}\n' a1.rpm a2.rpm a3.rpm
is working by giving package information.