Merge lp:~bregma/ginn/fix-699925 into lp:ginn

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 83
Proposed branch: lp:~bregma/ginn/fix-699925
Merge into: lp:ginn
Diff against target: 81 lines (+37/-7)
3 files modified
etc/Makefile.am (+6/-0)
src/Makefile.am (+1/-1)
src/ginn.c (+30/-6)
To merge this branch: bzr merge lp:~bregma/ginn/fix-699925
Reviewer Review Type Date Requested Status
Gustavo Luiz Duarte (community) Approve
Mohamed IKBEL Boulabiar (community) Approve
Review via email: mp+48625@code.launchpad.net

Description of the change

Adds $HOME/.ginn to the config (wishes) file search path and eliminates $(prefix)/share/ginn from the same path.

Also installs the default wishes.xml to $(sysconfdir)/ginn so it can be made a conffile.

This should resolve the complaints about things not working as expected.

To post a comment you must log in.
Revision history for this message
Mohamed IKBEL Boulabiar (boulabiar) wrote :

Thanks Stephen for this patch.

review: Approve
Revision history for this message
Gustavo Luiz Duarte (gustavold) wrote :

Thanks Stephen!
It works great here.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/Makefile.am'
2--- etc/Makefile.am 2010-12-10 14:15:40 +0000
3+++ etc/Makefile.am 2011-02-04 16:11:55 +0000
4@@ -1,4 +1,10 @@
5 # etc/Makefile.am - ginn configuration build recipe
6
7+pkgconfdir = ${sysconfdir}/ginn
8+
9+# install as a template
10 dist_pkgdata_DATA = wishes.xml
11
12+# install as a conffile
13+pkgconf_DATA = wishes.xml
14+
15
16=== modified file 'src/Makefile.am'
17--- src/Makefile.am 2010-12-10 14:15:40 +0000
18+++ src/Makefile.am 2011-02-04 16:11:55 +0000
19@@ -3,7 +3,7 @@
20
21 ginn_SOURCES = ginn.c config.h config.c xt.c bamf.c
22 ginn_CFLAGS = \
23- -DGINN_CONFIG_DIR=\"$(pkgdatadir)\" \
24+ -DGINN_CONFIG_DIR=\"$(sysconfdir)/ginn\" \
25 $(GEIS_CFLAGS) $(XTST_CFLAGS) $(X11_CFLAGS) $(XML2_CFLAGS) $(BAMF_CFLAGS)
26 ginn_LDFLAGS = $(GEIS_LIBS) $(XTST_LIBS) $(X11_LIBS) $(XML2_LIBS) $(BAMF_LIBS)
27
28
29=== modified file 'src/ginn.c'
30--- src/ginn.c 2011-01-26 16:25:33 +0000
31+++ src/ginn.c 2011-02-04 16:11:55 +0000
32@@ -284,7 +284,7 @@
33 "etc",
34 "../etc",
35 ".",
36- "/etc/ginn",
37+ "$HOME/.ginn",
38 GINN_CONFIG_DIR
39 };
40 static const int num_paths = sizeof(search_paths) / sizeof(const char *);
41@@ -293,11 +293,35 @@
42 for (i=0; i < num_paths; ++i)
43 {
44 struct stat sbuf;
45- char *file_name = calloc(strlen(search_paths[i])
46- + strlen(default_file_name)
47- + 1,
48- sizeof(char));
49- strcpy(file_name, search_paths[i]);
50+ char *file_name = NULL;
51+
52+ if (strstr(search_paths[i], "$HOME"))
53+ {
54+ char *home_dir = getenv("HOME");
55+ if (!home_dir)
56+ {
57+ continue;
58+ }
59+ else
60+ {
61+ char *cdr = index(search_paths[i], '/');
62+ size_t file_name_length = strlen(home_dir)
63+ + strlen(cdr)
64+ + strlen(default_file_name)
65+ + 1;
66+ file_name = calloc(file_name_length, sizeof(char));
67+ strcpy(file_name, home_dir);
68+ strcat(file_name, cdr);
69+ }
70+ }
71+ else
72+ {
73+ size_t file_name_length = strlen(search_paths[i])
74+ + strlen(default_file_name)
75+ + 1;
76+ file_name = calloc(file_name_length, sizeof(char));
77+ strcpy(file_name, search_paths[i]);
78+ }
79 strcat(file_name, default_file_name);
80 int sres = stat(file_name, &sbuf);
81 if (sres == 0)