Create OTA updater (#34)
* Create OTA updater * Create .gitignore * Update build-all.sh * Update hdd-image.sh * Update ota.sh * Update ota.sh * Update ota.sh * Update ota.sh * Update post-image.sh * Create name.sh * Update name.sh * Update post-build.sh * Update name.sh * Update post-image.sh * Update ota.sh * Update hdd-image.sh * Update post-image.sh * Update name.sh * Update ota.sh * Update post-image.sh * Update hdd-image.sh * Update hdd-image.sh * Update hdd-image.sh * Update post-image.sh * Update post-image.sh * Update hdd-image.sh * Update hdd-image.sh * Update post-image.sh * Update post-image.sh * Update post-image.sh * Update info * Update info * Update info * Update info * Update info * Update info * Rename buildroot-external/board/raspberrypi/uboot-boot64.sh to buildroot-external/board/raspberrypi/rpi3-64/uboot-boot.sh * Update rpi3_64_defconfig * Update hdd-image.sh * Update ota.sh * Update post-image.sh * Update post-image.sh * Fix building Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * Fix building v2 Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
@@ -18,8 +18,8 @@ DATA_SIZE=1G
|
||||
|
||||
|
||||
function create_boot_image() {
|
||||
local boot_data="${1}/boot"
|
||||
local boot_img="${1}/boot.vfat"
|
||||
local boot_data="${BINARIES_DIR}/boot"
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
|
||||
echo "mtools_skip_check=1" > ~/.mtoolsrc
|
||||
dd if=/dev/zero of=${boot_img} bs=${BOOT_SIZE} count=1
|
||||
@@ -29,7 +29,7 @@ function create_boot_image() {
|
||||
|
||||
|
||||
function create_overlay_image() {
|
||||
local overlay_img="${1}/overlay.ext4"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
|
||||
dd if=/dev/zero of=${overlay_img} bs=${OVERLAY_SIZE} count=1
|
||||
mkfs.ext4 -L "hassos-overlay" -E lazy_itable_init=0,lazy_journal_init=0 ${overlay_img}
|
||||
@@ -37,9 +37,9 @@ function create_overlay_image() {
|
||||
|
||||
|
||||
function create_kernel_image() {
|
||||
local kernel0_img="${1}/kernel0.ext4"
|
||||
local kernel1_img="${1}/kernel1.ext4"
|
||||
local kernel=${1}/${2}
|
||||
local kernel0_img="${BINARIES_DIR}/kernel0.ext4"
|
||||
local kernel1_img="${BINARIES_DIR}/kernel1.ext4"
|
||||
local kernel="${BINARIES_DIR}/${KERNEL_FILE}"
|
||||
|
||||
# Make image
|
||||
dd if=/dev/zero of=${kernel0_img} bs=${KERNEL_SIZE} count=1
|
||||
@@ -55,15 +55,22 @@ function create_kernel_image() {
|
||||
}
|
||||
|
||||
|
||||
function prepare_disk_image() {
|
||||
create_boot_image
|
||||
create_overlay_image
|
||||
create_kernel_image
|
||||
}
|
||||
|
||||
|
||||
function create_disk_image() {
|
||||
local boot_img="${1}/boot.vfat"
|
||||
local rootfs_img="${1}/rootfs.squashfs"
|
||||
local overlay_img="${1}/overlay.ext4"
|
||||
local data_img="${1}/data.ext4"
|
||||
local kernel0_img="${1}/kernel0.ext4"
|
||||
local kernel1_img="${1}/kernel1.ext4"
|
||||
local hdd_img=${2}
|
||||
local hdd_count=${3:-2}
|
||||
local boot_img="${BINARIES_DIR}/boot.vfat"
|
||||
local rootfs_img="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local overlay_img="${BINARIES_DIR}/overlay.ext4"
|
||||
local data_img="${BINARIES_DIR}/data.ext4"
|
||||
local kernel0_img="${BINARIES_DIR}/kernel0.ext4"
|
||||
local kernel1_img="${BINARIES_DIR}/kernel1.ext4"
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_count=${1:-2}
|
||||
|
||||
local loop_dev="/dev/mapper/$(losetup -f | cut -d'/' -f3)"
|
||||
local boot_offset=0
|
||||
@@ -112,8 +119,26 @@ function create_disk_image() {
|
||||
|
||||
|
||||
function fix_disk_image_mbr() {
|
||||
local hdd_img=${1}
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
|
||||
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ${hdd_img}
|
||||
dd if=${BR2_EXTERNAL_HASSOS_PATH}/misc/mbr.img of=${hdd_img} conv=notrunc bs=512 count=1
|
||||
}
|
||||
|
||||
|
||||
function convert_disk_image_vdmk() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
local hdd_vdmk="$(hassos_image_name vdmk)"
|
||||
|
||||
rm -f ${hdd_vdmk}
|
||||
qemu-img convert -O vmdk ${hdd_img} ${hdd_vdmk}
|
||||
rm -f ${hdd_img}
|
||||
}
|
||||
|
||||
|
||||
function convert_disk_image_gz() {
|
||||
local hdd_img="$(hassos_image_name img)"
|
||||
|
||||
rm -f ${hdd_img}.gz
|
||||
gzip --best ${hdd_img}
|
||||
}
|
||||
|
||||
13
buildroot-external/scripts/name.sh
Normal file
13
buildroot-external/scripts/name.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
function hassos_image_name() {
|
||||
echo "${BINARIES_DIR}/${HASSOS_ID}_${BOARD_ID}-${VERSION_MAJOR}.${VERSION_BUILD}.${1}"
|
||||
}
|
||||
|
||||
function hassos_rauc_compatible() {
|
||||
echo "${HASSOS_ID}-${BOARD_ID}"
|
||||
}
|
||||
|
||||
function hassos_version() {
|
||||
echo "${VERSION_MAJOR}.${VERSION_BUILD}"
|
||||
}
|
||||
32
buildroot-external/scripts/ota.sh
Normal file
32
buildroot-external/scripts/ota.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
function create_ota_update() {
|
||||
local ota_file="$(hassos_image_name raucb)"
|
||||
local rauc_folder="${BINARIES_DIR}/rauc"
|
||||
local boot_folder="${BINARIES_DIR}/boot"
|
||||
local kernel="${BINARIES_DIR}/${KERNEL_FILE}"
|
||||
local rootfs="${BINARIES_DIR}/rootfs.squashfs"
|
||||
local key="/build/key.pem"
|
||||
local cert="/build/cert.pem"
|
||||
|
||||
rm -rf ${rauc_folder} ${ota_file}
|
||||
mkdir -p ${rauc_folder}
|
||||
|
||||
tar -P -cf ${rauc_folder}/kernel.tar ${kernel}
|
||||
tar -P -cf ${rauc_folder}/boot.tar ${boot_folder}
|
||||
cp -f ${rootfs} ${rauc_folder}/rootfs.img
|
||||
|
||||
(
|
||||
echo "[update]"
|
||||
echo "compatible=$(hassos_rauc_compatible)"
|
||||
echo "version=$(hassos_version)"
|
||||
echo "[image.boot]"
|
||||
echo "filename=boot.tar"
|
||||
echo "[image.kernel]"
|
||||
echo "filename=kernel.tar"
|
||||
echo "[image.rootfs]"
|
||||
echo "filename=rootfs.img"
|
||||
) > ${rauc_folder}/manifest.raucm
|
||||
|
||||
rauc bundle -d --cert=${cert} --key=${key} ${rauc_folder} ${ota_file}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ BOARD_DIR=${2}
|
||||
. ${SCRIPT_DIR}/rootfs-layer.sh
|
||||
. ${BR2_EXTERNAL_HASSOS_PATH}/info
|
||||
. ${BOARD_DIR}/info
|
||||
. ${SCRIPT_DIR}/name.sh
|
||||
|
||||
|
||||
# HassOS tasks
|
||||
fix_rootfs
|
||||
@@ -32,7 +34,7 @@ install_hassos_cli
|
||||
) > ${TARGET_DIR}/etc/machine-info
|
||||
|
||||
# Settup rauc
|
||||
sed -i "s/%COMPATIBLE%/${HASSOS_ID}-${BOARD_ID}/g" ${TARGET_DIR}/etc/rauc/system.conf
|
||||
sed -i "s/%COMPATIBLE%/$(hassos_rauc_compatible)/g" ${TARGET_DIR}/etc/rauc/system.conf
|
||||
sed -i "s/%BOOTLOADER%/${BOOTLOADER}/g" ${TARGET_DIR}/etc/rauc/system.conf
|
||||
|
||||
# Settup the correct CA
|
||||
|
||||
Reference in New Issue
Block a user