armbian-next: extensions changes - MEGASQUASH - squashed changes from c9cf3fc241cfb4c872f4aef7bbc41d5854db7ea3 to 6809de3d6063cb041205a8318e19da6a4dee68c9 ref extensions_08_10_2022_pre_v30

This commit is contained in:
Ricardo Pardini
2022-10-08 13:26:47 +02:00
parent 6815b0ff57
commit ad21c12c2b
10 changed files with 246 additions and 45 deletions

View File

@@ -17,7 +17,6 @@ function extension_prepare_config__prepare_flash_kernel() {
export CLOUD_INIT_CONFIG_LOCATION="/boot/firmware" # use /boot/firmware for cloud-init as well
export VER="${FK__PUBLISHED_KERNEL_VERSION}" # For the VERSION
export EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-fk${FK__PUBLISHED_KERNEL_VERSION}" # Unique bsp name.
echo "-- starting" > "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log # Zero out the log for this extension.
}
function post_install_kernel_debs__install_kernel_and_flash_packages() {
@@ -25,8 +24,7 @@ function post_install_kernel_debs__install_kernel_and_flash_packages() {
if [[ "${FK__EXTRA_PACKAGES}" != "" ]]; then
display_alert "Installing flash-kernel extra packages" "${FK__EXTRA_PACKAGES}"
echo "-- install extra pkgs" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get ${APT_EXTRA_DIST_PARAMS} -yqq --no-install-recommends install ${FK__EXTRA_PACKAGES}" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log || {
chroot_sdcard_apt_get_install "${FK__EXTRA_PACKAGES}" || {
display_alert "Failed to install flash-kernel's extra packages." "${EXTENSION}" "err"
exit 28
}
@@ -34,8 +32,7 @@ function post_install_kernel_debs__install_kernel_and_flash_packages() {
if [[ "${FK__KERNEL_PACKAGES}" != "" ]]; then
display_alert "Installing flash-kernel kernel packages" "${FK__KERNEL_PACKAGES}"
echo "-- install kernel pkgs" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get ${APT_EXTRA_DIST_PARAMS} -yqq --no-install-recommends install ${FK__KERNEL_PACKAGES}" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log || {
chroot_sdcard_apt_get_install "${FK__KERNEL_PACKAGES}" || {
display_alert "Failed to install flash-kernel's kernel packages." "${EXTENSION}" "err"
exit 28
}
@@ -47,14 +44,15 @@ function post_install_kernel_debs__install_kernel_and_flash_packages() {
umount "${SDCARD}"/sys
mkdir -p "${SDCARD}"/sys/firmware/efi
echo "-- install flash-kernel package" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get ${APT_EXTRA_DIST_PARAMS} -yqq --no-install-recommends install ${FK__TOOL_PACKAGE}" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log || {
chroot_sdcard_apt_get_install "${FK__TOOL_PACKAGE}" || {
display_alert "Failed to install flash-kernel package." "${EXTENSION}" "err"
exit 28
}
# Remove fake /sys/firmware (/efi) directory
rm -rf "${SDCARD}"/sys/firmware
return 0 # prevent future shortcircuits exiting with error
}
# @TODO: extract u-boot into an extension, so that core bsps don't have this stuff in there to begin with.
@@ -69,18 +67,18 @@ post_family_tweaks_bsp__remove_uboot_flash_kernel() {
pre_umount_final_image__remove_uboot_initramfs_hook_flash_kernel() {
# even if BSP still contained this (cached .deb), make sure by removing from ${MOUNT}
[[ -f "$MOUNT"/etc/initramfs/post-update.d/99-uboot ]] && rm -v "$MOUNT"/etc/initramfs/post-update.d/99-uboot
return 0 # shortcircuit above
}
function pre_update_initramfs__setup_flash_kernel() {
local chroot_target=$MOUNT
cp /usr/bin/"$QEMU_BINARY" "$chroot_target"/usr/bin/
deploy_qemu_binary_to_chroot "${chroot_target}"
mount_chroot "$chroot_target/" # this already handles /boot/firmware which is required for it to work.
# hack, umount the chroot's /sys, otherwise flash-kernel tries to EFI flash due to the build host (!) being EFI
umount "$chroot_target/sys"
echo "-- flash-kernel disabling hooks" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "$chroot_target" /bin/bash -c "chmod -v -x /etc/kernel/postinst.d/initramfs-tools" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1
chroot "$chroot_target" /bin/bash -c "chmod -v -x /etc/initramfs/post-update.d/flash-kernel" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1
chroot_custom "$chroot_target" chmod -v -x "/etc/kernel/postinst.d/initramfs-tools"
chroot_custom "$chroot_target" chmod -v -x "/etc/initramfs/post-update.d/flash-kernel"
export FIRMWARE_DIR="${MOUNT}"/boot/firmware
call_extension_method "pre_initramfs_flash_kernel" <<- 'PRE_INITRAMFS_FLASH_KERNEL'
@@ -90,9 +88,8 @@ function pre_update_initramfs__setup_flash_kernel() {
local update_initramfs_cmd="update-initramfs -c -k all"
display_alert "Updating flash-kernel initramfs..." "$update_initramfs_cmd" ""
echo "-- flash-kernel initramfs" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "$chroot_target" /bin/bash -c "$update_initramfs_cmd" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1 || {
display_alert "Failed to run '$update_initramfs_cmd'" "Check ${DEST}/"${LOG_SUBPATH}"/flash-kernel.log" "err"
chroot_custom "$chroot_target" "$update_initramfs_cmd" || {
display_alert "Failed to run '$update_initramfs_cmd'" "Check logs" "err"
exit 29
}
@@ -104,19 +101,17 @@ function pre_update_initramfs__setup_flash_kernel() {
local flash_kernel_cmd="FK_FORCE=yes flash-kernel --machine '${FK__MACHINE_MODEL}'" # FK_FORCE=yes is required since flash-kernel 3.104ubuntu14 / 3.106ubuntu7
display_alert "flash-kernel" "${FK__MACHINE_MODEL}" "info"
echo "-- flash-kernel itself" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "$chroot_target" /bin/bash -c "${flash_kernel_cmd}" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1 || {
display_alert "Failed to run '${flash_kernel_cmd}'" "Check ${DEST}/"${LOG_SUBPATH}"/flash-kernel.log" "err"
chroot_custom "$chroot_target" "${flash_kernel_cmd}" || {
display_alert "Failed to run '${flash_kernel_cmd}'" "Check logs" "err"
exit 29
}
display_alert "Re-enabling" "initramfs-tools/flash-kernel hook for kernel"
echo "-- flash-kernel re-enabling hooks" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log
chroot "$chroot_target" /bin/bash -c "chmod -v +x /etc/kernel/postinst.d/initramfs-tools" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1
chroot "$chroot_target" /bin/bash -c "chmod -v +x /etc/initramfs/post-update.d/flash-kernel" >> "${DEST}"/"${LOG_SUBPATH}"/flash-kernel.log 2>&1
chroot_custom "$chroot_target" chmod -v +x "/etc/kernel/postinst.d/initramfs-tools"
chroot_custom "$chroot_target" chmod -v +x "/etc/initramfs/post-update.d/flash-kernel"
umount_chroot "$chroot_target/"
rm "$chroot_target"/usr/bin/"$QEMU_BINARY"
umount_chroot "${chroot_target}/"
undeploy_qemu_binary_from_chroot "${chroot_target}"
display_alert "Disabling Armbian-core update_initramfs, was already done above." "${EXTENSION}"
unset KERNELSOURCE # ugly. sorry. we'll have better mechanism for this soon. this is tested at lib/debootstrap.sh:844