armbian-build/lib/functions/image/compress-checksum.sh
Igor Pecovnik 4d60ce08f2 chore: update copyright years to 2026
Update all copyright notices in shell scripts from 2025 to 2026.

## Changes

- **Igor Pecovnik**: 2013-2025 → 2013-2026 (129 files)
- **Ricardo Pardini**: 2023-2025 → 2023-2026, 2020-2025 → 2020-2026 (5 files)

## Additional Improvements

Also updated the backtitle in `lib/functions/configuration/interactive.sh`:
- Changed title from "Armbian building script" to "Armbian Linux build framework"
- Removed docs link for cleaner display
- Uses dynamic year calculation with separate declaration (fixes shellcheck SC2155)
2025-12-25 12:03:34 +01:00

60 lines
2.2 KiB
Bash

#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2026 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function output_images_compress_and_checksum() {
[[ -n $SEND_TO_SERVER ]] && return 0
# check that 'version' is set
[[ -z $version ]] && exit_with_error "version is not set"
# compression_type: declared in outer scope
declare prefix_images="${1}"
# find all files that match prefix_images
declare -a images=("${prefix_images}"*)
# if no files match prefix_images, exit
if [[ ${#images[@]} -eq 0 ]]; then
display_alert "No files to compress and checksum" "no images will be compressed" "wrn"
return 0
fi
# loop over images
for uncompressed_file in "${images[@]}"; do
# if image is a symlink, skip it
[[ -L "${uncompressed_file}" ]] && continue
# if image is not a file, skip it
[[ ! -f "${uncompressed_file}" ]] && continue
# if filename ends in .txt, skip it
[[ "${uncompressed_file}" == *.txt ]] && continue
# get just the filename, sans path
declare uncompressed_file_basename
uncompressed_file_basename=$(basename "${uncompressed_file}")
declare xz_compression_ratio_image="${IMAGE_XZ_COMPRESSION_RATIO:-"1"}"
if [[ $COMPRESS_OUTPUTIMAGE == *xz* ]]; then
display_alert "Compressing with xz" "${uncompressed_file_basename}.xz" "info"
xz -T 0 "-${xz_compression_ratio_image}" "${uncompressed_file}" # "If xz is provided with input but no output, it will delete the input"
compression_type=".xz"
elif [[ $COMPRESS_OUTPUTIMAGE == *zst* ]]; then
display_alert "Compressing with zstd" "${uncompressed_file_basename}.zst" "info"
zstdmt "-${ZSTD_COMPRESSION_LEVEL:-9}" "${uncompressed_file}" -o "${uncompressed_file}.zst"
rm -f "${uncompressed_file}"
compression_type=".zst"
fi
if [[ $COMPRESS_OUTPUTIMAGE == *sha* ]]; then
display_alert "SHA256 calculating" "${uncompressed_file_basename}${compression_type}" "info"
# awk manipulation is needed to get rid of temporal folder path from SHA signature
sha256sum -b "${uncompressed_file}${compression_type}" | awk '{split($2, a, "/"); print $1, a[length(a)]}' > "${uncompressed_file}${compression_type}".sha
fi
done
}