summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2018-10-12 15:38:32 +0200
committerStefan Agner <stefan.agner@toradex.com>2018-10-12 15:51:47 +0200
commit412cfd9a1f139fd56ca66d312c7df22aafd02e48 (patch)
treed25e3b5af25c2617ee1da4f8944b76e6c9d67939
parent227bd6d5b806bb15e4dc3f286f07f9cb563d228c (diff)
downloadmeta-updater-412cfd9a1f139fd56ca66d312c7df22aafd02e48.tar.gz
image_types_ota: simplify image creation
Almost all code in create_ota is either tar or ext4 specific. Move the code directly into the respective IMAGE_CMD_ functions. This gets rid of unnecessary work for the tar image and simplifies code. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--classes/image_types_ota.bbclass43
1 files changed, 15 insertions, 28 deletions
diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass
index 8b363cc..929d092 100644
--- a/classes/image_types_ota.bbclass
+++ b/classes/image_types_ota.bbclass
@@ -122,48 +122,35 @@ fakeroot do_otasetup () {
122 rm -rf ${HOME_TMP} 122 rm -rf ${HOME_TMP}
123} 123}
124 124
125## Specific image creation 125IMAGE_CMD_ota-ext4 () {
126create_ota () {
127 FS_TYPE=${1}
128 # Calculate image type 126 # Calculate image type
129 OTA_ROOTFS_SIZE=$(calculate_size `du -ks $OTA_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}") 127 OTA_ROOTFS_SIZE=$(calculate_size `du -ks $OTA_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}")
130 128
131 if [ $OTA_ROOTFS_SIZE -lt 0 ]; then 129 if [ $OTA_ROOTFS_SIZE -lt 0 ]; then
132 exit -1 130 bbfatal "create_ota failed to calculate OTA rootfs size!"
133 fi 131 fi
132
134 eval local COUNT=\"0\" 133 eval local COUNT=\"0\"
135 eval local MIN_COUNT=\"60\" 134 eval local MIN_COUNT=\"60\"
136 if [ $OTA_ROOTFS_SIZE -lt $MIN_COUNT ]; then 135 if [ $OTA_ROOTFS_SIZE -lt $MIN_COUNT ]; then
137 eval COUNT=\"$MIN_COUNT\" 136 eval COUNT=\"$MIN_COUNT\"
138 fi 137 fi
139 138
140 # create image 139 rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg
141 if [ "${FS_TYPE}" = "ext4" ]; then 140 sync
142 rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg 141 dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg seek=${OTA_ROOTFS_SIZE} count=$COUNT bs=1024
143 sync 142 mkfs.ext4 -O ^64bit ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg -L otaroot -d ${OTA_SYSROOT}
144 dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg seek=${OTA_ROOTFS_SIZE} count=$COUNT bs=1024 143 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg
145 mkfs.ext4 -O ^64bit ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg -L otaroot -d ${OTA_SYSROOT} 144 ln -s ${IMAGE_NAME}.otaimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg
146 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg
147 ln -s ${IMAGE_NAME}.otaimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg
148 elif [ "${FS_TYPE}" = "tar" ]; then
149 rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg.tar
150 tar -cf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg.tar -C ${OTA_SYSROOT} .
151 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar
152 ln -s ${IMAGE_NAME}.otaimg.tar ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar
153 # To fit in with the rest of yocto's image utils, we create a rootfs.ota-tar in the deploy dir
154 cp ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar ${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.ota-tar
155 else
156 rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg*
157 bbfatal "create_ota Function called with unknown or unspecified FS_TYPE of ${FS_TYPE}. Failing!"
158 fi
159}
160
161IMAGE_CMD_ota-ext4 () {
162 create_ota "ext4"
163} 145}
164 146
165IMAGE_CMD_ota-tar () { 147IMAGE_CMD_ota-tar () {
166 create_ota "tar" 148 rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg.tar
149 tar -cf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg.tar -C ${OTA_SYSROOT} .
150 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar
151 ln -s ${IMAGE_NAME}.otaimg.tar ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar
152 # To fit in with the rest of yocto's image utils, we create a rootfs.ota-tar in the deploy dir
153 cp ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg.tar ${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.ota-tar
167} 154}
168 155
169do_otasetup[doc] = "Sets up the base ota rootfs used for subsequent image generation" 156do_otasetup[doc] = "Sets up the base ota rootfs used for subsequent image generation"