diff options
Diffstat (limited to 'recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb')
-rw-r--r-- | recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb index 4d5ff79..2763185 100644 --- a/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb +++ b/recipes-sota/aktualizr/aktualizr-ca-implicit-prov.bb | |||
@@ -7,67 +7,26 @@ DESCRIPTION = "Configuration for implicitly provisioning Aktualizr using externa | |||
7 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" | 7 | HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" |
8 | SECTION = "base" | 8 | SECTION = "base" |
9 | LICENSE = "MPL-2.0" | 9 | LICENSE = "MPL-2.0" |
10 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=9741c346eef56131163e13b9db1241b3" | 10 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" |
11 | 11 | ||
12 | DEPENDS = "aktualizr-native openssl-native" | 12 | DEPENDS = "aktualizr aktualizr-native openssl-native" |
13 | RDEPENDS_${PN} = "aktualizr" | 13 | RDEPENDS_${PN}_append = "${@' aktualizr-ca-implicit-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS', True) == '1' else ''}" |
14 | 14 | ||
15 | SRC_URI = " \ | ||
16 | file://LICENSE \ | ||
17 | file://ca.cnf \ | ||
18 | " | ||
19 | PV = "1.0" | 15 | PV = "1.0" |
20 | PR = "1" | 16 | PR = "1" |
21 | 17 | ||
22 | require environment.inc | 18 | require environment.inc |
23 | require credentials.inc | 19 | require credentials.inc |
24 | 20 | ||
25 | export SOTA_CACERT_PATH | ||
26 | export SOTA_CAKEY_PATH | ||
27 | |||
28 | do_install() { | 21 | do_install() { |
29 | install -m 0700 -d ${D}${libdir}/sota/conf.d | 22 | install -m 0700 -d ${D}${libdir}/sota/conf.d |
30 | 23 | ||
31 | if [ -z "${SOTA_PACKED_CREDENTIALS}" ]; then | 24 | install -m 0644 ${STAGING_DIR_HOST}${libdir}/sota/sota_implicit_prov_ca.toml \ |
32 | bberror "SOTA_PACKED_CREDENTIALS are required for implicit provisioning" | ||
33 | fi | ||
34 | |||
35 | if [ -z ${SOTA_CACERT_PATH} ]; then | ||
36 | SOTA_CACERT_PATH=${DEPLOY_DIR_IMAGE}/CA/cacert.pem | ||
37 | SOTA_CAKEY_PATH=${DEPLOY_DIR_IMAGE}/CA/ca.private.pem | ||
38 | mkdir -p ${DEPLOY_DIR_IMAGE}/CA | ||
39 | bbwarn "SOTA_CACERT_PATH is not specified, use default one at $SOTA_CACERT_PATH" | ||
40 | |||
41 | if [ ! -f ${SOTA_CACERT_PATH} ]; then | ||
42 | bbwarn "${SOTA_CACERT_PATH} does not exist, generate a new CA" | ||
43 | SOTA_CACERT_DIR_PATH="$(dirname "$SOTA_CACERT_PATH")" | ||
44 | openssl genrsa -out ${SOTA_CACERT_DIR_PATH}/ca.private.pem 4096 | ||
45 | openssl req -key ${SOTA_CACERT_DIR_PATH}/ca.private.pem -new -x509 -days 7300 -out ${SOTA_CACERT_PATH} -subj "/C=DE/ST=Berlin/O=Reis und Kichererbsen e.V/commonName=meta-updater" -batch -config ${WORKDIR}/ca.cnf -extensions cacert | ||
46 | bbwarn "${SOTA_CACERT_PATH} has been created, you'll need to upload it to the server" | ||
47 | fi | ||
48 | fi | ||
49 | |||
50 | if [ -z ${SOTA_CAKEY_PATH} ]; then | ||
51 | bberror "SOTA_CAKEY_PATH should be set when using implicit provisioning" | ||
52 | fi | ||
53 | |||
54 | install -m 0700 -d ${D}${localstatedir}/sota | ||
55 | install -m 0644 ${STAGING_DIR_NATIVE}${libdir}/sota/sota_implicit_prov_ca.toml \ | ||
56 | ${D}${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml | 25 | ${D}${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml |
57 | aktualizr_cert_provider --credentials ${SOTA_PACKED_CREDENTIALS} \ | ||
58 | --device-ca ${SOTA_CACERT_PATH} \ | ||
59 | --device-ca-key ${SOTA_CAKEY_PATH} \ | ||
60 | --root-ca \ | ||
61 | --server-url \ | ||
62 | --local ${D}${localstatedir}/sota \ | ||
63 | --config ${STAGING_DIR_NATIVE}${libdir}/sota/sota_implicit_prov_ca.toml | ||
64 | } | 26 | } |
65 | 27 | ||
66 | FILES_${PN} = " \ | 28 | FILES_${PN} = " \ |
67 | ${libdir}/sota/conf.d \ | ||
68 | ${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml \ | 29 | ${libdir}/sota/conf.d/20-sota_implicit_prov_ca.toml \ |
69 | ${libdir}/sota/root.crt \ | ||
70 | ${localstatedir}/sota/* \ | ||
71 | " | 30 | " |
72 | 31 | ||
73 | # vim:set ts=4 sw=4 sts=4 expandtab: | 32 | # vim:set ts=4 sw=4 sts=4 expandtab: |