diff options
| author | Martin Jansa <Martin.Jansa@gmail.com> | 2018-06-29 13:22:06 +0000 |
|---|---|---|
| committer | Andrei Gherzan <andrei@gherzan.com> | 2018-07-07 11:28:48 +0100 |
| commit | efa848ca84a5ed541d4a755d19e66855214bfa23 (patch) | |
| tree | 4a4fff66faa635eeb44c3e92ee3af9f540a2f3a9 /classes | |
| parent | 55aadae7aabe0d10b7a66d174105330bf1f54048 (diff) | |
| download | meta-raspberrypi-efa848ca84a5ed541d4a755d19e66855214bfa23.tar.gz | |
sdcard_image-rpi.bbclass: use 4 spaces for indentation instead of mix of tabs and spaces
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/sdcard_image-rpi.bbclass | 212 |
1 files changed, 106 insertions, 106 deletions
diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass index d6c0bdd..e7c34c6 100644 --- a/classes/sdcard_image-rpi.bbclass +++ b/classes/sdcard_image-rpi.bbclass | |||
| @@ -50,14 +50,14 @@ SDIMG_ROOTFS_TYPE ?= "ext3" | |||
| 50 | SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${SDIMG_ROOTFS_TYPE}" | 50 | SDIMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${SDIMG_ROOTFS_TYPE}" |
| 51 | 51 | ||
| 52 | do_image_rpi_sdimg[depends] = " \ | 52 | do_image_rpi_sdimg[depends] = " \ |
| 53 | parted-native:do_populate_sysroot \ | 53 | parted-native:do_populate_sysroot \ |
| 54 | mtools-native:do_populate_sysroot \ | 54 | mtools-native:do_populate_sysroot \ |
| 55 | dosfstools-native:do_populate_sysroot \ | 55 | dosfstools-native:do_populate_sysroot \ |
| 56 | virtual/kernel:do_deploy \ | 56 | virtual/kernel:do_deploy \ |
| 57 | ${IMAGE_BOOTLOADER}:do_deploy \ | 57 | ${IMAGE_BOOTLOADER}:do_deploy \ |
| 58 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot:do_deploy', '',d)} \ | 58 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot:do_deploy', '',d)} \ |
| 59 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'rpi-u-boot-scr:do_deploy', '',d)} \ | 59 | ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'rpi-u-boot-scr:do_deploy', '',d)} \ |
| 60 | " | 60 | " |
| 61 | 61 | ||
| 62 | do_image_rpi_sdimg[recrdeps] = "do_build" | 62 | do_image_rpi_sdimg[recrdeps] = "do_build" |
| 63 | 63 | ||
| @@ -92,107 +92,107 @@ def split_overlays(d, out, ver=None): | |||
| 92 | 92 | ||
| 93 | IMAGE_CMD_rpi-sdimg () { | 93 | IMAGE_CMD_rpi-sdimg () { |
| 94 | 94 | ||
| 95 | # Align partitions | 95 | # Align partitions |
| 96 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | 96 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) |
| 97 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | 97 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) |
| 98 | SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE) | 98 | SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE) |
| 99 | 99 | ||
| 100 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTFS_SIZE KiB" | 100 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTFS_SIZE KiB" |
| 101 | 101 | ||
| 102 | # Check if we are building with device tree support | 102 | # Check if we are building with device tree support |
| 103 | DTS="${KERNEL_DEVICETREE}" | 103 | DTS="${KERNEL_DEVICETREE}" |
| 104 | 104 | ||
| 105 | # Initialize sdcard image file | 105 | # Initialize sdcard image file |
| 106 | dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE} | 106 | dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE} |
| 107 | 107 | ||
| 108 | # Create partition table | 108 | # Create partition table |
| 109 | parted -s ${SDIMG} mklabel msdos | 109 | parted -s ${SDIMG} mklabel msdos |
| 110 | # Create boot partition and mark it as bootable | 110 | # Create boot partition and mark it as bootable |
| 111 | parted -s ${SDIMG} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) | 111 | parted -s ${SDIMG} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) |
| 112 | parted -s ${SDIMG} set 1 boot on | 112 | parted -s ${SDIMG} set 1 boot on |
| 113 | # Create rootfs partition to the end of disk | 113 | # Create rootfs partition to the end of disk |
| 114 | parted -s ${SDIMG} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s | 114 | parted -s ${SDIMG} -- unit KiB mkpart primary ext2 $(expr ${BOOT_SPACE_ALIGNED} \+ ${IMAGE_ROOTFS_ALIGNMENT}) -1s |
| 115 | parted ${SDIMG} print | 115 | parted ${SDIMG} print |
| 116 | 116 | ||
| 117 | # Create a vfat image with boot files | 117 | # Create a vfat image with boot files |
| 118 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') | 118 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDIMG} unit b print | awk '/ 1 / { print substr($4, 1, length($4 -1)) / 512 /2 }') |
| 119 | rm -f ${WORKDIR}/boot.img | 119 | rm -f ${WORKDIR}/boot.img |
| 120 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS | 120 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS |
| 121 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/ | 121 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/ |
| 122 | if test -n "${DTS}"; then | 122 | if test -n "${DTS}"; then |
| 123 | # Copy board device trees to root folder | 123 | # Copy board device trees to root folder |
| 124 | for dtbf in ${@split_overlays(d, True)}; do | 124 | for dtbf in ${@split_overlays(d, True)}; do |
| 125 | dtb=`basename $dtbf` | 125 | dtb=`basename $dtbf` |
| 126 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::$dtb | 126 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::$dtb |
| 127 | done | 127 | done |
| 128 | 128 | ||
| 129 | # Copy device tree overlays to dedicated folder | 129 | # Copy device tree overlays to dedicated folder |
| 130 | mmd -i ${WORKDIR}/boot.img overlays | 130 | mmd -i ${WORKDIR}/boot.img overlays |
| 131 | for dtbf in ${@split_overlays(d, False)}; do | 131 | for dtbf in ${@split_overlays(d, False)}; do |
| 132 | dtb=`basename $dtbf` | 132 | dtb=`basename $dtbf` |
| 133 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::overlays/$dtb | 133 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$dtb ::overlays/$dtb |
| 134 | done | 134 | done |
| 135 | fi | 135 | fi |
| 136 | if [ "${RPI_USE_U_BOOT}" = "1" ]; then | 136 | if [ "${RPI_USE_U_BOOT}" = "1" ]; then |
| 137 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_KERNELIMAGE} | 137 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_KERNELIMAGE} |
| 138 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${KERNEL_IMAGETYPE} | 138 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${KERNEL_IMAGETYPE} |
| 139 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr | 139 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr |
| 140 | else | 140 | else |
| 141 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE} | 141 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE} |
| 142 | fi | 142 | fi |
| 143 | 143 | ||
| 144 | if [ -n ${FATPAYLOAD} ] ; then | 144 | if [ -n ${FATPAYLOAD} ] ; then |
| 145 | echo "Copying payload into VFAT" | 145 | echo "Copying payload into VFAT" |
| 146 | for entry in ${FATPAYLOAD} ; do | 146 | for entry in ${FATPAYLOAD} ; do |
| 147 | # add the || true to stop aborting on vfat issues like not supporting .~lock files | 147 | # add the || true to stop aborting on vfat issues like not supporting .~lock files |
| 148 | mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true | 148 | mcopy -i ${WORKDIR}/boot.img -s -v ${IMAGE_ROOTFS}$entry :: || true |
| 149 | done | 149 | done |
| 150 | fi | 150 | fi |
| 151 | 151 | ||
| 152 | # Add stamp file | 152 | # Add stamp file |
| 153 | echo "${IMAGE_NAME}" > ${WORKDIR}/image-version-info | 153 | echo "${IMAGE_NAME}" > ${WORKDIR}/image-version-info |
| 154 | mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}/image-version-info :: | 154 | mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}/image-version-info :: |
| 155 | 155 | ||
| 156 | # Deploy vfat partition (for u-boot case only) | 156 | # Deploy vfat partition (for u-boot case only) |
| 157 | if [ "${RPI_USE_U_BOOT}" = "1" ]; then | 157 | if [ "${RPI_USE_U_BOOT}" = "1" ]; then |
| 158 | cp ${WORKDIR}/boot.img ${IMGDEPLOYDIR}/${SDIMG_VFAT} | 158 | cp ${WORKDIR}/boot.img ${IMGDEPLOYDIR}/${SDIMG_VFAT} |
| 159 | ln -sf ${SDIMG_VFAT} ${SDIMG_LINK_VFAT} | 159 | ln -sf ${SDIMG_VFAT} ${SDIMG_LINK_VFAT} |
| 160 | fi | 160 | fi |
| 161 | 161 | ||
| 162 | # Burn Partitions | 162 | # Burn Partitions |
| 163 | dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | 163 | dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 164 | # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat | 164 | # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat |
| 165 | if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz" | 165 | if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz" |
| 166 | then | 166 | then |
| 167 | xzcat ${SDIMG_ROOTFS} | dd of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | 167 | xzcat ${SDIMG_ROOTFS} | dd of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 168 | else | 168 | else |
| 169 | dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | 169 | dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) |
| 170 | fi | 170 | fi |
| 171 | 171 | ||
| 172 | # Optionally apply compression | 172 | # Optionally apply compression |
| 173 | case "${SDIMG_COMPRESSION}" in | 173 | case "${SDIMG_COMPRESSION}" in |
| 174 | "gzip") | 174 | "gzip") |
| 175 | gzip -k9 "${SDIMG}" | 175 | gzip -k9 "${SDIMG}" |
| 176 | ;; | 176 | ;; |
| 177 | "bzip2") | 177 | "bzip2") |
| 178 | bzip2 -k9 "${SDIMG}" | 178 | bzip2 -k9 "${SDIMG}" |
| 179 | ;; | 179 | ;; |
| 180 | "xz") | 180 | "xz") |
| 181 | xz -k "${SDIMG}" | 181 | xz -k "${SDIMG}" |
| 182 | ;; | 182 | ;; |
| 183 | esac | 183 | esac |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; " | 186 | ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; " |
| 187 | 187 | ||
| 188 | rpi_generate_sysctl_config() { | 188 | rpi_generate_sysctl_config() { |
| 189 | # systemd sysctl config | 189 | # systemd sysctl config |
| 190 | test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \ | 190 | test -d ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d && \ |
| 191 | echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf | 191 | echo "vm.min_free_kbytes = 8192" > ${IMAGE_ROOTFS}${sysconfdir}/sysctl.d/rpi-vm.conf |
| 192 | 192 | ||
| 193 | # sysv sysctl config | 193 | # sysv sysctl config |
| 194 | IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf" | 194 | IMAGE_SYSCTL_CONF="${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf" |
| 195 | test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \ | 195 | test -e ${IMAGE_ROOTFS}${sysconfdir}/sysctl.conf && \ |
| 196 | sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF} | 196 | sed -e "/vm.min_free_kbytes/d" -i ${IMAGE_SYSCTL_CONF} |
| 197 | echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF} | 197 | echo "" >> ${IMAGE_SYSCTL_CONF} && echo "vm.min_free_kbytes = 8192" >> ${IMAGE_SYSCTL_CONF} |
| 198 | } | 198 | } |
