Browse Source

chore(minversion): Log a warning if the client != required version

Added a simple check to log a warning when an image is generated with the client
installed, and the version installed will lead to the image being unusable.

Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
4.0.x
Ole Petter 2 years ago
parent
commit
d3dc6ffbae
No known key found for this signature in database GPG Key ID: 399DBE0F4D4B02EB
  1. 10
      mender-convert-package
  2. 33
      modules/versioncmp.sh

10
mender-convert-package

@ -39,6 +39,7 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
source modules/testscfg.sh
source modules/versioncmp.sh
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
@ -204,6 +205,15 @@ fi
# way, and write the rootfs image first.
run_and_log_cmd "mv --force work/rootfs/data work/data"
if [[ "${MENDER_CLIENT_INSTALL}" == y ]]; then
# If the client version is less than 3.4, then log a warning
if ! miminum_required_version "3.4.0" "${MENDER_CLIENT_VERSION}"; then
log_warn "You are now installing a Mender client which does not support the " \
"bootstrap Artifact present in the image. This means that updates will not " \
"work, and your image is impossible to update"
fi
fi
disk_create_file_system_from_folder "work/rootfs/" "work/rootfs.img" \
"${rootfs_image_sectors}" "${image_fs_type}"

33
modules/versioncmp.sh

@ -0,0 +1,33 @@
# Copyright 2022 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source modules/log.sh
source modules/probe.sh .
# Compare the version of a string to a given minimum version requirement
#
# NOTE: Also works for 'master', in that sort does sort it correctly by accident.
# The same goes for all other branches/names, which are not semver.
#
# $1 - Minimum required version
# $2 - Version string
#
# @return - bool
#
function minimum_required_version() {
if [[ $# -ne 2 ]]; then
log_fatal "minimum_required_version() requires two parameters"
fi
[[ "$1" == "$(printf "$1\n$2" | sort --version-sort | head --lines 1)" ]]
}
Loading…
Cancel
Save