Merge pull request #205 from BohdanBuinich/refactor-buildroot-scripts
[ALL] Refactor buildroot scripts
This commit is contained in:
commit
7f3487115a
|
@ -1,57 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
|
||||
. "${BR2_EXTERNAL_OPENVOICEOS_PATH}/meta"
|
||||
. "${BOARD_DIR}/meta"
|
||||
|
||||
# Write os-release
|
||||
{
|
||||
echo "NAME=\"${OVOS_NAME}\""
|
||||
echo "VERSION=\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "ID=${OVOS_ID}"
|
||||
echo "VERSION_ID=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}"
|
||||
echo "PRETTY_NAME=\"${OVOS_NAME} ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "CPE_NAME=cpe:2.3:o:openvoiceos:${OVOS_ID}:${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}:*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*"
|
||||
echo "HOME_URL=https://github.com/OpenVoiceOS/OpenVoiceOS"
|
||||
echo "DOCUMENTATION_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/tree/develop/documentation"
|
||||
echo "SUPPORT_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/issues"
|
||||
echo "VARIANT=\"${OVOS_NAME} - Buildroot Edition\""
|
||||
echo "VARIANT_ID=${OVOS_ID}-${BOARD_ID}-buildroot"
|
||||
} > "${TARGET_DIR}/usr/lib/os-release"
|
||||
|
||||
# Write machine-info
|
||||
{
|
||||
echo "CHASSIS=${CHASSIS}"
|
||||
echo "DEPLOYMENT=${DEPLOYMENT}"
|
||||
} > "${TARGET_DIR}/etc/machine-info"
|
||||
|
||||
cp -f ../buildroot-external/board/ovos/ova/grub-efi.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
|
||||
cp -f ../buildroot-external/board/ovos/ova/cmdline.txt ${BINARIES_DIR}
|
||||
cp -f ../buildroot-external/board/ovos/ova/sw-description ${BINARIES_DIR}
|
||||
|
||||
grub-editenv "${BINARIES_DIR}/efi-part/EFI/BOOT/grubenv" create
|
||||
|
||||
echo "Check for compressed kernel in ${TARGET_DIR}"
|
||||
if [ -f "${TARGET_DIR}/boot/bzImage" ]; then
|
||||
echo "Found bzImage, renaming to kernel"
|
||||
mv ${TARGET_DIR}/boot/bzImage ${TARGET_DIR}/boot/kernel
|
||||
fi
|
||||
|
||||
# Prepare home data
|
||||
rm -f ${BINARIES_DIR}/homefs.ext4
|
||||
truncate --size="6890M" ${BINARIES_DIR}/homefs.ext4
|
||||
mkfs.ext4 -L "homefs" -E lazy_itable_init=0,lazy_journal_init=0 ${BINARIES_DIR}/homefs.ext4
|
||||
|
||||
# Mount home image
|
||||
mkdir -p ${BINARIES_DIR}/home
|
||||
sudo mount -o loop,discard ${BINARIES_DIR}/homefs.ext4 ${BINARIES_DIR}/home
|
||||
|
||||
# sync home folder
|
||||
sudo rsync -ah --progress ${TARGET_DIR}/home/* ${BINARIES_DIR}/home/
|
||||
|
||||
# Unmount home image
|
||||
sudo umount ${BINARIES_DIR}/homefs.ext4
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
BOARD_NAME="$(basename ${BOARD_DIR})"
|
||||
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
|
||||
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
||||
SWUPDATE_FILES="sw-description rootfs.squashfs"
|
||||
|
||||
# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
|
||||
# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
|
||||
# space. We don't rely on genimage to build the rootfs image, just to insert a
|
||||
# pre-built one in the disk image.
|
||||
|
||||
trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
|
||||
ROOTPATH_TMP="$(mktemp -d)"
|
||||
|
||||
rm -rf "${GENIMAGE_TMP}"
|
||||
|
||||
genimage \
|
||||
--rootpath "${ROOTPATH_TMP}" \
|
||||
--tmppath "${GENIMAGE_TMP}" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config "${GENIMAGE_CFG}"
|
||||
|
||||
pushd ${BINARIES_DIR}
|
||||
for f in ${SWUPDATE_FILES} ; do
|
||||
echo ${f}
|
||||
done | cpio -ov -H crc > rootfs.swu
|
||||
popd
|
||||
|
||||
exit $?
|
|
@ -1,57 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
|
||||
. "${BR2_EXTERNAL_OPENVOICEOS_PATH}/meta"
|
||||
. "${BOARD_DIR}/meta"
|
||||
|
||||
# Write os-release
|
||||
{
|
||||
echo "NAME=\"${OVOS_NAME}\""
|
||||
echo "VERSION=\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "ID=${OVOS_ID}"
|
||||
echo "VERSION_ID=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}"
|
||||
echo "PRETTY_NAME=\"${OVOS_NAME} ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "CPE_NAME=cpe:2.3:o:openvoiceos:${OVOS_ID}:${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}:*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*"
|
||||
echo "HOME_URL=https://github.com/OpenVoiceOS/OpenVoiceOS"
|
||||
echo "DOCUMENTATION_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/tree/develop/documentation"
|
||||
echo "SUPPORT_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/issues"
|
||||
echo "VARIANT=\"${OVOS_NAME} - Buildroot Edition\""
|
||||
echo "VARIANT_ID=${OVOS_ID}-${BOARD_ID}-buildroot"
|
||||
} > "${TARGET_DIR}/usr/lib/os-release"
|
||||
|
||||
# Write machine-info
|
||||
{
|
||||
echo "CHASSIS=${CHASSIS}"
|
||||
echo "DEPLOYMENT=${DEPLOYMENT}"
|
||||
} > "${TARGET_DIR}/etc/machine-info"
|
||||
|
||||
cp -f ../buildroot-external/board/ovos/ova/grub-efi.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
|
||||
cp -f ../buildroot-external/board/ovos/ova/cmdline.txt ${BINARIES_DIR}
|
||||
cp -f ../buildroot-external/board/ovos/ova/sw-description ${BINARIES_DIR}
|
||||
|
||||
grub-editenv "${BINARIES_DIR}/efi-part/EFI/BOOT/grubenv" create
|
||||
|
||||
echo "Check for compressed kernel in ${TARGET_DIR}"
|
||||
if [ -f "${TARGET_DIR}/boot/bzImage" ]; then
|
||||
echo "Found bzImage, renaming to kernel"
|
||||
mv ${TARGET_DIR}/boot/bzImage ${TARGET_DIR}/boot/kernel
|
||||
fi
|
||||
|
||||
# Prepare home data
|
||||
rm -f ${BINARIES_DIR}/homefs.ext4
|
||||
truncate --size="6890M" ${BINARIES_DIR}/homefs.ext4
|
||||
mkfs.ext4 -L "homefs" -E lazy_itable_init=0,lazy_journal_init=0 ${BINARIES_DIR}/homefs.ext4
|
||||
|
||||
# Mount home image
|
||||
mkdir -p ${BINARIES_DIR}/home
|
||||
sudo mount -o loop,discard ${BINARIES_DIR}/homefs.ext4 ${BINARIES_DIR}/home
|
||||
|
||||
# sync home folder
|
||||
sudo rsync -ah --progress ${TARGET_DIR}/home/* ${BINARIES_DIR}/home/
|
||||
|
||||
# Unmount home image
|
||||
sudo umount ${BINARIES_DIR}/homefs.ext4
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
BOARD_NAME="$(basename ${BOARD_DIR})"
|
||||
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
|
||||
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
||||
SWUPDATE_FILES="sw-description rootfs.squashfs"
|
||||
|
||||
# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
|
||||
# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
|
||||
# space. We don't rely on genimage to build the rootfs image, just to insert a
|
||||
# pre-built one in the disk image.
|
||||
|
||||
trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
|
||||
ROOTPATH_TMP="$(mktemp -d)"
|
||||
|
||||
rm -rf "${GENIMAGE_TMP}"
|
||||
|
||||
genimage \
|
||||
--rootpath "${ROOTPATH_TMP}" \
|
||||
--tmppath "${GENIMAGE_TMP}" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config "${GENIMAGE_CFG}"
|
||||
|
||||
pushd ${BINARIES_DIR}
|
||||
for f in ${SWUPDATE_FILES} ; do
|
||||
echo ${f}
|
||||
done | cpio -ov -H crc > rootfs.swu
|
||||
popd
|
||||
|
||||
exit $?
|
|
@ -1,73 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
|
||||
. "${BR2_EXTERNAL_OPENVOICEOS_PATH}/meta"
|
||||
. "${BOARD_DIR}/meta"
|
||||
|
||||
# Write os-release
|
||||
{
|
||||
echo "NAME=\"${OVOS_NAME}\""
|
||||
echo "VERSION=\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "ID=${OVOS_ID}"
|
||||
echo "VERSION_ID=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}"
|
||||
echo "PRETTY_NAME=\"${OVOS_NAME} ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "CPE_NAME=cpe:2.3:o:openvoiceos:${OVOS_ID}:${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}:*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*"
|
||||
echo "HOME_URL=https://github.com/OpenVoiceOS/OpenVoiceOS"
|
||||
echo "DOCUMENTATION_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/tree/develop/documentation"
|
||||
echo "SUPPORT_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/issues"
|
||||
echo "VARIANT=\"${OVOS_NAME} - Buildroot Edition\""
|
||||
echo "VARIANT_ID=${OVOS_ID}-${BOARD_ID}-buildroot"
|
||||
} > "${TARGET_DIR}/usr/lib/os-release"
|
||||
|
||||
# Write machine-info
|
||||
{
|
||||
echo "CHASSIS=${CHASSIS}"
|
||||
echo "DEPLOYMENT=${DEPLOYMENT}"
|
||||
} > "${TARGET_DIR}/etc/machine-info"
|
||||
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/cmdline.txt ${BINARIES_DIR}/rpi-firmware/cmdline.txt
|
||||
grub-editenv "${BINARIES_DIR}/efi-part/EFI/BOOT/grubenv" create
|
||||
|
||||
echo "Check for kernel in ${TARGET_DIR}"
|
||||
if [ -f "${TARGET_DIR}/boot/Image" ]; then
|
||||
echo "Found Image, renaming to kernel"
|
||||
mv ${TARGET_DIR}/boot/Image ${TARGET_DIR}/boot/kernel
|
||||
fi
|
||||
|
||||
# Copy the right config.txt file
|
||||
for arg in "$@"
|
||||
do
|
||||
case "${arg}" in
|
||||
--rpi3)
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi3/config.txt ${BINARIES_DIR}/rpi-firmware/config.txt
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi3/RPI_EFI.fd ${BINARIES_DIR}/rpi-firmware/RPI_EFI.fd
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/grub-efi.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi3/sw-description ${BINARIES_DIR}
|
||||
;;
|
||||
--rpi4)
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi4/config.txt ${BINARIES_DIR}/rpi-firmware/config.txt
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi4/RPI_EFI.fd ${BINARIES_DIR}/rpi-firmware/RPI_EFI.fd
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/grub-efi.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg
|
||||
cp -f ../buildroot-external/board/ovos/raspberrypi/rpi4/sw-description ${BINARIES_DIR}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Prepare home data
|
||||
rm -f ${BINARIES_DIR}/homefs.ext4
|
||||
truncate --size="6890M" ${BINARIES_DIR}/homefs.ext4
|
||||
mkfs.ext4 -L "homefs" -E lazy_itable_init=0,lazy_journal_init=0 ${BINARIES_DIR}/homefs.ext4
|
||||
|
||||
# Mount home image
|
||||
mkdir -p ${BINARIES_DIR}/home
|
||||
sudo mount -o loop,discard ${BINARIES_DIR}/homefs.ext4 ${BINARIES_DIR}/home
|
||||
|
||||
# sync home folder
|
||||
sudo rsync -avPHSX ${TARGET_DIR}/home/* ${BINARIES_DIR}/home/
|
||||
|
||||
# Unmount home image
|
||||
sudo umount ${BINARIES_DIR}/homefs.ext4
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BOARD_DIR="$(dirname $0)"
|
||||
BOARD_NAME="$(basename ${BOARD_DIR})"
|
||||
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
|
||||
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
||||
SWUPDATE_FILES="sw-description rootfs.squashfs"
|
||||
|
||||
# Pass an empty rootpath. genimage makes a full copy of the given rootpath to
|
||||
# ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk
|
||||
# space. We don't rely on genimage to build the rootfs image, just to insert a
|
||||
# pre-built one in the disk image.
|
||||
|
||||
trap 'rm -rf "${ROOTPATH_TMP}"' EXIT
|
||||
ROOTPATH_TMP="$(mktemp -d)"
|
||||
|
||||
rm -rf "${GENIMAGE_TMP}"
|
||||
|
||||
genimage \
|
||||
--rootpath "${ROOTPATH_TMP}" \
|
||||
--tmppath "${GENIMAGE_TMP}" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config "${GENIMAGE_CFG}"
|
||||
|
||||
pushd ${BINARIES_DIR}
|
||||
for f in ${SWUPDATE_FILES} ; do
|
||||
echo ${f}
|
||||
done | cpio -ov -H crc > rootfs.swu
|
||||
popd
|
||||
|
||||
exit $?
|
|
@ -1 +0,0 @@
|
|||
../post-build.sh
|
|
@ -1 +0,0 @@
|
|||
../post-image.sh
|
|
@ -1 +0,0 @@
|
|||
../post-build.sh
|
|
@ -1 +0,0 @@
|
|||
../post-image.sh
|
|
@ -24,9 +24,9 @@ BR2_GENERATE_LOCALE="en_US.UTF-8"
|
|||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL)/user_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/ova/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/ovos/ova/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/ova/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="--ova"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/scripts/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/scripts/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_EXTERNAL)/board/ovos/ova"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.69"
|
||||
|
|
|
@ -25,9 +25,9 @@ BR2_GENERATE_LOCALE="en_US.UTF-8"
|
|||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL)/user_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/raspberrypi/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi3/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi3/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi3/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="--rpi3"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/scripts/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/scripts/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi3"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,3bb5880ab3dd31f75c07c3c33bf29c5d469b28f3)/linux-3bb5880ab3dd31f75c07c3c33bf29c5d469b28f3.tar.gz"
|
||||
|
|
|
@ -25,9 +25,9 @@ BR2_GENERATE_LOCALE="en_US.UTF-8"
|
|||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL)/user_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/raspberrypi/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi4/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi4/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi4/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="--rpi4"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/scripts/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/scripts/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_EXTERNAL)/board/ovos/raspberrypi/rpi4"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,3bb5880ab3dd31f75c07c3c33bf29c5d469b28f3)/linux-3bb5880ab3dd31f75c07c3c33bf29c5d469b28f3.tar.gz"
|
||||
|
|
|
@ -24,9 +24,9 @@ BR2_GENERATE_LOCALE="en_US.UTF-8"
|
|||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL)/user_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL)/rootfs-overlay $(BR2_EXTERNAL)/board/ovos/pc/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/board/ovos/pc/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/board/ovos/pc/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="--x86"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL)/scripts/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL)/scripts/post-image.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_EXTERNAL)/board/ovos/pc"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.73"
|
||||
|
|
|
@ -1,28 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Original script from Home Assistant
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
arch=$1
|
||||
image=$2
|
||||
dl_dir=$3
|
||||
dst_dir=$4
|
||||
set -eu
|
||||
|
||||
# Variables
|
||||
arch="$1"
|
||||
image="$2"
|
||||
dl_dir="$3"
|
||||
dst_dir="$4"
|
||||
image_name="docker.io/smartgic/${image}"
|
||||
full_image_name="${image_name}:alpha"
|
||||
image_digest=$(skopeo --override-arch "${arch}" inspect --retry-times=5 "docker://${full_image_name}" | jq -r '.Digest')
|
||||
|
||||
# Fetch image digest
|
||||
image_digest=$(skopeo --override-arch "${arch}" inspect --retry-times=5 "docker://${full_image_name}" | jq -r '.Digest')
|
||||
if [ -z "${image_digest}" ]; then
|
||||
echo "Failed to fetch digest for ${full_image_name}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare file paths
|
||||
image_file_name="${full_image_name//[:\/]/_}@${image_digest//[:\/]/_}"
|
||||
image_file_path="${dl_dir}/${image_file_name}.tar"
|
||||
dst_image_file_path="${dst_dir}/${image_file_name}.tar"
|
||||
lock_file="${image_file_path}.lock"
|
||||
|
||||
(
|
||||
# Use file locking to avoid race condition
|
||||
flock --verbose 3
|
||||
if [ ! -f "${image_file_path}" ]
|
||||
then
|
||||
# Function to fetch and copy image
|
||||
fetch_and_copy_image() {
|
||||
if [ ! -f "${image_file_path}" ]; then
|
||||
echo "Fetching image: ${full_image_name} (digest ${image_digest})"
|
||||
skopeo --override-arch "${arch}" copy "docker://${image_name}@${image_digest}" "docker-archive:${image_file_path}:${full_image_name}"
|
||||
else
|
||||
|
@ -30,4 +35,10 @@ dst_image_file_path="${dst_dir}/${image_file_name}.tar"
|
|||
fi
|
||||
|
||||
cp "${image_file_path}" "${dst_image_file_path}"
|
||||
) 3>"${image_file_path}.lock"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
{
|
||||
flock --verbose 3
|
||||
fetch_and_copy_image
|
||||
} 3>"${lock_file}"
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
# Define board directory and related variables
|
||||
BOARD_DIR=$2
|
||||
BOARD_TYPE=$(basename "${BOARD_DIR}")
|
||||
|
||||
# Source external metadata
|
||||
. "${BR2_EXTERNAL_OPENVOICEOS_PATH}/meta"
|
||||
. "${BOARD_DIR}/meta"
|
||||
|
||||
# Function to create and write os-release file
|
||||
write_os_release() {
|
||||
local os_release_file="${TARGET_DIR}/usr/lib/os-release"
|
||||
echo "Creating os-release at ${os_release_file}"
|
||||
{
|
||||
echo "NAME=\"${OVOS_NAME}\""
|
||||
echo "VERSION=\"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "ID=${OVOS_ID}"
|
||||
echo "VERSION_ID=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}"
|
||||
echo "PRETTY_NAME=\"${OVOS_NAME} ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD} ${BOARD_NAME}\""
|
||||
echo "CPE_NAME=cpe:2.3:o:openvoiceos:${OVOS_ID}:${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}:*:${DEPLOYMENT}:*:*:*:${BOARD_ID}:*"
|
||||
echo "HOME_URL=https://github.com/OpenVoiceOS/OpenVoiceOS"
|
||||
echo "DOCUMENTATION_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/tree/develop/documentation"
|
||||
echo "SUPPORT_URL=https://github.com/OpenVoiceOS/OpenVoiceOS/issues"
|
||||
echo "VARIANT=\"${OVOS_NAME} - Buildroot Edition\""
|
||||
echo "VARIANT_ID=${OVOS_ID}-${BOARD_ID}-buildroot"
|
||||
} > "${os_release_file}"
|
||||
}
|
||||
|
||||
# Function to create and write machine-info file
|
||||
write_machine_info() {
|
||||
local machine_info_file="${TARGET_DIR}/etc/machine-info"
|
||||
echo "Creating machine-info at ${machine_info_file}"
|
||||
{
|
||||
echo "CHASSIS=${CHASSIS}"
|
||||
echo "DEPLOYMENT=${DEPLOYMENT}"
|
||||
} > "${machine_info_file}"
|
||||
}
|
||||
|
||||
# Function to copy files based on board type
|
||||
copy_board_specific_files() {
|
||||
echo "Copying files for board type: ${BOARD_TYPE}"
|
||||
|
||||
case "${BOARD_TYPE}" in
|
||||
"rpi3"|"rpi4"|"rpi5")
|
||||
cp -f "${BOARD_DIR}/../cmdline.txt" "${BINARIES_DIR}/rpi-firmware/cmdline.txt"
|
||||
cp -f "${BOARD_DIR}/config.txt" "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||
cp -f "${BOARD_DIR}/RPI_EFI.fd" "${BINARIES_DIR}/rpi-firmware/RPI_EFI.fd"
|
||||
cp -f "${BOARD_DIR}/../grub-efi.cfg" "${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg"
|
||||
cp -f "${BOARD_DIR}/sw-description" "${BINARIES_DIR}"
|
||||
;;
|
||||
"ova")
|
||||
cp -f "${BOARD_DIR}/grub-efi.cfg" "${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg"
|
||||
cp -f "${BOARD_DIR}/cmdline.txt" "${BINARIES_DIR}"
|
||||
cp -f "${BOARD_DIR}/sw-description" "${BINARIES_DIR}"
|
||||
;;
|
||||
"pc")
|
||||
cp -f "${BOARD_DIR}/grub-efi.cfg" "${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg"
|
||||
;;
|
||||
*)
|
||||
echo "No specific files to copy for board type: ${BOARD_TYPE}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to handle kernel renaming based on board type
|
||||
handle_kernel_renaming() {
|
||||
case "${BOARD_TYPE}" in
|
||||
"rpi3"|"rpi4"|"rpi5")
|
||||
grub-editenv "${BINARIES_DIR}/efi-part/EFI/BOOT/grubenv" create
|
||||
if [ -f "${TARGET_DIR}/boot/Image" ]; then
|
||||
echo "Found Image, renaming to kernel"
|
||||
mv "${TARGET_DIR}/boot/Image" "${TARGET_DIR}/boot/kernel"
|
||||
fi
|
||||
;;
|
||||
"ova")
|
||||
grub-editenv "${BINARIES_DIR}/efi-part/EFI/BOOT/grubenv" create
|
||||
if [ -f "${TARGET_DIR}/boot/bzImage" ]; then
|
||||
echo "Found bzImage, renaming to kernel"
|
||||
mv "${TARGET_DIR}/boot/bzImage" "${TARGET_DIR}/boot/kernel"
|
||||
fi
|
||||
;;
|
||||
"pc")
|
||||
# No kernel renaming logic needed for pc(x86_64)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Main function to execute script logic
|
||||
main() {
|
||||
write_os_release
|
||||
write_machine_info
|
||||
copy_board_specific_files
|
||||
handle_kernel_renaming
|
||||
|
||||
# Prepare and sync home data
|
||||
local home_img="${BINARIES_DIR}/homefs.ext4"
|
||||
echo "Preparing home data at ${home_img}"
|
||||
rm -f "${home_img}"
|
||||
truncate --size="6890M" "${home_img}"
|
||||
mkfs.ext4 -L "homefs" -E lazy_itable_init=0,lazy_journal_init=0 "${home_img}"
|
||||
|
||||
local home_mount_point="${BINARIES_DIR}/home"
|
||||
mkdir -p "${home_mount_point}"
|
||||
sudo mount -o loop,discard "${home_img}" "${home_mount_point}"
|
||||
sudo rsync -avPHSX "${TARGET_DIR}/home/"* "${home_mount_point}/"
|
||||
sudo umount "${home_img}"
|
||||
}
|
||||
|
||||
# Ensure the script is called with the correct number of arguments
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <build_dir> <board_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Call the main function
|
||||
main
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
# Define board directory and related variables
|
||||
BOARD_DIR=$2
|
||||
BOARD_TYPE="$(basename "${BOARD_DIR}")"
|
||||
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_TYPE}.cfg"
|
||||
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
||||
|
||||
# Define files for SWUPDATE
|
||||
SWUPDATE_FILES=("sw-description" "rootfs.squashfs")
|
||||
|
||||
# Function to create SWU file
|
||||
create_swu_file() {
|
||||
local binaries_dir=$1
|
||||
local files=("${@:2}")
|
||||
|
||||
pushd "${binaries_dir}" > /dev/null
|
||||
printf '%s\n' "${files[@]}" | cpio -ov -H crc > rootfs.swu
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
# Clean up function for EXIT trap
|
||||
cleanup() {
|
||||
echo "Cleaning up temporary files."
|
||||
rm -rf "${ROOTPATH_TMP}" "${GENIMAGE_TMP}"
|
||||
}
|
||||
|
||||
# Main function to execute script logic
|
||||
main() {
|
||||
# Check if necessary files and directories exist
|
||||
if [ ! -d "${BUILD_DIR}" ] || [ ! -f "${GENIMAGE_CFG}" ]; then
|
||||
echo "Required directories or config files are missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate image using genimage
|
||||
echo "Generating image with genimage..."
|
||||
if ! genimage \
|
||||
--rootpath "${ROOTPATH_TMP}" \
|
||||
--tmppath "${GENIMAGE_TMP}" \
|
||||
--inputpath "${BINARIES_DIR}" \
|
||||
--outputpath "${BINARIES_DIR}" \
|
||||
--config "${GENIMAGE_CFG}"; then
|
||||
echo "Error during image generation."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create SWU file
|
||||
echo "Creating SWU file..."
|
||||
create_swu_file "${BINARIES_DIR}" "${SWUPDATE_FILES[@]}"
|
||||
}
|
||||
|
||||
# Setting up trap for cleanup on script exit
|
||||
trap cleanup EXIT
|
||||
|
||||
# Check for correct number of arguments
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <build_dir> <board_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary root path
|
||||
ROOTPATH_TMP="$(mktemp -d)"
|
||||
|
||||
# Call the main function
|
||||
main
|
Loading…
Reference in New Issue