Merge lp:~larryprice/libertine/liblibertine-plus-libertined into lp:libertine
- liblibertine-plus-libertined
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Larry Price |
Approved revision: | 370 |
Merged at revision: | 388 |
Proposed branch: | lp:~larryprice/libertine/liblibertine-plus-libertined |
Merge into: | lp:libertine |
Diff against target: |
2613 lines (+717/-723) 49 files modified
CMakeLists.txt (+1/-1) cmake/FindGObjectIntrospection.cmake (+0/-61) cmake/ListOperations.cmake (+0/-18) cmake/UseGObjectIntrospection.cmake (+0/-102) common/LibertineConfig.cpp (+1/-9) data/CMakeLists.txt (+1/-1) data/com.canonical.libertine.Service.service (+1/-1) debian/changelog (+7/-0) debian/control (+23/-17) debian/gir1.2-libertine.install (+0/-2) debian/libertine-tools.install (+0/-2) debian/libertined.install (+3/-0) debian/python3-libertine.install (+0/-1) debian/rules (+1/-1) liblibertine/CMakeLists.txt (+3/-30) liblibertine/libertine.cpp (+20/-164) liblibertine/libertine.h (+4/-4) liblibertine/libertined.cpp (+199/-0) liblibertine/libertined.h (+25/-0) python/libertine/ChrootContainer.py (+6/-7) python/libertine/ContainersConfig.py (+9/-0) python/libertine/Libertine.py (+43/-21) python/libertine/LxcContainer.py (+4/-5) python/libertine/LxdContainer.py (+13/-13) python/libertine/service/apt.py (+2/-6) python/libertine/service/container.py (+29/-5) python/libertine/service/manager.py (+8/-1) python/libertine/service/progress.py (+3/-3) python/libertine/service/task_dispatcher.py (+8/-5) python/libertine/service/tasks/__init__.py (+4/-2) python/libertine/service/tasks/base_task.py (+2/-4) python/libertine/service/tasks/container_info_task.py (+21/-5) python/libertine/service/tasks/list_app_ids_task.py (+35/-0) python/libertine/service/tasks/list_apps_task.py (+8/-4) python/libertine/service/tasks/list_task.py (+6/-4) python/libertine/utils.py (+15/-36) snapcraft.yaml (+13/-1) tests/integration/test_libertine_service.py (+26/-16) tests/unit/service/tasks/CMakeLists.txt (+1/-0) tests/unit/service/tasks/test_container_info_task.py (+14/-2) tests/unit/service/tasks/test_list_app_ids_task.py (+59/-0) tests/unit/service/tasks/test_list_task.py (+8/-6) tests/unit/service/test_apt.py (+37/-45) tests/unit/service/test_container.py (+36/-42) tests/unit/service/test_task_dispatcher.py (+14/-7) tests/unit/test_libertine_container.py (+2/-1) tests/unit/test_libertine_gir.py (+0/-65) tools/libertine-container-manager (+1/-2) tools/libertine-lxc-manager (+1/-1) |
To merge this branch: | bzr merge lp:~larryprice/libertine/liblibertine-plus-libertined |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Libertine CI Bot | continuous-integration | Approve | |
Christopher Townsend | Approve | ||
Review via email: mp+315495@code.launchpad.net |
Commit message
Refactor liblibertine as a client wrapper for libertined.
Description of the change
Refactor liblibertine as a client wrapper for libertined.
Libertine CI Bot (libertine-ci-bot) wrote : | # |
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:359
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:360
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:361
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:362
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:363
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:364
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:365
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:366
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:366
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:367
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Christopher Townsend (townsend) wrote : | # |
Ok, this looks good. +1
When we land this in the next release, we'll need to get python3-libertine promoted to main and libertined will be in main.
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:369
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
- 370. By Larry Price
-
add a try-except to the dbus session var method
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:370
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2017-01-13 20:11:25 +0000 | |||
3 | +++ CMakeLists.txt 2017-01-27 18:57:35 +0000 | |||
4 | @@ -7,7 +7,6 @@ | |||
5 | 7 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") | 7 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") |
6 | 8 | 8 | ||
7 | 9 | find_package(PkgConfig REQUIRED) | 9 | find_package(PkgConfig REQUIRED) |
8 | 10 | find_package(GObjectIntrospection REQUIRED) | ||
9 | 11 | include(GNUInstallDirs) | 10 | include(GNUInstallDirs) |
10 | 12 | include(CheckIncludeFile) | 11 | include(CheckIncludeFile) |
11 | 13 | include(CheckFunctionExists) | 12 | include(CheckFunctionExists) |
12 | @@ -17,6 +16,7 @@ | |||
13 | 17 | include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | 16 | include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) |
14 | 18 | 17 | ||
15 | 19 | find_package(Qt5Core REQUIRED) | 18 | find_package(Qt5Core REQUIRED) |
16 | 19 | find_package(Qt5DBus REQUIRED) | ||
17 | 20 | find_package(Qt5Gui REQUIRED) | 20 | find_package(Qt5Gui REQUIRED) |
18 | 21 | find_package(Qt5Quick REQUIRED) | 21 | find_package(Qt5Quick REQUIRED) |
19 | 22 | find_package(Qt5Widgets REQUIRED) | 22 | find_package(Qt5Widgets REQUIRED) |
20 | 23 | 23 | ||
21 | === removed directory 'cmake' | |||
22 | === removed file 'cmake/FindGObjectIntrospection.cmake' | |||
23 | --- cmake/FindGObjectIntrospection.cmake 2015-08-17 20:42:31 +0000 | |||
24 | +++ cmake/FindGObjectIntrospection.cmake 1970-01-01 00:00:00 +0000 | |||
25 | @@ -1,61 +0,0 @@ | |||
26 | 1 | # - try to find gobject-introspection | ||
27 | 2 | # | ||
28 | 3 | # Once done this will define | ||
29 | 4 | # | ||
30 | 5 | # INTROSPECTION_FOUND - system has gobject-introspection | ||
31 | 6 | # INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner | ||
32 | 7 | # INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler | ||
33 | 8 | # INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate | ||
34 | 9 | # INTROSPECTION_GIRDIR | ||
35 | 10 | # INTROSPECTION_TYPELIBDIR | ||
36 | 11 | # INTROSPECTION_CFLAGS | ||
37 | 12 | # INTROSPECTION_LIBS | ||
38 | 13 | # | ||
39 | 14 | # Copyright (C) 2010, Pino Toscano, <pino@kde.org> | ||
40 | 15 | # | ||
41 | 16 | # Redistribution and use is allowed according to the terms of the BSD license. | ||
42 | 17 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
43 | 18 | |||
44 | 19 | macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) | ||
45 | 20 | execute_process( | ||
46 | 21 | COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0 | ||
47 | 22 | OUTPUT_VARIABLE _result | ||
48 | 23 | RESULT_VARIABLE _null | ||
49 | 24 | ) | ||
50 | 25 | |||
51 | 26 | if (_null) | ||
52 | 27 | else() | ||
53 | 28 | string(REGEX REPLACE "[\r\n]" " " _result "${_result}") | ||
54 | 29 | string(REGEX REPLACE " +$" "" _result "${_result}") | ||
55 | 30 | separate_arguments(_result) | ||
56 | 31 | set(${_outvar} ${_result} CACHE INTERNAL "") | ||
57 | 32 | endif() | ||
58 | 33 | endmacro(_GIR_GET_PKGCONFIG_VAR) | ||
59 | 34 | |||
60 | 35 | find_package(PkgConfig) | ||
61 | 36 | if(PKG_CONFIG_FOUND) | ||
62 | 37 | if(PACKAGE_FIND_VERSION_COUNT GREATER 0) | ||
63 | 38 | set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}") | ||
64 | 39 | endif() | ||
65 | 40 | pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp}) | ||
66 | 41 | if(_pc_gir_FOUND) | ||
67 | 42 | set(INTROSPECTION_FOUND TRUE) | ||
68 | 43 | _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner") | ||
69 | 44 | _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler") | ||
70 | 45 | _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate") | ||
71 | 46 | _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir") | ||
72 | 47 | _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir") | ||
73 | 48 | set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}") | ||
74 | 49 | set(INTROSPECTION_LIBS "${_pc_gir_LIBS}") | ||
75 | 50 | endif() | ||
76 | 51 | endif() | ||
77 | 52 | |||
78 | 53 | mark_as_advanced( | ||
79 | 54 | INTROSPECTION_SCANNER | ||
80 | 55 | INTROSPECTION_COMPILER | ||
81 | 56 | INTROSPECTION_GENERATE | ||
82 | 57 | INTROSPECTION_GIRDIR | ||
83 | 58 | INTROSPECTION_TYPELIBDIR | ||
84 | 59 | INTROSPECTION_CFLAGS | ||
85 | 60 | INTROSPECTION_LIBS | ||
86 | 61 | ) | ||
87 | 62 | 0 | ||
88 | === removed file 'cmake/ListOperations.cmake' | |||
89 | --- cmake/ListOperations.cmake 2015-08-17 20:42:31 +0000 | |||
90 | +++ cmake/ListOperations.cmake 1970-01-01 00:00:00 +0000 | |||
91 | @@ -1,18 +0,0 @@ | |||
92 | 1 | |||
93 | 2 | macro(list_prefix _outvar _listvar _prefix) | ||
94 | 3 | set(${_outvar}) | ||
95 | 4 | foreach(_item IN LISTS ${_listvar}) | ||
96 | 5 | list(APPEND ${_outvar} ${_prefix}${_item}) | ||
97 | 6 | endforeach() | ||
98 | 7 | endmacro(list_prefix) | ||
99 | 8 | |||
100 | 9 | macro(list_make_absolute _outvar _listvar _prefix) | ||
101 | 10 | set(${_outvar}) | ||
102 | 11 | foreach(_item IN LISTS ${_listvar}) | ||
103 | 12 | if(IS_ABSOLUTE ${_item}) | ||
104 | 13 | list(APPEND ${_outvar} ${_item}) | ||
105 | 14 | else() | ||
106 | 15 | list(APPEND ${_outvar} ${_prefix}${_item}) | ||
107 | 16 | endif() | ||
108 | 17 | endforeach() | ||
109 | 18 | endmacro(list_make_absolute) | ||
110 | 19 | 0 | ||
111 | === removed file 'cmake/UseGObjectIntrospection.cmake' | |||
112 | --- cmake/UseGObjectIntrospection.cmake 2015-08-17 20:42:31 +0000 | |||
113 | +++ cmake/UseGObjectIntrospection.cmake 1970-01-01 00:00:00 +0000 | |||
114 | @@ -1,102 +0,0 @@ | |||
115 | 1 | # Copyright (C) 2010, Pino Toscano, <pino@kde.org> | ||
116 | 2 | # | ||
117 | 3 | # Redistribution and use is allowed according to the terms of the BSD license. | ||
118 | 4 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
119 | 5 | |||
120 | 6 | include(ListOperations) | ||
121 | 7 | |||
122 | 8 | macro(_gir_list_prefix _outvar _listvar _prefix) | ||
123 | 9 | set(${_outvar}) | ||
124 | 10 | foreach(_item IN LISTS ${_listvar}) | ||
125 | 11 | list(APPEND ${_outvar} ${_prefix}${_item}) | ||
126 | 12 | endforeach() | ||
127 | 13 | endmacro(_gir_list_prefix) | ||
128 | 14 | |||
129 | 15 | macro(gir_add_introspections introspections_girs) | ||
130 | 16 | |||
131 | 17 | foreach(gir IN LISTS ${introspections_girs}) | ||
132 | 18 | |||
133 | 19 | set(_gir_name "${gir}") | ||
134 | 20 | |||
135 | 21 | ## Transform the gir filename to something which can reference through a variable | ||
136 | 22 | ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir | ||
137 | 23 | string(REPLACE "-" "_" _gir_name "${_gir_name}") | ||
138 | 24 | string(REPLACE "." "_" _gir_name "${_gir_name}") | ||
139 | 25 | |||
140 | 26 | # Namespace and Version is either fetched from the gir filename | ||
141 | 27 | # or the _NAMESPACE/_VERSION variable combo | ||
142 | 28 | set(_gir_namespace "${${_gir_name}_NAMESPACE}") | ||
143 | 29 | if (_gir_namespace STREQUAL "") | ||
144 | 30 | string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}") | ||
145 | 31 | endif () | ||
146 | 32 | set(_gir_version "${${_gir_name}_VERSION}") | ||
147 | 33 | if (_gir_version STREQUAL "") | ||
148 | 34 | string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}") | ||
149 | 35 | endif () | ||
150 | 36 | |||
151 | 37 | # _PROGRAM is an optional variable which needs it's own --program argument | ||
152 | 38 | set(_gir_program "${${_gir_name}_PROGRAM}") | ||
153 | 39 | if (NOT _gir_program STREQUAL "") | ||
154 | 40 | set(_gir_program "--program=${_gir_program}") | ||
155 | 41 | endif () | ||
156 | 42 | |||
157 | 43 | # Variables which provides a list of things | ||
158 | 44 | _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=") | ||
159 | 45 | _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=") | ||
160 | 46 | _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=") | ||
161 | 47 | _gir_list_prefix(_gir_export_packages ${_gir_name}_EXPORT_PACKAGES "--pkg-export=") | ||
162 | 48 | |||
163 | 49 | # Reuse the LIBTOOL variable from by automake if it's set | ||
164 | 50 | set(_gir_libtool "--no-libtool") | ||
165 | 51 | |||
166 | 52 | add_custom_command( | ||
167 | 53 | COMMAND ${INTROSPECTION_SCANNER} | ||
168 | 54 | ${INTROSPECTION_SCANNER_ARGS} | ||
169 | 55 | --quiet | ||
170 | 56 | --warn-all | ||
171 | 57 | --namespace=${_gir_namespace} | ||
172 | 58 | --nsversion=${_gir_version} | ||
173 | 59 | ${_gir_libtool} | ||
174 | 60 | ${_gir_program} | ||
175 | 61 | ${_gir_libraries} | ||
176 | 62 | ${_gir_packages} | ||
177 | 63 | ${_gir_includes} | ||
178 | 64 | ${_gir_export_packages} | ||
179 | 65 | ${${_gir_name}_SCANNERFLAGS} | ||
180 | 66 | ${${_gir_name}_CFLAGS} | ||
181 | 67 | ${${_gir_name}_FILES} | ||
182 | 68 | --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} | ||
183 | 69 | DEPENDS ${${_gir_name}_FILES} | ||
184 | 70 | ${${_gir_name}_LIBS} | ||
185 | 71 | OUTPUT ${gir} | ||
186 | 72 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
187 | 73 | VERBATIM | ||
188 | 74 | ) | ||
189 | 75 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0) | ||
190 | 76 | |||
191 | 77 | string(REPLACE ".gir" ".typelib" _typelib "${gir}") | ||
192 | 78 | add_custom_command( | ||
193 | 79 | COMMAND ${INTROSPECTION_COMPILER} | ||
194 | 80 | ${INTROSPECTION_COMPILER_ARGS} | ||
195 | 81 | --includedir=. | ||
196 | 82 | ${CMAKE_CURRENT_BINARY_DIR}/${gir} | ||
197 | 83 | -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} | ||
198 | 84 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir} | ||
199 | 85 | OUTPUT ${_typelib} | ||
200 | 86 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
201 | 87 | ) | ||
202 | 88 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0) | ||
203 | 89 | |||
204 | 90 | add_custom_target(gir-${gir} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}) | ||
205 | 91 | add_custom_target(gir-typelibs-${_typelib} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}) | ||
206 | 92 | endforeach() | ||
207 | 93 | |||
208 | 94 | endmacro(gir_add_introspections) | ||
209 | 95 | |||
210 | 96 | macro(gir_get_cflags _output) | ||
211 | 97 | get_directory_property(_tmp_includes INCLUDE_DIRECTORIES) | ||
212 | 98 | list_prefix(_includes _tmp_includes "-I") | ||
213 | 99 | get_directory_property(_tmp_compile_definitions COMPILE_DEFINITIONS) | ||
214 | 100 | list_prefix(_compile_definitions _tmp_compile_definitions "-D") | ||
215 | 101 | set(${_output} ${_includes} ${_compile_definitions}) | ||
216 | 102 | endmacro(gir_get_cflags) | ||
217 | 103 | 0 | ||
218 | === modified file 'common/LibertineConfig.cpp' | |||
219 | --- common/LibertineConfig.cpp 2017-01-18 15:43:03 +0000 | |||
220 | +++ common/LibertineConfig.cpp 2017-01-27 18:57:35 +0000 | |||
221 | @@ -3,7 +3,7 @@ | |||
222 | 3 | * @brief Libertine Manager application-wide configuration module | 3 | * @brief Libertine Manager application-wide configuration module |
223 | 4 | */ | 4 | */ |
224 | 5 | /* | 5 | /* |
226 | 6 | * Copyright 2015 Canonical Ltd | 6 | * Copyright 2015-2017 Canonical Ltd |
227 | 7 | * | 7 | * |
228 | 8 | * Libertine is free software: you can redistribute it and/or modify it under | 8 | * Libertine is free software: you can redistribute it and/or modify it under |
229 | 9 | * the terms of the GNU General Public License, version 3, as published by the | 9 | * the terms of the GNU General Public License, version 3, as published by the |
230 | @@ -36,14 +36,6 @@ | |||
231 | 36 | path.replace(std::getenv("HOME"), snap_common); | 36 | path.replace(std::getenv("HOME"), snap_common); |
232 | 37 | } | 37 | } |
233 | 38 | 38 | ||
234 | 39 | // if libertine is installed as a snap but caller is not; | ||
235 | 40 | // workaround until ContainersConfig is only discovered from one location | ||
236 | 41 | if (QString(std::getenv("IGNORE_SNAP")) != "1" && QFile::exists("/snap/bin/libertine.libertine-launch")) | ||
237 | 42 | { | ||
238 | 43 | auto home = std::getenv("HOME"); | ||
239 | 44 | path.replace(home, QString(home) + "/snap/libertine/common"); | ||
240 | 45 | } | ||
241 | 46 | |||
242 | 47 | QDir dir(path); | 39 | QDir dir(path); |
243 | 48 | 40 | ||
244 | 49 | if (!dir.exists()) | 41 | if (!dir.exists()) |
245 | 50 | 42 | ||
246 | === modified file 'data/CMakeLists.txt' | |||
247 | --- data/CMakeLists.txt 2016-12-21 20:57:15 +0000 | |||
248 | +++ data/CMakeLists.txt 2017-01-27 18:57:35 +0000 | |||
249 | @@ -8,7 +8,7 @@ | |||
250 | 8 | DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) | 8 | DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions) |
251 | 9 | install(FILES libertine-lxc-sudo libertine-lxd-sudo | 9 | install(FILES libertine-lxc-sudo libertine-lxd-sudo |
252 | 10 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sudoers.d) | 10 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sudoers.d) |
254 | 11 | install(FILES com.canonical.libertine.ContainerManager.service | 11 | install(FILES com.canonical.libertine.Service.service |
255 | 12 | com.canonical.libertine.LxcManager.service | 12 | com.canonical.libertine.LxcManager.service |
256 | 13 | com.canonical.libertine.LxdManager.service | 13 | com.canonical.libertine.LxdManager.service |
257 | 14 | DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) | 14 | DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services) |
258 | 15 | 15 | ||
259 | === renamed file 'data/com.canonical.libertine.ContainerManager.service' => 'data/com.canonical.libertine.Service.service' | |||
260 | --- data/com.canonical.libertine.ContainerManager.service 2016-11-01 20:10:58 +0000 | |||
261 | +++ data/com.canonical.libertine.Service.service 2017-01-27 18:57:35 +0000 | |||
262 | @@ -1,3 +1,3 @@ | |||
263 | 1 | [D-BUS Service] | 1 | [D-BUS Service] |
265 | 2 | Name=com.canonical.libertine.ContainerManager | 2 | Name=com.canonical.libertine.Service |
266 | 3 | Exec=/usr/bin/libertined --cache-output | 3 | Exec=/usr/bin/libertined --cache-output |
267 | 4 | 4 | ||
268 | === modified file 'debian/changelog' | |||
269 | --- debian/changelog 2017-01-18 14:50:33 +0000 | |||
270 | +++ debian/changelog 2017-01-27 18:57:35 +0000 | |||
271 | @@ -1,3 +1,10 @@ | |||
272 | 1 | libertine (1.5.2-0ubuntu1) UNRELEASED; urgency=medium | ||
273 | 2 | |||
274 | 3 | [ Larry Price ] | ||
275 | 4 | * Bump version to 1.5.2. | ||
276 | 5 | |||
277 | 6 | -- Larry Price <larry.price@canonical.com> Thu, 26 Jan 2017 10:39:10 -0500 | ||
278 | 7 | |||
279 | 1 | libertine (1.5.1+17.04.20170118-0ubuntu1) zesty; urgency=medium | 8 | libertine (1.5.1+17.04.20170118-0ubuntu1) zesty; urgency=medium |
280 | 2 | 9 | ||
281 | 3 | [ Chris Townsend ] | 10 | [ Chris Townsend ] |
282 | 4 | 11 | ||
283 | === modified file 'debian/control' | |||
284 | --- debian/control 2016-12-07 17:45:28 +0000 | |||
285 | +++ debian/control 2017-01-27 18:57:35 +0000 | |||
286 | @@ -84,7 +84,6 @@ | |||
287 | 84 | Architecture: any | 84 | Architecture: any |
288 | 85 | Depends: libglib2.0-bin, | 85 | Depends: libglib2.0-bin, |
289 | 86 | lsb-release, | 86 | lsb-release, |
290 | 87 | python3-apt, | ||
291 | 88 | python3-dbus, | 87 | python3-dbus, |
292 | 89 | python3-distro-info, | 88 | python3-distro-info, |
293 | 90 | python3-libertine, | 89 | python3-libertine, |
294 | @@ -115,15 +114,33 @@ | |||
295 | 115 | Helper applications for using and interacting with Xmir such as launching | 114 | Helper applications for using and interacting with Xmir such as launching |
296 | 116 | Xmir and allowing copy and paste. | 115 | Xmir and allowing copy and paste. |
297 | 117 | 116 | ||
298 | 117 | Package: libertined | ||
299 | 118 | Architecture: any | ||
300 | 119 | Multi-Arch: same | ||
301 | 120 | Depends: python3-libertine, | ||
302 | 121 | python3-apt, | ||
303 | 122 | python3-dbus, | ||
304 | 123 | python3-gi, | ||
305 | 124 | ${misc:Depends}, | ||
306 | 125 | ${shlibs:Depends}, | ||
307 | 126 | ${python3:Depends} | ||
308 | 127 | Breaks: libertine-tools (<< 1.5.2) | ||
309 | 128 | Replaces: libertine-tools (<< 1.5.2) | ||
310 | 129 | Description: d-bus service for managing libertine containers | ||
311 | 130 | D-Bus service for asynchronously discovering and managing classic applications | ||
312 | 131 | using libertine containers. Allows installation and removal of deb-packaged | ||
313 | 132 | X11 apps within an isolated sandbox. | ||
314 | 133 | |||
315 | 118 | Package: liblibertine1 | 134 | Package: liblibertine1 |
316 | 119 | Architecture: any | 135 | Architecture: any |
317 | 120 | Multi-Arch: same | 136 | Multi-Arch: same |
319 | 121 | Depends: ${misc:Depends}, | 137 | Depends: libertined, |
320 | 138 | ${misc:Depends}, | ||
321 | 122 | ${shlibs:Depends} | 139 | ${shlibs:Depends} |
322 | 123 | Description: runtime for running deb-packaged X11 apps on Ubuntu Personal | 140 | Description: runtime for running deb-packaged X11 apps on Ubuntu Personal |
323 | 124 | Runtime library for creating and using the Ubuntu Personal sandbox for legacy | 141 | Runtime library for creating and using the Ubuntu Personal sandbox for legacy |
324 | 125 | Deb-packaged X11 applicatons. This library is used by the Libertine tools | 142 | Deb-packaged X11 applicatons. This library is used by the Libertine tools |
326 | 126 | and other software interacting wit hthe Libertine container, such as scopes | 143 | and other software interacting with the Libertine container, such as scopes |
327 | 127 | or application launchers. | 144 | or application launchers. |
328 | 128 | 145 | ||
329 | 129 | Package: liblibertine-dev | 146 | Package: liblibertine-dev |
330 | @@ -137,24 +154,11 @@ | |||
331 | 137 | Headers and shared libraries used to create the tools for creating and using | 154 | Headers and shared libraries used to create the tools for creating and using |
332 | 138 | the Ubuntu Personal sandbox for legacy Deb-packaged X11 applicatons. | 155 | the Ubuntu Personal sandbox for legacy Deb-packaged X11 applicatons. |
333 | 139 | 156 | ||
334 | 140 | Package: gir1.2-libertine | ||
335 | 141 | Architecture: any | ||
336 | 142 | Multi-Arch: same | ||
337 | 143 | Depends: liblibertine1 (= ${binary:Version}), | ||
338 | 144 | ${gir:Depends}, | ||
339 | 145 | ${misc:Depends} | ||
340 | 146 | Description: GObject introspection files for the Libertine application sandbox | ||
341 | 147 | The GObject introspection description files for the Libertine application | ||
342 | 148 | sandbox runtime. This package allows the Libertine API to be used from | ||
343 | 149 | GIR-compliant languages such as Python. | ||
344 | 150 | |||
345 | 151 | Package: python3-libertine | 157 | Package: python3-libertine |
346 | 152 | Architecture: any | 158 | Architecture: any |
347 | 153 | Section: python | 159 | Section: python |
348 | 154 | Multi-Arch: allowed | 160 | Multi-Arch: allowed |
352 | 155 | Depends: gir1.2-libertine, | 161 | Depends: python3-psutil, |
350 | 156 | python3-gi, | ||
351 | 157 | python3-psutil, | ||
353 | 158 | python3-xdg, | 162 | python3-xdg, |
354 | 159 | xdg-user-dirs, | 163 | xdg-user-dirs, |
355 | 160 | ${misc:Depends}, | 164 | ${misc:Depends}, |
356 | @@ -173,6 +177,7 @@ | |||
357 | 173 | python3-libertine, | 177 | python3-libertine, |
358 | 174 | python3-lxc, | 178 | python3-lxc, |
359 | 175 | uidmap, | 179 | uidmap, |
360 | 180 | python3-gi, | ||
361 | 176 | ${misc:Depends}, | 181 | ${misc:Depends}, |
362 | 177 | ${python3:Depends} | 182 | ${python3:Depends} |
363 | 178 | Replaces: libertine-tools (<< 1.3) | 183 | Replaces: libertine-tools (<< 1.3) |
364 | @@ -190,6 +195,7 @@ | |||
365 | 190 | python3-libertine, | 195 | python3-libertine, |
366 | 191 | python3-pexpect, | 196 | python3-pexpect, |
367 | 192 | python3-pylxd, | 197 | python3-pylxd, |
368 | 198 | python3-gi, | ||
369 | 193 | ${misc:Depends}, | 199 | ${misc:Depends}, |
370 | 194 | ${python3:Depends} | 200 | ${python3:Depends} |
371 | 195 | Description: Python3 scripts for the Libertine application sandbox | 201 | Description: Python3 scripts for the Libertine application sandbox |
372 | 196 | 202 | ||
373 | === removed file 'debian/gir1.2-libertine.install' | |||
374 | --- debian/gir1.2-libertine.install 2015-08-24 16:54:54 +0000 | |||
375 | +++ debian/gir1.2-libertine.install 1970-01-01 00:00:00 +0000 | |||
376 | @@ -1,2 +0,0 @@ | |||
377 | 1 | usr/lib/*/girepository-1.0/Libertine-1.typelib | ||
378 | 2 | usr/share/gir-1.0/Libertine-1.gir | ||
379 | 3 | 0 | ||
380 | === modified file 'debian/libertine-tools.install' | |||
381 | --- debian/libertine-tools.install 2016-11-01 20:10:58 +0000 | |||
382 | +++ debian/libertine-tools.install 2017-01-27 18:57:35 +0000 | |||
383 | @@ -1,6 +1,4 @@ | |||
384 | 1 | usr/bin/libertine-container-manager | 1 | usr/bin/libertine-container-manager |
385 | 2 | usr/bin/libertine-launch | 2 | usr/bin/libertine-launch |
386 | 3 | usr/bin/libertined | ||
387 | 4 | usr/share/dbus-1/services/com.canonical.libertine.ContainerManager.service | ||
388 | 5 | usr/share/bash-completion/completions/libertine-container-manager | 3 | usr/share/bash-completion/completions/libertine-container-manager |
389 | 6 | usr/share/man | 4 | usr/share/man |
390 | 7 | 5 | ||
391 | === added file 'debian/libertined.install' | |||
392 | --- debian/libertined.install 1970-01-01 00:00:00 +0000 | |||
393 | +++ debian/libertined.install 2017-01-27 18:57:35 +0000 | |||
394 | @@ -0,0 +1,3 @@ | |||
395 | 1 | usr/bin/libertined | ||
396 | 2 | usr/lib/python*/*/libertine/service | ||
397 | 3 | usr/share/dbus-1/services/com.canonical.libertine.Service.service | ||
398 | 0 | 4 | ||
399 | === modified file 'debian/python3-libertine.install' | |||
400 | --- debian/python3-libertine.install 2016-12-21 18:07:07 +0000 | |||
401 | +++ debian/python3-libertine.install 2017-01-27 18:57:35 +0000 | |||
402 | @@ -5,5 +5,4 @@ | |||
403 | 5 | usr/lib/python*/*/libertine/__init__.py | 5 | usr/lib/python*/*/libertine/__init__.py |
404 | 6 | usr/lib/python*/*/libertine/launcher | 6 | usr/lib/python*/*/libertine/launcher |
405 | 7 | usr/lib/python*/*/libertine/lifecycle | 7 | usr/lib/python*/*/libertine/lifecycle |
406 | 8 | usr/lib/python*/*/libertine/service | ||
407 | 9 | usr/lib/python*/*/libertine/utils.py | 8 | usr/lib/python*/*/libertine/utils.py |
408 | 10 | 9 | ||
409 | === modified file 'debian/rules' | |||
410 | --- debian/rules 2016-12-06 20:52:55 +0000 | |||
411 | +++ debian/rules 2017-01-27 18:57:35 +0000 | |||
412 | @@ -1,7 +1,7 @@ | |||
413 | 1 | #!/usr/bin/make -f | 1 | #!/usr/bin/make -f |
414 | 2 | 2 | ||
415 | 3 | %: | 3 | %: |
417 | 4 | dh $@ --with python3,gir | 4 | dh $@ --with python3 |
418 | 5 | 5 | ||
419 | 6 | override_dh_auto_test: | 6 | override_dh_auto_test: |
420 | 7 | dbus-run-session -- dh_auto_test | 7 | dbus-run-session -- dh_auto_test |
421 | 8 | 8 | ||
422 | === modified file 'liblibertine/CMakeLists.txt' | |||
423 | --- liblibertine/CMakeLists.txt 2016-11-03 19:19:40 +0000 | |||
424 | +++ liblibertine/CMakeLists.txt 2017-01-27 18:57:35 +0000 | |||
425 | @@ -1,15 +1,12 @@ | |||
426 | 1 | set(API_VERSION 1) | 1 | set(API_VERSION 1) |
427 | 2 | set(ABI_VERSION 1) | 2 | set(ABI_VERSION 1) |
428 | 3 | 3 | ||
429 | 4 | set(COMMON_DIR ${CMAKE_SOURCE_DIR}/common) | ||
430 | 5 | |||
431 | 6 | add_library( | 4 | add_library( |
432 | 7 | ${LIBERTINE_CORE} SHARED | 5 | ${LIBERTINE_CORE} SHARED |
433 | 8 | libertine.cpp | 6 | libertine.cpp |
434 | 9 | 7 | ||
438 | 10 | ${COMMON_DIR}/ContainerConfig.cpp | 8 | # libertined client |
439 | 11 | ${COMMON_DIR}/ContainerConfigList.cpp | 9 | libertined.cpp |
437 | 12 | ${COMMON_DIR}/LibertineConfig.cpp | ||
440 | 13 | ) | 10 | ) |
441 | 14 | 11 | ||
442 | 15 | set_target_properties(${LIBERTINE_CORE} PROPERTIES | 12 | set_target_properties(${LIBERTINE_CORE} PROPERTIES |
443 | @@ -22,6 +19,7 @@ | |||
444 | 22 | ${GLIB2_LIBRARIES} | 19 | ${GLIB2_LIBRARIES} |
445 | 23 | ${PYTHON3_LIBRARIES} | 20 | ${PYTHON3_LIBRARIES} |
446 | 24 | Qt5::Core | 21 | Qt5::Core |
447 | 22 | Qt5::DBus | ||
448 | 25 | ) | 23 | ) |
449 | 26 | 24 | ||
450 | 27 | # "liblibertine_headers_path" is used in libertine.pc.in | 25 | # "liblibertine_headers_path" is used in libertine.pc.in |
451 | @@ -32,28 +30,3 @@ | |||
452 | 32 | configure_file(libertine.pc.in ${CMAKE_BINARY_DIR}/libertine.pc @ONLY) | 30 | configure_file(libertine.pc.in ${CMAKE_BINARY_DIR}/libertine.pc @ONLY) |
453 | 33 | install(FILES ${CMAKE_BINARY_DIR}/libertine.pc | 31 | install(FILES ${CMAKE_BINARY_DIR}/libertine.pc |
454 | 34 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | 32 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
455 | 35 | |||
456 | 36 | ########################## | ||
457 | 37 | # Introspection | ||
458 | 38 | ########################## | ||
459 | 39 | |||
460 | 40 | include(UseGObjectIntrospection) | ||
461 | 41 | |||
462 | 42 | set(INTROSPECTION_GIRS) | ||
463 | 43 | set(_introspection_files libertine.h) | ||
464 | 44 | set(Libertine_1_gir "libertine") | ||
465 | 45 | set(Libertine_1_gir_INCLUDES GObject-2.0) | ||
466 | 46 | |||
467 | 47 | gir_get_cflags(_cflags) | ||
468 | 48 | set(Libertine_1_gir_CFLAGS ${c_flags}) | ||
469 | 49 | set(Libertine_1_gir_LIBS libertine) | ||
470 | 50 | |||
471 | 51 | list_make_absolute(_abs_introspection_files _introspection_files "${CMAKE_CURRENT_SOURCE_DIR}/") | ||
472 | 52 | set(Libertine_1_gir_FILES ${_abs_introspection_files}) | ||
473 | 53 | set(Libertine_1_gir_SCANNERFLAGS --c-include "libertine.h") | ||
474 | 54 | set(Libertine_1_gir_EXPORT_PACKAGES "libertine-${API_VERSION}") | ||
475 | 55 | |||
476 | 56 | list(APPEND INTROSPECTION_GIRS Libertine-1.gir) | ||
477 | 57 | gir_add_introspections(INTROSPECTION_GIRS) | ||
478 | 58 | |||
479 | 59 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Libertine-1.typelib" DESTINATION "${CMAKE_INSTALL_LIBDIR}/girepository-1.0") | ||
480 | 60 | 33 | ||
481 | === modified file 'liblibertine/libertine.cpp' | |||
482 | --- liblibertine/libertine.cpp 2017-01-18 15:43:03 +0000 | |||
483 | +++ liblibertine/libertine.cpp 2017-01-27 18:57:35 +0000 | |||
484 | @@ -1,9 +1,9 @@ | |||
485 | 1 | /** | 1 | /** |
487 | 2 | * @file libertine_common.cpp | 2 | * @file libertine.cpp |
488 | 3 | * @brief The Libertine Common shared library | 3 | * @brief The Libertine Common shared library |
489 | 4 | */ | 4 | */ |
490 | 5 | /* | 5 | /* |
492 | 6 | * Copyright 2015 Canonical Ltd. | 6 | * Copyright 2015-2017 Canonical Ltd. |
493 | 7 | * | 7 | * |
494 | 8 | * This program is free software: you can redistribute it and/or modify it under | 8 | * This program is free software: you can redistribute it and/or modify it under |
495 | 9 | * the terms of the GNU General Public License, version 3, as published by the | 9 | * the terms of the GNU General Public License, version 3, as published by the |
496 | @@ -17,121 +17,21 @@ | |||
497 | 17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License |
498 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
499 | 19 | */ | 19 | */ |
500 | 20 | |||
501 | 20 | #include "liblibertine/libertine.h" | 21 | #include "liblibertine/libertine.h" |
579 | 21 | 22 | #include "liblibertine/libertined.h" | |
580 | 22 | #include "common/ContainerConfigList.h" | 23 | |
504 | 23 | #include "common/LibertineConfig.h" | ||
505 | 24 | |||
506 | 25 | |||
507 | 26 | namespace | ||
508 | 27 | { | ||
509 | 28 | constexpr auto DESKTOP_EXTENSION = ".desktop"; | ||
510 | 29 | constexpr auto GLOBAL_APPLICATIONS = "usr/share/applications"; | ||
511 | 30 | constexpr auto LOCAL_APPLICATIONS = ".local/share/applications"; | ||
512 | 31 | |||
513 | 32 | |||
514 | 33 | GError* | ||
515 | 34 | list_apps_from_path(gchar* path, const gchar* container_id, GArray* apps) | ||
516 | 35 | { | ||
517 | 36 | GError* error = nullptr; | ||
518 | 37 | GDir* dir = g_dir_open(path, 0, &error); | ||
519 | 38 | if (error != nullptr) | ||
520 | 39 | { | ||
521 | 40 | return error; | ||
522 | 41 | } | ||
523 | 42 | |||
524 | 43 | const gchar * files; | ||
525 | 44 | while ((files = g_dir_read_name(dir)) != nullptr) | ||
526 | 45 | { | ||
527 | 46 | gchar *file = g_build_filename(path, files, nullptr); | ||
528 | 47 | if (g_file_test(file, G_FILE_TEST_IS_REGULAR) && g_str_has_suffix(files, DESKTOP_EXTENSION)) | ||
529 | 48 | { | ||
530 | 49 | auto name = g_strdup(files); | ||
531 | 50 | name[strlen(name)-strlen(DESKTOP_EXTENSION)] = 0; // truncate the file extension | ||
532 | 51 | |||
533 | 52 | gchar * app_id = g_strjoin("_", g_strdup(container_id), name, "0.0", nullptr); | ||
534 | 53 | g_array_append_val(apps, app_id); | ||
535 | 54 | g_free(name); | ||
536 | 55 | } | ||
537 | 56 | else if (g_file_test(file, G_FILE_TEST_IS_DIR)) | ||
538 | 57 | { | ||
539 | 58 | error = list_apps_from_path(file, container_id, apps); | ||
540 | 59 | if (error != nullptr) | ||
541 | 60 | { | ||
542 | 61 | return error; | ||
543 | 62 | } | ||
544 | 63 | } | ||
545 | 64 | g_free(file); | ||
546 | 65 | } | ||
547 | 66 | |||
548 | 67 | g_dir_close(dir); | ||
549 | 68 | return nullptr; | ||
550 | 69 | } | ||
551 | 70 | |||
552 | 71 | |||
553 | 72 | gchar* | ||
554 | 73 | id_from_list_index(const ContainerConfigList& container_list, guint index) | ||
555 | 74 | { | ||
556 | 75 | return (gchar*)container_list.data(container_list.index(index, 0), | ||
557 | 76 | (int)ContainerConfigList::DataRole::ContainerId) | ||
558 | 77 | .toString().toStdString().c_str(); | ||
559 | 78 | } | ||
560 | 79 | |||
561 | 80 | |||
562 | 81 | bool | ||
563 | 82 | running_snapped_libertine() | ||
564 | 83 | { | ||
565 | 84 | if (g_strcmp0(std::getenv("IGNORE_SNAP"), "1") == 0) | ||
566 | 85 | { | ||
567 | 86 | return false; | ||
568 | 87 | } | ||
569 | 88 | |||
570 | 89 | auto libertine_launch_path = g_build_filename("/", "snap", "bin", | ||
571 | 90 | "libertine.libertine-launch", | ||
572 | 91 | nullptr); | ||
573 | 92 | bool out = g_file_test(libertine_launch_path, G_FILE_TEST_EXISTS); | ||
574 | 93 | |||
575 | 94 | g_free(libertine_launch_path); | ||
576 | 95 | return out; | ||
577 | 96 | } | ||
578 | 97 | } | ||
581 | 98 | 24 | ||
582 | 99 | gchar** | 25 | gchar** |
583 | 100 | libertine_list_apps_for_container(const gchar* container_id) | 26 | libertine_list_apps_for_container(const gchar* container_id) |
584 | 101 | { | 27 | { |
585 | 102 | g_return_val_if_fail(container_id != nullptr, nullptr); | 28 | g_return_val_if_fail(container_id != nullptr, nullptr); |
586 | 103 | gchar* path = libertine_container_path(container_id); | ||
587 | 104 | GError* error = nullptr; | ||
588 | 105 | GArray* apps = g_array_new(TRUE, TRUE, sizeof(gchar*)); | 29 | GArray* apps = g_array_new(TRUE, TRUE, sizeof(gchar*)); |
618 | 106 | 30 | for (auto const& app: libertined_list_app_ids(container_id)) | |
619 | 107 | if (path != nullptr) | 31 | { |
620 | 108 | { | 32 | auto app_id = g_strdup((gchar *)app.toString().toStdString().c_str()); |
621 | 109 | auto global_path = g_build_filename("/", g_strdup(path), GLOBAL_APPLICATIONS, nullptr); | 33 | g_array_append_val(apps, app_id); |
622 | 110 | error = list_apps_from_path(global_path, container_id, apps); | 34 | } |
594 | 111 | if (error != nullptr) | ||
595 | 112 | { | ||
596 | 113 | g_free(global_path); | ||
597 | 114 | g_free(path); | ||
598 | 115 | g_error_free(error); | ||
599 | 116 | return (gchar**)g_array_free(apps, FALSE); | ||
600 | 117 | } | ||
601 | 118 | g_free(global_path); | ||
602 | 119 | } | ||
603 | 120 | g_free(path); | ||
604 | 121 | |||
605 | 122 | auto home_path = libertine_container_home_path(container_id); | ||
606 | 123 | if (home_path != nullptr) | ||
607 | 124 | { | ||
608 | 125 | auto local_path = g_build_filename(home_path, LOCAL_APPLICATIONS, nullptr); | ||
609 | 126 | |||
610 | 127 | error = list_apps_from_path(local_path, container_id, apps); | ||
611 | 128 | if (error != nullptr) | ||
612 | 129 | { | ||
613 | 130 | g_error_free(error); // free error, but return previously found apps | ||
614 | 131 | } | ||
615 | 132 | g_free(local_path); | ||
616 | 133 | } | ||
617 | 134 | g_free(home_path); | ||
623 | 135 | 35 | ||
624 | 136 | return (gchar**)g_array_free(apps, FALSE); | 36 | return (gchar**)g_array_free(apps, FALSE); |
625 | 137 | } | 37 | } |
626 | @@ -140,22 +40,12 @@ | |||
627 | 140 | gchar ** | 40 | gchar ** |
628 | 141 | libertine_list_containers(void) | 41 | libertine_list_containers(void) |
629 | 142 | { | 42 | { |
640 | 143 | guint container_count; | 43 | auto containers = g_array_new(TRUE, TRUE, sizeof(gchar *)); |
641 | 144 | guint i; | 44 | for (auto const& container: libertined_list()) |
632 | 145 | LibertineConfig config; | ||
633 | 146 | ContainerConfigList container_list(&config); | ||
634 | 147 | GArray * containers = g_array_new(TRUE, TRUE, sizeof(gchar *)); | ||
635 | 148 | QVariant id; | ||
636 | 149 | |||
637 | 150 | container_count = (guint)container_list.size(); | ||
638 | 151 | |||
639 | 152 | for (i = 0; i < container_count; ++i) | ||
642 | 153 | { | 45 | { |
645 | 154 | id = container_list.data(container_list.index(i, 0), (int)ContainerConfigList::DataRole::ContainerId); | 46 | auto container_id = g_strdup((gchar *)container.toString().toStdString().c_str()); |
644 | 155 | gchar * container_id = g_strdup((gchar *)id.toString().toStdString().c_str()); | ||
646 | 156 | g_array_append_val(containers, container_id); | 47 | g_array_append_val(containers, container_id); |
647 | 157 | } | 48 | } |
648 | 158 | |||
649 | 159 | return (gchar **)g_array_free(containers, FALSE); | 49 | return (gchar **)g_array_free(containers, FALSE); |
650 | 160 | } | 50 | } |
651 | 161 | 51 | ||
652 | @@ -164,19 +54,8 @@ | |||
653 | 164 | libertine_container_path(const gchar * container_id) | 54 | libertine_container_path(const gchar * container_id) |
654 | 165 | { | 55 | { |
655 | 166 | g_return_val_if_fail(container_id != nullptr, nullptr); | 56 | g_return_val_if_fail(container_id != nullptr, nullptr); |
669 | 167 | LibertineConfig config; | 57 | |
670 | 168 | ContainerConfigList container_list(&config); | 58 | gchar* path = g_strdup((gchar *)libertined_container_path(container_id).toStdString().c_str()); |
658 | 169 | gchar* path = g_build_filename(g_get_user_cache_dir(), "libertine-container", container_id, "rootfs", nullptr); | ||
659 | 170 | |||
660 | 171 | // temporary solution for discovering applications in unity8 until libertined | ||
661 | 172 | // has been updated to access location data | ||
662 | 173 | if (running_snapped_libertine()) | ||
663 | 174 | { | ||
664 | 175 | g_free(path); | ||
665 | 176 | path = g_build_filename("/", "home", g_get_user_name(), "snap", "libertine", "common", ".cache", "libertine-container", container_id, "rootfs", nullptr); | ||
666 | 177 | } | ||
667 | 178 | |||
668 | 179 | |||
671 | 180 | if (g_file_test(path, G_FILE_TEST_EXISTS)) | 59 | if (g_file_test(path, G_FILE_TEST_EXISTS)) |
672 | 181 | { | 60 | { |
673 | 182 | return path; | 61 | return path; |
674 | @@ -191,18 +70,8 @@ | |||
675 | 191 | libertine_container_home_path(const gchar * container_id) | 70 | libertine_container_home_path(const gchar * container_id) |
676 | 192 | { | 71 | { |
677 | 193 | g_return_val_if_fail(container_id != nullptr, nullptr); | 72 | g_return_val_if_fail(container_id != nullptr, nullptr); |
690 | 194 | LibertineConfig config; | 73 | |
691 | 195 | ContainerConfigList container_list(&config); | 74 | gchar* path = g_strdup((gchar *)libertined_container_home_path(container_id).toStdString().c_str()); |
680 | 196 | gchar * path = g_build_filename(g_get_user_data_dir(), "libertine-container", "user-data", container_id, nullptr); | ||
681 | 197 | |||
682 | 198 | // temporary solution for discovering applications in unity8 until libertined | ||
683 | 199 | // has been updated to access location data | ||
684 | 200 | if (running_snapped_libertine()) | ||
685 | 201 | { | ||
686 | 202 | g_free(path); | ||
687 | 203 | path = g_build_filename("/", "home", g_get_user_name(), "snap", "libertine", "common", ".local", "libertine-container", "user-data", container_id, nullptr); | ||
688 | 204 | } | ||
689 | 205 | |||
692 | 206 | if (g_file_test(path, G_FILE_TEST_EXISTS)) | 75 | if (g_file_test(path, G_FILE_TEST_EXISTS)) |
693 | 207 | { | 76 | { |
694 | 208 | return path; | 77 | return path; |
695 | @@ -216,20 +85,7 @@ | |||
696 | 216 | gchar * | 85 | gchar * |
697 | 217 | libertine_container_name(const gchar * container_id) | 86 | libertine_container_name(const gchar * container_id) |
698 | 218 | { | 87 | { |
715 | 219 | gchar * container_name = nullptr; | 88 | g_return_val_if_fail(container_id != nullptr, nullptr); |
716 | 220 | LibertineConfig config; | 89 | |
717 | 221 | ContainerConfigList container_list(&config); | 90 | return g_strdup((gchar *)libertined_container_name(container_id).toStdString().c_str()); |
702 | 222 | guint container_count = (guint)container_list.size(); | ||
703 | 223 | |||
704 | 224 | for (guint i = 0; i < container_count; ++i) | ||
705 | 225 | { | ||
706 | 226 | if (g_strcmp0(id_from_list_index(container_list, i), container_id) == 0) | ||
707 | 227 | { | ||
708 | 228 | QVariant name = container_list.data(container_list.index(i, 0), (int)ContainerConfigList::DataRole::ContainerName); | ||
709 | 229 | container_name = g_strdup(name.toString().toStdString().c_str()); | ||
710 | 230 | break; | ||
711 | 231 | } | ||
712 | 232 | } | ||
713 | 233 | |||
714 | 234 | return container_name; | ||
718 | 235 | } | 91 | } |
719 | 236 | 92 | ||
720 | === modified file 'liblibertine/libertine.h' | |||
721 | --- liblibertine/libertine.h 2016-09-06 12:36:47 +0000 | |||
722 | +++ liblibertine/libertine.h 2017-01-27 18:57:35 +0000 | |||
723 | @@ -1,5 +1,5 @@ | |||
724 | 1 | /* | 1 | /* |
726 | 2 | * Copyright 2015 Canonical Ltd. | 2 | * Copyright 2015-2017 Canonical Ltd. |
727 | 3 | * | 3 | * |
728 | 4 | * This program is free software: you can redistribute it and/or modify it under | 4 | * This program is free software: you can redistribute it and/or modify it under |
729 | 5 | * the terms of the GNU General Public License, version 3, as published by the | 5 | * the terms of the GNU General Public License, version 3, as published by the |
730 | @@ -15,8 +15,8 @@ | |||
731 | 15 | */ | 15 | */ |
732 | 16 | #include <glib.h> | 16 | #include <glib.h> |
733 | 17 | 17 | ||
736 | 18 | #ifndef _LIBERTINE_COMMON_H_ | 18 | #ifndef _LIBLIBERTINE_H_ |
737 | 19 | #define _LIBERTINE_COMMON_H_ | 19 | #define _LIBLIBERTINE_H_ |
738 | 20 | 20 | ||
739 | 21 | #ifdef __cplusplus | 21 | #ifdef __cplusplus |
740 | 22 | extern "C" { | 22 | extern "C" { |
741 | @@ -80,4 +80,4 @@ | |||
742 | 80 | } | 80 | } |
743 | 81 | #endif | 81 | #endif |
744 | 82 | 82 | ||
746 | 83 | #endif /* _LIBERTINE_COMMON_H_ */ | 83 | #endif /* _LIBLIBERTINE_H_ */ |
747 | 84 | 84 | ||
748 | === added file 'liblibertine/libertined.cpp' | |||
749 | --- liblibertine/libertined.cpp 1970-01-01 00:00:00 +0000 | |||
750 | +++ liblibertine/libertined.cpp 2017-01-27 18:57:35 +0000 | |||
751 | @@ -0,0 +1,199 @@ | |||
752 | 1 | /* | ||
753 | 2 | * Copyright 2017 Canonical Ltd | ||
754 | 3 | * | ||
755 | 4 | * Libertine is free software: you can redistribute it and/or modify it under | ||
756 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
757 | 6 | * Free Software Foundation. | ||
758 | 7 | * | ||
759 | 8 | * Libertine is distributed in the hope that it will be useful, but WITHOUT ANY | ||
760 | 9 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
761 | 10 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
762 | 11 | * | ||
763 | 12 | * You should have received a copy of the GNU General Public License | ||
764 | 13 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
765 | 14 | */ | ||
766 | 15 | |||
767 | 16 | |||
768 | 17 | #include "libertined.h" | ||
769 | 18 | |||
770 | 19 | #include <QDBusMessage> | ||
771 | 20 | #include <QDBusInterface> | ||
772 | 21 | #include <QDebug> | ||
773 | 22 | #include <thread> | ||
774 | 23 | #include <chrono> | ||
775 | 24 | #include <QJsonDocument> | ||
776 | 25 | #include <QJsonArray> | ||
777 | 26 | #include <QJsonObject> | ||
778 | 27 | |||
779 | 28 | namespace | ||
780 | 29 | { | ||
781 | 30 | static const auto SERVICE_INTERFACE = "com.canonical.libertine.Service"; | ||
782 | 31 | static const auto PROGRESS_INTERFACE = "com.canonical.libertine.Service.Progress"; | ||
783 | 32 | |||
784 | 33 | static QVariantList | ||
785 | 34 | dbusCall(QDBusConnection const& bus, QString const& iface, QString const& path, | ||
786 | 35 | QString const& method, QVariantList const& args = QVariantList()) | ||
787 | 36 | { | ||
788 | 37 | auto message = QDBusMessage::createMethodCall(SERVICE_INTERFACE, path, iface, method); | ||
789 | 38 | message.setArguments(args); | ||
790 | 39 | auto response = bus.call(message); | ||
791 | 40 | if (response.type() == QDBusMessage::ErrorMessage) | ||
792 | 41 | { | ||
793 | 42 | qWarning() << "error calling result" << response.errorMessage(); | ||
794 | 43 | return QVariantList(); | ||
795 | 44 | } | ||
796 | 45 | |||
797 | 46 | return response.arguments(); | ||
798 | 47 | } | ||
799 | 48 | |||
800 | 49 | static bool | ||
801 | 50 | isRunning(QDBusConnection const& bus, QString const& path) | ||
802 | 51 | { | ||
803 | 52 | auto args = dbusCall(bus, PROGRESS_INTERFACE, path, "running", QVariantList()); | ||
804 | 53 | |||
805 | 54 | if (args.isEmpty()) | ||
806 | 55 | { | ||
807 | 56 | qWarning() << "lastError - no arguments?"; | ||
808 | 57 | return false; | ||
809 | 58 | } | ||
810 | 59 | |||
811 | 60 | return args.first().toBool(); | ||
812 | 61 | } | ||
813 | 62 | |||
814 | 63 | static QString | ||
815 | 64 | result(QDBusConnection const& bus, QString const& path) | ||
816 | 65 | { | ||
817 | 66 | auto args = dbusCall(bus, PROGRESS_INTERFACE, path, "result"); | ||
818 | 67 | |||
819 | 68 | if (args.isEmpty()) | ||
820 | 69 | { | ||
821 | 70 | qWarning() << "lastError - no arguments?"; | ||
822 | 71 | return ""; | ||
823 | 72 | } | ||
824 | 73 | |||
825 | 74 | return args.first().toString(); | ||
826 | 75 | } | ||
827 | 76 | |||
828 | 77 | static QString | ||
829 | 78 | lastError(QDBusConnection const& bus, QString const& path) | ||
830 | 79 | { | ||
831 | 80 | auto args = dbusCall(bus, PROGRESS_INTERFACE, path, "last_error"); | ||
832 | 81 | |||
833 | 82 | if (args.isEmpty()) | ||
834 | 83 | { | ||
835 | 84 | qWarning() << "lastError - no arguments?"; | ||
836 | 85 | return ""; | ||
837 | 86 | } | ||
838 | 87 | |||
839 | 88 | return args.first().toString(); | ||
840 | 89 | } | ||
841 | 90 | |||
842 | 91 | static QString | ||
843 | 92 | call(QDBusConnection const& bus, QString const& method, QVariantList const& args) | ||
844 | 93 | { | ||
845 | 94 | auto results = dbusCall(bus, SERVICE_INTERFACE, "/Manager", method, args); | ||
846 | 95 | |||
847 | 96 | if (results.isEmpty()) | ||
848 | 97 | { | ||
849 | 98 | return QString(); | ||
850 | 99 | } | ||
851 | 100 | |||
852 | 101 | return qvariant_cast<QDBusObjectPath>(results.first()).path(); | ||
853 | 102 | } | ||
854 | 103 | |||
855 | 104 | static bool | ||
856 | 105 | waitForFinish(QDBusConnection const& bus, QString const& path) | ||
857 | 106 | { | ||
858 | 107 | std::chrono::microseconds wait(500); | ||
859 | 108 | for (auto i = 0; i < 2000; ++i) | ||
860 | 109 | { | ||
861 | 110 | if (!isRunning(bus, path)) | ||
862 | 111 | { | ||
863 | 112 | return true; | ||
864 | 113 | } | ||
865 | 114 | std::this_thread::sleep_for(wait); | ||
866 | 115 | } | ||
867 | 116 | return !isRunning(bus, path); | ||
868 | 117 | } | ||
869 | 118 | |||
870 | 119 | QString | ||
871 | 120 | container_info(char const* container_id, QString const& key) | ||
872 | 121 | { | ||
873 | 122 | auto bus = QDBusConnection::sessionBus(); | ||
874 | 123 | auto path = call(bus, "container_info", QVariantList{QVariant(container_id)}); | ||
875 | 124 | |||
876 | 125 | if (!waitForFinish(bus, path)) | ||
877 | 126 | { | ||
878 | 127 | return QString(); | ||
879 | 128 | } | ||
880 | 129 | |||
881 | 130 | auto error = lastError(bus, path); | ||
882 | 131 | if (!error.isEmpty()) | ||
883 | 132 | { | ||
884 | 133 | qWarning() << "error:" << error; | ||
885 | 134 | return QString(); | ||
886 | 135 | } | ||
887 | 136 | |||
888 | 137 | return QJsonDocument::fromJson(result(bus, path).toLatin1()).object().value(key).toString(); | ||
889 | 138 | } | ||
890 | 139 | } | ||
891 | 140 | |||
892 | 141 | QJsonArray | ||
893 | 142 | libertined_list() | ||
894 | 143 | { | ||
895 | 144 | auto bus = QDBusConnection::sessionBus(); | ||
896 | 145 | auto path = call(bus, "list", QVariantList()); | ||
897 | 146 | |||
898 | 147 | if (!waitForFinish(bus, path)) | ||
899 | 148 | { | ||
900 | 149 | return QJsonArray(); | ||
901 | 150 | } | ||
902 | 151 | |||
903 | 152 | auto error = lastError(bus, path); | ||
904 | 153 | if (!error.isEmpty()) | ||
905 | 154 | { | ||
906 | 155 | qWarning() << "error:" << error; | ||
907 | 156 | return QJsonArray(); | ||
908 | 157 | } | ||
909 | 158 | |||
910 | 159 | return QJsonDocument::fromJson(result(bus, path).toLatin1()).array(); | ||
911 | 160 | } | ||
912 | 161 | |||
913 | 162 | QJsonArray | ||
914 | 163 | libertined_list_app_ids(char const* container_id) | ||
915 | 164 | { | ||
916 | 165 | auto bus = QDBusConnection::sessionBus(); | ||
917 | 166 | auto path = call(bus, "list_app_ids", QVariantList{QVariant(container_id)}); | ||
918 | 167 | |||
919 | 168 | if (!waitForFinish(bus, path)) | ||
920 | 169 | { | ||
921 | 170 | return QJsonArray(); | ||
922 | 171 | } | ||
923 | 172 | |||
924 | 173 | auto error = lastError(bus, path); | ||
925 | 174 | if (!error.isEmpty()) | ||
926 | 175 | { | ||
927 | 176 | qWarning() << "error:" << error; | ||
928 | 177 | return QJsonArray(); | ||
929 | 178 | } | ||
930 | 179 | |||
931 | 180 | return QJsonDocument::fromJson(result(bus, path).toLatin1()).array(); | ||
932 | 181 | } | ||
933 | 182 | |||
934 | 183 | QString | ||
935 | 184 | libertined_container_path(char const* container_id) | ||
936 | 185 | { | ||
937 | 186 | return container_info(container_id, "root"); | ||
938 | 187 | } | ||
939 | 188 | |||
940 | 189 | QString | ||
941 | 190 | libertined_container_home_path(char const* container_id) | ||
942 | 191 | { | ||
943 | 192 | return container_info(container_id, "home"); | ||
944 | 193 | } | ||
945 | 194 | |||
946 | 195 | QString | ||
947 | 196 | libertined_container_name(char const* container_id) | ||
948 | 197 | { | ||
949 | 198 | return container_info(container_id, "name"); | ||
950 | 199 | } | ||
951 | 0 | 200 | ||
952 | === added file 'liblibertine/libertined.h' | |||
953 | --- liblibertine/libertined.h 1970-01-01 00:00:00 +0000 | |||
954 | +++ liblibertine/libertined.h 2017-01-27 18:57:35 +0000 | |||
955 | @@ -0,0 +1,25 @@ | |||
956 | 1 | /* | ||
957 | 2 | * Copyright 2017 Canonical Ltd | ||
958 | 3 | * | ||
959 | 4 | * Libertine is free software: you can redistribute it and/or modify it under | ||
960 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
961 | 6 | * Free Software Foundation. | ||
962 | 7 | * | ||
963 | 8 | * Libertine is distributed in the hope that it will be useful, but WITHOUT ANY | ||
964 | 9 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
965 | 10 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
966 | 11 | * | ||
967 | 12 | * You should have received a copy of the GNU General Public License | ||
968 | 13 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
969 | 14 | */ | ||
970 | 15 | |||
971 | 16 | #pragma once | ||
972 | 17 | |||
973 | 18 | #include <QDBusConnection> | ||
974 | 19 | #include <QJsonArray> | ||
975 | 20 | |||
976 | 21 | QJsonArray libertined_list(); | ||
977 | 22 | QString libertined_container_path(char const* container_id); | ||
978 | 23 | QString libertined_container_home_path(char const* container_id); | ||
979 | 24 | QString libertined_container_name(char const* container_id); | ||
980 | 25 | QJsonArray libertined_list_app_ids(char const* container_id); | ||
981 | 0 | 26 | ||
982 | === modified file 'python/libertine/ChrootContainer.py' | |||
983 | --- python/libertine/ChrootContainer.py 2017-01-17 20:19:30 +0000 | |||
984 | +++ python/libertine/ChrootContainer.py 2017-01-27 18:57:35 +0000 | |||
985 | @@ -1,4 +1,4 @@ | |||
987 | 1 | # Copyright 2015-2016 Canonical Ltd. | 1 | # Copyright 2015-2017 Canonical Ltd. |
988 | 2 | # | 2 | # |
989 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
990 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
991 | @@ -47,9 +47,8 @@ | |||
992 | 47 | A concrete container type implemented using a plain old chroot. | 47 | A concrete container type implemented using a plain old chroot. |
993 | 48 | """ | 48 | """ |
994 | 49 | 49 | ||
998 | 50 | def __init__(self, container_id): | 50 | def __init__(self, container_id, config): |
999 | 51 | super().__init__(container_id) | 51 | super().__init__(container_id, 'chroot', config) |
997 | 52 | self.container_type = "chroot" | ||
1000 | 53 | self._window_manager = None | 52 | self._window_manager = None |
1001 | 54 | # FIXME: Disabling seccomp is a temporary measure until we fully understand why we need | 53 | # FIXME: Disabling seccomp is a temporary measure until we fully understand why we need |
1002 | 55 | # it or figure out when we need it. | 54 | # it or figure out when we need it. |
1003 | @@ -112,7 +111,7 @@ | |||
1004 | 112 | fd.write(archive + self.installed_release + " multiverse\n") | 111 | fd.write(archive + self.installed_release + " multiverse\n") |
1005 | 113 | fd.write(archive + self.installed_release + "-updates multiverse\n") | 112 | fd.write(archive + self.installed_release + "-updates multiverse\n") |
1006 | 114 | 113 | ||
1008 | 115 | utils.create_libertine_user_data_dir(self.container_id) | 114 | self._create_libertine_user_data_dir() |
1009 | 116 | 115 | ||
1010 | 117 | self.update_locale() | 116 | self.update_locale() |
1011 | 118 | 117 | ||
1012 | @@ -140,7 +139,7 @@ | |||
1013 | 140 | self.update_packages() | 139 | self.update_packages() |
1014 | 141 | 140 | ||
1015 | 142 | # Check if the container was created as root and chown the user directories as necessary | 141 | # Check if the container was created as root and chown the user directories as necessary |
1017 | 143 | chown_recursive_dirs(utils.get_libertine_container_userdata_dir_path(self.container_id)) | 142 | chown_recursive_dirs(utils.get_libertine_container_home_dir(self.container_id)) |
1018 | 144 | 143 | ||
1019 | 145 | super().create_libertine_container() | 144 | super().create_libertine_container() |
1020 | 146 | 145 | ||
1021 | @@ -186,7 +185,7 @@ | |||
1022 | 186 | # Bind-mount common XDG direcotries | 185 | # Bind-mount common XDG direcotries |
1023 | 187 | bind_mounts = ( | 186 | bind_mounts = ( |
1024 | 188 | " -b %s:%s" | 187 | " -b %s:%s" |
1026 | 189 | % (utils.get_libertine_container_userdata_dir_path(self.container_id), home_path) | 188 | % (utils.get_libertine_container_home_dir(self.container_id), home_path) |
1027 | 190 | ) | 189 | ) |
1028 | 191 | 190 | ||
1029 | 192 | mounts = self._sanitize_bind_mounts(utils.get_common_xdg_user_directories() + \ | 191 | mounts = self._sanitize_bind_mounts(utils.get_common_xdg_user_directories() + \ |
1030 | 193 | 192 | ||
1031 | === modified file 'python/libertine/ContainersConfig.py' | |||
1032 | --- python/libertine/ContainersConfig.py 2017-01-24 20:21:16 +0000 | |||
1033 | +++ python/libertine/ContainersConfig.py 2017-01-27 18:57:35 +0000 | |||
1034 | @@ -242,6 +242,9 @@ | |||
1035 | 242 | if write_json: | 242 | if write_json: |
1036 | 243 | write_container_config_file(self.container_list) | 243 | write_container_config_file(self.container_list) |
1037 | 244 | 244 | ||
1038 | 245 | def get_containers(self): | ||
1039 | 246 | return [c["id"] for c in self.container_list.get('containerList', [])] | ||
1040 | 247 | |||
1041 | 245 | """ | 248 | """ |
1042 | 246 | Operations for the container itself. | 249 | Operations for the container itself. |
1043 | 247 | """ | 250 | """ |
1044 | @@ -303,6 +306,12 @@ | |||
1045 | 303 | def get_container_locale(self, container_id): | 306 | def get_container_locale(self, container_id): |
1046 | 304 | return self._get_value_by_key(container_id, 'locale') | 307 | return self._get_value_by_key(container_id, 'locale') |
1047 | 305 | 308 | ||
1048 | 309 | def get_container_name(self, container_id): | ||
1049 | 310 | return self._get_value_by_key(container_id, 'name') | ||
1050 | 311 | |||
1051 | 312 | def get_container_install_status(self, container_id): | ||
1052 | 313 | return self._get_value_by_key(container_id, 'installStatus') | ||
1053 | 314 | |||
1054 | 306 | """ | 315 | """ |
1055 | 307 | Operations for archive (PPA) maintenance in a Libertine container. | 316 | Operations for archive (PPA) maintenance in a Libertine container. |
1056 | 308 | """ | 317 | """ |
1057 | 309 | 318 | ||
1058 | === modified file 'python/libertine/Libertine.py' | |||
1059 | --- python/libertine/Libertine.py 2017-01-24 15:31:01 +0000 | |||
1060 | +++ python/libertine/Libertine.py 2017-01-27 18:57:35 +0000 | |||
1061 | @@ -1,4 +1,4 @@ | |||
1063 | 1 | # Copyright 2015-2016 Canonical Ltd. | 1 | # Copyright 2015-2017 Canonical Ltd. |
1064 | 2 | # | 2 | # |
1065 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
1066 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
1067 | @@ -13,7 +13,6 @@ | |||
1068 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1069 | 14 | 14 | ||
1070 | 15 | from .AppDiscovery import AppLauncherCache | 15 | from .AppDiscovery import AppLauncherCache |
1071 | 16 | from gi.repository import Libertine | ||
1072 | 17 | import abc | 16 | import abc |
1073 | 18 | import contextlib | 17 | import contextlib |
1074 | 19 | import os | 18 | import os |
1075 | @@ -81,14 +80,12 @@ | |||
1076 | 81 | 80 | ||
1077 | 82 | :param container_id: The machine-readable container name. | 81 | :param container_id: The machine-readable container name. |
1078 | 83 | """ | 82 | """ |
1084 | 84 | def __init__(self, container_id, containers_config=None): | 83 | def __init__(self, container_id, container_type, config): |
1085 | 85 | if containers_config is None: | 84 | self.container_type = container_type |
1081 | 86 | containers_config = ContainersConfig() | ||
1082 | 87 | |||
1083 | 88 | self.container_type = 'unknown' | ||
1086 | 89 | self.container_id = container_id | 85 | self.container_id = container_id |
1087 | 86 | self._config = config | ||
1088 | 90 | self.root_path = utils.get_libertine_container_rootfs_path(self.container_id) | 87 | self.root_path = utils.get_libertine_container_rootfs_path(self.container_id) |
1090 | 91 | self.locale = containers_config.get_container_locale(container_id) | 88 | self.locale = self._config.get_container_locale(container_id) |
1091 | 92 | self.language = self._get_language_from_locale() | 89 | self.language = self._get_language_from_locale() |
1092 | 93 | self.default_packages = ['matchbox-window-manager', | 90 | self.default_packages = ['matchbox-window-manager', |
1093 | 94 | 'libnss-extrausers', | 91 | 'libnss-extrausers', |
1094 | @@ -247,10 +244,10 @@ | |||
1095 | 247 | self.delete_file_in_container(dest) | 244 | self.delete_file_in_container(dest) |
1096 | 248 | 245 | ||
1097 | 249 | return ret | 246 | return ret |
1102 | 250 | else: | 247 | |
1103 | 251 | if no_dialog: | 248 | if no_dialog: |
1104 | 252 | os.environ['DEBIAN_FRONTEND'] = 'teletype' | 249 | os.environ['DEBIAN_FRONTEND'] = 'teletype' |
1105 | 253 | ret = self.run_in_container(_apt_command_prefix() + " install '" + package_name + "'") == 0 | 250 | ret = self.run_in_container(_apt_command_prefix() + " install '" + package_name + "'") == 0 |
1106 | 254 | 251 | ||
1107 | 255 | self.check_language_support() | 252 | self.check_language_support() |
1108 | 256 | 253 | ||
1109 | @@ -313,19 +310,26 @@ | |||
1110 | 313 | """ | 310 | """ |
1111 | 314 | The human-readable name of the container. | 311 | The human-readable name of the container. |
1112 | 315 | """ | 312 | """ |
1117 | 316 | name = Libertine.container_name(self.container_id) | 313 | return self._config.get_container_name(self.container_id) or 'Unknown' |
1118 | 317 | if not name: | 314 | |
1119 | 318 | name = 'Unknown' | 315 | def _create_libertine_user_data_dir(self): |
1120 | 319 | return name | 316 | user_data = utils.get_libertine_container_home_dir(self.container_id) |
1121 | 317 | |||
1122 | 318 | if not os.path.exists(user_data): | ||
1123 | 319 | os.makedirs(user_data) | ||
1124 | 320 | |||
1125 | 321 | config_path = os.path.join(user_data, ".config", "dconf") | ||
1126 | 322 | |||
1127 | 323 | if not os.path.exists(config_path): | ||
1128 | 324 | os.makedirs(config_path) | ||
1129 | 320 | 325 | ||
1130 | 321 | 326 | ||
1131 | 322 | class LibertineMock(BaseContainer): | 327 | class LibertineMock(BaseContainer): |
1132 | 323 | """ | 328 | """ |
1133 | 324 | A concrete mock container type. Used for unit testing. | 329 | A concrete mock container type. Used for unit testing. |
1134 | 325 | """ | 330 | """ |
1138 | 326 | def __init__(self, container_id, containers_config=None): | 331 | def __init__(self, container_id, config): |
1139 | 327 | super().__init__(container_id, containers_config) | 332 | super().__init__(container_id, 'mock', config) |
1137 | 328 | self.container_type = "mock" | ||
1140 | 329 | 333 | ||
1141 | 330 | def create_libertine_container(self, password=None, multiarch=False): | 334 | def create_libertine_container(self, password=None, multiarch=False): |
1142 | 331 | return True | 335 | return True |
1143 | @@ -395,7 +399,7 @@ | |||
1144 | 395 | self.container = LibertineLXD(container_id, self.containers_config) | 399 | self.container = LibertineLXD(container_id, self.containers_config) |
1145 | 396 | elif container_type == "chroot": | 400 | elif container_type == "chroot": |
1146 | 397 | from libertine.ChrootContainer import LibertineChroot | 401 | from libertine.ChrootContainer import LibertineChroot |
1148 | 398 | self.container = LibertineChroot(container_id) | 402 | self.container = LibertineChroot(container_id, self.containers_config) |
1149 | 399 | elif container_type == "mock": | 403 | elif container_type == "mock": |
1150 | 400 | self.container = LibertineMock(container_id, self.containers_config) | 404 | self.container = LibertineMock(container_id, self.containers_config) |
1151 | 401 | else: | 405 | else: |
1152 | @@ -514,7 +518,7 @@ | |||
1153 | 514 | Enumerates all application launchers (based on .desktop files) available | 518 | Enumerates all application launchers (based on .desktop files) available |
1154 | 515 | in the container. | 519 | in the container. |
1155 | 516 | 520 | ||
1157 | 517 | :param use_json: Indicates the returned string should be i JSON format. | 521 | :param use_json: Indicates the returned string should be in JSON format. |
1158 | 518 | The default format is some human-readble format. | 522 | The default format is some human-readble format. |
1159 | 519 | :rtype: A printable string containing a list of application launchers | 523 | :rtype: A printable string containing a list of application launchers |
1160 | 520 | available in the container. | 524 | available in the container. |
1161 | @@ -526,6 +530,24 @@ | |||
1162 | 526 | return str(AppLauncherCache(self.container.name, | 530 | return str(AppLauncherCache(self.container.name, |
1163 | 527 | self.container.root_path)) | 531 | self.container.root_path)) |
1164 | 528 | 532 | ||
1165 | 533 | def list_app_ids(self): | ||
1166 | 534 | """ | ||
1167 | 535 | Finds application ids (based on .desktop files) available in the | ||
1168 | 536 | container. | ||
1169 | 537 | |||
1170 | 538 | :rtype: A list of app ids consumable by tools such as ubuntu-app-launch | ||
1171 | 539 | """ | ||
1172 | 540 | home = utils.get_libertine_container_home_dir(self.container_id) | ||
1173 | 541 | app_ids = [] | ||
1174 | 542 | for apps_dir in ["{}/usr/share/applications".format(self.root_path), | ||
1175 | 543 | "{}/usr/local/share/applications".format(self.root_path), | ||
1176 | 544 | "{}/.local/share/applications".format(home)]: | ||
1177 | 545 | if os.path.exists(apps_dir): | ||
1178 | 546 | for root, dirs, files in os.walk(apps_dir): | ||
1179 | 547 | app_ids.extend(["{}_{}_0.0".format(self.container_id, f[:-8]) for f in files if f.endswith(".desktop")]) | ||
1180 | 548 | |||
1181 | 549 | return app_ids | ||
1182 | 550 | |||
1183 | 529 | def exec_command(self, exec_line): | 551 | def exec_command(self, exec_line): |
1184 | 530 | """ | 552 | """ |
1185 | 531 | Runs an arbitrary application in the container. Mainly used for status | 553 | Runs an arbitrary application in the container. Mainly used for status |
1186 | 532 | 554 | ||
1187 | === modified file 'python/libertine/LxcContainer.py' | |||
1188 | --- python/libertine/LxcContainer.py 2017-01-24 20:21:16 +0000 | |||
1189 | +++ python/libertine/LxcContainer.py 2017-01-27 18:57:35 +0000 | |||
1190 | @@ -158,9 +158,8 @@ | |||
1191 | 158 | A concrete container type implemented using an LXC container. | 158 | A concrete container type implemented using an LXC container. |
1192 | 159 | """ | 159 | """ |
1193 | 160 | 160 | ||
1197 | 161 | def __init__(self, container_id, config=None): | 161 | def __init__(self, container_id, config): |
1198 | 162 | super().__init__(container_id) | 162 | super().__init__(container_id, 'lxc', config) |
1196 | 163 | self.container_type = "lxc" | ||
1199 | 164 | self.container = lxc_container(container_id) | 163 | self.container = lxc_container(container_id) |
1200 | 165 | self.lxc_manager_interface = None | 164 | self.lxc_manager_interface = None |
1201 | 166 | self.window_manager = None | 165 | self.window_manager = None |
1202 | @@ -247,7 +246,7 @@ | |||
1203 | 247 | 246 | ||
1204 | 248 | self.container.load_config(config_file) | 247 | self.container.load_config(config_file) |
1205 | 249 | 248 | ||
1207 | 250 | utils.create_libertine_user_data_dir(self.container_id) | 249 | self._create_libertine_user_data_dir() |
1208 | 251 | 250 | ||
1209 | 252 | with EnvLxcSettings(): | 251 | with EnvLxcSettings(): |
1210 | 253 | lxc_logfile = get_logfile(self.container) | 252 | lxc_logfile = get_logfile(self.container) |
1211 | @@ -299,7 +298,7 @@ | |||
1212 | 299 | user_id = os.getuid() | 298 | user_id = os.getuid() |
1213 | 300 | home_entry = ( | 299 | home_entry = ( |
1214 | 301 | "%s %s none bind,create=dir" | 300 | "%s %s none bind,create=dir" |
1216 | 302 | % (utils.get_libertine_container_userdata_dir_path(self.container_id), | 301 | % (utils.get_libertine_container_home_dir(self.container_id), |
1217 | 303 | home_path.strip('/')) | 302 | home_path.strip('/')) |
1218 | 304 | ) | 303 | ) |
1219 | 305 | 304 | ||
1220 | 306 | 305 | ||
1221 | === modified file 'python/libertine/LxdContainer.py' | |||
1222 | --- python/libertine/LxdContainer.py 2017-01-25 16:27:15 +0000 | |||
1223 | +++ python/libertine/LxdContainer.py 2017-01-27 18:57:35 +0000 | |||
1224 | @@ -226,7 +226,7 @@ | |||
1225 | 226 | 226 | ||
1226 | 227 | 227 | ||
1227 | 228 | def update_bind_mounts(container, config, home_path): | 228 | def update_bind_mounts(container, config, home_path): |
1229 | 229 | userdata_dir = utils.get_libertine_container_userdata_dir_path(container.name) | 229 | userdata_dir = utils.get_libertine_container_home_dir(container.name) |
1230 | 230 | 230 | ||
1231 | 231 | container.devices.clear() | 231 | container.devices.clear() |
1232 | 232 | container.devices['root'] = {'type': 'disk', 'path': '/'} | 232 | container.devices['root'] = {'type': 'disk', 'path': '/'} |
1233 | @@ -251,7 +251,7 @@ | |||
1234 | 251 | 251 | ||
1235 | 252 | mounts = config.get_container_bind_mounts(container.name) | 252 | mounts = config.get_container_bind_mounts(container.name) |
1236 | 253 | if utils.is_snap_environment(): | 253 | if utils.is_snap_environment(): |
1238 | 254 | mounts += ["{}{}".format(home_path, d) for d in ["Documents", "Downloads", "Music", "Videos", "Pictures"]] | 254 | mounts += [os.path.join(home_path, d) for d in ["Documents", "Downloads", "Music", "Videos", "Pictures"]] |
1239 | 255 | else: | 255 | else: |
1240 | 256 | mounts += utils.get_common_xdg_user_directories() | 256 | mounts += utils.get_common_xdg_user_directories() |
1241 | 257 | 257 | ||
1242 | @@ -301,8 +301,7 @@ | |||
1243 | 301 | 301 | ||
1244 | 302 | class LibertineLXD(Libertine.BaseContainer): | 302 | class LibertineLXD(Libertine.BaseContainer): |
1245 | 303 | def __init__(self, name, config): | 303 | def __init__(self, name, config): |
1248 | 304 | super().__init__(name, config) | 304 | super().__init__(name, 'lxd', config) |
1247 | 305 | self._config = config | ||
1249 | 306 | self._host_info = HostInfo.HostInfo() | 305 | self._host_info = HostInfo.HostInfo() |
1250 | 307 | self._container = None | 306 | self._container = None |
1251 | 308 | self._matchbox_pid = None | 307 | self._matchbox_pid = None |
1252 | @@ -315,14 +314,15 @@ | |||
1253 | 315 | self._client = pylxd.Client() | 314 | self._client = pylxd.Client() |
1254 | 316 | self._window_manager = None | 315 | self._window_manager = None |
1255 | 317 | 316 | ||
1264 | 318 | try: | 317 | if not utils.is_snap_environment(): |
1265 | 319 | if utils.set_session_dbus_env_var(): | 318 | try: |
1266 | 320 | bus = dbus.SessionBus() | 319 | if utils.set_session_dbus_env_var(): |
1267 | 321 | self._manager = bus.get_object(get_lxd_manager_dbus_name(), get_lxd_manager_dbus_path()) | 320 | bus = dbus.SessionBus() |
1268 | 322 | except PermissionError as e: | 321 | self._manager = bus.get_object(get_lxd_manager_dbus_name(), get_lxd_manager_dbus_path()) |
1269 | 323 | utils.get_logger().warning("Failed to set dbus session env var") | 322 | except PermissionError as e: |
1270 | 324 | except dbus.exceptions.DBusException: | 323 | utils.get_logger().warning("Failed to set dbus session env var") |
1271 | 325 | utils.get_logger().warning("D-Bus Service not found.") | 324 | except dbus.exceptions.DBusException: |
1272 | 325 | utils.get_logger().warning("D-Bus Service not found.") | ||
1273 | 326 | 326 | ||
1274 | 327 | def create_libertine_container(self, password=None, multiarch=False): | 327 | def create_libertine_container(self, password=None, multiarch=False): |
1275 | 328 | if self._try_get_container(): | 328 | if self._try_get_container(): |
1276 | @@ -353,7 +353,7 @@ | |||
1277 | 353 | self.run_in_container("mkdir -p /home/{}".format(username)) | 353 | self.run_in_container("mkdir -p /home/{}".format(username)) |
1278 | 354 | self.run_in_container("chown {0}:{0} /home/{0}".format(username)) | 354 | self.run_in_container("chown {0}:{0} /home/{0}".format(username)) |
1279 | 355 | 355 | ||
1281 | 356 | utils.create_libertine_user_data_dir(self.container_id) | 356 | self._create_libertine_user_data_dir() |
1282 | 357 | 357 | ||
1283 | 358 | _setup_bind_mount_service(self._container, uid, username) | 358 | _setup_bind_mount_service(self._container, uid, username) |
1284 | 359 | 359 | ||
1285 | 360 | 360 | ||
1286 | === modified file 'python/libertine/service/apt.py' | |||
1287 | --- python/libertine/service/apt.py 2016-11-08 15:37:58 +0000 | |||
1288 | +++ python/libertine/service/apt.py 2017-01-27 18:57:35 +0000 | |||
1289 | @@ -1,4 +1,4 @@ | |||
1291 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1292 | 2 | # | 2 | # |
1293 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1294 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1295 | @@ -15,10 +15,6 @@ | |||
1296 | 15 | import apt | 15 | import apt |
1297 | 16 | import re | 16 | import re |
1298 | 17 | 17 | ||
1299 | 18 | import gi | ||
1300 | 19 | gi.require_version('Libertine', '1') | ||
1301 | 20 | from gi.repository import Libertine | ||
1302 | 21 | |||
1303 | 22 | from libertine import utils | 18 | from libertine import utils |
1304 | 23 | from os import path | 19 | from os import path |
1305 | 24 | from threading import Lock | 20 | from threading import Lock |
1306 | @@ -67,7 +63,7 @@ | |||
1307 | 67 | if self._cache is None: | 63 | if self._cache is None: |
1308 | 68 | try: | 64 | try: |
1309 | 69 | utils.get_logger().debug("Trying aptcache for container %s" % self._container) | 65 | utils.get_logger().debug("Trying aptcache for container %s" % self._container) |
1311 | 70 | container_path = Libertine.container_path(self._container) | 66 | container_path = utils.get_libertine_container_rootfs_path(self._container) |
1312 | 71 | if not container_path or not path.exists(container_path): | 67 | if not container_path or not path.exists(container_path): |
1313 | 72 | raise PermissionError | 68 | raise PermissionError |
1314 | 73 | 69 | ||
1315 | 74 | 70 | ||
1316 | === modified file 'python/libertine/service/container.py' | |||
1317 | --- python/libertine/service/container.py 2016-11-08 15:37:58 +0000 | |||
1318 | +++ python/libertine/service/container.py 2017-01-27 18:57:35 +0000 | |||
1319 | @@ -1,4 +1,4 @@ | |||
1321 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1322 | 2 | # | 2 | # |
1323 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1324 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1325 | @@ -14,18 +14,27 @@ | |||
1326 | 14 | 14 | ||
1327 | 15 | from libertine.service.tasks import * | 15 | from libertine.service.tasks import * |
1328 | 16 | from libertine import utils | 16 | from libertine import utils |
1330 | 17 | from libertine.service import apt | 17 | from threading import Lock |
1331 | 18 | |||
1332 | 19 | |||
1333 | 20 | if not utils.is_snap_environment(): | ||
1334 | 21 | from libertine.service import apt | ||
1335 | 18 | 22 | ||
1336 | 19 | 23 | ||
1337 | 20 | class Container(object): | 24 | class Container(object): |
1339 | 21 | def __init__(self, container_id, config, lock, connection, callback): | 25 | def __init__(self, container_id, config, connection, callback): |
1340 | 22 | self._id = container_id | 26 | self._id = container_id |
1341 | 23 | self._connection = connection | 27 | self._connection = connection |
1342 | 24 | self._callback = callback | 28 | self._callback = callback |
1343 | 25 | self._config = config | 29 | self._config = config |
1345 | 26 | self._lock = lock | 30 | self._lock = Lock() |
1346 | 27 | self._tasks = [] | 31 | self._tasks = [] |
1348 | 28 | self._cache = apt.AptCache(self.id) | 32 | |
1349 | 33 | if utils.is_snap_environment(): | ||
1350 | 34 | utils.get_logger().warning("Using AptCache not currently supported in snap environment") | ||
1351 | 35 | self._cache = None | ||
1352 | 36 | else: | ||
1353 | 37 | self._cache = apt.AptCache(self.id) | ||
1354 | 29 | 38 | ||
1355 | 30 | def _cleanup_task(self, task): | 39 | def _cleanup_task(self, task): |
1356 | 31 | utils.get_logger().debug("cleaning up tasks for container '%s'" % self.id) | 40 | utils.get_logger().debug("cleaning up tasks for container '%s'" % self.id) |
1357 | @@ -47,6 +56,9 @@ | |||
1358 | 47 | def search(self, query): | 56 | def search(self, query): |
1359 | 48 | utils.get_logger().debug("search container '%s' for package '%s'" % (self.id, query)) | 57 | utils.get_logger().debug("search container '%s' for package '%s'" % (self.id, query)) |
1360 | 49 | 58 | ||
1361 | 59 | if utils.is_snap_environment(): | ||
1362 | 60 | raise Exception("This operation is not currently supported within the snap") | ||
1363 | 61 | |||
1364 | 50 | task = SearchTask(self.id, self._cache, query, self._connection, self._cleanup_task) | 62 | task = SearchTask(self.id, self._cache, query, self._connection, self._cleanup_task) |
1365 | 51 | self._tasks.append(task) | 63 | self._tasks.append(task) |
1366 | 52 | task.start() | 64 | task.start() |
1367 | @@ -56,6 +68,9 @@ | |||
1368 | 56 | def app_info(self, package_name): | 68 | def app_info(self, package_name): |
1369 | 57 | utils.get_logger().debug("get info for package '%s' in container '%s'" % (package_name, self.id)) | 69 | utils.get_logger().debug("get info for package '%s' in container '%s'" % (package_name, self.id)) |
1370 | 58 | 70 | ||
1371 | 71 | if utils.is_snap_environment(): | ||
1372 | 72 | raise Exception("This operation is not currently supported within the snap") | ||
1373 | 73 | |||
1374 | 59 | related_task_ids = [t.id for t in self._tasks if t.package == package_name and t.running] | 74 | related_task_ids = [t.id for t in self._tasks if t.package == package_name and t.running] |
1375 | 60 | task = AppInfoTask(self.id, self._cache, package_name, related_task_ids, self._config, self._connection, self._cleanup_task) | 75 | task = AppInfoTask(self.id, self._cache, package_name, related_task_ids, self._config, self._connection, self._cleanup_task) |
1376 | 61 | 76 | ||
1377 | @@ -137,3 +152,12 @@ | |||
1378 | 137 | self._tasks.append(task) | 152 | self._tasks.append(task) |
1379 | 138 | task.start() | 153 | task.start() |
1380 | 139 | return task.id | 154 | return task.id |
1381 | 155 | |||
1382 | 156 | def list_app_ids(self): | ||
1383 | 157 | utils.get_logger().debug("List all app ids in container '%s'" % self.id) | ||
1384 | 158 | |||
1385 | 159 | task = ListAppIdsTask(self.id, self._config, self._connection, self._cleanup_task) | ||
1386 | 160 | |||
1387 | 161 | self._tasks.append(task) | ||
1388 | 162 | task.start() | ||
1389 | 163 | return task.id | ||
1390 | 140 | 164 | ||
1391 | === modified file 'python/libertine/service/manager.py' | |||
1392 | --- python/libertine/service/manager.py 2016-10-31 18:31:00 +0000 | |||
1393 | +++ python/libertine/service/manager.py 2017-01-27 18:57:35 +0000 | |||
1394 | @@ -1,4 +1,4 @@ | |||
1396 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1397 | 2 | # | 2 | # |
1398 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1399 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1400 | @@ -72,6 +72,13 @@ | |||
1401 | 72 | return self._dispatcher.list_apps(container_id) | 72 | return self._dispatcher.list_apps(container_id) |
1402 | 73 | 73 | ||
1403 | 74 | @dbus.service.method(LIBERTINE_MANAGER_INTERFACE, | 74 | @dbus.service.method(LIBERTINE_MANAGER_INTERFACE, |
1404 | 75 | in_signature='s', | ||
1405 | 76 | out_signature='o') | ||
1406 | 77 | def list_app_ids(self, container_id): | ||
1407 | 78 | utils.get_logger().debug("list_app_ids('{}')".format(container_id)) | ||
1408 | 79 | return self._dispatcher.list_app_ids(container_id) | ||
1409 | 80 | |||
1410 | 81 | @dbus.service.method(LIBERTINE_MANAGER_INTERFACE, | ||
1411 | 75 | out_signature='o') | 82 | out_signature='o') |
1412 | 76 | def list(self): | 83 | def list(self): |
1413 | 77 | utils.get_logger().debug("list()") | 84 | utils.get_logger().debug("list()") |
1414 | 78 | 85 | ||
1415 | === modified file 'python/libertine/service/progress.py' | |||
1416 | --- python/libertine/service/progress.py 2016-11-29 17:38:38 +0000 | |||
1417 | +++ python/libertine/service/progress.py 2017-01-27 18:57:35 +0000 | |||
1418 | @@ -1,4 +1,4 @@ | |||
1420 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1421 | 2 | # | 2 | # |
1422 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1423 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1424 | @@ -18,7 +18,7 @@ | |||
1425 | 18 | from time import time | 18 | from time import time |
1426 | 19 | 19 | ||
1427 | 20 | DOWNLOAD_INTERFACE = "com.canonical.applications.Download" | 20 | DOWNLOAD_INTERFACE = "com.canonical.applications.Download" |
1429 | 21 | PROGRESS_INTERFACE = "com.canonical.libertine.Progress" | 21 | PROGRESS_INTERFACE = "com.canonical.libertine.Service.Progress" |
1430 | 22 | 22 | ||
1431 | 23 | class Progress(dbus.service.Object): | 23 | class Progress(dbus.service.Object): |
1432 | 24 | def __init__(self, connection): | 24 | def __init__(self, connection): |
1433 | @@ -28,7 +28,7 @@ | |||
1434 | 28 | self._error = '' | 28 | self._error = '' |
1435 | 29 | dbus.service.Object.__init__(self, conn=connection, object_path=("/Progress/%s" % hex(int(time()*10000000))[2:])) | 29 | dbus.service.Object.__init__(self, conn=connection, object_path=("/Progress/%s" % hex(int(time()*10000000))[2:])) |
1436 | 30 | 30 | ||
1438 | 31 | self.emit_processing() | 31 | # self.emit_processing() # Disabled until something requires the Download interface |
1439 | 32 | 32 | ||
1440 | 33 | @property | 33 | @property |
1441 | 34 | def id(self): | 34 | def id(self): |
1442 | 35 | 35 | ||
1443 | === modified file 'python/libertine/service/task_dispatcher.py' | |||
1444 | --- python/libertine/service/task_dispatcher.py 2016-11-01 18:50:32 +0000 | |||
1445 | +++ python/libertine/service/task_dispatcher.py 2017-01-27 18:57:35 +0000 | |||
1446 | @@ -1,4 +1,4 @@ | |||
1448 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1449 | 2 | # | 2 | # |
1450 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1451 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1452 | @@ -24,7 +24,6 @@ | |||
1453 | 24 | def __init__(self, connection): | 24 | def __init__(self, connection): |
1454 | 25 | self._connection = connection | 25 | self._connection = connection |
1455 | 26 | self._config = libertine.ContainersConfig.ContainersConfig() | 26 | self._config = libertine.ContainersConfig.ContainersConfig() |
1456 | 27 | self._lock = Lock() | ||
1457 | 28 | self._containerless_tasks = [] | 27 | self._containerless_tasks = [] |
1458 | 29 | self._tasks = [] | 28 | self._tasks = [] |
1459 | 30 | self._containers = [] | 29 | self._containers = [] |
1460 | @@ -35,7 +34,7 @@ | |||
1461 | 35 | self._tasks.remove(task) | 34 | self._tasks.remove(task) |
1462 | 36 | 35 | ||
1463 | 37 | def _cleanup_container(self, container): | 36 | def _cleanup_container(self, container): |
1465 | 38 | utils.get_logger().debug("cleaning up container '%s'" % container) | 37 | utils.get_logger().debug("cleaning up container '%s'" % container.id) |
1466 | 39 | if container in self._containers: | 38 | if container in self._containers: |
1467 | 40 | self._containers.remove(container) | 39 | self._containers.remove(container) |
1468 | 41 | 40 | ||
1469 | @@ -45,7 +44,7 @@ | |||
1470 | 45 | if container is not None: | 44 | if container is not None: |
1471 | 46 | utils.get_logger().debug("using existing container '%s'" % container_id) | 45 | utils.get_logger().debug("using existing container '%s'" % container_id) |
1472 | 47 | return container | 46 | return container |
1474 | 48 | container = Container(container_id, self._config, self._lock, self._connection, self._cleanup_container) | 47 | container = Container(container_id, self._config, self._connection, self._cleanup_container) |
1475 | 49 | self._containers.append(container) | 48 | self._containers.append(container) |
1476 | 50 | 49 | ||
1477 | 51 | return container | 50 | return container |
1478 | @@ -89,6 +88,10 @@ | |||
1479 | 89 | utils.get_logger().debug("dispatching list all apps in container '%s'" % container_id) | 88 | utils.get_logger().debug("dispatching list all apps in container '%s'" % container_id) |
1480 | 90 | return self._find_or_create_container(container_id).list_apps() | 89 | return self._find_or_create_container(container_id).list_apps() |
1481 | 91 | 90 | ||
1482 | 91 | def list_app_ids(self, container_id): | ||
1483 | 92 | utils.get_logger().debug("dispatching list apps ids in container '%s'" % container_id) | ||
1484 | 93 | return self._find_or_create_container(container_id).list_app_ids() | ||
1485 | 94 | |||
1486 | 92 | # Containerless Tasks | 95 | # Containerless Tasks |
1487 | 93 | 96 | ||
1488 | 94 | def container_info(self, container_id): | 97 | def container_info(self, container_id): |
1489 | @@ -107,7 +110,7 @@ | |||
1490 | 107 | def list(self): | 110 | def list(self): |
1491 | 108 | utils.get_logger().debug("dispatching list all containers") | 111 | utils.get_logger().debug("dispatching list all containers") |
1492 | 109 | 112 | ||
1494 | 110 | task = ListTask(self._connection, self._cleanup_task) | 113 | task = ListTask(self._config, self._connection, self._cleanup_task) |
1495 | 111 | self._tasks.append(task) | 114 | self._tasks.append(task) |
1496 | 112 | task.start() | 115 | task.start() |
1497 | 113 | 116 | ||
1498 | 114 | 117 | ||
1499 | === modified file 'python/libertine/service/tasks/__init__.py' | |||
1500 | --- python/libertine/service/tasks/__init__.py 2016-11-01 17:38:38 +0000 | |||
1501 | +++ python/libertine/service/tasks/__init__.py 2017-01-27 18:57:35 +0000 | |||
1502 | @@ -1,4 +1,4 @@ | |||
1504 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1505 | 2 | # | 2 | # |
1506 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
1507 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
1508 | @@ -23,6 +23,7 @@ | |||
1509 | 23 | from .update_task import UpdateTask | 23 | from .update_task import UpdateTask |
1510 | 24 | from .list_task import ListTask | 24 | from .list_task import ListTask |
1511 | 25 | from .list_apps_task import ListAppsTask | 25 | from .list_apps_task import ListAppsTask |
1512 | 26 | from .list_app_ids_task import ListAppIdsTask | ||
1513 | 26 | 27 | ||
1514 | 27 | __all__ = [ | 28 | __all__ = [ |
1515 | 28 | 'AppInfoTask', | 29 | 'AppInfoTask', |
1516 | @@ -35,5 +36,6 @@ | |||
1517 | 35 | 'SearchTask', | 36 | 'SearchTask', |
1518 | 36 | 'UpdateTask', | 37 | 'UpdateTask', |
1519 | 37 | 'ListTask', | 38 | 'ListTask', |
1521 | 38 | 'ListAppsTask' | 39 | 'ListAppsTask', |
1522 | 40 | 'ListAppIdsTask' | ||
1523 | 39 | ] | 41 | ] |
1524 | 40 | 42 | ||
1525 | === modified file 'python/libertine/service/tasks/base_task.py' | |||
1526 | --- python/libertine/service/tasks/base_task.py 2016-11-07 20:37:54 +0000 | |||
1527 | +++ python/libertine/service/tasks/base_task.py 2017-01-27 18:57:35 +0000 | |||
1528 | @@ -1,4 +1,4 @@ | |||
1530 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1531 | 2 | # | 2 | # |
1532 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1533 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1534 | @@ -15,7 +15,6 @@ | |||
1535 | 15 | import libertine.service.progress | 15 | import libertine.service.progress |
1536 | 16 | import threading | 16 | import threading |
1537 | 17 | from abc import ABCMeta, abstractmethod | 17 | from abc import ABCMeta, abstractmethod |
1538 | 18 | from libertine import utils | ||
1539 | 19 | 18 | ||
1540 | 20 | 19 | ||
1541 | 21 | class BaseTask(metaclass=ABCMeta): | 20 | class BaseTask(metaclass=ABCMeta): |
1542 | @@ -60,7 +59,7 @@ | |||
1543 | 60 | if self._instant_callback: | 59 | if self._instant_callback: |
1544 | 61 | self._callback(self) | 60 | self._callback(self) |
1545 | 62 | else: | 61 | else: |
1547 | 63 | threading.Timer(30, lambda: self._callback(self)).start() | 62 | threading.Timer(10, lambda: self._callback(self)).start() |
1548 | 64 | 63 | ||
1549 | 65 | def start(self): | 64 | def start(self): |
1550 | 66 | self._progress = libertine.service.progress.Progress(self._connection) | 65 | self._progress = libertine.service.progress.Progress(self._connection) |
1551 | @@ -82,7 +81,6 @@ | |||
1552 | 82 | 81 | ||
1553 | 83 | if self.running: | 82 | if self.running: |
1554 | 84 | self._progress.finished(self.container) | 83 | self._progress.finished(self.container) |
1555 | 85 | utils.refresh_libertine_scope() | ||
1556 | 86 | 84 | ||
1557 | 87 | self._delayed_callback() | 85 | self._delayed_callback() |
1558 | 88 | 86 | ||
1559 | 89 | 87 | ||
1560 | === modified file 'python/libertine/service/tasks/container_info_task.py' | |||
1561 | --- python/libertine/service/tasks/container_info_task.py 2016-11-01 17:38:38 +0000 | |||
1562 | +++ python/libertine/service/tasks/container_info_task.py 2017-01-27 18:57:35 +0000 | |||
1563 | @@ -1,4 +1,4 @@ | |||
1565 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1566 | 2 | # | 2 | # |
1567 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1568 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1569 | @@ -13,6 +13,8 @@ | |||
1570 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1571 | 14 | 14 | ||
1572 | 15 | 15 | ||
1573 | 16 | import json | ||
1574 | 17 | |||
1575 | 16 | from .base_task import BaseTask | 18 | from .base_task import BaseTask |
1576 | 17 | from libertine import utils | 19 | from libertine import utils |
1577 | 18 | 20 | ||
1578 | @@ -23,7 +25,21 @@ | |||
1579 | 23 | self._tasks = tasks | 25 | self._tasks = tasks |
1580 | 24 | 26 | ||
1581 | 25 | def _run(self): | 27 | def _run(self): |
1586 | 26 | container = {'id': str(self._container)} | 28 | utils.get_logger().debug("Gathering info for container '{}'".format(self._container)) |
1587 | 27 | container['status'] = self._config._get_value_by_key(self._container, 'installStatus') or '' | 29 | container = {'id': str(self._container), 'task_ids': self._tasks} |
1588 | 28 | container['task_ids'] = self._tasks | 30 | |
1589 | 29 | self._progress.data(str(container)) | 31 | container['status'] = self._config.get_container_install_status(self._container) or '' |
1590 | 32 | container['name'] = self._config.get_container_name(self._container) or '' | ||
1591 | 33 | |||
1592 | 34 | container_type = self._config.get_container_type(self._container) | ||
1593 | 35 | container['root'] = utils.get_libertine_container_rootfs_path(self._container) | ||
1594 | 36 | container['home'] = utils.get_libertine_container_home_dir(self._container) | ||
1595 | 37 | |||
1596 | 38 | self._progress.data(json.dumps(container)) | ||
1597 | 39 | |||
1598 | 40 | def _before(self): | ||
1599 | 41 | if not self._config.container_exists(self._container): | ||
1600 | 42 | self._progress.error("Container '%s' does not exist, ignoring info request" % self._container) | ||
1601 | 43 | return False | ||
1602 | 44 | |||
1603 | 45 | return True | ||
1604 | 30 | 46 | ||
1605 | === added file 'python/libertine/service/tasks/list_app_ids_task.py' | |||
1606 | --- python/libertine/service/tasks/list_app_ids_task.py 1970-01-01 00:00:00 +0000 | |||
1607 | +++ python/libertine/service/tasks/list_app_ids_task.py 2017-01-27 18:57:35 +0000 | |||
1608 | @@ -0,0 +1,35 @@ | |||
1609 | 1 | # Copyright 2017 Canonical Ltd. | ||
1610 | 2 | # | ||
1611 | 3 | # This program is free software: you can redistribute it and/or modify | ||
1612 | 4 | # it under the terms of the GNU General Public License as published by | ||
1613 | 5 | # the Free Software Foundation; version 3 of the License. | ||
1614 | 6 | # | ||
1615 | 7 | # This program is distributed in the hope that it will be useful, | ||
1616 | 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1617 | 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1618 | 10 | # GNU General Public License for more details. | ||
1619 | 11 | # | ||
1620 | 12 | # You should have received a copy of the GNU General Public License | ||
1621 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1622 | 14 | |||
1623 | 15 | |||
1624 | 16 | import json | ||
1625 | 17 | from .base_task import BaseTask | ||
1626 | 18 | from libertine import LibertineContainer, utils | ||
1627 | 19 | import time | ||
1628 | 20 | |||
1629 | 21 | |||
1630 | 22 | class ListAppIdsTask(BaseTask): | ||
1631 | 23 | def __init__(self, container_id, config, connection, callback): | ||
1632 | 24 | super().__init__(lock=None, container_id=container_id, config=config, connection=connection, callback=callback) | ||
1633 | 25 | |||
1634 | 26 | def _run(self): | ||
1635 | 27 | utils.get_logger().debug("Listing app ids from container '%s'" % self._container) | ||
1636 | 28 | self._progress.data(json.dumps(LibertineContainer(self._container, self._config).list_app_ids())) | ||
1637 | 29 | |||
1638 | 30 | def _before(self): | ||
1639 | 31 | if not self._config.container_exists(self._container): | ||
1640 | 32 | self._progress.error("Container '%s' does not exist, skipping list" % self._container) | ||
1641 | 33 | return False | ||
1642 | 34 | |||
1643 | 35 | return True | ||
1644 | 0 | 36 | ||
1645 | === modified file 'python/libertine/service/tasks/list_apps_task.py' | |||
1646 | --- python/libertine/service/tasks/list_apps_task.py 2016-11-01 17:38:38 +0000 | |||
1647 | +++ python/libertine/service/tasks/list_apps_task.py 2017-01-27 18:57:35 +0000 | |||
1648 | @@ -1,4 +1,4 @@ | |||
1650 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1651 | 2 | # | 2 | # |
1652 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1653 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1654 | @@ -23,8 +23,12 @@ | |||
1655 | 23 | 23 | ||
1656 | 24 | def _run(self): | 24 | def _run(self): |
1657 | 25 | utils.get_logger().debug("Listing apps in container '%s'" % self._container) | 25 | utils.get_logger().debug("Listing apps in container '%s'" % self._container) |
1658 | 26 | container = LibertineContainer(self._container, self._config) | ||
1659 | 27 | self._progress.data(str(container.list_app_launchers(use_json=True))) | ||
1660 | 28 | |||
1661 | 29 | def _before(self): | ||
1662 | 26 | if not self._config.container_exists(self._container): | 30 | if not self._config.container_exists(self._container): |
1663 | 27 | self._progress.error("Container '%s' does not exist, skipping list" % self._container) | 31 | self._progress.error("Container '%s' does not exist, skipping list" % self._container) |
1667 | 28 | else: | 32 | return False |
1668 | 29 | container = LibertineContainer(self._container, self._config) | 33 | |
1669 | 30 | self._progress.data(str(container.list_app_launchers(use_json=True))) | 34 | return True |
1670 | 31 | 35 | ||
1671 | === modified file 'python/libertine/service/tasks/list_task.py' | |||
1672 | --- python/libertine/service/tasks/list_task.py 2016-11-01 18:50:32 +0000 | |||
1673 | +++ python/libertine/service/tasks/list_task.py 2017-01-27 18:57:35 +0000 | |||
1674 | @@ -1,4 +1,4 @@ | |||
1676 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1677 | 2 | # | 2 | # |
1678 | 3 | # This program is free software: you can redistribute it and/or modify | 3 | # This program is free software: you can redistribute it and/or modify |
1679 | 4 | # it under the terms of the GNU General Public License as published by | 4 | # it under the terms of the GNU General Public License as published by |
1680 | @@ -13,13 +13,15 @@ | |||
1681 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1682 | 14 | 14 | ||
1683 | 15 | 15 | ||
1684 | 16 | import json | ||
1685 | 17 | |||
1686 | 16 | from .base_task import BaseTask | 18 | from .base_task import BaseTask |
1687 | 17 | from libertine import utils | 19 | from libertine import utils |
1688 | 18 | 20 | ||
1689 | 19 | 21 | ||
1690 | 20 | class ListTask(BaseTask): | 22 | class ListTask(BaseTask): |
1693 | 21 | def __init__(self, connection, callback): | 23 | def __init__(self, config, connection, callback): |
1694 | 22 | super().__init__(lock=None, container_id=None, config=None, connection=connection, callback=callback) | 24 | super().__init__(lock=None, container_id=None, config=config, connection=connection, callback=callback) |
1695 | 23 | 25 | ||
1696 | 24 | def _run(self): | 26 | def _run(self): |
1698 | 25 | self._progress.data(str(utils.Libertine.list_containers())) | 27 | self._progress.data(json.dumps(self._config.get_containers())) |
1699 | 26 | 28 | ||
1700 | === modified file 'python/libertine/utils.py' | |||
1701 | --- python/libertine/utils.py 2017-01-18 21:07:39 +0000 | |||
1702 | +++ python/libertine/utils.py 2017-01-27 18:57:35 +0000 | |||
1703 | @@ -1,6 +1,6 @@ | |||
1704 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
1705 | 2 | 2 | ||
1707 | 3 | # Copyright (C) 2015-2016 Canonical Ltd. | 3 | # Copyright (C) 2015-2017 Canonical Ltd. |
1708 | 4 | # Author: Christopher Townsend <christopher.townsend@canonical.com> | 4 | # Author: Christopher Townsend <christopher.townsend@canonical.com> |
1709 | 5 | 5 | ||
1710 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
1711 | @@ -22,10 +22,6 @@ | |||
1712 | 22 | import subprocess | 22 | import subprocess |
1713 | 23 | import xdg.BaseDirectory as basedir | 23 | import xdg.BaseDirectory as basedir |
1714 | 24 | 24 | ||
1715 | 25 | from gi import require_version | ||
1716 | 26 | require_version('Libertine', '1') | ||
1717 | 27 | from gi.repository import Libertine | ||
1718 | 28 | |||
1719 | 29 | 25 | ||
1720 | 30 | def get_logger(): | 26 | def get_logger(): |
1721 | 31 | logger = logging.getLogger('__libertine_logger__') | 27 | logger = logging.getLogger('__libertine_logger__') |
1722 | @@ -64,12 +60,7 @@ | |||
1723 | 64 | 60 | ||
1724 | 65 | 61 | ||
1725 | 66 | def get_libertine_container_rootfs_path(container_id): | 62 | def get_libertine_container_rootfs_path(container_id): |
1732 | 67 | path = Libertine.container_path(container_id) | 63 | return os.path.join(get_libertine_containers_dir_path(), container_id, 'rootfs') |
1727 | 68 | |||
1728 | 69 | if path is None: | ||
1729 | 70 | path = os.path.join(get_libertine_containers_dir_path(), container_id, 'rootfs') | ||
1730 | 71 | |||
1731 | 72 | return path | ||
1733 | 73 | 64 | ||
1734 | 74 | 65 | ||
1735 | 75 | def get_libertine_containers_dir_path(): | 66 | def get_libertine_containers_dir_path(): |
1736 | @@ -100,11 +91,8 @@ | |||
1737 | 100 | return os.path.join(get_libertine_database_dir_path(), 'ContainersConfig.json') | 91 | return os.path.join(get_libertine_database_dir_path(), 'ContainersConfig.json') |
1738 | 101 | 92 | ||
1739 | 102 | 93 | ||
1745 | 103 | def get_libertine_container_userdata_dir_path(container_id): | 94 | def get_libertine_container_home_dir(container_id): |
1746 | 104 | path = Libertine.container_home_path(container_id) | 95 | path = os.path.join(basedir.xdg_data_home, 'libertine-container', 'user-data', container_id) |
1742 | 105 | |||
1743 | 106 | if path is None: | ||
1744 | 107 | path = os.path.join(basedir.xdg_data_home, 'libertine-container', 'user-data', container_id) | ||
1747 | 108 | 96 | ||
1748 | 109 | if is_snap_environment(): | 97 | if is_snap_environment(): |
1749 | 110 | path = path.replace(os.environ['HOME'], os.getenv('SNAP_USER_COMMON')) | 98 | path = path.replace(os.environ['HOME'], os.getenv('SNAP_USER_COMMON')) |
1750 | @@ -153,18 +141,6 @@ | |||
1751 | 153 | return dirs | 141 | return dirs |
1752 | 154 | 142 | ||
1753 | 155 | 143 | ||
1754 | 156 | def create_libertine_user_data_dir(container_id): | ||
1755 | 157 | user_data = get_libertine_container_userdata_dir_path(container_id) | ||
1756 | 158 | |||
1757 | 159 | if not os.path.exists(user_data): | ||
1758 | 160 | os.makedirs(user_data) | ||
1759 | 161 | |||
1760 | 162 | config_path = os.path.join(user_data, ".config", "dconf") | ||
1761 | 163 | |||
1762 | 164 | if not os.path.exists(config_path): | ||
1763 | 165 | os.makedirs(config_path) | ||
1764 | 166 | |||
1765 | 167 | |||
1766 | 168 | def get_libertine_lxc_pulse_socket_path(): | 144 | def get_libertine_lxc_pulse_socket_path(): |
1767 | 169 | return os.path.join(get_libertine_runtime_dir(), 'pulse_socket') | 145 | return os.path.join(get_libertine_runtime_dir(), 'pulse_socket') |
1768 | 170 | 146 | ||
1769 | @@ -194,14 +170,17 @@ | |||
1770 | 194 | 170 | ||
1771 | 195 | if not dbus_session_set: | 171 | if not dbus_session_set: |
1772 | 196 | for p in psutil.process_iter(): | 172 | for p in psutil.process_iter(): |
1781 | 197 | if p.name() == 'unity8' or p.name() == 'compiz': | 173 | try: |
1782 | 198 | p_environ = subprocess.check_output(["cat", "/proc/{}/environ".format(p.pid)]) | 174 | if p.name() == 'unity8' or p.name() == 'compiz': |
1783 | 199 | for line in p_environ.decode().split('\0'): | 175 | p_environ = subprocess.check_output(["cat", "/proc/{}/environ".format(p.pid)]) |
1784 | 200 | if line.startswith('DBUS_SESSION_BUS_ADDRESS'): | 176 | for line in p_environ.decode().split('\0'): |
1785 | 201 | os.environ['DBUS_SESSION_BUS_ADDRESS'] = line.partition('DBUS_SESSION_BUS_ADDRESS=')[2].rstrip('\n') | 177 | if line.startswith('DBUS_SESSION_BUS_ADDRESS'): |
1786 | 202 | dbus_session_set = True | 178 | os.environ['DBUS_SESSION_BUS_ADDRESS'] = line.partition('DBUS_SESSION_BUS_ADDRESS=')[2].rstrip('\n') |
1787 | 203 | break | 179 | dbus_session_set = True |
1788 | 204 | break | 180 | break |
1789 | 181 | break | ||
1790 | 182 | except psutil.NoSuchProcess as e: | ||
1791 | 183 | get_logger().warning(str(e)) | ||
1792 | 205 | 184 | ||
1793 | 206 | return dbus_session_set | 185 | return dbus_session_set |
1794 | 207 | 186 | ||
1795 | 208 | 187 | ||
1796 | === modified file 'snapcraft.yaml' | |||
1797 | --- snapcraft.yaml 2017-01-23 15:21:46 +0000 | |||
1798 | +++ snapcraft.yaml 2017-01-27 18:57:35 +0000 | |||
1799 | @@ -3,9 +3,15 @@ | |||
1800 | 3 | summary: Libertine suite | 3 | summary: Libertine suite |
1801 | 4 | description: | | 4 | description: | |
1802 | 5 | Suite for maintaining deb-based applications in a non-deb environment | 5 | Suite for maintaining deb-based applications in a non-deb environment |
1804 | 6 | confinement: devmode # TODO: update to 'strict' | 6 | confinement: strict # devmode # TODO: update to 'strict' |
1805 | 7 | grade: devel | 7 | grade: devel |
1806 | 8 | 8 | ||
1807 | 9 | slots: | ||
1808 | 10 | libertined: | ||
1809 | 11 | interface: dbus | ||
1810 | 12 | name: com.canonical.libertine.Service | ||
1811 | 13 | bus: session | ||
1812 | 14 | |||
1813 | 9 | apps: | 15 | apps: |
1814 | 10 | launch: | 16 | launch: |
1815 | 11 | command: usr/bin/snap-runner.wrapper libertine-launch | 17 | command: usr/bin/snap-runner.wrapper libertine-launch |
1816 | @@ -22,6 +28,12 @@ | |||
1817 | 22 | - opengl | 28 | - opengl |
1818 | 23 | - pulseaudio | 29 | - pulseaudio |
1819 | 24 | - alsa | 30 | - alsa |
1820 | 31 | libertined: | ||
1821 | 32 | command: usr/bin/snap-runner.wrapper libertined | ||
1822 | 33 | plugs: | ||
1823 | 34 | - lxd | ||
1824 | 35 | - network-bind | ||
1825 | 36 | # daemon: simple # Waiting on LP:1613420 | ||
1826 | 25 | container-manager: | 37 | container-manager: |
1827 | 26 | command: usr/bin/snap-runner.wrapper libertine-container-manager | 38 | command: usr/bin/snap-runner.wrapper libertine-container-manager |
1828 | 27 | aliases: | 39 | aliases: |
1829 | 28 | 40 | ||
1830 | === modified file 'tests/integration/test_libertine_service.py' | |||
1831 | --- tests/integration/test_libertine_service.py 2016-11-29 17:38:38 +0000 | |||
1832 | +++ tests/integration/test_libertine_service.py 2017-01-27 18:57:35 +0000 | |||
1833 | @@ -1,4 +1,4 @@ | |||
1835 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
1836 | 2 | # | 2 | # |
1837 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
1838 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
1839 | @@ -12,20 +12,24 @@ | |||
1840 | 12 | # You should have received a copy of the GNU General Public License along | 12 | # You should have received a copy of the GNU General Public License along |
1841 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1842 | 14 | 14 | ||
1843 | 15 | |||
1844 | 16 | import ast | ||
1845 | 15 | import dbus | 17 | import dbus |
1846 | 16 | import dbus.mainloop.glib | 18 | import dbus.mainloop.glib |
1847 | 19 | import os | ||
1848 | 20 | import tempfile | ||
1849 | 21 | import threading | ||
1850 | 22 | import time | ||
1851 | 17 | import unittest.mock | 23 | import unittest.mock |
1853 | 18 | from unittest import TestCase | 24 | |
1854 | 25 | from gi.repository import GLib | ||
1855 | 26 | from gi.repository import GObject | ||
1856 | 27 | from libertine import utils | ||
1857 | 19 | from libertine.service import tasks, apt | 28 | from libertine.service import tasks, apt |
1858 | 20 | from libertine.ContainersConfig import ContainersConfig | 29 | from libertine.ContainersConfig import ContainersConfig |
1859 | 21 | from subprocess import Popen, PIPE | 30 | from subprocess import Popen, PIPE |
1867 | 22 | import time | 31 | from unittest import TestCase |
1868 | 23 | from gi.repository import GLib | 32 | |
1862 | 24 | from gi.repository import GObject | ||
1863 | 25 | import os | ||
1864 | 26 | import tempfile | ||
1865 | 27 | import threading | ||
1866 | 28 | import ast | ||
1869 | 29 | 33 | ||
1870 | 30 | class TestLibertineService(TestCase): | 34 | class TestLibertineService(TestCase): |
1871 | 31 | _process = None | 35 | _process = None |
1872 | @@ -39,6 +43,7 @@ | |||
1873 | 39 | 43 | ||
1874 | 40 | environ = os.environ.copy() | 44 | environ = os.environ.copy() |
1875 | 41 | environ['XDG_DATA_HOME'] = cls._tempdir.name | 45 | environ['XDG_DATA_HOME'] = cls._tempdir.name |
1876 | 46 | |||
1877 | 42 | cls._process = Popen(['libertined', '--debug'], stdout=PIPE, stderr=PIPE, env=environ) | 47 | cls._process = Popen(['libertined', '--debug'], stdout=PIPE, stderr=PIPE, env=environ) |
1878 | 43 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | 48 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
1879 | 44 | cls._loop = GObject.MainLoop() | 49 | cls._loop = GObject.MainLoop() |
1880 | @@ -91,7 +96,7 @@ | |||
1881 | 91 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._finished_handler, | 96 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._finished_handler, |
1882 | 92 | dbus_interface='com.canonical.applications.Download', signal_name='finished')) | 97 | dbus_interface='com.canonical.applications.Download', signal_name='finished')) |
1883 | 93 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._data_handler, | 98 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._data_handler, |
1885 | 94 | dbus_interface='com.canonical.libertine.Progress', signal_name='data')) | 99 | dbus_interface='com.canonical.libertine.Service.Progress', signal_name='data')) |
1886 | 95 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._error_handler, | 100 | signals.append(self._bus.add_signal_receiver(path=obj_path, handler_function=self._error_handler, |
1887 | 96 | dbus_interface='com.canonical.applications.Download', signal_name='error')) | 101 | dbus_interface='com.canonical.applications.Download', signal_name='error')) |
1888 | 97 | 102 | ||
1889 | @@ -110,20 +115,25 @@ | |||
1890 | 110 | 115 | ||
1891 | 111 | def test_container_management(self): | 116 | def test_container_management(self): |
1892 | 112 | try: | 117 | try: |
1894 | 113 | self.assertEqual('[]', self._send(lambda: self._libertined.list())) | 118 | self.assertEqual([], ast.literal_eval(self._send(lambda: self._libertined.list()))) |
1895 | 114 | self._send(lambda: self._libertined.create('rey', 'Rey', 'xenial', 'mock')) | 119 | self._send(lambda: self._libertined.create('rey', 'Rey', 'xenial', 'mock')) |
1897 | 115 | self.assertEqual('[\'rey\']', self._send(lambda: self._libertined.list())) | 120 | self.assertEqual(['rey'], ast.literal_eval(self._send(lambda: self._libertined.list()))) |
1898 | 116 | 121 | ||
1899 | 117 | self._send(lambda: self._libertined.create('kylo', 'Kylo Ren', 'xenial', 'mock')) | 122 | self._send(lambda: self._libertined.create('kylo', 'Kylo Ren', 'xenial', 'mock')) |
1901 | 118 | self.assertEqual('[\'rey\', \'kylo\']', self._send(lambda: self._libertined.list())) | 123 | self.assertEqual(['rey', 'kylo'], ast.literal_eval(self._send(lambda: self._libertined.list()))) |
1902 | 119 | 124 | ||
1903 | 120 | self._send(lambda: self._libertined.update('kylo')) | 125 | self._send(lambda: self._libertined.update('kylo')) |
1904 | 121 | 126 | ||
1907 | 122 | self.assertEqual({'id': 'rey', 'status': 'ready', 'task_ids': []}, | 127 | self.assertEqual({'id': 'rey', |
1908 | 123 | ast.literal_eval(self._send(lambda: self._libertined.container_info('rey')))) | 128 | 'status': 'ready', |
1909 | 129 | 'name': 'Rey', | ||
1910 | 130 | 'task_ids': [], | ||
1911 | 131 | 'root': utils.get_libertine_container_rootfs_path('rey'), | ||
1912 | 132 | 'home': '{}/libertine-container/user-data/rey'.format(TestLibertineService._tempdir.name) | ||
1913 | 133 | }, ast.literal_eval(self._send(lambda: self._libertined.container_info('rey')))) | ||
1914 | 124 | 134 | ||
1915 | 125 | self._send(lambda: self._libertined.destroy('kylo')) | 135 | self._send(lambda: self._libertined.destroy('kylo')) |
1917 | 126 | self.assertEqual('[\'rey\']', self._send(lambda: self._libertined.list())) | 136 | self.assertEqual(['rey'], ast.literal_eval(self._send(lambda: self._libertined.list()))) |
1918 | 127 | except AssertionError as e: | 137 | except AssertionError as e: |
1919 | 128 | raise | 138 | raise |
1920 | 129 | except Exception as e: | 139 | except Exception as e: |
1921 | 130 | 140 | ||
1922 | === added directory 'tests/unit/service/containerroot/libertine-container' | |||
1923 | === added directory 'tests/unit/service/containerroot/libertine-container/palpatine' | |||
1924 | === added directory 'tests/unit/service/containerroot/libertine-container/palpatine/rootfs' | |||
1925 | === modified file 'tests/unit/service/tasks/CMakeLists.txt' | |||
1926 | --- tests/unit/service/tasks/CMakeLists.txt 2016-11-01 19:49:32 +0000 | |||
1927 | +++ tests/unit/service/tasks/CMakeLists.txt 2017-01-27 18:57:35 +0000 | |||
1928 | @@ -5,6 +5,7 @@ | |||
1929 | 5 | create_service_unit_test(test_install_task) | 5 | create_service_unit_test(test_install_task) |
1930 | 6 | create_service_unit_test(test_list_task) | 6 | create_service_unit_test(test_list_task) |
1931 | 7 | create_service_unit_test(test_list_apps_task) | 7 | create_service_unit_test(test_list_apps_task) |
1932 | 8 | create_service_unit_test(test_list_app_ids_task) | ||
1933 | 8 | create_service_unit_test(test_remove_task) | 9 | create_service_unit_test(test_remove_task) |
1934 | 9 | create_service_unit_test(test_search_task) | 10 | create_service_unit_test(test_search_task) |
1935 | 10 | create_service_unit_test(test_update_task) | 11 | create_service_unit_test(test_update_task) |
1936 | 11 | 12 | ||
1937 | === modified file 'tests/unit/service/tasks/test_container_info_task.py' | |||
1938 | --- tests/unit/service/tasks/test_container_info_task.py 2016-11-07 18:51:17 +0000 | |||
1939 | +++ tests/unit/service/tasks/test_container_info_task.py 2017-01-27 18:57:35 +0000 | |||
1940 | @@ -13,8 +13,10 @@ | |||
1941 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1942 | 14 | 14 | ||
1943 | 15 | 15 | ||
1944 | 16 | import ast | ||
1945 | 16 | import unittest.mock | 17 | import unittest.mock |
1946 | 17 | from unittest import TestCase | 18 | from unittest import TestCase |
1947 | 19 | from libertine import utils | ||
1948 | 18 | from libertine.service import tasks | 20 | from libertine.service import tasks |
1949 | 19 | from libertine.ContainersConfig import ContainersConfig | 21 | from libertine.ContainersConfig import ContainersConfig |
1950 | 20 | 22 | ||
1951 | @@ -33,12 +35,22 @@ | |||
1952 | 33 | progress = MockProgress.return_value | 35 | progress = MockProgress.return_value |
1953 | 34 | progress.done = False | 36 | progress.done = False |
1954 | 35 | 37 | ||
1956 | 36 | self.config._get_value_by_key.return_value = 'ready' | 38 | self.config.get_container_install_status.return_value = 'ready' |
1957 | 39 | self.config.get_container_name.return_value = 'Palpatine' | ||
1958 | 37 | task = tasks.ContainerInfoTask('palpatine', [1, 2, 3], self.config, self.connection, callback) | 40 | task = tasks.ContainerInfoTask('palpatine', [1, 2, 3], self.config, self.connection, callback) |
1959 | 38 | task._instant_callback = True | 41 | task._instant_callback = True |
1960 | 39 | task.start().join() | 42 | task.start().join() |
1961 | 40 | 43 | ||
1963 | 41 | progress.data.assert_called_once_with(str({'id': 'palpatine', 'status': 'ready', 'task_ids': [1, 2, 3]})) | 44 | progress.data.assert_called_once_with(unittest.mock.ANY) |
1964 | 45 | args, kwargs = progress.data.call_args | ||
1965 | 46 | self.assertEqual({'id': 'palpatine', | ||
1966 | 47 | 'status': 'ready', | ||
1967 | 48 | 'task_ids': [1, 2, 3], | ||
1968 | 49 | 'name': 'Palpatine', | ||
1969 | 50 | 'root': utils.get_libertine_container_rootfs_path('palpatine'), | ||
1970 | 51 | 'home': utils.get_libertine_container_home_dir('palpatine')}, | ||
1971 | 52 | ast.literal_eval(args[0])) | ||
1972 | 53 | |||
1973 | 42 | progress.finished.assert_called_once_with('palpatine') | 54 | progress.finished.assert_called_once_with('palpatine') |
1974 | 43 | 55 | ||
1975 | 44 | self.assertEqual(task, self.called_with) | 56 | self.assertEqual(task, self.called_with) |
1976 | 45 | 57 | ||
1977 | === added file 'tests/unit/service/tasks/test_list_app_ids_task.py' | |||
1978 | --- tests/unit/service/tasks/test_list_app_ids_task.py 1970-01-01 00:00:00 +0000 | |||
1979 | +++ tests/unit/service/tasks/test_list_app_ids_task.py 2017-01-27 18:57:35 +0000 | |||
1980 | @@ -0,0 +1,59 @@ | |||
1981 | 1 | # Copyright 2017 Canonical Ltd. | ||
1982 | 2 | # | ||
1983 | 3 | # This program is free software: you can redistribute it and/or modify it | ||
1984 | 4 | # under the terms of the GNU General Public License version 3, as published | ||
1985 | 5 | # by the Free Software Foundation. | ||
1986 | 6 | # | ||
1987 | 7 | # This program is distributed in the hope that it will be useful, but | ||
1988 | 8 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1989 | 9 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1990 | 10 | # PURPOSE. See the GNU General Public License for more details. | ||
1991 | 11 | # | ||
1992 | 12 | # You should have received a copy of the GNU General Public License along | ||
1993 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1994 | 14 | |||
1995 | 15 | import json | ||
1996 | 16 | import unittest.mock | ||
1997 | 17 | from unittest import TestCase | ||
1998 | 18 | from libertine.service import tasks | ||
1999 | 19 | from libertine.ContainersConfig import ContainersConfig | ||
2000 | 20 | |||
2001 | 21 | |||
2002 | 22 | class TestListAppIdsTask(TestCase): | ||
2003 | 23 | def setUp(self): | ||
2004 | 24 | self.config = unittest.mock.create_autospec(ContainersConfig) | ||
2005 | 25 | self.connection = unittest.mock.Mock() | ||
2006 | 26 | self.lock = unittest.mock.MagicMock() | ||
2007 | 27 | self.called_with = None | ||
2008 | 28 | |||
2009 | 29 | def callback(self, task): | ||
2010 | 30 | self.called_with = task | ||
2011 | 31 | |||
2012 | 32 | def test_sends_error_on_non_existent_container(self): | ||
2013 | 33 | self.config.container_exists.return_value = False | ||
2014 | 34 | with unittest.mock.patch('libertine.service.tasks.base_task.libertine.service.progress.Progress') as MockProgress: | ||
2015 | 35 | progress = MockProgress.return_value | ||
2016 | 36 | task = tasks.ListAppIdsTask('palpatine', self.config, self.connection, self.callback) | ||
2017 | 37 | task._instant_callback = True | ||
2018 | 38 | |||
2019 | 39 | with unittest.mock.patch('libertine.service.tasks.list_apps_task.LibertineContainer') as MockContainer: | ||
2020 | 40 | task.start().join() | ||
2021 | 41 | |||
2022 | 42 | progress.error.assert_called_once_with('Container \'palpatine\' does not exist, skipping list') | ||
2023 | 43 | self.assertEqual(task, self.called_with) | ||
2024 | 44 | |||
2025 | 45 | def test_successfully_lists_apps(self): | ||
2026 | 46 | self.config.container_exists.return_value = True | ||
2027 | 47 | with unittest.mock.patch('libertine.service.tasks.base_task.libertine.service.progress.Progress') as MockProgress: | ||
2028 | 48 | progress = MockProgress.return_value | ||
2029 | 49 | progress.done = False | ||
2030 | 50 | task = tasks.ListAppIdsTask('palpatine', self.config, self.connection, self.callback) | ||
2031 | 51 | task._instant_callback = True | ||
2032 | 52 | |||
2033 | 53 | with unittest.mock.patch('libertine.service.tasks.list_app_ids_task.LibertineContainer') as MockContainer: | ||
2034 | 54 | MockContainer.return_value.list_app_ids.return_value = '["palpatine_gedit_0.0","palpatine_xterm_0.0"]' | ||
2035 | 55 | task.start().join() | ||
2036 | 56 | |||
2037 | 57 | progress.finished.assert_called_once_with('palpatine') | ||
2038 | 58 | progress.data.assert_called_once_with(json.dumps('["palpatine_gedit_0.0","palpatine_xterm_0.0"]')) | ||
2039 | 59 | self.assertEqual(task, self.called_with) | ||
2040 | 0 | 60 | ||
2041 | === modified file 'tests/unit/service/tasks/test_list_task.py' | |||
2042 | --- tests/unit/service/tasks/test_list_task.py 2016-11-07 18:51:17 +0000 | |||
2043 | +++ tests/unit/service/tasks/test_list_task.py 2017-01-27 18:57:35 +0000 | |||
2044 | @@ -1,4 +1,4 @@ | |||
2046 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
2047 | 2 | # | 2 | # |
2048 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
2049 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
2050 | @@ -13,7 +13,9 @@ | |||
2051 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2052 | 14 | 14 | ||
2053 | 15 | 15 | ||
2054 | 16 | import json | ||
2055 | 16 | import unittest.mock | 17 | import unittest.mock |
2056 | 18 | |||
2057 | 17 | from unittest import TestCase | 19 | from unittest import TestCase |
2058 | 18 | from libertine.service import tasks | 20 | from libertine.service import tasks |
2059 | 19 | from libertine.ContainersConfig import ContainersConfig | 21 | from libertine.ContainersConfig import ContainersConfig |
2060 | @@ -32,14 +34,14 @@ | |||
2061 | 32 | with unittest.mock.patch('libertine.service.tasks.base_task.libertine.service.progress.Progress') as MockProgress: | 34 | with unittest.mock.patch('libertine.service.tasks.base_task.libertine.service.progress.Progress') as MockProgress: |
2062 | 33 | progress = MockProgress.return_value | 35 | progress = MockProgress.return_value |
2063 | 34 | progress.done = False | 36 | progress.done = False |
2065 | 35 | task = tasks.ListTask(self.connection, callback) | 37 | |
2066 | 38 | task = tasks.ListTask(self.config, self.connection, callback) | ||
2067 | 36 | task._instant_callback = True | 39 | task._instant_callback = True |
2068 | 37 | 40 | ||
2072 | 38 | with unittest.mock.patch('libertine.service.tasks.list_task.utils.Libertine') as MockLibertine: | 41 | self.config.get_containers.return_value = ['palatine', 'vader', 'maul'] |
2073 | 39 | MockLibertine.list_containers.return_value = 'palpatine\nvader\nmaul' | 42 | task.start().join() |
2071 | 40 | task.start().join() | ||
2074 | 41 | 43 | ||
2076 | 42 | progress.data.assert_called_once_with('palpatine\nvader\nmaul') | 44 | progress.data.assert_called_once_with(json.dumps(['palatine', 'vader', 'maul'])) |
2077 | 43 | progress.finished.assert_called_once_with('') | 45 | progress.finished.assert_called_once_with('') |
2078 | 44 | 46 | ||
2079 | 45 | self.assertEqual(task, self.called_with) | 47 | self.assertEqual(task, self.called_with) |
2080 | 46 | 48 | ||
2081 | === modified file 'tests/unit/service/test_apt.py' | |||
2082 | --- tests/unit/service/test_apt.py 2016-11-03 20:10:47 +0000 | |||
2083 | +++ tests/unit/service/test_apt.py 2017-01-27 18:57:35 +0000 | |||
2084 | @@ -1,4 +1,4 @@ | |||
2086 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
2087 | 2 | # | 2 | # |
2088 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
2089 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
2090 | @@ -14,8 +14,9 @@ | |||
2091 | 14 | 14 | ||
2092 | 15 | import os | 15 | import os |
2093 | 16 | import unittest.mock | 16 | import unittest.mock |
2094 | 17 | from libertine import utils | ||
2095 | 18 | from libertine.service import apt | ||
2096 | 17 | from unittest import TestCase | 19 | from unittest import TestCase |
2097 | 18 | from libertine.service import apt | ||
2098 | 19 | 20 | ||
2099 | 20 | 21 | ||
2100 | 21 | def build_mock_app(name, summary, website, description): | 22 | def build_mock_app(name, summary, website, description): |
2101 | @@ -30,13 +31,13 @@ | |||
2102 | 30 | 31 | ||
2103 | 31 | 32 | ||
2104 | 32 | class TestAptCache(TestCase): | 33 | class TestAptCache(TestCase): |
2105 | 34 | def setUp(self): | ||
2106 | 35 | os.environ['XDG_CACHE_HOME'] = "{}/containerroot".format(os.environ['LIBERTINE_DATA_DIR']) | ||
2107 | 36 | |||
2108 | 33 | def test_search_returns_empty_when_no_matching_results(self): | 37 | def test_search_returns_empty_when_no_matching_results(self): |
2109 | 34 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 38 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2110 | 35 | MockCache.return_value.keys.return_value = [] | 39 | MockCache.return_value.keys.return_value = [] |
2115 | 36 | 40 | self.assertEqual(apt.AptCache('palpatine').search('vim'), []) | |
2112 | 37 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | ||
2113 | 38 | MockLibertine.container_path.return_value = '/some/junk' | ||
2114 | 39 | self.assertEqual(apt.AptCache('palpatine').search('vim'), []) | ||
2116 | 40 | 41 | ||
2117 | 41 | def test_search_returns_matching_results(self): | 42 | def test_search_returns_matching_results(self): |
2118 | 42 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 43 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2119 | @@ -47,9 +48,7 @@ | |||
2120 | 47 | "vim-common": build_mock_app("vim-common", "common vim stuff", "vim.common", "dependencies") | 48 | "vim-common": build_mock_app("vim-common", "common vim stuff", "vim.common", "dependencies") |
2121 | 48 | } | 49 | } |
2122 | 49 | 50 | ||
2126 | 50 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | 51 | results = apt.AptCache('palpatine').search('vim') |
2124 | 51 | MockLibertine.container_path.return_value = '/some/junk' | ||
2125 | 52 | results = apt.AptCache('palpatine').search('vim') | ||
2127 | 53 | 52 | ||
2128 | 54 | self.assertEqual(len(results), 2) | 53 | self.assertEqual(len(results), 2) |
2129 | 55 | results = sorted(results, key=lambda xx: xx['id']) | 54 | results = sorted(results, key=lambda xx: xx['id']) |
2130 | @@ -67,15 +66,13 @@ | |||
2131 | 67 | self.assertEqual(results[1]['website'], 'vim.common') | 66 | self.assertEqual(results[1]['website'], 'vim.common') |
2132 | 68 | self.assertEqual(results[1]['package'], 'vim-common') | 67 | self.assertEqual(results[1]['package'], 'vim-common') |
2133 | 69 | 68 | ||
2135 | 70 | MockCache.assert_called_once_with() | 69 | MockCache.assert_called_once_with(rootdir=utils.get_libertine_container_rootfs_path('palpatine')) |
2136 | 71 | 70 | ||
2137 | 72 | def test_app_info_returns_empty_dict_when_no_such_app_exists(self): | 71 | def test_app_info_returns_empty_dict_when_no_such_app_exists(self): |
2138 | 73 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 72 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2139 | 74 | MockCache.return_value = {} | 73 | MockCache.return_value = {} |
2144 | 75 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | 74 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), {}) |
2145 | 76 | MockLibertine.container_path.return_value = '/some/junk' | 75 | MockCache.assert_called_once_with(rootdir=utils.get_libertine_container_rootfs_path('palpatine')) |
2142 | 77 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), {}) | ||
2143 | 78 | MockCache.assert_called_once_with() | ||
2146 | 79 | 76 | ||
2147 | 80 | def test_app_info_returns_values_for_app(self): | 77 | def test_app_info_returns_values_for_app(self): |
2148 | 81 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 78 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2149 | @@ -83,17 +80,15 @@ | |||
2150 | 83 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), | 80 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), |
2151 | 84 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), | 81 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), |
2152 | 85 | } | 82 | } |
2164 | 86 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | 83 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), { |
2165 | 87 | MockLibertine.container_path.return_value = '/some/junk' | 84 | 'name': 'vim', |
2166 | 88 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), { | 85 | 'id': 'vim', |
2167 | 89 | 'name': 'vim', | 86 | 'package': 'vim', |
2168 | 90 | 'id': 'vim', | 87 | 'summary': 'vi improved', |
2169 | 91 | 'package': 'vim', | 88 | 'description': 'who even uses raw vi', |
2170 | 92 | 'summary': 'vi improved', | 89 | 'website': 'vim.com' |
2171 | 93 | 'description': 'who even uses raw vi', | 90 | }) |
2172 | 94 | 'website': 'vim.com' | 91 | MockCache.assert_called_once_with(rootdir=utils.get_libertine_container_rootfs_path('palpatine')) |
2162 | 95 | }) | ||
2163 | 96 | MockCache.assert_called_once_with() | ||
2173 | 97 | 92 | ||
2174 | 98 | def test_loads_cache_from_container_directory(self): | 93 | def test_loads_cache_from_container_directory(self): |
2175 | 99 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 94 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2176 | @@ -101,19 +96,17 @@ | |||
2177 | 101 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), | 96 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), |
2178 | 102 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), | 97 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), |
2179 | 103 | } | 98 | } |
2193 | 104 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | 99 | |
2194 | 105 | containerpath = "%s/containerroot" % os.path.dirname(os.path.realpath(__file__)) | 100 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), { |
2195 | 106 | MockLibertine.container_path.return_value = containerpath | 101 | 'name': 'vim', |
2196 | 107 | self.assertEqual(apt.AptCache('palpatine').app_info("vim"), { | 102 | 'id': 'vim', |
2197 | 108 | 'name': 'vim', | 103 | 'package': 'vim', |
2198 | 109 | 'id': 'vim', | 104 | 'summary': 'vi improved', |
2199 | 110 | 'package': 'vim', | 105 | 'description': 'who even uses raw vi', |
2200 | 111 | 'summary': 'vi improved', | 106 | 'website': 'vim.com' |
2201 | 112 | 'description': 'who even uses raw vi', | 107 | }) |
2202 | 113 | 'website': 'vim.com' | 108 | |
2203 | 114 | }) | 109 | MockCache.assert_called_once_with(rootdir=utils.get_libertine_container_rootfs_path('palpatine')) |
2191 | 115 | |||
2192 | 116 | MockCache.assert_called_once_with(rootdir=containerpath) | ||
2204 | 117 | 110 | ||
2205 | 118 | def test_loads_cache_only_once(self): | 111 | def test_loads_cache_only_once(self): |
2206 | 119 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: | 112 | with unittest.mock.patch('libertine.service.apt.apt.Cache') as MockCache: |
2207 | @@ -121,13 +114,12 @@ | |||
2208 | 121 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), | 114 | "vim": build_mock_app("vim", "vi improved", "vim.com", "who even uses raw vi"), |
2209 | 122 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), | 115 | "gimp": build_mock_app("gimp", "foss photoshop", "gimp.com", "visual text editor"), |
2210 | 123 | } | 116 | } |
2218 | 124 | with unittest.mock.patch('libertine.service.apt.Libertine') as MockLibertine: | 117 | |
2219 | 125 | MockLibertine.container_path.return_value = '/some/junk' | 118 | cache = apt.AptCache('palpatine') |
2220 | 126 | cache = apt.AptCache('palpatine') | 119 | cache.app_info("vim") |
2221 | 127 | cache.app_info("vim") | 120 | cache.app_info("vim") |
2222 | 128 | cache.app_info("vim") | 121 | |
2223 | 129 | 122 | MockCache.assert_called_once_with(rootdir=utils.get_libertine_container_rootfs_path('palpatine')) | |
2217 | 130 | MockCache.assert_called_once_with() | ||
2224 | 131 | 123 | ||
2225 | 132 | 124 | ||
2226 | 133 | if __name__ == '__main__': | 125 | if __name__ == '__main__': |
2227 | 134 | 126 | ||
2228 | === modified file 'tests/unit/service/test_container.py' | |||
2229 | --- tests/unit/service/test_container.py 2016-11-04 15:54:34 +0000 | |||
2230 | +++ tests/unit/service/test_container.py 2017-01-27 18:57:35 +0000 | |||
2231 | @@ -1,4 +1,4 @@ | |||
2233 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
2234 | 2 | # | 2 | # |
2235 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
2236 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
2237 | @@ -22,12 +22,11 @@ | |||
2238 | 22 | def setUp(self): | 22 | def setUp(self): |
2239 | 23 | self._connection = unittest.mock.Mock() | 23 | self._connection = unittest.mock.Mock() |
2240 | 24 | self._config = unittest.mock.Mock() | 24 | self._config = unittest.mock.Mock() |
2241 | 25 | self._lock = unittest.mock.Mock() | ||
2242 | 26 | 25 | ||
2243 | 27 | def test_search_creates_search_task(self): | 26 | def test_search_creates_search_task(self): |
2244 | 28 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 27 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2245 | 29 | cache = MockCache.return_value | 28 | cache = MockCache.return_value |
2247 | 30 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | 29 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2248 | 31 | with unittest.mock.patch('libertine.service.container.SearchTask') as MockSearchTask: | 30 | with unittest.mock.patch('libertine.service.container.SearchTask') as MockSearchTask: |
2249 | 32 | c.search('darkseid') | 31 | c.search('darkseid') |
2250 | 33 | MockSearchTask.assert_called_once_with('palpatine', cache, 'darkseid', self._connection, unittest.mock.ANY) | 32 | MockSearchTask.assert_called_once_with('palpatine', cache, 'darkseid', self._connection, unittest.mock.ANY) |
2251 | @@ -36,7 +35,7 @@ | |||
2252 | 36 | def test_app_info_creates_app_info_task(self): | 35 | def test_app_info_creates_app_info_task(self): |
2253 | 37 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 36 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2254 | 38 | cache = MockCache.return_value | 37 | cache = MockCache.return_value |
2256 | 39 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | 38 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2257 | 40 | with unittest.mock.patch('libertine.service.container.AppInfoTask') as MockAppInfoTask: | 39 | with unittest.mock.patch('libertine.service.container.AppInfoTask') as MockAppInfoTask: |
2258 | 41 | c.app_info('force') | 40 | c.app_info('force') |
2259 | 42 | MockAppInfoTask.assert_called_once_with('palpatine', cache, 'force', [], self._config, self._connection, unittest.mock.ANY) | 41 | MockAppInfoTask.assert_called_once_with('palpatine', cache, 'force', [], self._config, self._connection, unittest.mock.ANY) |
2260 | @@ -45,7 +44,7 @@ | |||
2261 | 45 | def test_app_info_gets_related_task_info(self): | 44 | def test_app_info_gets_related_task_info(self): |
2262 | 46 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 45 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2263 | 47 | cache = MockCache.return_value | 46 | cache = MockCache.return_value |
2265 | 48 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | 47 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2266 | 49 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: | 48 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: |
2267 | 50 | MockInstallTask.return_value.package = 'darkside' | 49 | MockInstallTask.return_value.package = 'darkside' |
2268 | 51 | MockInstallTask.return_value.matches.return_value = False | 50 | MockInstallTask.return_value.matches.return_value = False |
2269 | @@ -60,119 +59,115 @@ | |||
2270 | 60 | 59 | ||
2271 | 61 | def test_install_creates_install_task(self): | 60 | def test_install_creates_install_task(self): |
2272 | 62 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 61 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2275 | 63 | cache = MockCache.return_value | 62 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2274 | 64 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2276 | 65 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: | 63 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: |
2277 | 66 | c.install('force') | 64 | c.install('force') |
2279 | 67 | MockInstallTask.assert_called_once_with('force', 'palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 65 | MockInstallTask.assert_called_once_with('force', 'palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2280 | 68 | MockInstallTask.return_value.start.assert_called_once_with() | 66 | MockInstallTask.return_value.start.assert_called_once_with() |
2281 | 69 | 67 | ||
2282 | 70 | def test_install_only_calls_once_when_unfinished(self): | 68 | def test_install_only_calls_once_when_unfinished(self): |
2283 | 71 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 69 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2286 | 72 | cache = MockCache.return_value | 70 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2285 | 73 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2287 | 74 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: | 71 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: |
2288 | 75 | c.install('darkside') | 72 | c.install('darkside') |
2289 | 76 | c.install('darkside') | 73 | c.install('darkside') |
2290 | 77 | c.install('darkside') | 74 | c.install('darkside') |
2292 | 78 | # MockInstallTask.assert_called_once_with('darkside', 'palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 75 | MockInstallTask.assert_called_once_with('darkside', 'palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2293 | 79 | MockInstallTask.return_value.start.assert_called_once_with() | 76 | MockInstallTask.return_value.start.assert_called_once_with() |
2294 | 80 | 77 | ||
2295 | 81 | def test_remove_creates_remove_task(self): | 78 | def test_remove_creates_remove_task(self): |
2296 | 82 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 79 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2299 | 83 | cache = MockCache.return_value | 80 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2298 | 84 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2300 | 85 | with unittest.mock.patch('libertine.service.container.RemoveTask') as MockRemoveTask: | 81 | with unittest.mock.patch('libertine.service.container.RemoveTask') as MockRemoveTask: |
2301 | 86 | c.remove('force') | 82 | c.remove('force') |
2303 | 87 | MockRemoveTask.assert_called_once_with('force', 'palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 83 | MockRemoveTask.assert_called_once_with('force', 'palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2304 | 88 | MockRemoveTask.return_value.start.assert_called_once_with() | 84 | MockRemoveTask.return_value.start.assert_called_once_with() |
2305 | 89 | 85 | ||
2306 | 90 | def test_remove_only_calls_once_when_unfinished(self): | 86 | def test_remove_only_calls_once_when_unfinished(self): |
2307 | 91 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 87 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2310 | 92 | cache = MockCache.return_value | 88 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2309 | 93 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2311 | 94 | with unittest.mock.patch('libertine.service.container.RemoveTask') as MockRemoveTask: | 89 | with unittest.mock.patch('libertine.service.container.RemoveTask') as MockRemoveTask: |
2312 | 95 | c.remove('darkside') | 90 | c.remove('darkside') |
2313 | 96 | c.remove('darkside') | 91 | c.remove('darkside') |
2314 | 97 | c.remove('darkside') | 92 | c.remove('darkside') |
2316 | 98 | # MockRemoveTask.assert_called_once_with('darkside', 'palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 93 | MockRemoveTask.assert_called_once_with('darkside', 'palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2317 | 99 | MockRemoveTask.return_value.start.assert_called_once_with() | 94 | MockRemoveTask.return_value.start.assert_called_once_with() |
2318 | 100 | 95 | ||
2319 | 101 | def test_create_creates_create_task(self): | 96 | def test_create_creates_create_task(self): |
2320 | 102 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 97 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2323 | 103 | cache = MockCache.return_value | 98 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2322 | 104 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2324 | 105 | with unittest.mock.patch('libertine.service.container.CreateTask') as MockCreateTask: | 99 | with unittest.mock.patch('libertine.service.container.CreateTask') as MockCreateTask: |
2325 | 106 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) | 100 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) |
2326 | 107 | MockCreateTask.assert_called_once_with('palpatine', 'Emperor Palpatine', 'zesty', 'lxd', False, | 101 | MockCreateTask.assert_called_once_with('palpatine', 'Emperor Palpatine', 'zesty', 'lxd', False, |
2328 | 108 | self._config, self._lock, self._connection, unittest.mock.ANY) | 102 | self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2329 | 109 | MockCreateTask.return_value.start.assert_called_once_with() | 103 | MockCreateTask.return_value.start.assert_called_once_with() |
2330 | 110 | 104 | ||
2331 | 111 | def test_create_only_calls_once_when_unfinished(self): | 105 | def test_create_only_calls_once_when_unfinished(self): |
2332 | 112 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 106 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2335 | 113 | cache = MockCache.return_value | 107 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2334 | 114 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2336 | 115 | with unittest.mock.patch('libertine.service.container.CreateTask') as MockCreateTask: | 108 | with unittest.mock.patch('libertine.service.container.CreateTask') as MockCreateTask: |
2337 | 116 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) | 109 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) |
2338 | 117 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) | 110 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) |
2339 | 118 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) | 111 | c.create('Emperor Palpatine', 'zesty', 'lxd', False) |
2342 | 119 | # MockCreateTask.assert_called_once_with('palpatine', 'Emperor Palpatine', 'zesty', 'lxd', False, | 112 | MockCreateTask.assert_called_once_with('palpatine', 'Emperor Palpatine', 'zesty', 'lxd', False, |
2343 | 120 | # self._config, self._lock, self._connection, unittest.mock.ANY) | 113 | self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2344 | 121 | MockCreateTask.return_value.start.assert_called_once_with() | 114 | MockCreateTask.return_value.start.assert_called_once_with() |
2345 | 122 | 115 | ||
2346 | 123 | def test_destroy_creates_destroy_task(self): | 116 | def test_destroy_creates_destroy_task(self): |
2347 | 124 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 117 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2350 | 125 | cache = MockCache.return_value | 118 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2349 | 126 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2351 | 127 | with unittest.mock.patch('libertine.service.container.DestroyTask') as MockDestroyTask: | 119 | with unittest.mock.patch('libertine.service.container.DestroyTask') as MockDestroyTask: |
2352 | 128 | c.destroy() | 120 | c.destroy() |
2354 | 129 | # MockDestroyTask.assert_called_once_with('palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 121 | MockDestroyTask.assert_called_once_with('palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2355 | 130 | MockDestroyTask.return_value.start.assert_called_once_with() | 122 | MockDestroyTask.return_value.start.assert_called_once_with() |
2356 | 131 | 123 | ||
2357 | 132 | def test_destroy_only_calls_once_when_unfinished(self): | 124 | def test_destroy_only_calls_once_when_unfinished(self): |
2358 | 133 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 125 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2361 | 134 | cache = MockCache.return_value | 126 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2360 | 135 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2362 | 136 | with unittest.mock.patch('libertine.service.container.DestroyTask') as MockDestroyTask: | 127 | with unittest.mock.patch('libertine.service.container.DestroyTask') as MockDestroyTask: |
2363 | 137 | c.destroy() | 128 | c.destroy() |
2364 | 138 | c.destroy() | 129 | c.destroy() |
2365 | 139 | c.destroy() | 130 | c.destroy() |
2367 | 140 | # MockDestroyTask.assert_called_once_with('palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 131 | MockDestroyTask.assert_called_once_with('palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2368 | 141 | MockDestroyTask.return_value.start.assert_called_once_with() | 132 | MockDestroyTask.return_value.start.assert_called_once_with() |
2369 | 142 | 133 | ||
2370 | 143 | def test_update_creates_update_task(self): | 134 | def test_update_creates_update_task(self): |
2371 | 144 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 135 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2374 | 145 | cache = MockCache.return_value | 136 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2373 | 146 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2375 | 147 | with unittest.mock.patch('libertine.service.container.UpdateTask') as MockUpdateTask: | 137 | with unittest.mock.patch('libertine.service.container.UpdateTask') as MockUpdateTask: |
2376 | 148 | c.update() | 138 | c.update() |
2378 | 149 | MockUpdateTask.assert_called_once_with('palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 139 | MockUpdateTask.assert_called_once_with('palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2379 | 150 | MockUpdateTask.return_value.start.assert_called_once_with() | 140 | MockUpdateTask.return_value.start.assert_called_once_with() |
2380 | 151 | 141 | ||
2381 | 152 | def test_update_only_calls_once_when_unfinished(self): | 142 | def test_update_only_calls_once_when_unfinished(self): |
2382 | 153 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 143 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2385 | 154 | cache = MockCache.return_value | 144 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2384 | 155 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2386 | 156 | with unittest.mock.patch('libertine.service.container.UpdateTask') as MockUpdateTask: | 145 | with unittest.mock.patch('libertine.service.container.UpdateTask') as MockUpdateTask: |
2387 | 157 | c.update() | 146 | c.update() |
2388 | 158 | c.update() | 147 | c.update() |
2389 | 159 | c.update() | 148 | c.update() |
2391 | 160 | # MockUpdateTask.assert_called_once_with('palpatine', self._config, self._lock, self._connection, unittest.mock.ANY) | 149 | MockUpdateTask.assert_called_once_with('palpatine', self._config, unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2392 | 161 | MockUpdateTask.return_value.start.assert_called_once_with() | 150 | MockUpdateTask.return_value.start.assert_called_once_with() |
2393 | 162 | 151 | ||
2394 | 163 | def test_list_apps_creates_list_apps_task(self): | 152 | def test_list_apps_creates_list_apps_task(self): |
2395 | 164 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 153 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2398 | 165 | cache = MockCache.return_value | 154 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2397 | 166 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2399 | 167 | with unittest.mock.patch('libertine.service.container.ListAppsTask') as MockListAppsTask: | 155 | with unittest.mock.patch('libertine.service.container.ListAppsTask') as MockListAppsTask: |
2400 | 168 | c.list_apps() | 156 | c.list_apps() |
2401 | 169 | MockListAppsTask.assert_called_once_with('palpatine', self._config, self._connection, unittest.mock.ANY) | 157 | MockListAppsTask.assert_called_once_with('palpatine', self._config, self._connection, unittest.mock.ANY) |
2402 | 170 | MockListAppsTask.return_value.start.assert_called_once_with() | 158 | MockListAppsTask.return_value.start.assert_called_once_with() |
2403 | 171 | 159 | ||
2404 | 160 | def test_list_app_ids_creates_list_app_ids_task(self): | ||
2405 | 161 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | ||
2406 | 162 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) | ||
2407 | 163 | with unittest.mock.patch('libertine.service.container.ListAppIdsTask') as MockListAppsTask: | ||
2408 | 164 | c.list_app_ids() | ||
2409 | 165 | MockListAppsTask.assert_called_once_with('palpatine', self._config, self._connection, unittest.mock.ANY) | ||
2410 | 166 | MockListAppsTask.return_value.start.assert_called_once_with() | ||
2411 | 167 | |||
2412 | 172 | def test_removes_task_during_callback(self): | 168 | def test_removes_task_during_callback(self): |
2413 | 173 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 169 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2416 | 174 | cache = MockCache.return_value | 170 | c = container.Container('palpatine', self._config, self._connection, lambda task: task) |
2415 | 175 | c = container.Container('palpatine', self._config, self._lock, self._connection, lambda task: task) | ||
2417 | 176 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: | 171 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: |
2418 | 177 | MockInstallTask.return_value.package = 'force' | 172 | MockInstallTask.return_value.package = 'force' |
2419 | 178 | c.install('force') | 173 | c.install('force') |
2420 | @@ -186,11 +181,10 @@ | |||
2421 | 186 | 181 | ||
2422 | 187 | def test_completing_all_tasks_fires_callback(self): | 182 | def test_completing_all_tasks_fires_callback(self): |
2423 | 188 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: | 183 | with unittest.mock.patch('libertine.service.container.apt.AptCache') as MockCache: |
2424 | 189 | cache = MockCache.return_value | ||
2425 | 190 | self._container_id = None | 184 | self._container_id = None |
2426 | 191 | def callback(container): | 185 | def callback(container): |
2427 | 192 | self._container_id = container.id | 186 | self._container_id = container.id |
2429 | 193 | c = container.Container('palpatine', self._config, self._lock, self._connection, callback) | 187 | c = container.Container('palpatine', self._config, self._connection, callback) |
2430 | 194 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: | 188 | with unittest.mock.patch('libertine.service.container.InstallTask') as MockInstallTask: |
2431 | 195 | c.install('force') | 189 | c.install('force') |
2432 | 196 | name, args, kwargs = MockInstallTask.mock_calls[0] | 190 | name, args, kwargs = MockInstallTask.mock_calls[0] |
2433 | 197 | 191 | ||
2434 | === modified file 'tests/unit/service/test_task_dispatcher.py' | |||
2435 | --- tests/unit/service/test_task_dispatcher.py 2016-11-03 20:20:15 +0000 | |||
2436 | +++ tests/unit/service/test_task_dispatcher.py 2017-01-27 18:57:35 +0000 | |||
2437 | @@ -1,4 +1,4 @@ | |||
2439 | 1 | # Copyright 2016 Canonical Ltd. | 1 | # Copyright 2016-2017 Canonical Ltd. |
2440 | 2 | # | 2 | # |
2441 | 3 | # This program is free software: you can redistribute it and/or modify it | 3 | # This program is free software: you can redistribute it and/or modify it |
2442 | 4 | # under the terms of the GNU General Public License version 3, as published | 4 | # under the terms of the GNU General Public License version 3, as published |
2443 | @@ -83,6 +83,13 @@ | |||
2444 | 83 | self.assertEqual(123, self._dispatcher.list_apps('palpatine')) | 83 | self.assertEqual(123, self._dispatcher.list_apps('palpatine')) |
2445 | 84 | c.list_apps.assert_called_once_with() | 84 | c.list_apps.assert_called_once_with() |
2446 | 85 | 85 | ||
2447 | 86 | def test_list_apps_calls_list_apps_on_container(self): | ||
2448 | 87 | with unittest.mock.patch('libertine.service.task_dispatcher.Container') as MockContainer: | ||
2449 | 88 | c = MockContainer.return_value | ||
2450 | 89 | c.list_app_ids.return_value = 123 | ||
2451 | 90 | self.assertEqual(123, self._dispatcher.list_app_ids('palpatine')) | ||
2452 | 91 | c.list_app_ids.assert_called_once_with() | ||
2453 | 92 | |||
2454 | 86 | def test_containers_reused_on_subsequent_calls(self): | 93 | def test_containers_reused_on_subsequent_calls(self): |
2455 | 87 | with unittest.mock.patch('libertine.service.task_dispatcher.Container') as MockContainer: | 94 | with unittest.mock.patch('libertine.service.task_dispatcher.Container') as MockContainer: |
2456 | 88 | c = MockContainer.return_value | 95 | c = MockContainer.return_value |
2457 | @@ -90,20 +97,20 @@ | |||
2458 | 90 | self._dispatcher.list_apps('palpatine') | 97 | self._dispatcher.list_apps('palpatine') |
2459 | 91 | self._dispatcher.list_apps('palpatine') | 98 | self._dispatcher.list_apps('palpatine') |
2460 | 92 | self._dispatcher.list_apps('palpatine') | 99 | self._dispatcher.list_apps('palpatine') |
2462 | 93 | MockContainer.assert_called_once_with('palpatine', unittest.mock.ANY, unittest.mock.ANY, self._connection, unittest.mock.ANY) | 100 | MockContainer.assert_called_once_with('palpatine', unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2463 | 94 | 101 | ||
2464 | 95 | def test_container_callback_removes_container(self): | 102 | def test_container_callback_removes_container(self): |
2465 | 96 | with unittest.mock.patch('libertine.service.task_dispatcher.Container') as MockContainer: | 103 | with unittest.mock.patch('libertine.service.task_dispatcher.Container') as MockContainer: |
2466 | 97 | c = MockContainer.return_value | 104 | c = MockContainer.return_value |
2467 | 98 | c.id = 'palpatine' | 105 | c.id = 'palpatine' |
2468 | 99 | self._dispatcher.list_apps('palpatine') | 106 | self._dispatcher.list_apps('palpatine') |
2470 | 100 | MockContainer.assert_called_once_with('palpatine', unittest.mock.ANY, unittest.mock.ANY, self._connection, unittest.mock.ANY) | 107 | MockContainer.assert_called_once_with('palpatine', unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2471 | 101 | name, args, kwargs = MockContainer.mock_calls[0] | 108 | name, args, kwargs = MockContainer.mock_calls[0] |
2472 | 102 | args[len(args)-1](MockContainer.return_value) | 109 | args[len(args)-1](MockContainer.return_value) |
2473 | 103 | self._dispatcher.list_apps('palpatine') | 110 | self._dispatcher.list_apps('palpatine') |
2474 | 104 | MockContainer.assert_has_calls([ # verify container constructed twice | 111 | MockContainer.assert_has_calls([ # verify container constructed twice |
2477 | 105 | unittest.mock.call('palpatine', unittest.mock.ANY, unittest.mock.ANY, self._connection, unittest.mock.ANY), | 112 | unittest.mock.call('palpatine', unittest.mock.ANY, self._connection, unittest.mock.ANY), |
2478 | 106 | unittest.mock.call('palpatine', unittest.mock.ANY, unittest.mock.ANY, self._connection, unittest.mock.ANY) | 113 | unittest.mock.call('palpatine', unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2479 | 107 | ], any_order=True) | 114 | ], any_order=True) |
2480 | 108 | 115 | ||
2481 | 109 | def test_container_info_creates_container_info_task(self): | 116 | def test_container_info_creates_container_info_task(self): |
2482 | @@ -131,13 +138,13 @@ | |||
2483 | 131 | task = MockListTask.return_value | 138 | task = MockListTask.return_value |
2484 | 132 | task.id = 123 | 139 | task.id = 123 |
2485 | 133 | self.assertEqual(123, self._dispatcher.list()) | 140 | self.assertEqual(123, self._dispatcher.list()) |
2487 | 134 | MockListTask.assert_called_once_with(self._connection, unittest.mock.ANY) | 141 | MockListTask.assert_called_once_with(unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2488 | 135 | task.start.assert_called_once_with() | 142 | task.start.assert_called_once_with() |
2489 | 136 | 143 | ||
2490 | 137 | def test_containerless_tasks_are_cleaned_up(self): | 144 | def test_containerless_tasks_are_cleaned_up(self): |
2491 | 138 | with unittest.mock.patch('libertine.service.task_dispatcher.ListTask') as MockListTask: | 145 | with unittest.mock.patch('libertine.service.task_dispatcher.ListTask') as MockListTask: |
2492 | 139 | self._dispatcher.list() | 146 | self._dispatcher.list() |
2494 | 140 | MockListTask.assert_called_once_with(self._connection, unittest.mock.ANY) | 147 | MockListTask.assert_called_once_with(unittest.mock.ANY, self._connection, unittest.mock.ANY) |
2495 | 141 | name, args, kwargs = MockListTask.mock_calls[0] | 148 | name, args, kwargs = MockListTask.mock_calls[0] |
2496 | 142 | self.assertEqual(1, len(self._dispatcher._tasks)) | 149 | self.assertEqual(1, len(self._dispatcher._tasks)) |
2497 | 143 | args[len(args)-1](MockListTask.return_value) | 150 | args[len(args)-1](MockListTask.return_value) |
2498 | 144 | 151 | ||
2499 | === modified file 'tests/unit/test_libertine_container.py' | |||
2500 | --- tests/unit/test_libertine_container.py 2016-11-10 17:40:14 +0000 | |||
2501 | +++ tests/unit/test_libertine_container.py 2017-01-27 18:57:35 +0000 | |||
2502 | @@ -1,5 +1,5 @@ | |||
2503 | 1 | """Unit tests for the LibertineContainer interface.""" | 1 | """Unit tests for the LibertineContainer interface.""" |
2505 | 2 | # Copyright 2015 Canonical Ltd. | 2 | # Copyright 2015-2017 Canonical Ltd. |
2506 | 3 | # | 3 | # |
2507 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2508 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2509 | @@ -52,6 +52,7 @@ | |||
2510 | 52 | 52 | ||
2511 | 53 | def test_container_name_default(self): | 53 | def test_container_name_default(self): |
2512 | 54 | container_id = "test-id-3" | 54 | container_id = "test-id-3" |
2513 | 55 | self._config.get_container_name.return_value = None | ||
2514 | 55 | container = Libertine.LibertineContainer(container_id, self._config) | 56 | container = Libertine.LibertineContainer(container_id, self._config) |
2515 | 56 | 57 | ||
2516 | 57 | self.assertThat(container.name, Equals("Unknown")) | 58 | self.assertThat(container.name, Equals("Unknown")) |
2517 | 58 | 59 | ||
2518 | === removed file 'tests/unit/test_libertine_gir.py' | |||
2519 | --- tests/unit/test_libertine_gir.py 2017-01-18 15:43:03 +0000 | |||
2520 | +++ tests/unit/test_libertine_gir.py 1970-01-01 00:00:00 +0000 | |||
2521 | @@ -1,65 +0,0 @@ | |||
2522 | 1 | # Copyright 2015 Canonical Ltd. | ||
2523 | 2 | # | ||
2524 | 3 | # This program is free software: you can redistribute it and/or modify it | ||
2525 | 4 | # under the terms of the GNU General Public License version 3, as published | ||
2526 | 5 | # by the Free Software Foundation. | ||
2527 | 6 | # | ||
2528 | 7 | # This program is distributed in the hope that it will be useful, but | ||
2529 | 8 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2530 | 9 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2531 | 10 | # PURPOSE. See the GNU General Public License for more details. | ||
2532 | 11 | # | ||
2533 | 12 | # You should have received a copy of the GNU General Public License along | ||
2534 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2535 | 14 | |||
2536 | 15 | import os | ||
2537 | 16 | from testtools import TestCase | ||
2538 | 17 | from testtools.matchers import Equals | ||
2539 | 18 | from gi.repository import Libertine | ||
2540 | 19 | from unittest import skip | ||
2541 | 20 | from unittest.mock import patch | ||
2542 | 21 | |||
2543 | 22 | |||
2544 | 23 | class TestLibertineGir(TestCase): | ||
2545 | 24 | |||
2546 | 25 | def setUp(self): | ||
2547 | 26 | super(TestLibertineGir, self).setUp() | ||
2548 | 27 | self.cmake_source_dir = os.environ['LIBERTINE_DATA_DIR'] | ||
2549 | 28 | |||
2550 | 29 | def test_list_containers(self): | ||
2551 | 30 | with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config', 'IGNORE_SNAP': '1'}): | ||
2552 | 31 | containers = Libertine.list_containers() | ||
2553 | 32 | |||
2554 | 33 | self.assertThat(containers[0], Equals('wily')) | ||
2555 | 34 | self.assertThat(containers[1], Equals('wily-2')) | ||
2556 | 35 | |||
2557 | 36 | @skip("need to work around cached globals in glib") | ||
2558 | 37 | def test_container_path(self): | ||
2559 | 38 | container_id = 'wily' | ||
2560 | 39 | with patch.dict('os.environ', {'XDG_CACHE_HOME': self.cmake_source_dir + '/libertine-data', 'IGNORE_SNAP': '1'}): | ||
2561 | 40 | container_path = Libertine.container_path(container_id) | ||
2562 | 41 | |||
2563 | 42 | self.assertThat(container_path, Equals(self.cmake_source_dir + '/libertine-data/libertine-container/wily/rootfs')) | ||
2564 | 43 | |||
2565 | 44 | def test_container_home_path(self): | ||
2566 | 45 | container_id = 'wily' | ||
2567 | 46 | with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-home', 'IGNORE_SNAP': '1'}): | ||
2568 | 47 | container_home_path = Libertine.container_home_path(container_id) | ||
2569 | 48 | |||
2570 | 49 | self.assertThat(container_home_path, Equals(self.cmake_source_dir + '/libertine-home/libertine-container/user-data/wily')) | ||
2571 | 50 | |||
2572 | 51 | def test_container_name(self): | ||
2573 | 52 | with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config', 'IGNORE_SNAP': '1'}): | ||
2574 | 53 | container_name = Libertine.container_name('wily') | ||
2575 | 54 | |||
2576 | 55 | self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf'")) | ||
2577 | 56 | |||
2578 | 57 | container_name = Libertine.container_name('wily-2') | ||
2579 | 58 | |||
2580 | 59 | self.assertThat(container_name, Equals("Ubuntu 'Wily Werewolf' (2)")) | ||
2581 | 60 | |||
2582 | 61 | def test_list_apps_for_container(self): | ||
2583 | 62 | with patch.dict('os.environ', {'XDG_DATA_HOME': self.cmake_source_dir + '/libertine-config', 'IGNORE_SNAP': '1'}): | ||
2584 | 63 | apps = Libertine.list_apps_for_container('wily') | ||
2585 | 64 | |||
2586 | 65 | self.assertThat(len(apps), Equals(0)) | ||
2587 | 66 | 0 | ||
2588 | === modified file 'tools/libertine-container-manager' | |||
2589 | --- tools/libertine-container-manager 2017-01-25 16:27:15 +0000 | |||
2590 | +++ tools/libertine-container-manager 2017-01-27 18:57:35 +0000 | |||
2591 | @@ -218,8 +218,7 @@ | |||
2592 | 218 | self.containers_config.update_container_install_status(container_id, "ready") | 218 | self.containers_config.update_container_install_status(container_id, "ready") |
2593 | 219 | 219 | ||
2594 | 220 | def list(self, args): | 220 | def list(self, args): |
2597 | 221 | containers = libertine.utils.Libertine.list_containers() | 221 | for container in ContainersConfig().get_containers(): |
2596 | 222 | for container in containers: | ||
2598 | 223 | print("%s" % container) | 222 | print("%s" % container) |
2599 | 224 | 223 | ||
2600 | 225 | def list_apps(self, args): | 224 | def list_apps(self, args): |
2601 | 226 | 225 | ||
2602 | === modified file 'tools/libertine-lxc-manager' | |||
2603 | --- tools/libertine-lxc-manager 2017-01-24 20:21:16 +0000 | |||
2604 | +++ tools/libertine-lxc-manager 2017-01-27 18:57:35 +0000 | |||
2605 | @@ -83,7 +83,7 @@ | |||
2606 | 83 | mounts = self._sanitize_bind_mounts(libertine.utils.get_common_xdg_user_directories() + \ | 83 | mounts = self._sanitize_bind_mounts(libertine.utils.get_common_xdg_user_directories() + \ |
2607 | 84 | self._containers_config.get_container_bind_mounts(container_id)) | 84 | self._containers_config.get_container_bind_mounts(container_id)) |
2608 | 85 | 85 | ||
2610 | 86 | data_dir = libertine.utils.get_libertine_container_userdata_dir_path(container_id) | 86 | data_dir = libertine.utils.get_libertine_container_home_dir(container_id) |
2611 | 87 | for user_dir in libertine.utils.generate_binding_directories(mounts, self._home): | 87 | for user_dir in libertine.utils.generate_binding_directories(mounts, self._home): |
2612 | 88 | if os.path.isabs(user_dir[1]): | 88 | if os.path.isabs(user_dir[1]): |
2613 | 89 | path = user_dir[1].strip('/') | 89 | path = user_dir[1].strip('/') |
FAILED: Continuous integration, rev:357 /jenkins. canonical. com/libertine/ job/lp- libertine- ci/343/ /jenkins. canonical. com/libertine/ job/build/ 672/console /jenkins. canonical. com/libertine/ job/build- 0-fetch/ 682 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 663/console /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= zesty/663/ console /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 663/console /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= zesty/663/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/libertine/ job/lp- libertine- ci/343/ rebuild
https:/