forked from pantavisor/pantavisor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
264 lines (243 loc) · 6.55 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# Set the minimum required version of CMake
cmake_minimum_required(VERSION 3.0)
# Set the project name and version
project(pantavisor VERSION 019)
# subdirectories
add_subdirectory(plugins)
# include cmake packages
include(FindPackageHandleStandardArgs)
# feature flags
set(PANTAVISOR_DM_VERITY OFF CACHE BOOL "Enable support for dm verity mounted squash volumes")
set(PANTAVISOR_DM_CRYPT OFF CACHE BOOL "Enable support for dm crypt mounted disks")
set(PANTAVISOR_PVZRAM_TEST OFF CACHE BOOL "Build pvzram-test binary")
set(PANTAVISOR_DEBUG OFF CACHE BOOL "Enable debug features for Pantavisor")
set(PANTAVISOR_APPENGINE OFF CACHE BOOL "Build Pantavisor as appengine")
set(PANTAVISOR_DEFAULTS_SKIP_INSTALL OFF CACHE BOOL "Skip installing defaults/ to etc/pantavisor")
set(PANTAVISOR_PVS_SKIP_INSTALL OFF CACHE BOOL "Skip installing developer trust store")
# set cmake defintions
set(CODE_INSTALL_BASE "\$ENV{DESTDIR}")
# Find the shared library
find_library(THTTP thttp)
find_library(PICOHTTPPARSER picohttpparser)
find_library(LXC lxc)
find_library(ZLIB z)
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
find_library(MBEDTLS_LIBRARY mbedtls)
find_library(MBEDX509_LIBRARY mbedx509)
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
# Generate version.c
add_custom_command(
OUTPUT version.c
COMMAND sh
-c
\"cd ${CMAKE_CURRENT_SOURCE_DIR}\; ./gen_version.sh CMAKE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SYSTEM_PROCESSOR}\"
)
# Build and Install Pantavisor
add_executable(pantavisor
addons.c
addons.h
apparmor.c
apparmor.h
blkid.c
blkid.h
bootloader.c
bootloader.h
buffer.c
buffer.h
cgroup.c
cgroup.h
condition.c
condition.h
config.c
config.h
config_parser.c
config_parser.h
ctrl.c
ctrl.h
daemons.c
daemons.h
debug.c
debug.h
disk/disk.c
disk/disk.h
disk/disk_crypt.c
disk/disk_impl.h
disk/disk_swap.c
disk/disk_utils.c
disk/disk_utils.h
disk/disk_volume.c
disk/disk_volume.h
disk/disk_zram.c
disk/disk_zram_utils.c
disk/disk_zram_utils.h
drivers.c
drivers.h
group.c
group.h
grub.c
init.c
init.h
jsons.c
jsons.h
log.c
log.h
logger.c
logger.h
logserver/logserver.c
logserver/logserver.h
logserver/logserver_filetree.c
logserver/logserver_filetree.h
logserver/logserver_null.c
logserver/logserver_null.h
logserver/logserver_out.c
logserver/logserver_out.h
logserver/logserver_singlefile.c
logserver/logserver_singlefile.h
logserver/logserver_stdout.c
logserver/logserver_stdout.h
logserver/logserver_timestamp.c
logserver/logserver_timestamp.h
logserver/logserver_update.c
logserver/logserver_update.h
logserver/logserver_utils.c
logserver/logserver_utils.h
loop.c
loop.h
metadata.c
metadata.h
mount.c
mount.h
network.c
network.h
objects.c
objects.h
pantahub.c
pantahub.h
pantavisor.c
pantavisor.h
parser/parser.c
parser/parser.h
parser/parser_bundle.h
parser/parser_multi1.c
parser/parser_multi1.h
parser/parser_system1.c
parser/parser_system1.h
paths.c
paths.h
ph_logger.c
ph_logger.h
platforms.c
platforms.h
pvctl_utils.c
pvctl_utils.h
pvlogger.c
pvlogger.h
rpiab.c
signature.c
signature.h
state.c
state.h
storage.c
storage.h
trestclient.c
trestclient.h
uboot.c
updater.c
updater.h
utils/base64.c
utils/fs.c
utils/json.c
utils/math.c
utils/pvsignals.c
utils/pvsignals.h
utils/pvzlib.c
utils/pvzlib.h
utils/socket.c
utils/socket.h
utils/str.c
utils/strrep.c
utils/system.c
utils/timer.c
utils/tsh.c
version.c version.h
version.h
volumes.c
volumes.h
wdt.c
wdt.h
)
target_include_directories(pantavisor PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/utils ${MBEDTLS_INCLUDE_DIR})
target_link_libraries(pantavisor ${THTTP} ${PICOHTTPPARSER} ${MBEDTLS_LIBRARIES} ${LXC} ${ZLIB})
install(TARGETS pantavisor DESTINATION bin)
IF(PANTAVISOR_DEBUG)
target_compile_definitions(pantavisor PRIVATE PANTAVISOR_DEBUG)
ENDIF()
## install basic filesystem skeleton
install(DIRECTORY skel/ DESTINATION /)
IF(NOT PANTAVISOR_DEFAULTS_SKIP_INSTALL)
### ... insert defaults/
install(DIRECTORY defaults DESTINATION /etc/pantavisor)
ENDIF()
### install PVS secureboot files
IF(NOT PANTAVISOR_PVS_SKIP_INSTALL)
IF(DEFINED PANTAVISOR_PVS_DIR)
install(DIRECTORY ${PANTAVISOR_PVS_DIR}/ DESTINATION /etc/pantavisor/pvs/trust FILES_MATCHING PATTERN "*.crt")
ELSE()
install(DIRECTORY pvs/ DESTINATION /etc/pantavisor/pvs)
ENDIF()
ENDIF()
### install /init link if not appengine build
if(NOT PANTAVISOR_APPENGINE)
install(CODE "file(CREATE_LINK usr/bin/pantavisor ${CODE_INSTALL_BASE}/init SYMBOLIC)")
ENDIF()
### install scripts
install(FILES scripts/JSON.sh scripts/pv_e2fsgrow scripts/pvcrash
PERMISSIONS WORLD_READ WORLD_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
DESTINATION /lib/pv/)
install(DIRECTORY scripts/hooks_lxc-mount.d
FILE_PERMISSIONS WORLD_READ WORLD_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
DESTINATION /lib/pv)
install(PROGRAMS tools/pventer
tools/fallbear-cmd
DESTINATION /usr/bin)
### install dm crypt feature
IF(PANTAVISOR_DM_CRYPT)
install(DIRECTORY scripts/volmount/crypt
FILE_PERMISSIONS WORLD_READ WORLD_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
DESTINATION /lib/pv/volmount)
ENDIF()
### install dm verity feature
IF(PANTAVISOR_DM_VERITY)
install(DIRECTORY scripts/volmount/verity
FILE_PERMISSIONS WORLD_READ WORLD_EXECUTE GROUP_READ GROUP_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
DESTINATION /lib/pv/volmount)
ENDIF()
# Build and install tests feature
IF(PANTAVISOR_TESTS)
add_executable(test-pv-zram
disk/disk_zram_utils.c
disk/disk_zram_utils.h
utils/pv_zram.c
)
target_link_libraries(test-pv-zram -largp)
install(TARGETS test-pv-zram DESTINATION bin)
add_executable(test-pv-json
utils/json.test.c
utils/json.c
utils/tsh.c utils/tsh.h
utils/pvsignals.h utils/pvsignals.c
)
target_link_libraries(test-pv-json ${THTTP})
install(TARGETS test-pv-json DESTINATION bin)
add_executable(test-pv-tsh
utils/tsh.test.c
utils/tsh.c utils/tsh.h
utils/pvsignals.c utils/pvsignals.h
)
target_link_libraries(test-pv-tsh)
install(TARGETS test-pv-tsh DESTINATION bin)
ENDIF()