diff options
-rw-r--r-- | classes/image_types_ota.bbclass | 43 |
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 | 125 | IMAGE_CMD_ota-ext4 () { |
126 | create_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 | |||
161 | IMAGE_CMD_ota-ext4 () { | ||
162 | create_ota "ext4" | ||
163 | } | 145 | } |
164 | 146 | ||
165 | IMAGE_CMD_ota-tar () { | 147 | IMAGE_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 | ||
169 | do_otasetup[doc] = "Sets up the base ota rootfs used for subsequent image generation" | 156 | do_otasetup[doc] = "Sets up the base ota rootfs used for subsequent image generation" |