commando icon indicating copy to clipboard operation
commando copied to clipboard

Is the information powering command-not-found.com publicly available?

Open curusarn opened this issue 4 years ago • 4 comments

Hi, I got here from command-not-found.com and I'm wondering where you get the information you serve on command-not-found.com? Specifically, I'm interested in the installation instructions, not the usage help.

Is it publicly available? Is there an API?

Thanks

Simon

curusarn avatar Apr 23 '20 10:04 curusarn

+1

MaxPeal avatar Jun 04 '20 19:06 MaxPeal

+1

jdnixx avatar Sep 18 '20 06:09 jdnixx

I have not released that publicly, however underneath the command-not-found.com indexer are common commands you use every day to maintain packages on the chosen Linux distribution. The indexer runs more than 100 docker jobs to index several Linux distributions in different versions. It targets and indexes all binaries reported. The documentation is taken from the package metadata and man files stored in the package, additionally tl;dr; is used.

Example scripts to index packages:

$ cat alpine/bin/list-packages.sh
#!/usr/bin/env bash
# http://uk.alpinelinux.org/alpine/v3.8/main/x86_64/
# http://uk.alpinelinux.org/alpine/v3.8/community/x86_64/
apk info -q -U -a '*' 2>/dev/null

$ cat debian/bin/list-packages.sh
#!/usr/bin/env bash
(
    apt-cache show '*' ||
    apt-cache show '.*'
) 2>/dev/null

$ cat centos/bin/list-packages.sh
#!/usr/bin/env bash
yum info '*'

$ cat fedora/bin/list-packages.sh
#!/usr/bin/env bash
dnf info -q -y '*'

Examples for fetching the database of commands:

$ cat debian/bin/list-binaries.sh
#!/usr/bin/env bash
apt-file search "/bin/"
apt-file search "/sbin/"

$ cat centos/bin/list-binaries.sh
#!/usr/bin/env bash
yum -q whatprovides '*/bin/*'
yum -q whatprovides '*/sbin/*'

lukaszlach avatar Sep 29 '21 21:09 lukaszlach

Commando uses the one and only API HTTP endpoint exposed by command-not-found.com (https://github.com/lukaszlach/commando/blob/master/builder/alpine/install.sh#L6) to fetch the package name for Alpine.

lukaszlach avatar Sep 29 '21 21:09 lukaszlach