Browse code

Added a archive cache for OS X.

Nat! authored on 15-03-2017 18:14:52
Showing 4 changed files
... ...
@@ -1763,7 +1763,7 @@ build_xcodebuild_schemes_or_target()
1763 1763
 
1764 1764
    if [ "${targets}" = "" -a "${schemes}" = "" ]
1765 1765
    then
1766
-      log_fluff "Building project \"${project}\"..."
1766
+      log_fluff "Building project \"${project}\" ..."
1767 1767
       build_xcodebuild "$@"
1768 1768
    fi
1769 1769
 }
... ...
@@ -1282,7 +1282,7 @@ work_clones()
1282 1282
       if [ "${remember}" = "YES" ]
1283 1283
       then
1284 1284
          # branch could be overwritten
1285
-         log_debug "${C_INFO}Remembering ${clone}..."
1285
+         log_debug "${C_INFO}Remembering ${clone} ..."
1286 1286
 
1287 1287
          remember_stash_of_repository "${clone}" \
1288 1288
                                       "${reposdir}" \
... ...
@@ -1520,14 +1520,14 @@ fetch_loop()
1520 1520
 
1521 1521
    if is_master_bootstrap_project
1522 1522
    then
1523
-     log_info "Extracting minions' precis..."
1523
+     log_info "Extracting minions' precis ..."
1524 1524
 
1525 1525
       extract_minion_precis
1526 1526
 
1527 1527
       fetch_once_minions_embedded_repositories
1528 1528
    fi
1529 1529
 
1530
-   log_info "Checking repositories..."
1530
+   log_info "Checking repositories ..."
1531 1531
 
1532 1532
    fetch_once_embedded_repositories
1533 1533
 
... ...
@@ -783,6 +783,16 @@ local_environment_initialize()
783 783
          USR_LOCAL_INCLUDE=/usr/local/include
784 784
       ;;
785 785
    esac
786
+
787
+   #
788
+   # default archive
789
+   #
790
+   case "${UNAME}" in
791
+      darwin)
792
+         DEFAULT_ARCHIVE_CACHE="${HOME}/Library/Caches/mulle-bootstrap/archives"
793
+      ;;
794
+   esac
795
+
786 796
 }
787 797
 
788 798
 
... ...
@@ -608,9 +608,48 @@ _move_stuff()
608 608
 #
609 609
 # What we do is
610 610
 # a) download the package using curl
611
-# b) create a temporary directory, extract into it
612
-# c) move it into place
611
+# b) optionally copy it into a cache for next time
612
+# c) create a temporary directory, extract into it
613
+# d) move it into place
613 614
 #
615
+_tar_download()
616
+{
617
+   local download="$1"
618
+
619
+   local archive_cache
620
+   local cachable_path
621
+   local cached_archive
622
+
623
+   archive_cache="`read_config_setting "archive_cache" "${DEFAULT_ARCHIVE_CACHE}"`"
624
+
625
+   if [ ! -z "${archive_cache}" -a "${archive_cache}" != "NO" ]
626
+   then
627
+      cachable_path="${archive_cache}/${download}"
628
+      if [ -e "${cachable_path}" ]
629
+      then
630
+         cached_archive="${cachable_path}"
631
+      fi
632
+   fi
633
+
634
+   if [ ! -z "${cached_archive}" ] && [ -f "${cached_archive}" ]
635
+   then
636
+      log_info "Using cached \"${cached_archive}\" for ${C_MAGENTA}${C_BOLD}${url}${C_INFO} ..."
637
+      exekutor ln -s "${cached_archive}" || fail "failed to symlink \"${cached_archive}\""
638
+      cachable_path=""
639
+   else
640
+      exekutor curl -O -L ${CURLOPTIONS} "${url}" || fail "failed to download \"${url}\""
641
+   fi
642
+
643
+   _validate_download "${download}" "${SCM_OPTIONS}" || exit 1
644
+
645
+   if [ ! -z "${cachable_path}" ]
646
+   then
647
+      log_info "Saving \"${download}\" to archive cache \"${archive_cache}\" ..."
648
+      mkdir_if_missing "${archive_cache}" || fail "failed to create archive cacheĀ \"${archive_cache}\""
649
+      exekutor cp "${download}" "${cachable_path}" || fail "failed to copy \"${download}\" to cache \"${archive_cache}\""
650
+   fi
651
+}
652
+
614 653
 
615 654
 tar_unpack()
616 655
 {
... ...
@@ -646,10 +685,7 @@ tar_unpack()
646 685
    (
647 686
       exekutor cd "${tmpdir}" || exit 1
648 687
 
649
-      log_info "Downloading ${C_MAGENTA}${C_BOLD}${url}${C_INFO} ..."
650
-
651
-      exekutor curl -O -L ${CURLOPTIONS} "${url}" || exit 1
652
-      _validate_download "${download}" "${SCM_OPTIONS}" || exit 1
688
+      _tar_download "${download}" || exit 1
653 689
 
654 690
       case "${url}" in
655 691
          *.zip)