mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
armbian-next: artifacts: firmware/rootfs and actual usage of artifacts during image build
- artifacts: introduce `ARTIFACT_IGNORE_CACHE=yes` - artifacts: introduce `DONT_BUILD_ARTIFACTS`, list of artifacts that if not found cached, fail the build - kernel_package_source() is no more - a long dissertation about kernels, families, and the universe - artifacts: actually use rootfs artifact for image build - artifacts: detangle via artifact_base_dir - artifacts: rootfs: use folders in artifact_name; include cache_type - artifacts: some cleanups / validations - rootfs artifact; drop old rootfs cli - artifacts: new CLI shortcuts; remove old firmware CLI - artifacts: full firmware & usage - use firmware artifacts in image build and install its debs - kernel artifact sans legacy; use tmpdir for .deb target for all packages - legacy artifact versions is no more; pack/unpack now in common obtain; - artifacts: uboot: cleanup legacy renaming, use artifact version directly - artifacts: add firmware (small) artifact - deploy uboot to loop from artifact; allow tty to artifact; todos for cleaning - fixes, kernel dtb/headers conditional; remove `.git` from Makefile url; use mapfile for finding files to hash - completely remove KERNEL_HAS_WORKING_HEADERS_FULL_SOURCE and `kernel_package_callback_linux_headers_full_source()` - don't use realpath for artifact_file_relative - curb some warnings - fix: only install headers & dtbs if such exist - kernel .config hook modification hash versioning - OCI_TARGET_BASE vs per-artifact defaults; only deploy to remote from CLI with OTB - artifact revolver & installing into image - add artifact_map_packages and artifact_map_debs dicts - revolver accumulates all info - REPOSITORY_INSTALL is no more (for uboot/kernel, later others) - rename `VER` to `IMAGE_INSTALLED_KERNEL_VERSION`
This commit is contained in:
136
lib/functions/artifacts/artifact-rootfs.sh
Normal file
136
lib/functions/artifacts/artifact-rootfs.sh
Normal file
@@ -0,0 +1,136 @@
|
||||
function artifact_rootfs_prepare_version() {
|
||||
artifact_version="undetermined" # outer scope
|
||||
artifact_version_reason="undetermined" # outer scope
|
||||
|
||||
assert_requires_aggregation # Bombs if aggregation has not run
|
||||
|
||||
declare -g rootfs_cache_id="none_yet"
|
||||
|
||||
calculate_rootfs_cache_id # sets rootfs_cache_id
|
||||
|
||||
display_alert "Going to build rootfs" "packages_hash: '${packages_hash:-}' cache_type: '${cache_type:-}' rootfs_cache_id: '${rootfs_cache_id}'" "info"
|
||||
|
||||
declare -a reasons=(
|
||||
"arch \"${ARCH}\""
|
||||
"release \"${RELEASE}\""
|
||||
"type \"${cache_type}\""
|
||||
"cache_id \"${rootfs_cache_id}\""
|
||||
)
|
||||
|
||||
# @TODO: "rootfs_cache_id" contains "cache_type", split so we don't repeat ourselves
|
||||
# @TODO: gotta include the extensions rootfs-modifying id to cache_type...
|
||||
|
||||
# outer scope
|
||||
artifact_version="${rootfs_cache_id}"
|
||||
artifact_version_reason="${reasons[*]}"
|
||||
artifact_name="rootfs/rootfs-${ARCH}/rootfs-${ARCH}-${RELEASE}-${cache_type}"
|
||||
artifact_type="tar.zst"
|
||||
artifact_base_dir="${SRC}/cache/rootfs"
|
||||
artifact_final_file="${SRC}/cache/rootfs/${ARCH}-${RELEASE}-${rootfs_cache_id}.tar.zst"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function artifact_rootfs_build_from_sources() {
|
||||
debug_var artifact_final_file
|
||||
debug_var artifact_final_file_basename
|
||||
|
||||
# Creates a cleanup handler 'trap_handler_cleanup_rootfs_and_image'
|
||||
LOG_SECTION="prepare_rootfs_build_params_and_trap" do_with_logging prepare_rootfs_build_params_and_trap
|
||||
|
||||
debug_var artifact_final_file
|
||||
debug_var artifact_final_file_basename
|
||||
|
||||
# validate that tmpfs_estimated_size is set and higher than zero, or exit_with_error
|
||||
[[ -z ${tmpfs_estimated_size} ]] && exit_with_error "tmpfs_estimated_size is not set"
|
||||
[[ ${tmpfs_estimated_size} -le 0 ]] && exit_with_error "tmpfs_estimated_size is not higher than zero"
|
||||
|
||||
# "rootfs" CLI skips over a lot goes straight to create the rootfs. It doesn't check cache etc.
|
||||
LOG_SECTION="create_new_rootfs_cache" do_with_logging create_new_rootfs_cache
|
||||
|
||||
debug_var artifact_final_file
|
||||
debug_var artifact_final_file_basename
|
||||
debug_var cache_name
|
||||
debug_var cache_fname
|
||||
|
||||
if [[ ! -f "${artifact_final_file}" ]]; then
|
||||
exit_with_error "Rootfs cache file '${artifact_final_file}' does not exist after create_new_rootfs_cache()."
|
||||
else
|
||||
display_alert "Rootfs cache file '${artifact_final_file}' exists after create_new_rootfs_cache()." "YESSS" "warn"
|
||||
fi
|
||||
|
||||
# obtain the size, in MiB, of "${SDCARD}" at this point.
|
||||
declare -i rootfs_size_mib
|
||||
rootfs_size_mib=$(du -sm "${SDCARD}" | awk '{print $1}')
|
||||
display_alert "Actual rootfs size" "${rootfs_size_mib}MiB after basic/cache" ""
|
||||
|
||||
# warn if rootfs_size_mib is higher than the tmpfs_estimated_size
|
||||
if [[ ${rootfs_size_mib} -gt ${tmpfs_estimated_size} ]]; then
|
||||
display_alert "Rootfs actual size is larger than estimated tmpfs size after basic/cache" "${rootfs_size_mib}MiB > ${tmpfs_estimated_size}MiB" "wrn"
|
||||
fi
|
||||
|
||||
# Run the cleanup handler.
|
||||
execute_and_remove_cleanup_handler trap_handler_cleanup_rootfs_and_image
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function artifact_rootfs_cli_adapter_pre_run() {
|
||||
declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="yes" # Require prepare_host_basic to run before the command.
|
||||
|
||||
# "gimme root on a Linux machine"
|
||||
cli_standard_relaunch_docker_or_sudo
|
||||
}
|
||||
|
||||
function artifact_rootfs_cli_adapter_config_prep() {
|
||||
declare -g ROOTFS_COMPRESSION_RATIO="${ROOTFS_COMPRESSION_RATIO:-"15"}" # default to Compress stronger when we make rootfs cache
|
||||
|
||||
# If BOARD is set, use it to convert to an ARCH.
|
||||
if [[ -n ${BOARD} ]]; then
|
||||
display_alert "BOARD is set, converting to ARCH for rootfs building" "'BOARD=${BOARD}'" "warn"
|
||||
# Convert BOARD to ARCH; source the BOARD and FAMILY stuff
|
||||
LOG_SECTION="config_source_board_file" do_with_conditional_logging config_source_board_file
|
||||
LOG_SECTION="source_family_config_and_arch" do_with_conditional_logging source_family_config_and_arch
|
||||
display_alert "Done sourcing board file" "'${BOARD}' - arch: '${ARCH}'" "warn"
|
||||
fi
|
||||
|
||||
declare -a vars_need_to_be_set=("RELEASE" "ARCH")
|
||||
# loop through all vars and check if they are not set and bomb out if so
|
||||
for var in "${vars_need_to_be_set[@]}"; do
|
||||
if [[ -z ${!var} ]]; then
|
||||
exit_with_error "Param '${var}' is not set but needs to be set for rootfs CLI."
|
||||
fi
|
||||
done
|
||||
|
||||
declare -r __wanted_rootfs_arch="${ARCH}"
|
||||
declare -g -r RELEASE="${RELEASE}" # make readonly for finding who tries to change it
|
||||
declare -g -r NEEDS_BINFMT="yes" # make sure binfmts are installed during prepare_host_interactive
|
||||
|
||||
# prep_conf_main_only_rootfs_ni is prep_conf_main_only_rootfs_ni() + mark_aggregation_required_in_default_build_start()
|
||||
prep_conf_main_only_rootfs_ni < /dev/null # no stdin for this, so it bombs if tries to be interactive.
|
||||
|
||||
declare -g -r ARCH="${ARCH}" # make readonly for finding who tries to change it
|
||||
if [[ "${ARCH}" != "${__wanted_rootfs_arch}" ]]; then
|
||||
exit_with_error "Param 'ARCH' is set to '${ARCH}' after config, but different from wanted '${__wanted_rootfs_arch}'"
|
||||
fi
|
||||
}
|
||||
|
||||
function artifact_rootfs_get_default_oci_target() {
|
||||
artifact_oci_target_base="ghcr.io/rpardini/armbian-release/"
|
||||
}
|
||||
|
||||
function artifact_rootfs_is_available_in_local_cache() {
|
||||
is_artifact_available_in_local_cache
|
||||
}
|
||||
|
||||
function artifact_rootfs_is_available_in_remote_cache() {
|
||||
is_artifact_available_in_remote_cache
|
||||
}
|
||||
|
||||
function artifact_rootfs_obtain_from_remote_cache() {
|
||||
obtain_artifact_from_remote_cache
|
||||
}
|
||||
|
||||
function artifact_rootfs_deploy_to_remote_cache() {
|
||||
upload_artifact_to_oci
|
||||
}
|
||||
Reference in New Issue
Block a user