Skip to content

Commit

Permalink
extensions: don't export, declare -g
Browse files Browse the repository at this point in the history
  • Loading branch information
rpardini committed Apr 15, 2023
1 parent 0d276c9 commit f6f621b
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 101 deletions.
2 changes: 1 addition & 1 deletion extensions/c-plus-plus-compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

function add_host_dependencies__add_arm64_c_plus_plus_compiler() {
display_alert "Adding arm64 c++ compiler to host dependencies" "g++" "debug"
export EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} g++-aarch64-linux-gnu g++" # @TODO: convert to array later
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} g++-aarch64-linux-gnu g++" # @TODO: convert to array later
}
2 changes: 1 addition & 1 deletion extensions/cleanup-space-final-image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function add_host_dependencies__cleanup_space_final_image_zerofree() {
export EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} zerofree"
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} zerofree"
}

function post_customize_image__998_cleanup_apt_stuff() {
Expand Down
30 changes: 15 additions & 15 deletions extensions/flash-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# This runs *after* user_config. Don't change anything not coming from other variables or meant to be configured by the user.
function extension_prepare_config__prepare_flash_kernel() {
# Configuration defaults, or lack thereof.
export FK__TOOL_PACKAGE="${FK__TOOL_PACKAGE:-flash-kernel}"
export FK__PUBLISHED_KERNEL_VERSION="${FK__PUBLISHED_KERNEL_VERSION:-undefined-flash-kernel-version}"
export FK__EXTRA_PACKAGES="${FK__EXTRA_PACKAGES:-undefined-flash-kernel-kernel-package}"
export FK__KERNEL_PACKAGES="${FK__KERNEL_PACKAGES:-}"
export FK__MACHINE_MODEL="${FK__MACHINE_MODEL:-Undefined Flash-Kernel Machine}"
declare -g FK__TOOL_PACKAGE="${FK__TOOL_PACKAGE:-flash-kernel}"
declare -g FK__PUBLISHED_KERNEL_VERSION="${FK__PUBLISHED_KERNEL_VERSION:-undefined-flash-kernel-version}"
declare -g FK__EXTRA_PACKAGES="${FK__EXTRA_PACKAGES:-undefined-flash-kernel-kernel-package}"
declare -g FK__KERNEL_PACKAGES="${FK__KERNEL_PACKAGES:-}"
declare -g FK__MACHINE_MODEL="${FK__MACHINE_MODEL:-Undefined Flash-Kernel Machine}"

# Override certain variables. A case of "this extension knows better and modifies user configurable stuff".
export BOOTCONFIG="none" # To try and convince lib/ to not build or install u-boot.
unset BOOTSOURCE # To try and convince lib/ to not build or install u-boot.
export UEFISIZE=256 # in MiB. Not really UEFI, but partition layout is the same.
export BOOTSIZE=0 # No separate /boot, flash-kernel will "flash" the kernel+initrd to the firmware part.
export UEFI_MOUNT_POINT="/boot/firmware" # mount uefi partition at /boot/firmware
export CLOUD_INIT_CONFIG_LOCATION="/boot/firmware" # use /boot/firmware for cloud-init as well
export IMAGE_INSTALLED_KERNEL_VERSION="${FK__PUBLISHED_KERNEL_VERSION}" # For the VERSION
export EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-fk${FK__PUBLISHED_KERNEL_VERSION}" # Unique bsp name.
declare -g BOOTCONFIG="none" # To try and convince lib/ to not build or install u-boot.
unset BOOTSOURCE # To try and convince lib/ to not build or install u-boot.
declare -g UEFISIZE=256 # in MiB. Not really UEFI, but partition layout is the same.
declare -g BOOTSIZE=0 # No separate /boot, flash-kernel will "flash" the kernel+initrd to the firmware part.
declare -g UEFI_MOUNT_POINT="/boot/firmware" # mount uefi partition at /boot/firmware
declare -g CLOUD_INIT_CONFIG_LOCATION="/boot/firmware" # use /boot/firmware for cloud-init as well
declare -g IMAGE_INSTALLED_KERNEL_VERSION="${FK__PUBLISHED_KERNEL_VERSION}" # For the VERSION
declare -g EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-fk${FK__PUBLISHED_KERNEL_VERSION}" # Unique bsp name.
}

function post_install_kernel_debs__install_kernel_and_flash_packages() {
export INSTALL_ARMBIAN_FIRMWARE="no" # Disable Armbian-firmware install, which would happen after this method.
declare -g INSTALL_ARMBIAN_FIRMWARE="no" # Disable Armbian-firmware install, which would happen after this method.

if [[ "${FK__EXTRA_PACKAGES}" != "" ]]; then
display_alert "Installing flash-kernel extra packages" "${FK__EXTRA_PACKAGES}"
Expand Down Expand Up @@ -80,7 +80,7 @@ function pre_update_initramfs__setup_flash_kernel() {
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
declare -g FIRMWARE_DIR="${MOUNT}"/boot/firmware
call_extension_method "pre_initramfs_flash_kernel" <<- 'PRE_INITRAMFS_FLASH_KERNEL'
*prepare to update-initramfs before flashing kernel via flash_kernel*
A good spot to write firmware config to ${FIRMWARE_DIR} (/boot/firmware) before flash-kernel actually runs.
Expand Down
18 changes: 9 additions & 9 deletions extensions/gen-sample-extension-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ function extension_metadata_ready__docs_sample_extension() {

### Common stuff
function read_common_data() {
export HOOK_POINT_CALLS_COUNT=$(wc -l < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt")
export HOOK_POINT_CALLS_UNIQUE_COUNT=$(sort < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt" | uniq | wc -l)
export HOOK_POINTS_WITH_MULTIPLE_CALLS=""
declare -g HOOK_POINT_CALLS_COUNT=$(wc -l < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt")
declare -g HOOK_POINT_CALLS_UNIQUE_COUNT=$(sort < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt" | uniq | wc -l)
declare -g HOOK_POINTS_WITH_MULTIPLE_CALLS=""

# Read the hook_points (main, official names) from the hook point ordering file.
export ALL_HOOK_POINT_CALLS=$(xargs echo -n < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt")
declare -g ALL_HOOK_POINT_CALLS=$(xargs echo -n < "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt")
}

function loop_over_hook_points_and_call() {
local callback="$1"
HOOK_POINT_COUNTER=0
for one_hook_point in ${ALL_HOOK_POINT_CALLS}; do
export HOOK_POINT_COUNTER=$((HOOK_POINT_COUNTER + 1))
export HOOK_POINT="${one_hook_point}"
export MARKDOWN_HEAD="$(head -1 "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.orig.md")"
export MARKDOWN_BODY="$(tail -n +2 "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.orig.md")"
export COMPATIBILITY_NAMES="$(xargs echo -n < "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.compat")"
declare -g HOOK_POINT_COUNTER=$((HOOK_POINT_COUNTER + 1))
declare -g HOOK_POINT="${one_hook_point}"
declare -g MARKDOWN_HEAD="$(head -1 "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.orig.md")"
declare -g MARKDOWN_BODY="$(tail -n +2 "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.orig.md")"
declare -g COMPATIBILITY_NAMES="$(xargs echo -n < "${EXTENSION_MANAGER_TMP_DIR}/${one_hook_point}.compat")"
${callback}
done
}
Expand Down
28 changes: 14 additions & 14 deletions extensions/grub-riscv64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
function extension_prepare_config__prepare_grub-riscv64() {
display_alert "Prepare config" "${EXTENSION}" "info"
# Extension configuration defaults.
export DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:-no} # if yes, does not build our own kernel, instead, uses generic one from distro
export UEFI_GRUB_TERMINAL="${UEFI_GRUB_TERMINAL:-serial console}" # 'serial' forces grub menu on serial console. empty to not include
export UEFI_GRUB_DISABLE_OS_PROBER="${UEFI_GRUB_DISABLE_OS_PROBER:-}" # 'true' will disable os-probing, useful for SD cards.
export UEFI_GRUB_DISTRO_NAME="${UEFI_GRUB_DISTRO_NAME:-Armbian}" # Will be used on grub menu display
export UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-0} # Small timeout by default
export GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:-""}" # Cmdline by default
declare -g DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:-no} # if yes, does not build our own kernel, instead, uses generic one from distro
declare -g UEFI_GRUB_TERMINAL="${UEFI_GRUB_TERMINAL:-serial console}" # 'serial' forces grub menu on serial console. empty to not include
declare -g UEFI_GRUB_DISABLE_OS_PROBER="${UEFI_GRUB_DISABLE_OS_PROBER:-}" # 'true' will disable os-probing, useful for SD cards.
declare -g UEFI_GRUB_DISTRO_NAME="${UEFI_GRUB_DISTRO_NAME:-Armbian}" # Will be used on grub menu display
declare -g UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-0} # Small timeout by default
declare -g GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:-""}" # Cmdline by default
# User config overrides.
export BOOTCONFIG="none" # To try and convince lib/ to not build or install u-boot.
unset BOOTSOURCE # To try and convince lib/ to not build or install u-boot.
export IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff.
export UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions
export BOOTSIZE=0 # No separate /boot when using UEFI.
export CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub.
export EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name.
export UEFI_GRUB_TARGET="riscv64-efi" # Default for x86_64
declare -g BOOTCONFIG="none" # To try and convince lib/ to not build or install u-boot.
unset BOOTSOURCE # To try and convince lib/ to not build or install u-boot.
declare -g IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff.
declare -g UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions
declare -g BOOTSIZE=0 # No separate /boot when using UEFI.
declare -g CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub.
declare -g EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name.
declare -g UEFI_GRUB_TARGET="riscv64-efi" # Default for x86_64

if [[ "${DISTRIBUTION}" != "Ubuntu" && "${BUILDING_IMAGE}" == "yes" ]]; then
exit_with_error "${DISTRIBUTION} is not supported yet"
Expand Down
36 changes: 18 additions & 18 deletions extensions/grub-sbc-media.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
function extension_prepare_config__prepare_grub-sbc-media() {
display_alert "Prepare config" "${EXTENSION}" "info"
# Extension configuration defaults.
export DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:-no} # if yes, does not build our own kernel, instead, uses generic one from distro
export UEFI_GRUB_DISABLE_OS_PROBER="${UEFI_GRUB_DISABLE_OS_PROBER:-}" # 'true' will disable os-probing, useful for SD cards.
export UEFI_GRUB_DISTRO_NAME="${UEFI_GRUB_DISTRO_NAME:-Armbian}" # Will be used on grub menu display
export UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-3} # Small timeout by default
export UEFI_GRUB_RECORDFAIL_TIMEOUT=${UEFI_GRUB_RECORDFAIL_TIMEOUT:-3}
export GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:-}" # Cmdline by default
export UEFI_ENABLE_BIOS_AMD64="${UEFI_ENABLE_BIOS_AMD64:-no}" # Enable BIOS too if target is amd64
declare -g DISTRO_GENERIC_KERNEL=${DISTRO_GENERIC_KERNEL:-no} # if yes, does not build our own kernel, instead, uses generic one from distro
declare -g UEFI_GRUB_DISABLE_OS_PROBER="${UEFI_GRUB_DISABLE_OS_PROBER:-}" # 'true' will disable os-probing, useful for SD cards.
declare -g UEFI_GRUB_DISTRO_NAME="${UEFI_GRUB_DISTRO_NAME:-Armbian}" # Will be used on grub menu display
declare -g UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-3} # Small timeout by default
declare -g UEFI_GRUB_RECORDFAIL_TIMEOUT=${UEFI_GRUB_RECORDFAIL_TIMEOUT:-3}
declare -g GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT:-}" # Cmdline by default
declare -g UEFI_ENABLE_BIOS_AMD64="${UEFI_ENABLE_BIOS_AMD64:-no}" # Enable BIOS too if target is amd64
# User config overrides.
export IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff.
export UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions
export BOOTSIZE=0 # No separate /boot when using UEFI.
export CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub.
export EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name.
export UEFI_GRUB_TARGET_BIOS="" # Target for BIOS GRUB install, set to i386-pc when UEFI_ENABLE_BIOS_AMD64=yes and target is amd64
local uefi_packages="efibootmgr efivar" # Use growroot, add some efi-related packages
uefi_packages="os-prober grub-efi-${ARCH}-bin ${uefi_packages}" # This works for Ubuntu and Debian, by sheer luck; common for EFI and BIOS

[[ "${ARCH}" == "arm64" ]] && export uefi_packages="${uefi_packages} grub-efi-${ARCH}"
[[ "${ARCH}" == "arm64" ]] && export UEFI_GRUB_TARGET="arm64-efi" # Default for arm64-efi
declare -g IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff.
declare -g UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions
declare -g BOOTSIZE=0 # No separate /boot when using UEFI.
declare -g CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub.
declare -g EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name.
declare -g UEFI_GRUB_TARGET_BIOS="" # Target for BIOS GRUB install, set to i386-pc when UEFI_ENABLE_BIOS_AMD64=yes and target is amd64
local uefi_packages="efibootmgr efivar" # Use growroot, add some efi-related packages
uefi_packages="os-prober grub-efi-${ARCH}-bin ${uefi_packages}" # This works for Ubuntu and Debian, by sheer luck; common for EFI and BIOS

[[ "${ARCH}" == "arm64" ]] && declare -g uefi_packages="${uefi_packages} grub-efi-${ARCH}"
[[ "${ARCH}" == "arm64" ]] && declare -g UEFI_GRUB_TARGET="arm64-efi" # Default for arm64-efi

DISTRO_KERNEL_PACKAGES=""
DISTRO_FIRMWARE_PACKAGES=""
Expand Down
Loading

0 comments on commit f6f621b

Please sign in to comment.