Package: command-not-found / 0.2.38-1

adjust-paths.diff Patch series | 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Change the path for the databases to /var/cache/command-not-found and the path
of the script itself to /usr/share/command-not-found/command-not-found.

Also do not extract the component and architecture from the filename,
use a key named :component: and drop arch.
--- a/command-not-found
+++ b/command-not-found
@@ -14,7 +14,7 @@ from optparse import OptionParser
 def main():
     parser = OptionParser(version = __version__, usage=_("%prog [options] <command-name>"))
     parser.add_option('-d', '--data-dir', action='store',
-                      default="/usr/share/command-not-found",
+                      default="/var/cache/command-not-found",
                       help=_("use this path to locate data fields"))
     parser.add_option('--ignore-installed', '--ignore-installed',
                       action='store_true',  default=False,
--- a/CommandNotFound/CommandNotFound.py
+++ b/CommandNotFound/CommandNotFound.py
@@ -45,8 +45,8 @@ class ProgramDatabase:
     (PACKAGE, BASENAME_PATH) = range(2)
     def __init__(self, filename):
         basename = os.path.basename(filename)
-        (self.arch, self.component) = basename.split(".")[0].split("-")
         self.db = BinaryDatabase(filename)
+        self.component = self.db.db[':component:']
     def lookup(self, command):
         result = self.db.lookup(command)
         if result:
@@ -67,15 +67,15 @@ def similar_words(word):
     return set(deletes + transposes + replaces + inserts)
 
 class CommandNotFound:
-    programs_dir = "programs.d"
-    prefixes = ("/bin", 
-                "/usr/bin", 
-                "/usr/local/bin", 
+    programs_dir = ""
+    prefixes = ("/bin",
+                "/usr/bin",
+                "/usr/local/bin",
                 "/sbin", "/usr/sbin",
-                "/usr/local/sbin", 
+                "/usr/local/sbin",
                 "/usr/games")
     def __init__(self, data_dir=os.sep.join(
-            ('/','usr','share','command-not-found'))):
+            ('/','var','cache','command-not-found'))):
         self.programs = []
         self.priority_overrides = []
         p = os.path.join(data_dir, "priority.txt")
@@ -158,7 +158,7 @@ class CommandNotFound:
         " give advice where to find the given command to stderr "
         def _in_prefix(prefix, command):
             " helper that returns if a command is found in the given prefix "
-            return (os.path.exists(os.path.join(prefix, command)) and 
+            return (os.path.exists(os.path.join(prefix, command)) and
                     not os.path.isdir(os.path.join(prefix, command)))
 
         if command.startswith("/"):
--- a/bash_command_not_found
+++ b/bash_command_not_found
@@ -5,8 +5,8 @@
 # installation of packages available from the repository
 
 command_not_found_handle() {
-  if  [ -x /usr/lib/command-not-found ]; then
-     /usr/bin/python /usr/lib/command-not-found -- "$1" 
+  if  [ -x /usr/share/command-not-found/command-not-found ]; then
+     /usr/share/command-not-found/command-not-found -- "$1" 
      return $?
   else
      return 127
--- a/zsh_command_not_found
+++ b/zsh_command_not_found
@@ -7,15 +7,15 @@
 # Pseudo-namespace cnf_
 
 function cnf_preexec() {
-	typeset -g cnf_command="${1%% *}"
+    typeset -g cnf_command="${1%% *}"
 }
 
 function cnf_precmd() {
-	(($?)) && [ -n "$cnf_command" ] && [ -x /usr/lib/command-not-found ] && {
-		whence -- "$cnf_command" >& /dev/null ||
-			/usr/bin/python /usr/lib/command-not-found -- "$cnf_command"
-		unset cnf_command
-	}
+    (($?)) && [ -n "$cnf_command" ] && [ -x /usr/share/command-not-found/command-not-found ] && {
+        whence -- "$cnf_command" >& /dev/null ||
+            /usr/bin/python /usr/share/command-not-found/command-not-found -- "$cnf_command"
+        unset cnf_command
+    }
 }
 
 typeset -ga preexec_functions