diff options
author | Anton Gerasimov <anton@advancedtelematic.com> | 2017-04-24 13:59:21 +0200 |
---|---|---|
committer | Anton Gerasimov <anton@advancedtelematic.com> | 2017-04-24 13:59:21 +0200 |
commit | abe6250af91c4b3193511f4dd5fbfb7ee40d76d5 (patch) | |
tree | 040bcd7509accf453145b2c0c77b06d8e35a13e9 /meta-sota/classes | |
parent | e4bc8c7058fbf27969a967a5e30f15fcf22544bd (diff) |
Wipe out sota-related codeeel_4.99.3eel_4.99.2eel_4.99.1eel/4.99.3eel/4.99.2eel/4.99.1dab_3.99.1dab/3.99.14.99.34.99.24.99.13.99.1
Moved to meta-updater@github.com/advancedtelenmatic
Change-Id: I7c89d373e43a88a89155c72de87c0b4b5238bc52
Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
Diffstat (limited to 'meta-sota/classes')
-rw-r--r-- | meta-sota/classes/image_types_ostree.bbclass | 143 | ||||
-rw-r--r-- | meta-sota/classes/image_types_ota.bbclass | 127 | ||||
-rw-r--r-- | meta-sota/classes/sdcard_image-dra7xx-evm-ota.bbclass | 75 | ||||
-rw-r--r-- | meta-sota/classes/sdcard_image-porter-ota.bbclass | 78 | ||||
-rw-r--r-- | meta-sota/classes/sdcard_image-rpi-ota.bbclass | 196 |
5 files changed, 0 insertions, 619 deletions
diff --git a/meta-sota/classes/image_types_ostree.bbclass b/meta-sota/classes/image_types_ostree.bbclass deleted file mode 100644 index 1bbeb2d..0000000 --- a/meta-sota/classes/image_types_ostree.bbclass +++ /dev/null @@ -1,143 +0,0 @@ -# OSTree deployment - -inherit image - -IMAGE_DEPENDS_ostree = "ostree-native:do_populate_sysroot \ - virtual/kernel:do_deploy \ - ${OSTREE_INITRAMFS_IMAGE}:do_image_complete" - -export OSTREE_REPO -export OSTREE_BRANCHNAME - -RAMDISK_EXT ?= ".ext4.gz" -RAMDISK_EXT_arm ?= ".ext4.gz.u-boot" - -OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" - -IMAGE_CMD_ostree () { - if [ -z "$OSTREE_REPO" ]; then - bbfatal "OSTREE_REPO should be set in your local.conf" - fi - - if [ -z "$OSTREE_BRANCHNAME" ]; then - bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" - fi - - OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` - cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} - chmod a+rx ${OSTREE_ROOTFS} - sync - - cd ${OSTREE_ROOTFS} - - # Create sysroot directory to which physical sysroot will be mounted - mkdir sysroot - ln -sf sysroot/ostree ostree - - rm -rf tmp/* - ln -sf sysroot/tmp tmp - - mkdir -p usr/rootdirs - - mv etc usr/ - # Implement UsrMove - dirs="bin sbin lib" - - for dir in ${dirs} ; do - if [ -d ${dir} ] && [ ! -L ${dir} ] ; then - mv ${dir} usr/rootdirs/ - rm -rf ${dir} - ln -sf usr/rootdirs/${dir} ${dir} - fi - done - - if [ ! -d "usr/etc/tmpfiles.d" ]; then - mkdir usr/etc/tmpfiles.d - fi - tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf - - echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} - echo "L /var/rootdirs/home - - - - /sysroot/home" >>${tmpfiles_conf} - - # Preserve OSTREE_BRANCHNAME for future information - mkdir -p usr/share/sota/ - echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname - # Preserve data in /home to be later copied to /sysroot/home by - # sysroot generating procedure - mkdir -p usr/homedirs - if [ -d "home" ] && [ ! -L "home" ]; then - mv home usr/homedirs/home - ln -sf var/rootdirs/home home - fi - - # Move persistent directories to /var - dirs="opt mnt media srv" - - for dir in ${dirs}; do - if [ -d ${dir} ] && [ ! -L ${dir} ]; then - if [ "$(ls -A $dir)" ]; then - bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" - fi - echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} - rm -rf ${dir} - ln -sf var/rootdirs/${dir} ${dir} - fi - done - - if [ -d root ] && [ ! -L root ]; then - if [ "$(ls -A root)" ]; then - bberror "Data in /root directory is not preserved by OSTree." - fi - echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} - rm -rf root - ln -sf var/roothome root - fi - - # Creating boot directories is required for "ostree admin deploy" - - mkdir -p boot/loader.0 - mkdir -p boot/loader.1 - ln -sf boot/loader.0 boot/loader - - checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "` - - cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} - cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum} - - # Copy image manifest - cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest - - cd ${WORKDIR} - - # Create a tarball that can be then commited to OSTree repo - OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 - tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . - sync - - rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 - ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 - - if [ ! -d ${OSTREE_REPO} ]; then - ostree --repo=${OSTREE_REPO} init --mode=archive-z2 - fi - - # Commit the result - ostree --repo=${OSTREE_REPO} commit \ - --tree=dir=${OSTREE_ROOTFS} \ - --skip-if-unchanged \ - --branch=${OSTREE_BRANCHNAME} \ - --subject="Commit-id: ${IMAGE_NAME}" - - rm -rf ${OSTREE_ROOTFS} -} - -IMAGE_TYPEDEP_ostreepush = "ostree" -IMAGE_DEPENDS_ostreepush = "sota-tools-native:do_populate_sysroot" -IMAGE_CMD_ostreepush () { - if [ ${OSTREE_PUSH_CREDENTIALS} ]; then - garage-push --repo=${OSTREE_REPO} \ - --ref=${OSTREE_BRANCHNAME} \ - --credentials=${OSTREE_PUSH_CREDENTIALS} \ - --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt - fi -} diff --git a/meta-sota/classes/image_types_ota.bbclass b/meta-sota/classes/image_types_ota.bbclass deleted file mode 100644 index d2d9991..0000000 --- a/meta-sota/classes/image_types_ota.bbclass +++ /dev/null @@ -1,127 +0,0 @@ -# Image to use with u-boot as BIOS and OSTree deployment system - -#inherit image_types - -# Boot filesystem size in MiB -# OSTree updates may require some space on boot file system for -# boot scripts, kernel and initramfs images -# - -inherit image - -OSTREE_BOOTLOADER ??= 'u-boot' - -IMAGE_DEPENDS_otaimg = "e2fsprogs-native:do_populate_sysroot \ - ${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER', True) == 'grub' else ''} \ - ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot' else ''}" - -calculate_size () { - BASE=$1 - SCALE=$2 - MIN=$3 - MAX=$4 - EXTRA=$5 - ALIGN=$6 - - SIZE=`echo "$BASE * $SCALE" | bc -l` - REM=`echo $SIZE | cut -d "." -f 2` - SIZE=`echo $SIZE | cut -d "." -f 1` - - if [ -n "$REM" -o ! "$REM" -eq 0 ]; then - SIZE=`expr $SIZE \+ 1` - fi - - if [ "$SIZE" -lt "$MIN" ]; then - $SIZE=$MIN - fi - - SIZE=`expr $SIZE \+ $EXTRA` - SIZE=`expr $SIZE \+ $ALIGN \- 1` - SIZE=`expr $SIZE \- $SIZE \% $ALIGN` - - if [ -n "$MAX" ]; then - if [ "$SIZE" -gt "$MAX" ]; then - return -1 - fi - fi - - echo "${SIZE}" -} - -export OSTREE_OSNAME -export OSTREE_BRANCHNAME -export OSTREE_REPO -export OSTREE_BOOTLOADER - -IMAGE_CMD_otaimg () { - if ${@bb.utils.contains('IMAGE_FSTYPES', 'otaimg', 'true', 'false', d)}; then - if [ -z "$OSTREE_REPO" ]; then - bbfatal "OSTREE_REPO should be set in your local.conf" - fi - - if [ -z "$OSTREE_OSNAME" ]; then - bbfatal "OSTREE_OSNAME should be set in your local.conf" - fi - - if [ -z "$OSTREE_BRANCHNAME" ]; then - bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" - fi - - - PHYS_SYSROOT=`mktemp -d ${WORKDIR}/ota-sysroot-XXXXX` - - ostree admin --sysroot=${PHYS_SYSROOT} init-fs ${PHYS_SYSROOT} - ostree admin --sysroot=${PHYS_SYSROOT} os-init ${OSTREE_OSNAME} - - mkdir -p ${PHYS_SYSROOT}/boot/loader.0 - ln -s loader.0 ${PHYS_SYSROOT}/boot/loader - - if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then - mkdir -p ${PHYS_SYSROOT}/boot/grub2 - touch ${PHYS_SYSROOT}/boot/grub2/grub.cfg - elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then - touch ${PHYS_SYSROOT}/boot/loader/uEnv.txt - else - bberror "Invalid bootloader: ${OSTREE_BOOTLOADER}" - fi; - - ostree --repo=${PHYS_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${OSTREE_BRANCHNAME} - export OSTREE_BOOT_PARTITION="/boot" - kargs_list="" - for arg in ${OSTREE_KERNEL_ARGS}; do - kargs_list="${kargs_list} --karg-append=$arg" - done - - ostree admin --sysroot=${PHYS_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} - - # Copy deployment /home and /var/sota to sysroot - HOME_TMP=`mktemp -d ${WORKDIR}/home-tmp-XXXXX` - tar --xattrs --xattrs-include='*' -C ${HOME_TMP} -xf ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 ./usr/homedirs ./var/sota || true - mv ${HOME_TMP}/usr/homedirs/home ${PHYS_SYSROOT}/ - mv ${HOME_TMP}/var/sota ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true - rm -rf ${HOME_TMP} - - OTA_ROOTFS_SIZE=$(calculate_size `du -ks $PHYS_SYSROOT | cut -f 1` "${IMAGE_OVERHEAD_FACTOR}" "${IMAGE_ROOTFS_SIZE}" "${IMAGE_ROOTFS_MAXSIZE}" `expr ${IMAGE_ROOTFS_EXTRA_SPACE}` "${IMAGE_ROOTFS_ALIGNMENT}") - - if [ $OTA_ROOTFS_SIZE -lt 0 ]; then - exit -1 - fi - eval local COUNT=\"0\" - eval local MIN_COUNT=\"60\" - if [ $OTA_ROOTFS_SIZE -lt $MIN_COUNT ]; then - eval COUNT=\"$MIN_COUNT\" - fi - - rm -rf ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg - sync - dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg seek=$OTA_ROOTFS_SIZE count=$COUNT bs=1024 - mkfs.ext4 -O ^64bit ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.otaimg -d ${PHYS_SYSROOT} - - rm -rf ${PHYS_SYSROOT} - - rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg - ln -s ${IMAGE_NAME}.otaimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.otaimg - fi -} - -IMAGE_TYPEDEP_otaimg = "ostree" diff --git a/meta-sota/classes/sdcard_image-dra7xx-evm-ota.bbclass b/meta-sota/classes/sdcard_image-dra7xx-evm-ota.bbclass deleted file mode 100644 index 179ed10..0000000 --- a/meta-sota/classes/sdcard_image-dra7xx-evm-ota.bbclass +++ /dev/null @@ -1,75 +0,0 @@ -inherit image_types - -# Boot partition volume id -BOOTDD_VOLUME_ID ?= "${MACHINE}" - -# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) -BOOT_SPACE ?= "4096" - -IMAGE_ROOTFS_ALIGNMENT = "4096" -SDIMG_OTA_ROOTFS_TYPE ?= "otaimg" -SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}" - -IMAGE_TYPEDEP_dra7xx-evm-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" -IMAGE_DEPENDS_dra7xx-evm-sdimg-ota = " \ - parted-native \ - mtools-native \ - dosfstools-native \ - " - -SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.dra7xx-evm-sdimg-ota" - -IMAGE_CMD_dra7xx-evm-sdimg-ota () { - OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1` - OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) - SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE) - - echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB" - - # Initialize sdcard image file - dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE} - - # Create partition table - parted -s ${SDIMG_OTA} mklabel msdos - # Create boot partition and mark it as bootable - parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) - parted -s ${SDIMG_OTA} set 1 boot on - # Create rootfs partition to the end of disk - parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s - parted ${SDIMG_OTA} print - - # Create a vfat image with boot files - BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') - rm -f ${WORKDIR}/boot.img - mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS - sync - - sync - #dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - - if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz" - then - xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - else - dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - fi - - # Optionally apply compression - case "${SDIMG_OTA_COMPRESSION}" in - "gzip") - gzip -k9 "${SDIMG_OTA}" - ;; - "bzip2") - bzip2 -k9 "${SDIMG_OTA}" - ;; - "xz") - xz -k "${SDIMG_OTA}" - ;; - esac - - rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.dra7xx-evm-sdimg-ota - ln -s ${IMAGE_NAME}.rootfs.dra7xx-evm-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.dra7xx-evm-sdimg-ota -} - diff --git a/meta-sota/classes/sdcard_image-porter-ota.bbclass b/meta-sota/classes/sdcard_image-porter-ota.bbclass deleted file mode 100644 index a9619dc..0000000 --- a/meta-sota/classes/sdcard_image-porter-ota.bbclass +++ /dev/null @@ -1,78 +0,0 @@ -inherit image_types - -# Boot partition volume id -BOOTDD_VOLUME_ID ?= "${MACHINE}" - -# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) -BOOT_SPACE ?= "4096" - -IMAGE_ROOTFS_ALIGNMENT = "4096" -SDIMG_OTA_ROOTFS_TYPE ?= "otaimg" -SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}" - -IMAGE_TYPEDEP_porter-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" -IMAGE_DEPENDS_porter-sdimg-ota = " \ - parted-native \ - mtools-native \ - dosfstools-native \ - porter-bootfiles \ - " - -SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.porter-sdimg-ota" - -IMAGE_CMD_porter-sdimg-ota () { - OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1` - OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) - SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE) - - echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB" - - # Initialize sdcard image file - dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE} - - # Create partition table - parted -s ${SDIMG_OTA} mklabel msdos - # Create boot partition and mark it as bootable - parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) - parted -s ${SDIMG_OTA} set 1 boot on - # Create rootfs partition to the end of disk - parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s - parted ${SDIMG_OTA} print - - # Create a vfat image with boot files - BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') - rm -f ${WORKDIR}/boot.img - mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS - sync - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/porter-bootfiles/* ::/ - - sync - dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - - if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz" - then - xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - else - dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - fi - - # Optionally apply compression - case "${SDIMG_OTA_COMPRESSION}" in - "gzip") - gzip -k9 "${SDIMG_OTA}" - ;; - "bzip2") - bzip2 -k9 "${SDIMG_OTA}" - ;; - "xz") - xz -k "${SDIMG_OTA}" - ;; - esac - - rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.porter-sdimg-ota - ln -s ${IMAGE_NAME}.rootfs.porter-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.porter-sdimg-ota -} - diff --git a/meta-sota/classes/sdcard_image-rpi-ota.bbclass b/meta-sota/classes/sdcard_image-rpi-ota.bbclass deleted file mode 100644 index deea8d1..0000000 --- a/meta-sota/classes/sdcard_image-rpi-ota.bbclass +++ /dev/null @@ -1,196 +0,0 @@ -inherit image_types -inherit linux-raspberrypi-base - -# -# Create an image that can by written onto a SD card using dd. -# -# The disk layout used is: -# -# 0 -> IMAGE_ROOTFS_ALIGNMENT - reserved for other data -# IMAGE_ROOTFS_ALIGNMENT -> BOOT_SPACE - bootloader and kernel -# BOOT_SPACE -> SDIMG_OTA_SIZE - rootfs -# - -# Default Free space = 1.3x -# Use IMAGE_OVERHEAD_FACTOR to add more space -# <---------> -# 4MiB 40MiB SDIMG_OTA_ROOTFS -# <-----------------------> <----------> <----------------------> -# ------------------------ ------------ ------------------------ -# | IMAGE_ROOTFS_ALIGNMENT | BOOT_SPACE | OTAROOT_SIZE | -# ------------------------ ------------ ------------------------ -# ^ ^ ^ ^ -# | | | | -# 0 4MiB 4MiB + 40MiB 4MiB + 40Mib + SDIMG_OTA_ROOTFS - -# This image depends on the rootfs image -IMAGE_TYPEDEP_rpi-sdimg-ota = "${SDIMG_OTA_ROOTFS_TYPE}" - -# Set kernel and boot loader -IMAGE_BOOTLOADER ?= "bcm2835-bootfiles" - -# Set initramfs extension -KERNEL_INITRAMFS ?= "" - -# Kernel image name -SDIMG_OTA_KERNELIMAGE_raspberrypi ?= "kernel.img" -SDIMG_OTA_KERNELIMAGE_raspberrypi2 ?= "kernel7.img" - -# Boot partition volume id -BOOTDD_VOLUME_ID ?= "${MACHINE}" - -# Boot partition size [in KiB] (will be rounded up to IMAGE_ROOTFS_ALIGNMENT) -BOOT_SPACE ?= "40960" - -# Set alignment to 4MB [in KiB] -IMAGE_ROOTFS_ALIGNMENT = "4096" - -# Use an uncompressed ext3 by default as rootfs -SDIMG_OTA_ROOTFS_TYPE ?= "otaimg" -SDIMG_OTA_ROOTFS = "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.${SDIMG_OTA_ROOTFS_TYPE}" - -IMAGE_DEPENDS_rpi-sdimg-ota = " \ - parted-native \ - mtools-native \ - dosfstools-native \ - virtual/kernel:do_deploy \ - ${IMAGE_BOOTLOADER} \ - u-boot \ - " -IMAGE_TYPEDEP_rpi-sdimg-ota = "otaimg" - -# SD card image name -SDIMG_OTA = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.rpi-sdimg-ota" - -# Compression method to apply to SDIMG_OTA after it has been created. Supported -# compression formats are "gzip", "bzip2" or "xz". The original .rpi-sdimg-ota file -# is kept and a new compressed file is created if one of these compression -# formats is chosen. If SDIMG_OTA_COMPRESSION is set to any other value it is -# silently ignored. -#SDIMG_OTA_COMPRESSION ?= "" - -# Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS. -FATPAYLOAD ?= "" - -IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}" -IMAGE_CMD_rpi-sdimg-ota[vardepsexclude] += "IMAGEDATESTAMP" -IMAGE_CMD_rpi-sdimg-ota[vardepsexclude] += "DATETIME" - -IMAGE_CMD_rpi-sdimg-ota () { - - # Align partitions - OTAROOT_SIZE=`du -Lb ${SDIMG_OTA_ROOTFS} | cut -f1` - OTAROOT_SIZE=$(expr ${OTAROOT_SIZE} / 1024 + 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) - BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) - SDIMG_OTA_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $OTAROOT_SIZE) - - echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $OTAROOT_SIZE KiB" - - # Check if we are building with device tree support - DTS="${@get_dts(d, None)}" - - # Initialize sdcard image file - dd if=/dev/zero of=${SDIMG_OTA} bs=1024 count=0 seek=${SDIMG_OTA_SIZE} - - # Create partition table - parted -s ${SDIMG_OTA} mklabel msdos - # Create boot partition and mark it as bootable - parted -s ${SDIMG_OTA} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) - parted -s ${SDIMG_OTA} set 1 boot on - # Create rootfs partition to the end of disk - parted -s ${SDIMG_OTA} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s - parted ${SDIMG_OTA} print - - # Create a vfat image with boot files - BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG_OTA} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') - rm -f ${WORKDIR}/boot.img - mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS - sync - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/ - - if test -n "${DTS}"; then - # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder - DT_OVERLAYS="${@split_overlays(d, 0)}" - DT_ROOT="${@split_overlays(d, 1)}" - - # Copy board device trees to root folder - for DTB in ${DT_ROOT}; do - DTB_BASE_NAME=`basename ${DTB} .dtb` - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb - done - - # Copy device tree overlays to dedicated folder - mmd -i ${WORKDIR}/boot.img overlays - for DTB in ${DT_OVERLAYS}; do - DTB_EXT=${DTB##*.} - DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` - - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.${DTB_EXT} ::overlays/${DTB_BASE_NAME}.${DTB_EXT} - done - fi - - case "${KERNEL_IMAGETYPE}" in - "uImage") - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_OTA_KERNELIMAGE} - ;; - *) - bbfatal "Kernel uImage is required for OTA image. Please set KERNEL_IMAGETYPE to \"uImage\"" - ;; - esac - - if [ -n ${FATPAYLOAD} ] ; then - echo "Copying payload into VFAT" - for entry in ${FATPAYLOAD} ; do - # add the || true to stop aborting on vfat issues like not supporting .~lock files - mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true - done - fi - - # Add stamp file - echo "${IMAGE_NAME}-${IMAGEDATESTAMP}" > ${WORKDIR}/image-version-info - mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}//image-version-info :: - - # Burn Partitions - sync - dd if=${WORKDIR}/boot.img of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - # If SDIMG_OTA_ROOTFS_TYPE is a .xz file use xzcat - if echo "${SDIMG_OTA_ROOTFS_TYPE}" | egrep -q "*\.xz" - then - xzcat ${SDIMG_OTA_ROOTFS} | dd of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - else - dd if=${SDIMG_OTA_ROOTFS} of=${SDIMG_OTA} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync - fi - - # Optionally apply compression - case "${SDIMG_OTA_COMPRESSION}" in - "gzip") - gzip -k9 "${SDIMG_OTA}" - ;; - "bzip2") - bzip2 -k9 "${SDIMG_OTA}" - ;; - "xz") - xz -k "${SDIMG_OTA}" - ;; - esac - - rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.rpi-sdimg-ota - ln -s ${IMAGE_NAME}.rootfs.rpi-sdimg-ota ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.rpi-sdimg-ota -} - -ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; " - -rpi_generate_sysctl_config() { - # systemd sysctl config - test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \ - echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf - - # sysv sysctl config - IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf" - test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \ - sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF} - echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF} -} |