File: README.md

package info (click to toggle)
command-not-found 18.04.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 8,184 kB
  • sloc: python: 995; sh: 43; makefile: 9
file content (78 lines) | stat: -rw-r--r-- 2,628 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Command-not-found

This application implements the command-not-found spec at:
https://wiki.ubuntu.com/CommandNotFoundMagic

If you want automatic prompts to install the package, set
COMMAND_NOT_FOUND_INSTALL_PROMPT in your environment.

To use it in bash, please add the following line to your .bashrc file:
. /etc/bash_command_not_found

To use it in zsh, please add the following line to your .zshrc file:
. /etc/zsh_command_not_found
Note that it overrides the preexec and precmd functions, in case you have
defined your own.

## Data sources

Command-not-found will for the following data sources:
1. sqlite3 DB in /usr/share/command-not-found/commands.db, if that is
   *not* found it will fallback to (2)
2. legacy /usr/share/command-not-found/programs.d/*.db gdbm style database

The datasource (1) is generated from data found on the archive server
in deb822 format. The data is generated via
https://code.launchpad.net/~mvo/command-not-found-extractor/+git/command-not-found-extractor
and is downloaded via `apt update`.

The datasource (2) is generated via a static `command-not-found-data`
deb package. It is less rich and dynamic than (1) and should be
considered legacy and only be used if no better data source is
available.

### DB schemas

#### Legacy DB:

Simple key/value store with key `program_name` (e.g. bash) and value a
comma separated list of packages that provide the program name. The
filename indicates the component and architecuture via:
`$component-$arch.db`.

#### Sqlite3 DB:

The database looks like this:
```
           CREATE TABLE IF NOT EXISTS "commands" 
           (
            [command] TEXT PRIMARY KEY NOT NULL,
            [pkgID] INTEGER NOT NULL,
            FOREIGN KEY ([pkgID]) REFERENCES "pkgs" ([pkgID])
           );
           CREATE TABLE IF NOT EXISTS "packages"
           (
            [pkgID] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
            [name] TEXT,
            [version] TEXT,
            [priority] INTEGER
           );
```

There is no need to store the component because we do not display that
in c-n-f. Note that the "name" in the "pkgs" table may include an
architecture qualifier. This is an optimization for multi-arch
systems, by default if there is "bash:amd64" and "bash:i386" on an
amd64 multi-arch systems we will not store "bash:i386" in the DB at
all and will store "bash:amd64" just as "bash". However for commands
that are only available for the foreign arch (e.g. "wine:i386") the
full qualified package name is stored in the DB and used in the c-n-f
output.


## Development

To run the tests type:

    $ python -m unittest discover