From 2b3997df531f278c96538600ac238a859e38bf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Sun, 9 Feb 2020 10:25:41 +0100 Subject: [PATCH] When seeking for rootfs cache files it also checks previous version. This solves problem described in [AR-166] (#1790) --- lib/debootstrap.sh | 32 ++++++++++++++++++++++---------- lib/general.sh | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/debootstrap.sh b/lib/debootstrap.sh index 4f64f84795..6749937ec2 100644 --- a/lib/debootstrap.sh +++ b/lib/debootstrap.sh @@ -99,17 +99,29 @@ debootstrap_ng() # create_rootfs_cache() { - local packages_hash=$(get_package_list_hash) - local cache_type=$(if [[ ${BUILD_DESKTOP} == yes ]]; then echo "desktop"; elif [[ ${BUILD_MINIMAL} == yes ]]; then echo "minimal"; else echo "cli";fi) - local cache_name=${RELEASE}-${cache_type}-${ARCH}.$packages_hash.tar.lz4 - local cache_fname=${SRC}/cache/rootfs/${cache_name} - local display_name=${RELEASE}-${cache_type}-${ARCH}.${packages_hash:0:3}...${packages_hash:29}.tar.lz4 + # seek last cache, proceed to previous otherwise build it + for ((n=0;n<2;n++)); do - display_alert "Checking for local cache" "$display_name" "info" - if [[ ! -f $cache_fname && "$ROOT_FS_CREATE_ONLY" != "force" ]]; then - display_alert "searching on servers" - download_and_verify "_rootfs" "$cache_name" - fi + local packages_hash=$(get_package_list_hash "$(($ROOTFSCACHE_VERSION - $n))") + local cache_type=$(if [[ ${BUILD_DESKTOP} == yes ]]; then echo "desktop"; elif [[ ${BUILD_MINIMAL} == yes ]]; then echo "minimal"; else echo "cli";fi) + local cache_name=${RELEASE}-${cache_type}-${ARCH}.$packages_hash.tar.lz4 + local cache_fname=${SRC}/cache/rootfs/${cache_name} + local display_name=${RELEASE}-${cache_type}-${ARCH}.${packages_hash:0:3}...${packages_hash:29}.tar.lz4 + + display_alert "Checking for local cache" "$display_name" "info" + + if [[ ! -f $cache_fname && "$ROOT_FS_CREATE_ONLY" != "force" ]]; then + display_alert "searching on servers" + download_and_verify "_rootfs" "$cache_name" + fi + + if [[ -f $cache_fname ]]; then + break + else + display_alert "not found: try to use previous cache" + fi + + done if [[ -f $cache_fname && "$ROOT_FS_CREATE_ONLY" != "force" ]]; then local date_diff=$(( ($(date +%s) - $(stat -c %Y $cache_fname)) / 86400 )) diff --git a/lib/general.sh b/lib/general.sh index 765330bf8e..20a4d6c23a 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -119,7 +119,7 @@ exit_with_error() get_package_list_hash() { - ( printf '%s\n' $PACKAGE_LIST | sort -u; printf '%s\n' $PACKAGE_LIST_EXCLUDE | sort -u; echo "$ROOTFSCACHE_VERSION" ) \ + ( printf '%s\n' $PACKAGE_LIST | sort -u; printf '%s\n' $PACKAGE_LIST_EXCLUDE | sort -u; echo "$1" ) \ | md5sum | cut -d' ' -f 1 }