mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
kernel: introduce new hook pre_package_kernel_image; show vmlinuz file magic before/after hook; add -HK hook hash to kernel artifact version
This commit is contained in:
@@ -132,6 +132,13 @@ function artifact_kernel_prepare_version() {
|
||||
vars_config_hash="${hash_vars}"
|
||||
declare var_config_hash_short="${vars_config_hash:0:${short_hash_size}}"
|
||||
|
||||
# Hash the extension hooks
|
||||
declare -a extension_hooks_to_hash=("pre_package_kernel_image")
|
||||
declare -a extension_hooks_hashed=("$(dump_extension_method_sources_functions "${extension_hooks_to_hash[@]}")")
|
||||
declare hash_hooks="undetermined"
|
||||
hash_hooks="$(echo "${extension_hooks_hashed[@]}" | sha256sum | cut -d' ' -f1)"
|
||||
declare hash_hooks_short="${hash_hooks:0:${short_hash_size}}"
|
||||
|
||||
# @TODO: include the compiler version? host release?
|
||||
|
||||
# get the hashes of the lib/ bash sources involved...
|
||||
@@ -140,7 +147,7 @@ function artifact_kernel_prepare_version() {
|
||||
declare bash_hash="${hash_files}"
|
||||
declare bash_hash_short="${bash_hash:0:${short_hash_size}}"
|
||||
|
||||
declare common_version_suffix="S${short_sha1}-D${kernel_drivers_hash_short}-P${kernel_patches_hash_short}-C${config_hash_short}H${kernel_config_modification_hash_short}-V${var_config_hash_short}-B${bash_hash_short}"
|
||||
declare common_version_suffix="S${short_sha1}-D${kernel_drivers_hash_short}-P${kernel_patches_hash_short}-C${config_hash_short}H${kernel_config_modification_hash_short}-HK${hash_hooks_short}-V${var_config_hash_short}-B${bash_hash_short}"
|
||||
|
||||
# outer scope
|
||||
if [[ "${KERNEL_SKIP_MAKEFILE_VERSION:-"no"}" == "yes" ]]; then
|
||||
|
||||
@@ -171,18 +171,37 @@ function kernel_package_hook_helper() {
|
||||
function kernel_package_callback_linux_image() {
|
||||
display_alert "linux-image deb packaging" "${package_directory}" "debug"
|
||||
|
||||
declare installed_image_path="boot/vmlinuz-${kernel_version_family}" # using old mkdebian terminology here.
|
||||
declare image_name="Image" # "Image" for arm64. or, "zImage" for arm, or "vmlinuz" for others.
|
||||
# @TODO: we expect _all_ kernels to produce this, which is... not true.
|
||||
declare kernel_pre_package_path="${tmp_kernel_install_dirs[INSTALL_PATH]}"
|
||||
declare kernel_image_pre_package_path="${kernel_pre_package_path}/vmlinuz-${kernel_version_family}"
|
||||
declare installed_image_path="boot/vmlinuz-${kernel_version_family}" # using old mkdebian terminology here for compatibility
|
||||
|
||||
display_alert "Showing contents of Kbuild produced /boot" "linux-image" "debug"
|
||||
run_host_command_logged tree -C --du -h "${tmp_kernel_install_dirs[INSTALL_PATH]}"
|
||||
|
||||
display_alert "Kernel-built image filetype" "vmlinuz-${kernel_version_family}: $(file --brief "${kernel_image_pre_package_path}")" "info"
|
||||
|
||||
declare image_name="Image" # "Image" for arm64. or, "zImage" for arm, or "vmlinuz" for others. 'image_name' is for easy mkdebian compat
|
||||
# If NAME_KERNEL is set (usually in arch config file), warn and use that instead.
|
||||
if [[ -n "${NAME_KERNEL}" ]]; then
|
||||
display_alert "NAME_KERNEL is set" "using '${NAME_KERNEL}' instead of '${image_name}'" "debug"
|
||||
image_name="${NAME_KERNEL}"
|
||||
else
|
||||
display_alert "NAME_KERNEL is not set" "using default '${image_name}'" "debug"
|
||||
fi
|
||||
|
||||
display_alert "Showing contents of Kbuild produced /boot" "linux-image" "debug"
|
||||
run_host_command_logged tree -C --du -h "${tmp_kernel_install_dirs[INSTALL_PATH]}"
|
||||
# allow hook to do stuff here. Some (legacy/vendor/weird) kernels spit out a vmlinuz that needs manual conversion to uImage, etc.
|
||||
run_host_command_logged ls -la "${kernel_pre_package_path}" "${kernel_image_pre_package_path}"
|
||||
|
||||
call_extension_method "pre_package_kernel_image" <<- 'PRE_PACKAGE_KERNEL_IMAGE'
|
||||
*fix Image/uImage/zImage before packaging kernel*
|
||||
Some (legacy/vendor) kernels need preprocessing of the produced Image/uImage/zImage before packaging.
|
||||
Use this hook to do that, by modifying the file in place, in `${kernel_pre_package_path}` directory.
|
||||
The final file that will be used is stored in `${kernel_image_pre_package_path}` -- which you shouldn't change.
|
||||
PRE_PACKAGE_KERNEL_IMAGE
|
||||
|
||||
display_alert "Kernel image filetype after pre_package_kernel_image" "vmlinuz-${kernel_version_family}: $(file --brief "${kernel_image_pre_package_path}")" "info"
|
||||
|
||||
unset kernel_pre_package_path # be done with var after hook
|
||||
unset kernel_image_pre_package_path # be done with var after hook
|
||||
|
||||
run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_PATH]}" "${package_directory}/" # /boot stuff
|
||||
run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_MOD_PATH]}/lib" "${package_directory}/" # so "lib" stuff sits at the root
|
||||
|
||||
Reference in New Issue
Block a user