How to find out which package provides some feature or file ?

4 posts / 0 new
Last post
#1 Fri, 2016-06-24 04:56
iamtzh
  • iamtzh's picture
  • Offline
  • Last seen: 1 year 9 months ago
  • Joined: 2016-06-23

For example, if i wanna find out which package provides ab (Apache HTTP server benchmarking tool) in RHEL/CentOS :

[root@test01 ~]# yum whatprovides '*bin/ab'
 
httpd-tools-2.2.15-53.el6.centos.x86_64 : Tools for use with the Apache HTTP Server
Repo        : base
Matched from:
Filename    : /usr/bin/ab
 
httpd24u-tools-2.4.20-3.ius.el6.x86_64 : Tools for use with the Apache HTTP Server
Repo        : ius
Matched from:
Filename    : /usr/bin/ab

In Alpine Linux, `apk info --who-owns /sbin/lbu` just like `rpm -qf /sbin/lbu`, only for installed packages, can not search package in the repository. I cann't find any command support this feature like `yum whatprovides`.
Any help would be appreciated!

Fri, 2016-06-24 11:04
ScrumpyJack
  • ScrumpyJack's picture
  • Offline
  • Last seen: 6 months 3 weeks ago
  • Joined: 2013-06-20

You can search http://pkgs.alpinelinux.org/packages
There is an API being developed

Until then you can script the site like this

apkfind() {wget -q --no-check-certificate -O - http://pkgs.alpinelinux.org/contents\?file=$1 | sed -e '1,119d' -e '/panel-footer/,$ d' -e 's/]*>//g' -e 's/\&\#x2F\;/\//g' -e '/^ *$/d' | xargs -n 5 | awk '{ printf("%-20s %-7s %-11s %-13s %s\n",$2,$3,$4,$5,$1)}' }

Mon, 2016-06-27 07:42
iamtzh
  • iamtzh's picture
  • Offline
  • Last seen: 1 year 9 months ago
  • Joined: 2016-06-23

Thanks for your reply!

curl -s 'http://pkgs.alpinelinux.org/contents?file=xmllint&path=%2Fusr%2Fbin&repo=main&arch=x86_64' \
    | xmllint --html --xpath '//*[@id="main"]/div/div[3]/table[@class="table table-striped table-bordered table-condensed" and @data-toggle="table"]' - 2>/dev/null \
    | lynx --dump -stdin
         File           Package      Branch Repository Architecture
   /usr/bin/xmllint [1]libxml2-utils v3.3   main       x86_64
   /usr/bin/xmllint [2]libxml2-utils v3.4   main       x86_64
   /usr/bin/xmllint [3]libxml2-utils edge   main       x86_64
 
References
 
   1. file:///package/v3.3/main/x86_64/libxml2-utils
   2. file:///package/v3.4/main/x86_64/libxml2-utils
   3. file:///package/edge/main/x86_64/libxml2-utils

Wed, 2017-01-04 06:01
stuartnelson3
  • stuartnelson3's picture
  • Offline
  • Last seen: 1 year 2 months ago
  • Joined: 2017-01-04

Any update on the API, or where I can follow progress?

Log in or register to post comments