File: global_database

package info (click to toggle)
haskell-hoogle 5.0.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 504 kB
  • ctags: 37
  • sloc: haskell: 2,762; ansic: 110; sh: 33; xml: 20; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 1,353 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
Description: Use Debian's hoogle database
 Allow hoogle to fall back to the Debian's global database
 if the default doesn't exist.
Author: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Forwarded: no, Debian specific

Index: b/src/Action/CmdLine.hs
===================================================================
--- a/src/Action/CmdLine.hs
+++ b/src/Action/CmdLine.hs
@@ -71,9 +71,17 @@ getCmdLine args = do
     args <- withArgs args $ cmdArgsRun cmdLineMode
 
     -- fill in the default database
+    -- If a database has not been given, and the default does not exist,
+    -- and this is not a generate command, fallback to the Debian database.
     args <- if database args /= "" then return args else do
         dir <- getAppUserDataDirectory "hoogle"
-        return $ args{database=dir </> "default-" ++ lower (show $ language args) ++ "-" ++ showVersion version ++ ".hoo"}
+        let db = dir </> "default-" ++ lower (show $ language args) ++ "-    " ++ showVersion version ++ ".hoo"
+            debdb = "/var/lib/hoogle/databases/default.hoo"
+        db_exists <- doesFileExist db
+        case args of
+          Generate{..} -> return $ args{database=db}
+          _ | db_exists -> return $ args{database=db}
+          _ -> return $ args{database=debdb}
 
     -- fix up people using Hoogle 4 instructions
     args <- case args of