bsp-cli/BETA: fixes for bsp-cli bootscript hashing; don't normalize bootscript vars; debugging for BETA=yes/no stuff

also:
- get rid of comments and `SUBREVISION` and `RC` variables
- better debugging in calculate_hash_for_variables() do_normalize_src_path=yes/no
- tag a few places where output/debs might wrong in face of BETA=yes/no
This commit is contained in:
Ricardo Pardini 2023-05-25 14:08:35 +02:00 committed by igorpecovnik
parent 316c4117dd
commit 31131fe14e
6 changed files with 43 additions and 24 deletions

View File

@ -35,22 +35,33 @@ function artifact_armbian-bsp-cli_prepare_version() {
hash_hooks="$(echo "${hooks_to_hash[@]}" | sha256sum | cut -d' ' -f1)"
declare hash_hooks_short="${hash_hooks:0:${short_hash_size}}"
# Hash variables/bootscripts that affect the contents of bsp-cli package
get_bootscript_info # get bootscript info, that is included in bsp-cli, hash it
# get the bootscript info...
declare -A bootscript_info=()
get_bootscript_info # fills in bootscript_info array
# Hash variables/bootscripts that affect the contents of bsp-cli package.
# Those contain /armbian a lot, so don't normalize them.
declare -a vars_to_hash_no_normalize=(
"bootscript_file_contents: ${bootscript_info[bootscript_file_contents]}"
"bootenv_file_contents: ${bootscript_info[bootenv_file_contents]}"
)
declare hash_variables="undetermined" # will be set by calculate_hash_for_variables(), but without normalization
do_normalize_src_path="no" calculate_hash_for_variables "${vars_to_hash_no_normalize[@]}" # don't normalize
declare hash_vars_no_normalize="${hash_variables}"
declare -a vars_to_hash=(
"${bootscript_info[bootscript_file_contents]}"
"${bootscript_info[bootenv_file_contents]}"
"${bootscript_info[has_bootscript]}"
"${bootscript_info[has_extlinux]}"
"${UBOOT_FW_ENV}" # not included in bootscript
"${KEEP_ORIGINAL_OS_RELEASE:-"no"}" # /etc/os-release
"${BOARDFAMILY}" # /etc/armbian-release
"${LINUXFAMILY}" # /etc/armbian-release
"${IMAGE_TYPE}" # /etc/armbian-release
"${BOARD_TYPE}" # /etc/armbian-release
"${INITRD_ARCH}" # /etc/armbian-release
"${KERNEL_IMAGE_TYPE}" # /etc/armbian-release
"${VENDOR}" # /etc/armbian-release
"has_bootscript: ${bootscript_info[has_bootscript]}"
"has_extlinux: ${bootscript_info[has_extlinux]}"
"UBOOT_FW_ENV: ${UBOOT_FW_ENV}" # not included in bootscript
"KEEP_ORIGINAL_OS_RELEASE: ${KEEP_ORIGINAL_OS_RELEASE:-"no"}" # /etc/os-release
"BOARDFAMILY: ${BOARDFAMILY}" # /etc/armbian-release
"LINUXFAMILY: ${LINUXFAMILY}" # /etc/armbian-release
"IMAGE_TYPE: ${IMAGE_TYPE}" # /etc/armbian-release
"BOARD_TYPE: ${BOARD_TYPE}" # /etc/armbian-release
"INITRD_ARCH: ${INITRD_ARCH}" # /etc/armbian-release
"KERNEL_IMAGE_TYPE: ${KERNEL_IMAGE_TYPE}" # /etc/armbian-release
"VENDOR: ${VENDOR}" # /etc/armbian-release
"hash_vars_no_normalize: ${hash_vars_no_normalize}" # The non-normalized part, above
)
declare hash_variables="undetermined" # will be set by calculate_hash_for_variables(), which normalizes the input
calculate_hash_for_variables "${vars_to_hash[@]}"

View File

@ -73,7 +73,7 @@ function cli_json_info_run() {
if [[ ! -f "${DEBS_TO_REPO_INFO_FILE}" ]]; then
exit_with_error "debs-to-repo-download :: no ${DEBS_TO_REPO_INFO_FILE} file found; did you restore the pipeline artifacts correctly?"
fi
declare DEBS_OUTPUT_DIR="${DEST}/debs"
declare DEBS_OUTPUT_DIR="${DEST}/debs" # @TODO: this is wrong if BETA=yes!!!
run_host_command_logged mkdir -pv "${DEBS_OUTPUT_DIR}"
run_host_command_logged "${PYTHON3_VARS[@]}" "${PYTHON3_INFO[BIN]}" "${INFO_TOOLS_DIR}"/download-debs.py "${DEBS_TO_REPO_INFO_FILE}" "${DEBS_OUTPUT_DIR}"

View File

@ -21,19 +21,17 @@ function do_main_configuration() {
declare -g -r PACKAGE_LIST_DESKTOP
# common options
# daily beta build contains date in subrevision
#if [[ $BETA == yes && -z $SUBREVISION ]]; then SUBREVISION="."$(date --date="tomorrow" +"%j"); fi
declare revision_from="undetermined"
if [ -f $USERPATCHES_PATH/VERSION ]; then
REVISION=$(cat "${USERPATCHES_PATH}"/VERSION)"$SUBREVISION" # all boards have same revision
if [ -f "${USERPATCHES_PATH}"/VERSION ]; then
REVISION=$(cat "${USERPATCHES_PATH}"/VERSION)
revision_from="userpatches VERSION file"
else
REVISION=$(cat "${SRC}"/VERSION)"$SUBREVISION" # all boards have same revision
REVISION=$(cat "${SRC}"/VERSION)
revision_from="main VERSION file"
fi
declare -g -r REVISION="${REVISION}"
display_alert "Using revision from" "${revision_from}: '${REVISION}" "info"
display_alert "Using revision from" "${revision_from}: '${REVISION}'" "info"
# This is the prefix used by all artifacts. Readonly. It's just $REVISION and a double dash.
declare -r -g artifact_prefix_version="${REVISION}--"

View File

@ -108,12 +108,18 @@ function calculate_hash_for_variables() {
declare -a values_to_hash=("$@")
declare all_values="${values_to_hash[*]}" # expand...
declare all_values_pre_normalize="${all_values}"
if [[ "${do_normalize_src_path:-"yes"}" == "yes" ]]; then
all_values="${all_values//${SRC}/}" # remove all occurences of ${SRC} from all_values
fi
hash_variables="$(echo "${all_values}" | sha256sum | cut -d' ' -f1)" # outer scope
display_alert "calculate_hash_for_variables normalized" "${all_values}" "debug"
display_alert "calculate_hash_for_variables all_values_pre_normalize" "${all_values_pre_normalize}" "debug"
if [[ "${do_normalize_src_path:-"yes"}" == "yes" ]]; then
display_alert "calculate_hash_for_variables normalized" "${all_values}" "debug"
else
display_alert "calculate_hash_for_variables normalized?" "no" "debug"
fi
display_alert "calculate_hash_for_variables hashed" "${hash_variables}" "debug"
return 0

View File

@ -33,6 +33,7 @@ function prepare_armbian_mountpoints_description_dict() {
["output"]="docker_kind_linux=bind docker_kind_darwin=bind" # catch-all output. specific subdirs are mounted below. it's a bind mount by default on both Linux and Darwin.
["output/images"]="docker_kind_linux=bind docker_kind_darwin=bind" # 99% of users want this as the result of their build, no matter if it's slow or not. bind on both.
["output/debs"]="docker_kind_linux=bind docker_kind_darwin=bind" # generated output .deb files. most people are interested in this, to update kernels or dtbs after initial build. bind on both Linux and Darwin.
# output/debs-beta ... ! not needed cos "output" is fully mapped above.
["output/logs"]="docker_kind_linux=bind docker_kind_darwin=bind" # log files produced. 100% of users want this. Bind on both Linux and Darwin. Is used to integrate launcher and actual-build logs, so must exist and work otherwise confusion ensues.
["cache"]="docker_kind_linux=bind docker_kind_darwin=namedvolume" # catch-all cache, could be bind-mounted or a volume. On Darwin it's too slow to bind-mount, so it's a volume by default. On Linux, it's a bind-mount by default.
["cache/git-bare"]="docker_kind_linux=bind docker_kind_darwin=namedvolume" # Git bare repos (kernel/u-boot). On Darwin it's too slow to bind-mount, so it's a volume by default. On Linux, it's a bind-mount by default.

View File

@ -187,10 +187,13 @@ function config_post_main() {
fi
if [[ "$BETA" == "yes" ]]; then
display_alert "BETA" "BETA==yes, nightly image" "debug"
IMAGE_TYPE=nightly
elif [ "$BETA" == "no" ] || [ "$RC" == "yes" ]; then
elif [[ "$BETA" == "no" ]]; then
display_alert "BETA" "BETA==no, stable image" "debug"
IMAGE_TYPE=stable
else
display_alert "BETA" "Not yes nor no, user-built" "debug"
IMAGE_TYPE=user-built
fi