summaryrefslogtreecommitdiff
path: root/debian/patches/0001-Support-finding-databases-in-var-as-well-as-usr.patch
blob: 8e2603fcd697d34d350fd1ab764d0e154861be87 (plain)
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
From: Russ Allbery <rra@debian.org>
Date: Sun, 26 Apr 2015 19:21:42 -0700
Subject: Support finding databases in /var as well as /usr

The bearoff database is built (optionally) at installation time
instead of included in the package, and the Debian package recommends
downloading additional packages into /var instead of /usr, since
modifying /usr or encouraging users to store files in it seems wrong
from an FHS perspective.  Patch gnubg to support finding databases in
/var as well as /usr.
---
 eval.c | 10 ++++++----
 util.h |  3 +++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/eval.c b/eval.c
index 54d5b69..b501e47 100644
--- a/eval.c
+++ b/eval.c
@@ -656,7 +656,9 @@ EvalInitialise(char *szWeights, char *szWeightsBinary, int fNoBearoff, void (*pf
             pbc1 = BearoffInit(NULL, BO_HEURISTIC, pfProgress);
 
         /* read two-sided db from gnubg.bd */
-        gnubg_bearoff = BuildFilename("gnubg_ts0.bd");
+        /* For Debian, load dynamic databases from /var/lib/gnubg
+           instead.  -- rra, 2008-02-16 */
+        gnubg_bearoff = BuildVarFilename("gnubg_ts0.bd");
         pbc2 = BearoffInit(gnubg_bearoff, BO_IN_MEMORY | BO_MUST_BE_TWO_SIDED, NULL);
         g_free(gnubg_bearoff);
 
@@ -669,12 +671,12 @@ EvalInitialise(char *szWeights, char *szWeightsBinary, int fNoBearoff, void (*pf
                     "with the command: makebearoff -t 6x6 -f gnubg_ts0.bd\n"
                     "You can also generate other bearoff databases; see\n" "README for more details\n\n");
 
-        gnubg_bearoff_os = BuildFilename("gnubg_os.bd");
+        gnubg_bearoff_os = BuildVarFilename("gnubg_os.bd");
         /* init one-sided db */
         pbcOS = BearoffInit(gnubg_bearoff_os, BO_IN_MEMORY|BO_MUST_BE_ONE_SIDED, NULL);
         g_free(gnubg_bearoff_os);
 
-        gnubg_bearoff = BuildFilename("gnubg_ts.bd");
+        gnubg_bearoff = BuildVarFilename("gnubg_ts.bd");
         /* init two-sided db */
         pbcTS = BearoffInit(gnubg_bearoff, BO_IN_MEMORY|BO_MUST_BE_TWO_SIDED, NULL);
         g_free(gnubg_bearoff);
@@ -685,7 +687,7 @@ EvalInitialise(char *szWeights, char *szWeightsBinary, int fNoBearoff, void (*pf
             char *fn;
             char sz[10];
             sprintf(sz, "hyper%1d.bd", i + 1);
-            fn = BuildFilename(sz);
+            fn = BuildVarFilename(sz);
             apbcHyper[i] = BearoffInit(fn, BO_IN_MEMORY, NULL);
             g_free(fn);
         }
diff --git a/util.h b/util.h
index bcddff7..11cf75f 100644
--- a/util.h
+++ b/util.h
@@ -36,6 +36,9 @@ extern char *getDocDir(void);
 #define BuildFilename(file) g_build_filename(getPkgDataDir(), file, NULL)
 #define BuildFilename2(file1, file2) g_build_filename(getPkgDataDir(), file1, file2, NULL)
 
+/* Added for Debian -- rra, 2008-02-16 */
+#define BuildVarFilename(file) g_build_filename("/var/lib/gnubg", file, NULL)
+
 extern void PrintSystemError(const char *message);
 extern void PrintError(const char *message);
 extern FILE *GetTemporaryFile(const char *nameTemplate, char **retName);