summaryrefslogtreecommitdiffstats
path: root/classes/image_types_ostree.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'classes/image_types_ostree.bbclass')
-rw-r--r--classes/image_types_ostree.bbclass80
1 files changed, 27 insertions, 53 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 05c73ff..41b8d0d 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -1,42 +1,28 @@
1# OSTree deployment 1# OSTree deployment
2 2
3do_image_ostree[depends] += "ostree-native:do_populate_sysroot \
4 openssl-native:do_populate_sysroot \
5 coreutils-native:do_populate_sysroot \
6 unzip-native:do_populate_sysroot \
7 virtual/kernel:do_deploy \
8 ${INITRAMFS_IMAGE}:do_image_complete \
9"
10do_image_ostree[lockfiles] += "${OSTREE_REPO}/ostree.lock"
11
12export OSTREE_REPO
13export OSTREE_BRANCHNAME
14export GARAGE_TARGET_NAME
15
16OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" 3OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}"
17 4OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs"
18OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" 5OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}"
19OSTREE_COMMIT_BODY ??= "" 6OSTREE_COMMIT_BODY ??= ""
20OSTREE_UPDATE_SUMMARY ??= "0" 7OSTREE_UPDATE_SUMMARY ??= "0"
21 8
22export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" 9BUILD_OSTREE_TARBALL ??= "1"
23 10
24IMAGE_CMD_ostree () { 11SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}"
25 if [ -z "$OSTREE_REPO" ]; then
26 bbfatal "OSTREE_REPO should be set in your local.conf"
27 fi
28 12
29 if [ -z "$OSTREE_BRANCHNAME" ]; then 13IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*"
30 bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" 14CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}; ${IMAGE_CMD_TAR} --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.tar -C ${OTA_IMAGE_ROOTFS} . || [ $? -eq 1 ]"
31 fi 15CONVERSIONTYPES_append = " tar"
32 16
33 OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` 17OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}"
34 cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} 18do_image_ostree[dirs] = "${OSTREE_ROOTFS}"
19do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}"
20do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete"
21IMAGE_CMD_ostree () {
22 cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS}
35 chmod a+rx ${OSTREE_ROOTFS} 23 chmod a+rx ${OSTREE_ROOTFS}
36 sync 24 sync
37 25
38 cd ${OSTREE_ROOTFS}
39
40 for d in var/*; do 26 for d in var/*; do
41 if [ "${d}" != "var/local" ]; then 27 if [ "${d}" != "var/local" ]; then
42 rm -rf ${d} 28 rm -rf ${d}
@@ -64,7 +50,7 @@ IMAGE_CMD_ostree () {
64 fi 50 fi
65 done 51 done
66 52
67 if [ -n "$SYSTEMD_USED" ]; then 53 if [ -n "${SYSTEMD_USED}" ]; then
68 mkdir -p usr/etc/tmpfiles.d 54 mkdir -p usr/etc/tmpfiles.d
69 tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf 55 tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf
70 echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} 56 echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf}
@@ -100,7 +86,7 @@ IMAGE_CMD_ostree () {
100 bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" 86 bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr"
101 fi 87 fi
102 88
103 if [ -n "$SYSTEMD_USED" ]; then 89 if [ -n "${SYSTEMD_USED}" ]; then
104 echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} 90 echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf}
105 else 91 else
106 echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} 92 echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf}
@@ -112,11 +98,10 @@ IMAGE_CMD_ostree () {
112 98
113 if [ -d root ] && [ ! -L root ]; then 99 if [ -d root ] && [ ! -L root ]; then
114 if [ "$(ls -A root)" ]; then 100 if [ "$(ls -A root)" ]; then
115 bberror "Data in /root directory is not preserved by OSTree." 101 bbfatal "Data in /root directory is not preserved by OSTree."
116 exit 1
117 fi 102 fi
118 103
119 if [ -n "$SYSTEMD_USED" ]; then 104 if [ -n "${SYSTEMD_USED}" ]; then
120 echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} 105 echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf}
121 else 106 else
122 echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} 107 echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf}
@@ -140,17 +125,12 @@ IMAGE_CMD_ostree () {
140 125
141 # Copy image manifest 126 # Copy image manifest
142 cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest 127 cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest
128}
143 129
144 cd ${WORKDIR} 130IMAGE_TYPEDEP_ostreecommit = "ostree"
145 131do_image_ostreecommit[depends] += "ostree-native:do_populate_sysroot"
146 # Create a tarball that can be then commited to OSTree repo 132do_image_ostreecommit[lockfiles] += "${WORKDIR}/${OSTREE_REPO}-commit.lock"
147 OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 133IMAGE_CMD_ostreecommit () {
148 tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} .
149 sync
150
151 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2
152 ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2
153
154 if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then 134 if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then
155 ostree --repo=${OSTREE_REPO} init --mode=archive-z2 135 ostree --repo=${OSTREE_REPO} init --mode=archive-z2
156 fi 136 fi
@@ -166,11 +146,9 @@ IMAGE_CMD_ostree () {
166 if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then 146 if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then
167 ostree --repo=${OSTREE_REPO} summary -u 147 ostree --repo=${OSTREE_REPO} summary -u
168 fi 148 fi
169
170 rm -rf ${OSTREE_ROOTFS}
171} 149}
172 150
173IMAGE_TYPEDEP_ostreepush = "ostree" 151IMAGE_TYPEDEP_ostreepush = "ostreecommit"
174do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" 152do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot"
175IMAGE_CMD_ostreepush () { 153IMAGE_CMD_ostreepush () {
176 # Print warnings if credetials are not set or if the file has not been found. 154 # Print warnings if credetials are not set or if the file has not been found.
@@ -189,7 +167,7 @@ IMAGE_CMD_ostreepush () {
189} 167}
190 168
191IMAGE_TYPEDEP_garagesign = "ostreepush" 169IMAGE_TYPEDEP_garagesign = "ostreepush"
192do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" 170do_image_garagesign[depends] += "unzip-native:do_populate_sysroot"
193IMAGE_CMD_garagesign () { 171IMAGE_CMD_garagesign () {
194 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then 172 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
195 # if credentials are issued by a server that doesn't support offline signing, exit silently 173 # if credentials are issued by a server that doesn't support offline signing, exit silently
@@ -197,11 +175,9 @@ IMAGE_CMD_garagesign () {
197 175
198 java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) 176 java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' )
199 if [ "${java_version}" = "" ]; then 177 if [ "${java_version}" = "" ]; then
200 bberror "Java is required for synchronization with update backend, but is not installed on the host machine" 178 bbfatal "Java is required for synchronization with update backend, but is not installed on the host machine"
201 exit 1
202 elif [ "${java_version}" \< "1.8" ]; then 179 elif [ "${java_version}" \< "1.8" ]; then
203 bberror "Java version >= 8 is required for synchronization with update backend" 180 bbfatal "Java version >= 8 is required for synchronization with update backend"
204 exit 1
205 fi 181 fi
206 182
207 rm -rf ${GARAGE_SIGN_REPO} 183 rm -rf ${GARAGE_SIGN_REPO}
@@ -252,14 +228,12 @@ IMAGE_CMD_garagesign () {
252 rm -rf ${GARAGE_SIGN_REPO} 228 rm -rf ${GARAGE_SIGN_REPO}
253 229
254 if [ "$push_success" -ne "1" ]; then 230 if [ "$push_success" -ne "1" ]; then
255 bberror "Couldn't push to garage repository" 231 bbfatal "Couldn't push to garage repository"
256 exit 1
257 fi 232 fi
258 fi 233 fi
259} 234}
260 235
261IMAGE_TYPEDEP_garagecheck = "ostreepush garagesign" 236IMAGE_TYPEDEP_garagecheck = "garagesign"
262do_image_garagecheck[depends] += "aktualizr-native:do_populate_sysroot"
263IMAGE_CMD_garagecheck () { 237IMAGE_CMD_garagecheck () {
264 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then 238 if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
265 # if credentials are issued by a server that doesn't support offline signing, exit silently 239 # if credentials are issued by a server that doesn't support offline signing, exit silently