Merge lp:~muktupavels/compiz/config into lp:compiz/0.9.13

Proposed by Alberts Muktupāvels on 2019-02-06
Status: Merged
Approved by: Dmitry Shachnev on 2019-02-08
Approved revision: 4210
Merged at revision: 4209
Proposed branch: lp:~muktupavels/compiz/config
Merge into: lp:compiz/0.9.13
Diff against target: 441 lines (+150/-120)
15 files modified
cmake/CompizCommon.cmake (+0/-17)
compizconfig/CMakeLists.txt (+3/-0)
compizconfig/libcompizconfig/config/CMakeLists.txt (+2/-8)
compizconfig/libcompizconfig/config/config (+0/-8)
compizconfig/libcompizconfig/config/config.conf (+27/-0)
compizconfig/libcompizconfig/libcompizconfig.pc.in (+3/-1)
compizconfig/libcompizconfig/src/CMakeLists.txt (+2/-2)
compizconfig/libcompizconfig/src/ccs_config_file.c (+105/-47)
compizconfig/libcompizconfig/src/main.c (+2/-2)
compizconfig/libcompizconfig/tests/CMakeLists.txt (+1/-1)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_context.cpp (+3/-3)
debian/compizconfig (+0/-27)
debian/libcompizconfig0.install (+1/-1)
debian/libcompizconfig0.maintscript (+1/-0)
debian/rules (+0/-3)
To merge this branch: bzr merge lp:~muktupavels/compiz/config
Reviewer Review Type Date Requested Status
Dmitry Shachnev 2019-02-06 Approve on 2019-02-07
Marco Trevisan (Treviño) 2019-02-06 Pending
Khurshid Alam 2019-02-06 Pending
Review via email: mp+362799@code.launchpad.net

Commit message

Add support for loading configuration from multiple files.

Description of the change

Add support for loading configuration from multiple files.

This is needed to allow external / other projects provide their own configuration without adding them to compiz. This is preparation to move unity config and upgrade files to unity.

To post a comment you must log in.
Dmitry Shachnev (mitya57) :
review: Approve
lp:~muktupavels/compiz/config updated on 2019-02-08
4210. By Alberts Muktupāvels on 2019-02-08

Remove old config file.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake/CompizCommon.cmake'
2--- cmake/CompizCommon.cmake 2019-02-05 20:39:56 +0000
3+++ cmake/CompizCommon.cmake 2019-02-08 11:43:36 +0000
4@@ -958,23 +958,6 @@
5
6 endmacro (compiz_test)
7
8-#### optional file install
9-
10-function (compiz_opt_install_file _src _dst)
11- install (CODE
12- "message (\"-- Installing: ${_dst}\")
13- execute_process (
14- COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${_src}\" \"$ENV{DESTDIR}${_dst}\"
15- RESULT_VARIABLE _result
16- OUTPUT_QUIET ERROR_QUIET
17- )
18- if (_result)
19- message (\"-- Failed to install: ${_dst}\")
20- endif ()
21- "
22- )
23-endfunction ()
24-
25 #### uninstall
26
27 function (compiz_add_code_to_uninstall_target CODE WORKING_DIRECTORY)
28
29=== modified file 'compizconfig/CMakeLists.txt'
30--- compizconfig/CMakeLists.txt 2016-05-12 10:14:55 +0000
31+++ compizconfig/CMakeLists.txt 2019-02-08 11:43:36 +0000
32@@ -4,6 +4,9 @@
33 set (COMPIZCONFIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/libcompizconfig/include)
34 set (COMPIZCONFIG_LIBRARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libcompizconfig)
35
36+set (COMPIZCONFIG_CONFIG_DIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/compizconfig)
37+set (COMPIZCONFIG_UPGRADES_DIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/compizconfig/upgrades)
38+
39 if (COMPIZ_PACKAGING_ENABLED)
40 set (libcompizconfig_prefix ${CMAKE_INSTALL_PREFIX} CACHE PATH "prefix")
41 set (libcompizconfig_libdir ${CMAKE_INSTALL_FULL_LIBDIR} CACHE PATH "libdir")
42
43=== modified file 'compizconfig/libcompizconfig/config/CMakeLists.txt'
44--- compizconfig/libcompizconfig/config/CMakeLists.txt 2012-07-23 06:22:04 +0000
45+++ compizconfig/libcompizconfig/config/CMakeLists.txt 2019-02-08 11:43:36 +0000
46@@ -1,13 +1,7 @@
47 set (_config_file
48- config)
49+ config.conf)
50
51 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config_test
52 ${CMAKE_CURRENT_BINARY_DIR}/compiz-1/compizconfig/config)
53
54-compiz_opt_install_file (${CMAKE_CURRENT_SOURCE_DIR}/${_config_file} ${COMPIZ_SYSCONFDIR}/compizconfig/${_config_file})
55-
56-add_custom_target (
57- config_install
58- ${CMAKE_COMMAND} -E make_directory ${CMAKE_ROOT}/Modules &&
59- ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/config/${_config_file} ${COMPIZ_SYSCONFDIR}/compizconfig/${_config_file}
60- )
61+install (FILES ${_config_file} DESTINATION ${COMPIZCONFIG_CONFIG_DIR})
62
63=== removed file 'compizconfig/libcompizconfig/config/config'
64--- compizconfig/libcompizconfig/config/config 2019-02-04 20:24:41 +0000
65+++ compizconfig/libcompizconfig/config/config 1970-01-01 00:00:00 +0000
66@@ -1,8 +0,0 @@
67-[gnome_session]
68-backend = gconf
69-integration = true
70-plugin_list_autosort = true
71-
72-[general]
73-backend = ini
74-plugin_list_autosort = true
75
76=== added file 'compizconfig/libcompizconfig/config/config.conf'
77--- compizconfig/libcompizconfig/config/config.conf 1970-01-01 00:00:00 +0000
78+++ compizconfig/libcompizconfig/config/config.conf 2019-02-08 11:43:36 +0000
79@@ -0,0 +1,27 @@
80+[general]
81+backend = ini
82+plugin_list_autosort = true
83+
84+[gnome_session]
85+backend = gsettings
86+integration = true
87+plugin_list_autosort = true
88+profile = Default
89+
90+[general_mate]
91+backend = gsettings
92+integration = false
93+plugin_list_autosort = true
94+profile = mate
95+
96+[general_ubuntu]
97+backend = gsettings
98+integration = true
99+plugin_list_autosort = true
100+profile = unity
101+
102+[general_ubuntu-lowgfx]
103+backend = gsettings
104+integration = true
105+plugin_list_autosort = true
106+profile = unity-lowgfx
107
108=== modified file 'compizconfig/libcompizconfig/libcompizconfig.pc.in'
109--- compizconfig/libcompizconfig/libcompizconfig.pc.in 2012-05-23 12:15:16 +0000
110+++ compizconfig/libcompizconfig/libcompizconfig.pc.in 2019-02-08 11:43:36 +0000
111@@ -3,6 +3,9 @@
112 libdir=@libcompizconfig_libdir@
113 includedir=@libcompizconfig_includedir@
114
115+configdir=@COMPIZCONFIG_CONFIG_DIR@
116+upgradesdir=@COMPIZCONFIG_UPGRADES_DIR@
117+
118 Name: libcompizconfig
119 Description: Compiz configuration system
120 Version: @VERSION@
121@@ -10,4 +13,3 @@
122 Requires: compiz
123 Libs: -L@libcompizconfig_libdir@ -lcompizconfig
124 Cflags: -I@libcompizconfig_includedir@
125-
126
127=== modified file 'compizconfig/libcompizconfig/src/CMakeLists.txt'
128--- compizconfig/libcompizconfig/src/CMakeLists.txt 2018-07-24 09:36:54 +0000
129+++ compizconfig/libcompizconfig/src/CMakeLists.txt 2019-02-08 11:43:36 +0000
130@@ -27,8 +27,8 @@
131 -DPLUGINDIR="${COMPIZ_PLUGINDIR}"
132 -DIMAGEDIR="${COMPIZ_IMAGEDIR}"
133 -DMETADATADIR="${COMPIZ_METADATADIR}"
134- -DSYSCONFDIR="${COMPIZ_SYSCONFDIR}"
135- -DDATADIR="${COMPIZ_DATADIR}"
136+ -DCONFIGDIR="${COMPIZCONFIG_CONFIG_DIR}"
137+ -DUPGRADESDIR="${COMPIZCONFIG_UPGRADES_DIR}"
138 -DLIBDIR="${COMPIZ_LIBDIR}"
139 )
140
141
142=== modified file 'compizconfig/libcompizconfig/src/ccs_config_file.c'
143--- compizconfig/libcompizconfig/src/ccs_config_file.c 2015-10-26 17:15:43 +0000
144+++ compizconfig/libcompizconfig/src/ccs_config_file.c 2019-02-08 11:43:36 +0000
145@@ -26,6 +26,9 @@
146 #ifndef _GNU_SOURCE
147 #define _GNU_SOURCE
148 #endif
149+
150+#include <dirent.h>
151+#include <errno.h>
152 #include <stdio.h>
153 #include <stdlib.h>
154 #include <string.h>
155@@ -92,56 +95,111 @@
156 }
157
158 static Bool
159+ccsReadGlobalConfigFromFile (const char *file,
160+ ConfigOption option,
161+ char **value)
162+{
163+ IniDictionary *iniFile;
164+ char *entry = NULL;
165+ char *section;
166+ Bool ret;
167+
168+ iniFile = ccsIniOpen (file);
169+ if (!iniFile)
170+ return FALSE;
171+
172+ switch (option)
173+ {
174+ case OptionProfile:
175+ entry = "profile";
176+ break;
177+ case OptionBackend:
178+ entry = "backend";
179+ break;
180+ case OptionIntegration:
181+ entry = "integration";
182+ break;
183+ case OptionAutoSort:
184+ entry = "plugin_list_autosort";
185+ break;
186+ default:
187+ break;
188+ }
189+
190+ if (!entry)
191+ {
192+ ccsIniClose (iniFile);
193+ return FALSE;
194+ }
195+
196+ *value = NULL;
197+ section = getSectionName();
198+ ret = ccsIniGetString (iniFile, section, entry, value);
199+ free (section);
200+ ccsIniClose (iniFile);
201+
202+ return ret;
203+}
204+
205+static int
206+configFilter (const struct dirent *entry)
207+{
208+ const char *suffix;
209+ size_t suffixLen;
210+ size_t nameLen;
211+
212+ suffix = ".conf";
213+ suffixLen = strlen (suffix);
214+ nameLen = strlen (entry->d_name);
215+
216+ if (nameLen < suffixLen)
217+ return 0;
218+
219+ if (strcmp (entry->d_name + nameLen - suffixLen, suffix) == 0)
220+ return 1;
221+
222+ return 0;
223+}
224+
225+static Bool
226 ccsReadGlobalConfig (ConfigOption option,
227 char **value)
228 {
229- IniDictionary *iniFile;
230- char *entry = NULL;
231- char *section;
232- Bool ret;
233- FILE *fp;
234-
235- /* check if the global config file exists - if it doesn't, exit
236- to avoid it being created by ccsIniOpen */
237- fp = fopen (SYSCONFDIR "/compizconfig/config", "r");
238- if (!fp)
239- return FALSE;
240- fclose (fp);
241-
242- iniFile = ccsIniOpen (SYSCONFDIR "/compizconfig/config");
243- if (!iniFile)
244- return FALSE;
245-
246- switch (option)
247- {
248- case OptionProfile:
249- entry = "profile";
250- break;
251- case OptionBackend:
252- entry = "backend";
253- break;
254- case OptionIntegration:
255- entry = "integration";
256- break;
257- case OptionAutoSort:
258- entry = "plugin_list_autosort";
259- break;
260- default:
261- break;
262- }
263-
264- if (!entry)
265- {
266- ccsIniClose (iniFile);
267- return FALSE;
268- }
269-
270- *value = NULL;
271- section = getSectionName();
272- ret = ccsIniGetString (iniFile, section, entry, value);
273- free (section);
274- ccsIniClose (iniFile);
275-
276+ Bool ret;
277+ const char *configDir;
278+ struct dirent **nameList;
279+ int num;
280+ int i;
281+
282+ ret = FALSE;
283+ configDir = CONFIGDIR;
284+
285+ num = scandir (configDir, &nameList, configFilter, alphasort);
286+
287+ if (num == -1)
288+ {
289+ ccsError ("error occurred during scandir(%s): %s", configDir, strerror (errno));
290+ return FALSE;
291+ }
292+
293+ for (i = 0; i < num; i++)
294+ {
295+ char *filename;
296+
297+ if (asprintf (&filename, "%s/%s", configDir, nameList[i]->d_name) == -1)
298+ continue;
299+
300+ ret = ccsReadGlobalConfigFromFile (filename, option, value);
301+ free (filename);
302+
303+ if (ret)
304+ break;
305+ }
306+
307+ for (i = 0; i < num; i++)
308+ free (nameList[i]);
309+ free (nameList);
310+
311 return ret;
312 }
313
314
315=== modified file 'compizconfig/libcompizconfig/src/main.c'
316--- compizconfig/libcompizconfig/src/main.c 2018-06-27 16:01:19 +0000
317+++ compizconfig/libcompizconfig/src/main.c 2019-02-08 11:43:36 +0000
318@@ -3344,7 +3344,7 @@
319 void
320 ccsSetProfileDefault (CCSContext * context, const char *name)
321 {
322- const char *globalProfileDir = SYSCONFDIR "/compizconfig";
323+ const char *globalProfileDir = CONFIGDIR;
324 CCSStringList availableInBackend = NULL;
325 CCSStringList availableInSysconfDir = NULL;
326
327@@ -4911,7 +4911,7 @@
328 ccsFreeUpgrade (upgrade);
329 }
330
331-static const char * CCS_UPGRADE_PATH = DATADIR "/compizconfig/upgrades";
332+static const char * CCS_UPGRADE_PATH = UPGRADESDIR;
333
334 static void
335 ccsApplyUnappliedUpgrades (CCSContext *context,
336
337=== modified file 'compizconfig/libcompizconfig/tests/CMakeLists.txt'
338--- compizconfig/libcompizconfig/tests/CMakeLists.txt 2018-07-24 09:36:54 +0000
339+++ compizconfig/libcompizconfig/tests/CMakeLists.txt 2019-02-08 11:43:36 +0000
340@@ -11,7 +11,7 @@
341
342 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
343
344-add_definitions (-DSYSCONFDIR="${COMPIZ_SYSCONFDIR}")
345+add_definitions (-DCONFIGDIR="${COMPIZCONFIG_CONFIG_DIR}")
346
347 add_executable (compizconfig_test_ccs_object
348 ${CMAKE_CURRENT_SOURCE_DIR}/compizconfig_test_ccs_object.cpp)
349
350=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_context.cpp'
351--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_context.cpp 2013-02-21 16:41:49 +0000
352+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_context.cpp 2019-02-08 11:43:36 +0000
353@@ -303,7 +303,7 @@
354 * just load the profile and end up with an empty config */
355 TEST_F (CCSContextTestWithMockedBackendProfile, ImportProfileIfNotAvailableInBackend)
356 {
357- const std::string sysconfProfile (std::string (SYSCONFDIR) + "/compizconfig/" + unavailableProfileStr);
358+ const std::string sysconfProfile (std::string (CONFIGDIR) + "/" + unavailableProfileStr);
359
360 ExistingProfile (availableProfileStr);
361 AddAvailableSysconfProfile (sysconfProfile);
362@@ -316,7 +316,7 @@
363
364 TEST_F (CCSContextTestWithMockedBackendProfile, ImportProfileDotIni)
365 {
366- const std::string sysconfProfile (std::string (SYSCONFDIR) + "/compizconfig/" + unavailableProfileStr + ".ini");
367+ const std::string sysconfProfile (std::string (CONFIGDIR) + "/" + unavailableProfileStr + ".ini");
368
369 ExistingProfile (availableProfileStr);
370 AddAvailableSysconfProfile (sysconfProfile);
371@@ -329,7 +329,7 @@
372
373 TEST_F (CCSContextTestWithMockedBackendProfile, ImportProfileDotProfile)
374 {
375- const std::string sysconfProfile (std::string (SYSCONFDIR) + "/compizconfig/" + unavailableProfileStr + ".profile");
376+ const std::string sysconfProfile (std::string (CONFIGDIR) + "/" + unavailableProfileStr + ".profile");
377
378 ExistingProfile (availableProfileStr);
379 AddAvailableSysconfProfile (sysconfProfile);
380
381=== removed file 'debian/compizconfig'
382--- debian/compizconfig 2016-07-04 10:12:34 +0000
383+++ debian/compizconfig 1970-01-01 00:00:00 +0000
384@@ -1,27 +0,0 @@
385-[general]
386-backend = ini
387-plugin_list_autosort = true
388-
389-[gnome_session]
390-backend = gsettings
391-integration = true
392-plugin_list_autosort = true
393-profile = Default
394-
395-[general_mate]
396-backend = gsettings
397-integration = false
398-plugin_list_autosort = true
399-profile = mate
400-
401-[general_ubuntu]
402-backend = gsettings
403-integration = true
404-plugin_list_autosort = true
405-profile = unity
406-
407-[general_ubuntu-lowgfx]
408-backend = gsettings
409-integration = true
410-plugin_list_autosort = true
411-profile = unity-lowgfx
412
413=== modified file 'debian/libcompizconfig0.install'
414--- debian/libcompizconfig0.install 2014-11-24 22:25:07 +0000
415+++ debian/libcompizconfig0.install 2019-02-08 11:43:36 +0000
416@@ -1,4 +1,4 @@
417-config /etc/compizconfig
418+etc/compizconfig
419 usr/lib/*/compizconfig/backends/libini.so
420 usr/lib/*/compiz/libccp.so
421 usr/lib/*/libcompizconfig.so.0
422
423=== added file 'debian/libcompizconfig0.maintscript'
424--- debian/libcompizconfig0.maintscript 1970-01-01 00:00:00 +0000
425+++ debian/libcompizconfig0.maintscript 2019-02-08 11:43:36 +0000
426@@ -0,0 +1,1 @@
427+rm_conffile /etc/compizconfig/config 1:0.9.13.1+19.04.20190208-0ubuntu1~ libcompizconfig0
428
429=== modified file 'debian/rules'
430--- debian/rules 2019-02-05 13:11:07 +0000
431+++ debian/rules 2019-02-08 11:43:36 +0000
432@@ -51,9 +51,6 @@
433 # remove acceptance test binary
434 rm -f debian/tmp/usr/bin/compiz_autopilot_acceptance_tests
435
436- # work around having a file with a conflicted special name (#1156294)
437- cp debian/compizconfig debian/tmp/config
438-
439 dh_install --fail-missing
440
441 # remove the compizconfig dev file from compiz-dev

Subscribers

People subscribed via source and target branches