/
snapcraft.yaml
261 lines (230 loc) · 6.98 KB
/
snapcraft.yaml
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
name: deviceupdate-agent # you probably want to 'snapcraft register <name>'
base: core20 # the base snap is the execution environment for this snap
license: MIT
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: IoT Hub Device Update Agent for Ubuntu Core # 79 char long summary
description: |
The IoT Hub Device Update Agent snap for Ubuntu Core.
How To Configure The Agent
==========================
This snap provides a command called "set-config" that takes configuration file name and base64-encoded binary data as input and saves the decoded data to the $SNAP_DATA/config folder.
Example usage:
sudo deviceupdate-agent.set-config --config-file du-config.json -d "$(base64 /path/to/your/du-config.json)"
For more information:
deviceupdate-agent.set-config --help
grade: devel
confinement: strict
# Use passthrough for the moment, until the appropriate snapcraft release lands
# system-usernames:
# snap_aziotedge: shared
passthrough:
system-usernames:
snap_aziotdu: shared
#####
#
# Keywords
#
# after - Specifies part's dependencies.
# See https://snapcraft.io/docs/parts-lifecycle#heading--step-dependencies
# https://snapcraft.io/docs/parts-lifecycle
# plugin - Specifies a plugin required for building the part.
#
# see also:
# environment variables - https://snapcraft.io/docs/parts-environment-variables
#
#####
parts:
installdeps:
plugin: nil
source: ./scripts
override-build: |
./install-deps.sh --install-cmake --work-folder $SNAPCRAFT_STAGE/du-workfolder --install-shellcheck --install-catch2
build-packages:
- wget
stage-packages:
- libboost-filesystem1.71.0
azure-iot-hub-client-csdk:
after:
- installdeps
source: https://github.com/Azure/azure-iot-sdk-c.git
source-type: git
source-tag: LTS_07_2021_Ref01
plugin: cmake
source-depth: 1
build-packages:
- libcurl4-openssl-dev
- libssl-dev
- uuid-dev
override-build: |
cd $SNAPCRAFT_PART_SRC
git submodule update --init
mkdir -p $SNAPCRAFT_PART_SRC/cmake
pushd $SNAPCRAFT_PART_SRC/cmake
cmake -Duse_amqp:BOOL=OFF -Duse_http:BOOL=ON -Duse_mqtt:BOOL=ON -Duse_wsio:BOOL=ON -Dskip_samples:BOOL=ON -Dbuild_service_client:BOOL=OFF -Dbuild_provisioning_service_client:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Debug -Dskip_samples:BOOL=ON ..
cmake --build .
cmake --build . --target install
azure-blob-stroage-file-upload-utility:
after:
- azure-iot-hub-client-csdk
plugin: nil
source: ./scripts
build-packages:
- git
override-build: |
./install-deps.sh --work-folder $SNAPCRAFT_STAGE/du-workfolder --install-abs-file-upload-utility 6969d0fc9d222a5c132d0b8fb4305697a6017383
deliveryoptimization-sdk:
after:
- installdeps
plugin: nil
source: ./scripts
override-build: |
./install-deps.sh --install-do --do-ref develop --do-cmake-option "-DDO_BUILD_FOR_SNAP=1" --work-folder $SNAPCRAFT_STAGE/du-workfolder
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/lib
cp /usr/local/lib/libdeliveryoptimization.so* $SNAPCRAFT_PART_INSTALL/usr/lib
#
# Agent component
# This is the main agent application.
#
du-agent:
plugin: nil
source: .
stage-snaps:
- deliveryoptimization-agent/beta
override-build: |
./scripts/install-deps.sh --work-folder /tmp --install-cmake
./scripts/build.sh --work-folder /tmp --ubuntu-core-snap-only
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/bin
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/lib/adu
mkdir -p $SNAPCRAFT_PART_INSTALL/var/lib/adu/extensions/sources
mkdir -p $SNAPCRAFT_PART_INSTALL/conf
cp $SNAPCRAFT_PART_BUILD/out/bin/AducIotAgent $SNAPCRAFT_PART_INSTALL/usr/bin/AducIotAgent
cp $SNAPCRAFT_PART_BUILD/out/bin/adu-shell $SNAPCRAFT_PART_INSTALL/usr/lib/adu
chmod u=rx $SNAPCRAFT_PART_INSTALL/usr/lib/adu/adu-shell
cp $SNAPCRAFT_PART_BUILD/out/lib/*.so $SNAPCRAFT_PART_INSTALL/var/lib/adu/extensions/sources
# Require install-deps
after:
- installdeps
- azure-iot-hub-client-csdk
- deliveryoptimization-sdk
- azure-blob-stroage-file-upload-utility
stage:
- usr/bin/*
- usr/lib/*
- usr/lib/adu/*
- var/lib/adu/extensions/sources/*.so
- conf/*.*
stage-packages:
- curl
- libasn1-8-heimdal
- libboost-filesystem1.71.0
- libbrotli1
- libcurl4
- libgssapi3-heimdal
- libhcrypto4-heimdal
- libheimbase1-heimdal
- libheimntlm0-heimdal
- libhx509-5-heimdal
- libicu66
- libkrb5-26-heimdal
- libldap-2.4-2
- libnghttp2-14
- libpsl5
- libroken18-heimdal
- librtmp1
- libsasl2-2
- libssh-4
- libwind0-heimdal
- libxml2
du-agent-commands:
source: .
plugin: nil
override-build: |
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/bin/adu
cp snap-commands/*.* $SNAPCRAFT_PART_INSTALL/usr/bin/adu
stage:
- usr/bin/adu/*
# Install the "jq" package
jq:
plugin: nil
stage-packages:
- jq
apps:
# 'deviceupdate-agent' service
# See document: https://forum.snapcraft.io/t/snapcraft-app-and-service-metadata/8335
deviceupdate-agent:
command: usr/bin/AducIotAgent -l 0 -e
daemon: simple
refresh-mode: restart
restart-condition: on-failure
restart-delay: 10s
plugs:
- home
- network
- snapd-control
- account-control
- hardware-observe
set-config:
command: usr/bin/adu/set-config.sh
plugs:
- home
plugs:
do-port-numbers:
interface: content
content: do-port-numbers
target: $SNAP_DATA/do-port-numbers
do-configs:
interface: content
content: do-configs
target: $SNAP_DATA/do-configs
snapd-control:
interface: snapd-control
identity-service:
interface: content
content: aziot-identity-service
target: $SNAP_DATA
account-control:
interface: account-control
hardware-observe:
interface: hardware-observe
home:
interface: home
# Provides resources to be accssed by other snaps.
slots:
#
# A downloads folder.
#
# Consumer(s):
#
# Delivery Optimization : writes downloaded file to this folder and/or sub-folders.
#
deviceupdate-agent-downloads:
interface: content
content: deviceupdate-agent-downloads
write:
- $SNAP_DATA/data/downloads
environment:
LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET"
layout:
# adu_data_dir
/var/lib/adu:
symlink: $SNAP_DATA/data
/var/lib/deviceupdate-agent-downloads:
symlink: $SNAP_DATA/data/downloads
# adu_conf_dir
/etc/adu:
symlink: $SNAP_DATA/config
# adu_shell_dir
/usr/lib/adu:
symlink: $SNAP/usr/lib/adu
# adu_log_dir
/var/log/adu:
symlink: $SNAP_DATA/log
# curl command
/usr/bin/curl-downloader:
symlink: $SNAP/usr/bin/curl
# aziot config
/etc/aziot:
symlink: $SNAP_DATA/shared/config/aziot
# aziot sockets
/var/sockets/aziot:
symlink: $SNAP_DATA/shared/sockets/aziot