1

I am writing a little program that packages configuration files as rpm, and it puts a series of %triggers to handle installation/upgrade of the packages that bring a copy/version of the same file.

I am stuck trying to format yum provides output. The default output is:

# yum provides */named.conf -q
32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.i686 : A chroot runtime environment for the ISC BIND DNS server, named(8)
Repo        : base
Matched from:
Filename    : /var/named/chroot/etc/named.conf


sblim-cmpi-dns-test-1.0-1.el6.i686 : SBLIM WBEM-SMT Dns - Testcase Files
Repo        : base
Matched from:
Filename    : /usr/share/sblim-testsuite/named.conf

But i need only the package name. Using cut does not seem like a good idea. The delimiter would be - but there are several packages with a - in the middle of the package name.

Ideally I'd need the output to be formattable like for rpm queries:

rpm -qa --queryformat "%{NAME}\n"
make
rubygem-multi_json
attr
ncurses-base
rubygem-rack-test
strace
rubygem-polyglot
gpg-pubkey
rubygem-journey
tzdata
...
1
  • It seems that isn't available at all. Neither does it's replacement for Fedora, dnf.
    – vonbrand
    Commented Mar 7, 2014 at 17:43

2 Answers 2

0

You will be happier if you ditch yum in favor of the repoquery command from the yum-utils package. With this, you just run:

$ repoquery --whatprovides '*/named.conf' --qf '%{NAME}'

Which, on my system, returns:

bind
sblim-cmpi-dns-test
bind
bind-chroot
rubygem-openshift-origin-dns-bind
system-config-bind
logwatch
bind-chroot
1
  • Great. I will implement both solutions, so if repoquery will be used if available, otherwise the "fudge" above will be used
    – Bruno9779
    Commented Mar 10, 2014 at 11:30
0

I have devised an ugly solution for this problem using various yum commands, sed, grep and cut:

PKLIST=`yum provides -q */$FILE | grep -v 'Repo\|Matched\|Filename' | sed "s/32://g" | cut -d':' -f1 | sed "s/ //g" | grep -e '^$' -v`
array=($PKLIST)
arr2=()
for i in "${array[@]}"
do
        x=`yum info -C $i | grep "Name        :" | sed "s/Name        : //g"`
        arr2+=($x)
done

Then I removed duplicates from the array

arr3=$(echo "${arr2[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')

With my current bash knowledge it is the best I could do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .