@@ -37,44 +37,46 @@ cleanup_old_caches() {
3737}
3838
3939setup_homebrew_cache () {
40- echo " Setting up Homebrew cache..."
41- mkdir -p " $HOMEBREW_CACHE_DIR "
42-
43- export HOMEBREW_CACHE=" $HOMEBREW_CACHE_DIR "
44- # check if cache for homebrew exists
45- if [ " ${HOMEBREW_CACHE} " = " true" ]; then
46- echo " Homebrew cache found, restoring cached packages"
47- export HOMEBREW_NO_AUTO_UPDATE=1
48- else
49- echo " No Homebrew cache - downloading fresh packages"
50- fi
40+ if [ " ${CACHING_ENABLED} " = " true" ]; then
41+ echo " Setting up Homebrew cache..."
42+ mkdir -p " $HOMEBREW_CACHE_DIR "
43+
44+ export HOMEBREW_CACHE=" $HOMEBREW_CACHE_DIR "
45+ # check if cache for homebrew exists
46+ if [ " ${HOMEBREW_CACHE} " = " true" ]; then
47+ echo " Homebrew cache found, restoring cached packages"
48+ export HOMEBREW_NO_AUTO_UPDATE=1
49+ else
50+ echo " No Homebrew cache - downloading fresh packages"
51+ fi
52+ fi
5153}
5254
5355setup_git_cache () {
54- echo " Setting up Git cache..."
55- mkdir -p " $GIT_CACHE_DIR "
56-
57- if [ " ${GIT_REPOS_CACHE} " = " true" ]; then
58- echo " Git repositories cache found, restoring cached repositories"
59- # Validate cache isn't corrupted
60- if [ -d " $GIT_CACHE_DIR " ] && [ " $( ls -A $GIT_CACHE_DIR 2> /dev/null) " ]; then
61- export GIT_CACHE_ENABLED=true
62- else
63- echo " Git cache directory empty - clearing and rebuilding"
64- rm -rf " $GIT_CACHE_DIR "
65- mkdir -p " $GIT_CACHE_DIR "
66- export GIT_CACHE_ENABLED=false
67- fi
68- else
69- echo " No Git cache - cloning fresh repositories"
70- export GIT_CACHE_ENABLED=false
71- fi
56+ if [ " ${CACHING_ENABLED} " = " true" ]; then
57+ echo " Setting up Git cache..."
58+ mkdir -p " $GIT_CACHE_DIR "
59+
60+ if [ " ${GIT_REPOS_CACHE} " = " true" ]; then
61+ echo " Git repositories cache found, restoring cached repositories"
62+ # Validate cache isn't corrupted
63+ if [ -d " $GIT_CACHE_DIR " ] && [ " $( ls -A $GIT_CACHE_DIR 2> /dev/null) " ]; then
64+ export GIT_CACHE_ENABLED=true
65+ else
66+ echo " Git cache directory empty - clearing and rebuilding"
67+ rm -rf " $GIT_CACHE_DIR "
68+ mkdir -p " $GIT_CACHE_DIR "
69+ export GIT_CACHE_ENABLED=false
70+ fi
71+ else
72+ echo " No Git cache - cloning fresh repositories"
73+ export GIT_CACHE_ENABLED=false
74+ fi
75+ fi
7276}
7377
7478setup_dependencies_cache () {
75- echo " Setting up dependencies cache..."
76-
77- if [ " ${BUILT_DEPS_CACHE} " = " true" ]; then
79+ if [ " ${CACHING_ENABLED} " = " true" ] && [ " ${BUILT_DEPS_CACHE} " = " true" ]; then
7880 echo " Built dependencies cache found, restoring cached dependencies"
7981 # Validate cache isn't corrupted
8082 if [ -d " $STAGING_AREA_DEPS " ] && [ " $( ls -A $STAGING_AREA_DEPS 2> /dev/null) " ]; then
@@ -116,7 +118,7 @@ install_packages() {
116118 major_version=$( echo " $macos_version " | cut -d ' .' -f 1)
117119
118120 # Package installation based on cache status
119- if [ " ${HOMEBREW_CACHE} " = " true" ]; then
121+ if [ " ${CACHING_ENABLED} " = " true " ] && [ " ${ HOMEBREW_CACHE}" = " true" ]; then
120122 echo " Installing packages with cache optimization (skipping update/upgrade)..."
121123 export HOMEBREW_NO_AUTO_UPDATE=1
122124 else
@@ -164,7 +166,7 @@ clone() {
164166 mkdir -p $STAGING_AREA
165167 pushd $STAGING_AREA
166168
167- if [ " $GIT_CACHE_ENABLED " = " true" ]; then
169+ if [ " ${CACHING_ENABLED} " = " true " ] && [ " $ GIT_CACHE_ENABLED" = " true" ]; then
168170 echo " Using cached repositories..."
169171
170172 # If cache directory has content, use it
0 commit comments