Skip to content

Commit 009ad31

Browse files
committed
bootable: cleanup logging; use bat/tree helpers
Signed-off-by: Ricardo Pardini <[email protected]>
1 parent 3e68832 commit 009ad31

File tree

4 files changed

+26
-36
lines changed

4 files changed

+26
-36
lines changed

bash/bootable-media.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ function build_bootable_media() {
1313
get_bootable_info_dict "${bootable_id}"
1414

1515
# Dump the bootable_info dict
16-
log info "bootable_info: $(declare -p bootable_info)"
16+
log debug "bootable_info: $(declare -p bootable_info)"
1717

1818
# Get the kernel info from the bootable_info INVENTORY_ID
1919
declare -g -A kernel_info=()
2020
declare -g inventory_id="${bootable_info['INVENTORY_ID']}"
2121
get_kernel_info_dict "${inventory_id}"
22-
log info "kernel_info: $(declare -p kernel_info)"
22+
log debug "kernel_info: $(declare -p kernel_info)"
2323
set_kernel_vars_from_info_dict
2424
kernel_obtain_output_id # sets OUTPUT_ID
2525

@@ -82,11 +82,16 @@ function output_bootable_media() {
8282
return 0
8383
fi
8484

85+
declare human_size_input_file=""
86+
human_size_input_file="$(du -h "${input_file}" | awk '{print $1}')"
87+
8588
# Use pixz to compress the image; use all CPU cores, default compression level
86-
log info "Compressing image file ${input_file} to ${full_output_fn} -- wait..."
89+
log info "Compressing image file ${input_file} (${human_size_input_file}) to ${full_output_fn} -- wait..."
8790
pixz -i "${input_file}" -o "${full_output_fn}"
88-
ls -lah "${full_output_fn}"
89-
log info "Compressed image file ${input_file} to ${full_output_fn}"
91+
92+
declare human_size_output_file=""
93+
human_size_output_file="$(du -h "${full_output_fn}" | awk '{print $1}')"
94+
log info "Compressed image file to ${full_output_fn} (${human_size_output_file})"
9095

9196
return 0
9297
}

bash/bootable/armbian-u-boot.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ function build_bootable_armbian_uboot() {
122122
mkdir -p "${fat32_root_dir}"
123123

124124
# Kernel and initrd go directly in the root of the FAT32 partition
125-
cp -vp "out/hook/vmlinuz-${hook_id}" "${fat32_root_dir}/vmlinuz"
126-
cp -vp "out/hook/initramfs-${hook_id}" "${fat32_root_dir}/initramfs"
125+
cp -p "${debug_dash_v[@]}" "out/hook/vmlinuz-${hook_id}" "${fat32_root_dir}/vmlinuz"
126+
cp -p "${debug_dash_v[@]}" "out/hook/initramfs-${hook_id}" "${fat32_root_dir}/initramfs"
127127

128128
declare -i initramfs_size_bytes
129129
initramfs_size_bytes=$(stat --format="%s" "${fat32_root_dir}/initramfs")
@@ -139,34 +139,25 @@ function build_bootable_armbian_uboot() {
139139
# it also might require the metadata files from the uboot tarball, as those have details eg the exact DTB to use, console information, etc.
140140
write_uboot_script_or_extlinux "${fat32_root_dir}"
141141

142-
# Show the state
143-
du -h -d 1 "${bootable_base_dir}"
144-
145142
# Use a Dockerfile to assemble a GPT image, with a single FAT32 partition, containing the files in the fat32-root directory
146143
# This is common across all GPT-based bootable media; the only difference is the ESP flag, which is set for UEFI bootable media but not for Rockchip/RaspberryPi
147144
# The u-boot binaries are written _later_ in the process, after the image is created, using Armbian's helper scripts.
148145
create_image_fat32_root_from_dir "${bootable_base_dir}" "bootable-media-${BOARD}-${BRANCH}.img" "${bootable_dir}/fat32-root"
149146

150-
log info "Show info about produced image..."
151-
ls -lah "${bootable_base_dir}/bootable-media-${BOARD}-${BRANCH}.img"
152-
153147
# Deploy u-boot binaries to the image; use the function defined in the platform_install.sh script
154148
# They should only use 'dd' or such; we've special handling for dd, to add 'conv=trunc'
155149

156150
# shellcheck disable=SC2317 # used by write_uboot_platform
157151
function dd() {
158152
# We're going to use dd to write the u-boot binaries to the image; log the command and then run it
159-
log info "dd: ${1} + conv=notrunc"
153+
log debug "dd: ${1} + conv=notrunc"
160154
log debug "dd: ${*@Q}"
161155
command dd "$@" "conv=notrunc"
162156
}
163157

164158
log info "Writing u-boot binaries to the image..."
165159
write_uboot_platform "${uboot_extract_dir}" "${bootable_base_dir}/bootable-media-${BOARD}-${BRANCH}.img"
166160

167-
log info "Show info about produced image (with written u-boot)..."
168-
ls -lah "${bootable_base_dir}/bootable-media-${BOARD}-${BRANCH}.img"
169-
170161
log info "Done building Armbian u-boot for hook ${hook_id} with type ${uboot_type}"
171162
output_bootable_media "${bootable_base_dir}/bootable-media-${BOARD}-${BRANCH}.img" "hook-bootable-${BOARD}-${BRANCH}.img"
172163

@@ -221,7 +212,7 @@ function write_uboot_script() {
221212
booti \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}
222213
BOOT_CMD
223214

224-
command -v bat &> /dev/null && bat --file-name "boot.scr" "${boot_cmd_file}"
215+
log_file_bat "${boot_cmd_file}" "info" "Produced Armbian u-boot boot.cmd/boot.scr"
225216

226217
return 0
227218
}
@@ -249,7 +240,7 @@ function write_uboot_extlinux() {
249240
EXTLINUX_CONF
250241
# @TODO: fdtdir when UBOOT_KERNEL_DTB is unset
251242

252-
command -v bat && bat --file-name "extlinux.conf" "${extlinux_conf}"
243+
log_file_bat "${extlinux_conf}" "info" "Produced Armbian u-boot extlinux.conf"
253244

254245
return 0
255246
}

bash/bootable/grub.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function build_bootable_grub() {
4949
mkdir -p "${fat32_root_dir}"
5050

5151
# Kernel and initrd go directly in the root of the FAT32 partition
52-
cp -vp "out/hook/${hook_files['kernel']}" "${fat32_root_dir}/vmlinuz"
53-
cp -vp "out/hook/${hook_files['initrd']}" "${fat32_root_dir}/initrd.img"
52+
cp -p "${debug_dash_v[@]}" "out/hook/${hook_files['kernel']}" "${fat32_root_dir}/vmlinuz"
53+
cp -p "${debug_dash_v[@]}" "out/hook/${hook_files['initrd']}" "${fat32_root_dir}/initrd.img"
5454

5555
# Handle DTBs
5656
if [[ "${has_dtbs}" == "yes" ]]; then
@@ -78,19 +78,16 @@ function build_bootable_grub() {
7878
initrd /initrd.img
7979
}
8080
GRUB_CFG
81+
bat_language="Plain text" log_file_bat "${fat32_efi_dir}/grub.cfg" "info" "Produced GRUB grub.cfg"
8182

8283
# Show the state
83-
du -h -d 1 "${bootable_base_dir}"
8484
log_tree "${bootable_base_dir}" "debug" "State of the bootable directory"
8585

8686
# Use a Dockerfile to assemble a GPT image, with a single FAT32 partition, containing the files in the fat32-root directory
8787
# This is common across all GPT-based bootable media; the only difference is the ESP flag, which is set for UEFI bootable media.
8888
esp_partitition="yes" \
8989
create_image_fat32_root_from_dir "${bootable_base_dir}" "${bootable_img}" "${bootable_dir}/fat32-root"
9090

91-
log info "Show info about produced image..."
92-
ls -lah "${bootable_base_dir}/${bootable_img}"
93-
9491
log info "Done building grub bootable for hook ${hook_id}"
9592
output_bootable_media "${bootable_base_dir}/${bootable_img}" "hook-bootable-grub-${OUTPUT_ID}.img"
9693

bash/bootable/rpi.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ function build_bootable_rpi_firmware() {
3535
mkdir -p "${fat32_root_dir}"
3636

3737
# Kernel and initrd go directly in the root of the FAT32 partition
38-
cp -vp "out/hook/vmlinuz-${hook_id}" "${fat32_root_dir}/vmlinuz"
39-
cp -vp "out/hook/initramfs-${hook_id}" "${fat32_root_dir}/initrd.img"
38+
cp -p "${debug_dash_v[@]}" "out/hook/vmlinuz-${hook_id}" "${fat32_root_dir}/vmlinuz"
39+
cp -p "${debug_dash_v[@]}" "out/hook/initramfs-${hook_id}" "${fat32_root_dir}/initrd.img"
4040

4141
# Handle DTBs for rpi
4242
mkdir -p "${fat32_root_dir}/dtb"
4343
tar -C "${fat32_root_dir}/dtb" --strip-components=1 -xzf "out/hook/dtbs-${hook_id}.tar.gz"
4444
log_tree "${fat32_root_dir}" "debug" "State of the FAT32 directory pre-moving DTBs"
4545

4646
# RPi: put DTBs directly in the fat32-root directory; overlays go into a subdirectory
47-
mv -v "${fat32_root_dir}/dtb/overlays" "${fat32_root_dir}/overlays"
48-
mv -v "${fat32_root_dir}/dtb/broadcom"/*.dtb "${fat32_root_dir}/"
47+
mv "${debug_dash_v[@]}" "${fat32_root_dir}/dtb/overlays" "${fat32_root_dir}/overlays"
48+
mv "${debug_dash_v[@]}" "${fat32_root_dir}/dtb/broadcom"/*.dtb "${fat32_root_dir}/"
4949
rm -rf "${fat32_root_dir}/dtb"
5050
log_tree "${fat32_root_dir}" "debug" "State of the FAT32 directory post-moving DTBs"
5151

@@ -54,18 +54,11 @@ function build_bootable_rpi_firmware() {
5454
rpi_write_config_txt "${fat32_root_dir}"
5555
rpi_write_cmdline_txt "${fat32_root_dir}"
5656

57-
# Show the state
58-
du -h -d 1 "${bootable_base_dir}"
59-
tree "${bootable_base_dir}"
60-
6157
# Use a Dockerfile to assemble a GPT image, with a single FAT32 partition, containing the files in the fat32-root directory
6258
# This is common across all GPT-based bootable media; the only difference is the ESP flag, which is set for UEFI bootable media but not for Rockchip/RaspberryPi
6359
# The u-boot binaries are written _later_ in the process, after the image is created, using Armbian's helper scripts.
6460
create_image_fat32_root_from_dir "${bootable_base_dir}" "bootable-media-rpi.img" "${bootable_dir}/fat32-root"
6561

66-
log info "Show info about produced image..."
67-
ls -lah "${bootable_base_dir}/bootable-media-rpi.img"
68-
6962
log info "Done building rpi bootable for hook ${hook_id}"
7063
output_bootable_media "${bootable_base_dir}/bootable-media-rpi.img" "hook-bootable-rpi.img"
7164

@@ -129,6 +122,8 @@ function rpi_write_config_txt() {
129122
initramfs initrd.img followkernel
130123
arm_64bit=1
131124
RPI_CONFIG_TXT
125+
126+
bat_language="ini" log_file_bat "${fat32_root_dir}/config.txt" "info" "Produced rpi config.txt"
132127
}
133128

134129
function rpi_write_cmdline_txt() {
@@ -140,4 +135,6 @@ function rpi_write_cmdline_txt() {
140135
cat <<- RPI_CMDLINE_TXT > "${fat32_root_dir}/cmdline.txt"
141136
console=tty1 console=ttyAMA0,115200 loglevel=7 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory ${tinkerbell_args}
142137
RPI_CMDLINE_TXT
138+
139+
log_file_bat "${fat32_root_dir}/cmdline.txt" "info" "Produced rpi cmdline.txt"
143140
}

0 commit comments

Comments
 (0)