When seeking for rootfs cache files it also checks previous version. This solves problem described in [AR-166] (#1790)

This commit is contained in:
Igor Pečovnik
2020-02-09 10:25:41 +01:00
committed by GitHub
parent 72c5fdf6fb
commit 2b3997df53
2 changed files with 23 additions and 11 deletions

View File

@@ -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 ))

View File

@@ -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
}