run_sdk_container: Add -U flag to use the version file unchanged

This change adds a -U flag to run_sdk_container. If provided, the script
will not regenerate version.txt but instead use the existing file as-is.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
This commit is contained in:
Thilo Fromm 2023-10-17 18:13:18 +02:00
parent 919d368688
commit 428503083f

View File

@ -45,11 +45,13 @@ usage() {
echo " -C - Use an entirely custom container image instead of the SDK's" echo " -C - Use an entirely custom container image instead of the SDK's"
echo " $sdk_container_common_registry/flatcar-sdk-[ARCH]:[SDK VERSION]" echo " $sdk_container_common_registry/flatcar-sdk-[ARCH]:[SDK VERSION]"
echo " Useful for CI." echo " Useful for CI."
echo " -U Do not update the versionfile. Instead, use the version from the versionfile as-is."
echo " -h Print this help." echo " -h Print this help."
echo echo
} }
# -- # --
update_versionfile="true"
while [ 0 -lt $# ] ; do while [ 0 -lt $# ] ; do
case "$1" in case "$1" in
-h) usage; exit 0;; -h) usage; exit 0;;
@ -62,6 +64,10 @@ while [ 0 -lt $# ] ; do
--rm) remove=true; shift;; --rm) remove=true; shift;;
-x) cleanup="$2"; shift; shift;; -x) cleanup="$2"; shift; shift;;
-C) custom_image="$2"; shift; shift;; -C) custom_image="$2"; shift; shift;;
-U) sdk_version="$(get_sdk_version_from_versionfile)"
os_version="$(get_version_from_versionfile)"
update_versionfile="false"
shift;;
*) break;; *) break;;
esac esac
done done
@ -73,7 +79,9 @@ else
container_image_name="$sdk_container_common_registry/flatcar-sdk-${arch}:${docker_sdk_vernum}" container_image_name="$sdk_container_common_registry/flatcar-sdk-${arch}:${docker_sdk_vernum}"
fi fi
create_versionfile "$sdk_version" "$os_version" if [[ "${update_versionfile}" == true ]] ; then
create_versionfile "$sdk_version" "$os_version"
fi
if [ -z "$name" ] ; then if [ -z "$name" ] ; then
docker_sdk_vernum="$(vernum_to_docker_image_version "${sdk_version}")" docker_sdk_vernum="$(vernum_to_docker_image_version "${sdk_version}")"