diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/image_types_ostree.bbclass | 28 | ||||
-rw-r--r-- | classes/image_types_ota.bbclass | 14 | ||||
-rw-r--r-- | classes/sota_sanity.bbclass | 23 |
3 files changed, 39 insertions, 26 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a8a6c39..051dcf9 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -10,6 +10,7 @@ OSTREE_COMMIT_BODY ??= "" | |||
10 | OSTREE_COMMIT_VERSION ??= "${DISTRO_VERSION}" | 10 | OSTREE_COMMIT_VERSION ??= "${DISTRO_VERSION}" |
11 | OSTREE_UPDATE_SUMMARY ??= "0" | 11 | OSTREE_UPDATE_SUMMARY ??= "0" |
12 | OSTREE_DEPLOY_DEVICETREE ??= "0" | 12 | OSTREE_DEPLOY_DEVICETREE ??= "0" |
13 | OSTREE_DEVICETREE ??= "${KERNEL_DEVICETREE}" | ||
13 | 14 | ||
14 | BUILD_OSTREE_TARBALL ??= "1" | 15 | BUILD_OSTREE_TARBALL ??= "1" |
15 | 16 | ||
@@ -141,9 +142,9 @@ IMAGE_CMD_ostree () { | |||
141 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") | 142 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") |
142 | touch boot/initramfs-${checksum} | 143 | touch boot/initramfs-${checksum} |
143 | else | 144 | else |
144 | if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then | 145 | if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${OSTREE_DEVICETREE}" ]; then |
145 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") | 146 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${OSTREE_DEVICETREE} | sha256sum | cut -f 1 -d " ") |
146 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | 147 | for DTS_FILE in ${OSTREE_DEVICETREE}; do |
147 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) | 148 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) |
148 | cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} | 149 | cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} |
149 | done | 150 | done |
@@ -168,25 +169,20 @@ IMAGE_CMD_ostreecommit () { | |||
168 | fi | 169 | fi |
169 | 170 | ||
170 | # Commit the result | 171 | # Commit the result |
171 | ostree --repo=${OSTREE_REPO} commit \ | 172 | ostree_target_hash=$(ostree --repo=${OSTREE_REPO} commit \ |
172 | --tree=dir=${OSTREE_ROOTFS} \ | 173 | --tree=dir=${OSTREE_ROOTFS} \ |
173 | --skip-if-unchanged \ | 174 | --skip-if-unchanged \ |
174 | --branch=${OSTREE_BRANCHNAME} \ | 175 | --branch=${OSTREE_BRANCHNAME} \ |
175 | --subject="${OSTREE_COMMIT_SUBJECT}" \ | 176 | --subject="${OSTREE_COMMIT_SUBJECT}" \ |
176 | --body="${OSTREE_COMMIT_BODY}" \ | 177 | --body="${OSTREE_COMMIT_BODY}" \ |
177 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ | 178 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ |
178 | --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" | 179 | ${EXTRA_OSTREE_COMMIT}) |
179 | 180 | ||
180 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 181 | echo $ostree_target_hash > ${WORKDIR}/ostree_manifest |
182 | |||
183 | if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then | ||
181 | ostree --repo=${OSTREE_REPO} summary -u | 184 | ostree --repo=${OSTREE_REPO} summary -u |
182 | fi | 185 | fi |
183 | |||
184 | # To enable simultaneous bitbaking of two images with the same branch name, | ||
185 | # create a new ref in the repo using the basename of the image. (This first | ||
186 | # requires deleting it if it already exists.) Fixes OTA-2211. | ||
187 | ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} | ||
188 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) | ||
189 | ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash} | ||
190 | } | 186 | } |
191 | 187 | ||
192 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" | 188 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" |
@@ -201,7 +197,7 @@ IMAGE_CMD_ostreepush () { | |||
201 | 197 | ||
202 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 198 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
203 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then | 199 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then |
204 | garage-push -vv --repo=${OSTREE_REPO} \ | 200 | garage-push --loglevel 0 --repo=${OSTREE_REPO} \ |
205 | --ref=${OSTREE_BRANCHNAME} \ | 201 | --ref=${OSTREE_BRANCHNAME} \ |
206 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | 202 | --credentials=${SOTA_PACKED_CREDENTIALS} \ |
207 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \ | 203 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \ |
@@ -236,7 +232,7 @@ IMAGE_CMD_garagesign () { | |||
236 | --home-dir ${GARAGE_SIGN_REPO} \ | 232 | --home-dir ${GARAGE_SIGN_REPO} \ |
237 | --credentials ${SOTA_PACKED_CREDENTIALS} | 233 | --credentials ${SOTA_PACKED_CREDENTIALS} |
238 | 234 | ||
239 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 235 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
240 | 236 | ||
241 | # Use OSTree target hash as version if none was provided by the user | 237 | # Use OSTree target hash as version if none was provided by the user |
242 | target_version=${ostree_target_hash} | 238 | target_version=${ostree_target_hash} |
@@ -312,7 +308,7 @@ IMAGE_CMD_garagecheck () { | |||
312 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 308 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
313 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 | 309 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 |
314 | 310 | ||
315 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 311 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
316 | 312 | ||
317 | garage-check --ref=${ostree_target_hash} \ | 313 | garage-check --ref=${ostree_target_hash} \ |
318 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | 314 | --credentials=${SOTA_PACKED_CREDENTIALS} \ |
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 374ddc2..a8a19b5 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass | |||
@@ -64,15 +64,25 @@ IMAGE_CMD_ota () { | |||
64 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" | 64 | bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" |
65 | fi | 65 | fi |
66 | 66 | ||
67 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 67 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
68 | 68 | ||
69 | # Use OSTree hash to avoid any potential race conditions between | ||
70 | # multiple builds accessing the same ${OSTREE_REPO}. | ||
69 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} | 71 | ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} |
70 | kargs_list="" | 72 | kargs_list="" |
71 | for arg in ${OSTREE_KERNEL_ARGS}; do | 73 | for arg in ${OSTREE_KERNEL_ARGS}; do |
72 | kargs_list="${kargs_list} --karg-append=$arg" | 74 | kargs_list="${kargs_list} --karg-append=$arg" |
73 | done | 75 | done |
74 | 76 | ||
75 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${ostree_target_hash} | 77 | # Create the same reference on the device we use in the archive OSTree |
78 | # repo in ${OSTREE_REPO}. This reference will show up when showing the | ||
79 | # deployment on the device: | ||
80 | # ostree admin status | ||
81 | # If a remote with the name ${OSTREE_OSNAME} is configured, this also | ||
82 | # will allow to use: | ||
83 | # ostree admin upgrade | ||
84 | ostree --repo=${OTA_SYSROOT}/ostree/repo refs --create=${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} ${ostree_target_hash} | ||
85 | ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} | ||
76 | 86 | ||
77 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true | 87 | cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true |
78 | # Create /var/sota if it doesn't exist yet | 88 | # Create /var/sota if it doesn't exist yet |
diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass index 74973eb..02ca2e7 100644 --- a/classes/sota_sanity.bbclass +++ b/classes/sota_sanity.bbclass | |||
@@ -1,5 +1,12 @@ | |||
1 | # Sanity check the sota setup for common misconfigurations | 1 | # Sanity check the sota setup for common misconfigurations |
2 | 2 | ||
3 | def sota_check_boolean_variable(var, d): | ||
4 | try: | ||
5 | oe.types.boolean(d.getVar(var)) | ||
6 | except: | ||
7 | return False | ||
8 | return True | ||
9 | |||
3 | def sota_check_overrides(status, d): | 10 | def sota_check_overrides(status, d): |
4 | for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST') or "").split(): | 11 | for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST') or "").split(): |
5 | if var in d.getVar('OVERRIDES').split(':'): | 12 | if var in d.getVar('OVERRIDES').split(':'): |
@@ -47,14 +54,14 @@ def sota_check_variables_validity(status, d): | |||
47 | path = os.path.abspath(credentials) | 54 | path = os.path.abspath(credentials) |
48 | if not os.path.exists(path): | 55 | if not os.path.exists(path): |
49 | status.addresult("SOTA_PACKED_CREDENTIALS is not set correctly. The zipped credentials file does not exist.\n") | 56 | status.addresult("SOTA_PACKED_CREDENTIALS is not set correctly. The zipped credentials file does not exist.\n") |
50 | if d.getVar("OSTREE_UPDATE_SUMMARY") and d.getVar("OSTREE_UPDATE_SUMMARY") not in ("0", "1", ""): | 57 | if not sota_check_boolean_variable("OSTREE_UPDATE_SUMMARY", d): |
51 | status.addresult("OSTREE_UPDATE_SUMMARY should be set to 0 or 1.\n") | 58 | status.addresult("OSTREE_UPDATE_SUMMARY (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_UPDATE_SUMMARY")) |
52 | if d.getVar("OSTREE_DEPLOY_DEVICETREE") and d.getVar("OSTREE_DEPLOY_DEVICETREE") not in ("0", "1", ""): | 59 | if not sota_check_boolean_variable("OSTREE_DEPLOY_DEVICETREE", d): |
53 | status.addresult("OSTREE_DEPLOY_DEVICETREE should be set to 0 or 1.\n") | 60 | status.addresult("OSTREE_DEPLOY_DEVICETREE (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_DEPLOY_DEVICETREE")) |
54 | if d.getVar("GARAGE_SIGN_AUTOVERSION") and d.getVar("GARAGE_SIGN_AUTOVERSION") not in ("0", "1", ""): | 61 | if not sota_check_boolean_variable("GARAGE_SIGN_AUTOVERSION", d): |
55 | status.addresult("GARAGE_SIGN_AUTOVERSION should be set to 0 or 1.\n") | 62 | status.addresult("GARAGE_SIGN_AUTOVERSION (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("GARAGE_SIGN_AUTOVERSION")) |
56 | if d.getVar("SOTA_DEPLOY_CREDENTIALS") and d.getVar("SOTA_DEPLOY_CREDENTIALS") not in ("0", "1", ""): | 63 | if not sota_check_boolean_variable("SOTA_DEPLOY_CREDENTIALS", d): |
57 | status.addresult("SOTA_DEPLOY_CREDENTIALS should be set to 0 or 1.\n") | 64 | status.addresult("SOTA_DEPLOY_CREDENTIALS (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("SOTA_DEPLOY_CREDENTIALS")) |
58 | 65 | ||
59 | def sota_raise_sanity_error(msg, d): | 66 | def sota_raise_sanity_error(msg, d): |
60 | if d.getVar("SANITY_USE_EVENTS") == "1": | 67 | if d.getVar("SANITY_USE_EVENTS") == "1": |