|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +[ $# -eq 0 ] && { echo "Usage: $0 <full path to APPLICATION checkout>"; exit 1; } |
| 4 | + |
| 5 | +confirm() { |
| 6 | + read -r -p "${1:-Are you sure? [y/N]} " response |
| 7 | + case "$response" in |
| 8 | + [yY][eE][sS]|[yY]) |
| 9 | + true |
| 10 | + ;; |
| 11 | + *) |
| 12 | + false |
| 13 | + ;; |
| 14 | + esac |
| 15 | +} |
| 16 | + |
| 17 | +APPLICATION_DIR="$1" |
| 18 | + |
| 19 | +header() { |
| 20 | + echo -e "\e[35m$1\e[0m" |
| 21 | +} |
| 22 | + |
| 23 | +echo "APPLICATION dir: " ${APPLICATION_DIR} |
| 24 | + |
| 25 | +[ ! -d ${APPLICATION_DIR} ] && { echo "${APPLICATION_DIR} DOES NOT EXIST"; exit 1; } |
| 26 | + |
| 27 | +export CONAN_USER_HOME="/Users/patriciaaas/Code/conan-cache-turtlebrowser" |
| 28 | + |
| 29 | +[ ! -d ${CONAN_USER_HOME} ] && { echo "${CONAN_USER_HOME} DOES NOT EXIST"; exit 1; } |
| 30 | + |
| 31 | +export CONAN_USER_HOME_SHORT=${CONAN_USER_HOME}/short |
| 32 | + |
| 33 | +[ ! -d ${CONAN_USER_HOME_SHORT} ] && { echo "${CONAN_USER_HOME_SHORT} DOES NOT EXIST"; exit 1; } |
| 34 | + |
| 35 | +export LFS_LIMIT=50 |
| 36 | + |
| 37 | +header "Prepare Cache for update" |
| 38 | + |
| 39 | +confirm "Clean cache? [y/N]" && cd ${CONAN_USER_HOME} && git clean -df && git checkout . && git checkout host-macOS-target-macOS-macos-11.0-master |
| 40 | + |
| 41 | +confirm "Update cache? [y/N]" && cd ${CONAN_USER_HOME} && git pull && git lfs pull |
| 42 | + |
| 43 | +confirm "DELETE the whole cache? [y/N]" && cd ${CONAN_USER_HOME} && conan remove -f "*" && rm -rf short/* && touch short/conan-cache.marker |
| 44 | + |
| 45 | +confirm "Prepare short paths [y/N]" && cd ${CONAN_USER_HOME} && find .conan/ -name .conan_link -exec perl -pi -e 's=CONAN_USER_HOME_SHORT=$ENV{CONAN_USER_HOME_SHORT}=g' {} + |
| 46 | + |
| 47 | +header "Populate the Cache" |
| 48 | + |
| 49 | +confirm "Update APPLICATION? [y/N]" && cd ${APPLICATION_DIR} && git pull |
| 50 | + |
| 51 | +confirm "Remove old build directory? [y/N]" && cd ${APPLICATION_DIR} && rm -rf build |
| 52 | + |
| 53 | +confirm "Create build directory? [y/N]" && cd ${APPLICATION_DIR} && mkdir build |
| 54 | + |
| 55 | +confirm "Start build? [y/N]" && cd ${APPLICATION_DIR} && cd build && cmake -DUPDATE_CONAN=ON -DCMAKE_BUILD_TYPE=Release .. |
| 56 | + |
| 57 | +header "Clean Conan" |
| 58 | + |
| 59 | +confirm "Clean Conan builds? [y/N]" && conan remove -f "*" --builds |
| 60 | + |
| 61 | +confirm "Clean Conan src? [y/N]" && conan remove -f "*" --src |
| 62 | + |
| 63 | +confirm "Clean Conan system-reqs? [y/N]" && conan remove -f "*" --system-reqs |
| 64 | + |
| 65 | +header "Prep for cache upload" |
| 66 | + |
| 67 | +confirm "Fix short paths? [y/N]" && cd ${CONAN_USER_HOME} && find .conan/ -name .conan_link -exec perl -pi -e 's=$ENV{CONAN_USER_HOME_SHORT}=CONAN_USER_HOME_SHORT=g' {} + |
| 68 | + |
| 69 | +confirm "Clean up .conan_link.bak? [y/N]" && cd ${CONAN_USER_HOME} && find -name .conan_link.bak -execdir rm {} \; |
| 70 | + |
| 71 | +confirm "List files over ${LFS_LIMIT}M? [y/N]" && cd ${CONAN_USER_HOME} && find .conan short -type f -size +${LFS_LIMIT}M -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' |
| 72 | + |
| 73 | +confirm "LFS track files over ${LFS_LIMIT}M? [y/N]" && cd ${CONAN_USER_HOME} && find .conan short -type f -size +${LFS_LIMIT}M -execdir git lfs track {} \; |
| 74 | + |
| 75 | +header "Upload cache" |
| 76 | + |
| 77 | +confirm "Add everything to git? [y/N]" && cd ${CONAN_USER_HOME} && git add -A |
| 78 | + |
| 79 | +confirm "Commit to git? [y/N]" && cd ${CONAN_USER_HOME} && git commit -m "Local build" |
| 80 | + |
| 81 | +confirm "Push to GitHub? [y/N]" && cd ${CONAN_USER_HOME} && git push |
| 82 | + |
| 83 | +header "Test cache locally" |
| 84 | + |
| 85 | +confirm "TEST: Prepare short paths [y/N]" && cd ${CONAN_USER_HOME} && find .conan/ -name .conan_link -exec perl -pi -e 's=CONAN_USER_HOME_SHORT=$ENV{CONAN_USER_HOME_SHORT}=g' {} + |
| 86 | + |
| 87 | +confirm "TEST: Remove old build directory? [y/N]" && cd ${APPLICATION_DIR} && rm -rf build |
| 88 | + |
| 89 | +confirm "TEST: Create build directory? [y/N]" && cd ${APPLICATION_DIR} && mkdir build |
| 90 | + |
| 91 | +confirm "TEST: Start REGULAR build? [y/N]" && cd ${APPLICATION_DIR} && cd build && cmake -DUPDATE_CONAN=OFF -DCMAKE_BUILD_TYPE=Release .. |
0 commit comments