|
| 1 | +#! /bin/bash |
| 2 | + |
| 3 | +shopt -s expand_aliases |
| 4 | + |
| 5 | +# colors |
| 6 | +RED='\033[0;31m' |
| 7 | +GREEN='\033[0;32m' |
| 8 | +YELLOW='\033[0;33m' |
| 9 | +CYAN='\033[0;36m' |
| 10 | +COLOR_OFF='\033[0m' |
| 11 | + |
| 12 | +GIT_TOPLEVEL=$(git rev-parse --show-toplevel) |
| 13 | +ICEORYX_CPP_BASE_DIR=$GIT_TOPLEVEL/iceoryx-sys/iceoryx-cpp |
| 14 | +ICEORYX_TAG="v0.0.0" |
| 15 | + |
| 16 | +DO_BUILD_ONLY=false |
| 17 | +DO_PREPARATORY_WORK=false |
| 18 | +DO_RELEASE=false |
| 19 | + |
| 20 | +OPTION_COUNTER=0 |
| 21 | +while (( "$#" )); do |
| 22 | + ((OPTION_COUNTER+=1)) |
| 23 | + if [[ $OPTION_COUNTER -gt 1 ]]; then |
| 24 | + echo -e "${RED}Error:${COLOR_OFF} Too many arguments specified! Try '--help' for more information." |
| 25 | + exit -1 |
| 26 | + fi |
| 27 | + |
| 28 | + case $1 in |
| 29 | + -h|--help) |
| 30 | + echo "Script to update bundled iceoryx C++ source archive" |
| 31 | + echo "" |
| 32 | + echo "Usage: update-iceoryx-cpp.sh [option]" |
| 33 | + echo "Only one option at a time is allowed!" |
| 34 | + echo "Options:" |
| 35 | + echo " -t, --tag <TAG> Updates the bundled source archive with" |
| 36 | + echo " the given <TAG>" |
| 37 | + echo " -h, --help Prints this help" |
| 38 | + echo "" |
| 39 | + echo "Example:" |
| 40 | + echo " update-iceoryx-cpp.sh --tag v2.0.0" |
| 41 | + exit 0 |
| 42 | + ;; |
| 43 | + -t|--tag) |
| 44 | + if [[ $# -ne 2 ]]; then |
| 45 | + echo -e "${RED}Error:${COLOR_OFF} No parameter specified! Try '--help' for more information." |
| 46 | + fi |
| 47 | + ICEORYX_TAG="$2" |
| 48 | + |
| 49 | + shift 2 |
| 50 | + ;; |
| 51 | + *) |
| 52 | + echo "Invalid argument '$1'. Try '--help' for options." |
| 53 | + exit -1 |
| 54 | + ;; |
| 55 | + esac |
| 56 | +done |
| 57 | + |
| 58 | +if [[ $OPTION_COUNTER -eq 0 ]]; then |
| 59 | + echo -e "${RED}Error:${COLOR_OFF} No arguments specified! Try '--help' for more information." |
| 60 | + exit -1 |
| 61 | +fi |
| 62 | + |
| 63 | +#################### |
| 64 | +# cd into base dir # |
| 65 | +#################### |
| 66 | + |
| 67 | +cd $ICEORYX_CPP_BASE_DIR |
| 68 | + |
| 69 | +echo -e "${CYAN}Info:${COLOR_OFF} Entering '$(pwd)'" |
| 70 | + |
| 71 | +####################### |
| 72 | +# Remove old archives # |
| 73 | +####################### |
| 74 | + |
| 75 | +echo -e "${CYAN}Info:${COLOR_OFF} Removing old archives with the naming pattern 'v*.tar.gz*'" |
| 76 | + |
| 77 | +rm -rf v*\.tar\.gz* |
| 78 | + |
| 79 | +####################### |
| 80 | +# Downloading archive # |
| 81 | +####################### |
| 82 | + |
| 83 | +ICEORYX_ARCHIVE="${ICEORYX_TAG}.tar.gz" |
| 84 | +ICEORYX_ARCHIVE_LINK="https://github.com/eclipse-iceoryx/iceoryx/archive/refs/tags/${ICEORYX_ARCHIVE}" |
| 85 | + |
| 86 | +echo -e "${CYAN}Info:${COLOR_OFF} Fetching '${ICEORYX_ARCHIVE_LINK}'" |
| 87 | + |
| 88 | +wget ${ICEORYX_ARCHIVE_LINK} --quiet --show-progress |
| 89 | + |
| 90 | +if [ $? -ne 0 ]; then |
| 91 | + echo -e "${RED}Error:${COLOR_OFF} Could not fetch '${ICEORYX_ARCHIVE_LINK}'" |
| 92 | + exit -1 |
| 93 | +fi |
| 94 | + |
| 95 | +########################## |
| 96 | +# Extracting new archive # |
| 97 | +########################## |
| 98 | + |
| 99 | +echo -e "${CYAN}Info:${COLOR_OFF} Extracting new source archive to '${ICEORYX_TAG}'" |
| 100 | + |
| 101 | +mkdir -p ${ICEORYX_TAG} |
| 102 | +tar -xf ${ICEORYX_ARCHIVE} -C ${ICEORYX_TAG} --strip-components=1 --atime-preserve=replace |
| 103 | + |
| 104 | +################# |
| 105 | +# Strip archive # |
| 106 | +################# |
| 107 | + |
| 108 | +echo -e "${CYAN}Info:${COLOR_OFF} Stripping source archive from unnecessary files" |
| 109 | + |
| 110 | +rm -rf ${ICEORYX_TAG}/.clang-format |
| 111 | +rm -rf ${ICEORYX_TAG}/.clang-tidy |
| 112 | +rm -rf ${ICEORYX_TAG}/.codecov.yml |
| 113 | +rm -rf ${ICEORYX_TAG}/.gitattributes |
| 114 | +rm -rf ${ICEORYX_TAG}/.github |
| 115 | +rm -rf ${ICEORYX_TAG}/.gitignore |
| 116 | +rm -rf ${ICEORYX_TAG}/cmake |
| 117 | +rm -rf ${ICEORYX_TAG}/doc |
| 118 | +rm -rf ${ICEORYX_TAG}/iceoryx_binding_c |
| 119 | +rm -rf ${ICEORYX_TAG}/iceoryx_dds |
| 120 | +rm -rf ${ICEORYX_TAG}/iceoryx_examples |
| 121 | +rm -rf ${ICEORYX_TAG}/iceoryx_integrationtest |
| 122 | +rm -rf ${ICEORYX_TAG}/iceoryx_meta |
| 123 | +rm -rf ${ICEORYX_TAG}/mkdocs.yml |
| 124 | +rm -rf ${ICEORYX_TAG}/tools |
| 125 | + |
| 126 | +rm -rf ${ICEORYX_TAG}/iceoryx_hoofs/test |
| 127 | +rm -rf ${ICEORYX_TAG}/iceoryx_posh/test |
| 128 | +# restore modified timestamp to prevent changes in archive checksum for repetitive updates to the same tag |
| 129 | +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG}/iceoryx_hoofs |
| 130 | +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG}/iceoryx_posh |
| 131 | +touch -r ${ICEORYX_TAG}/VERSION ${ICEORYX_TAG} |
| 132 | + |
| 133 | +####################### |
| 134 | +# Re-compress archive # |
| 135 | +####################### |
| 136 | + |
| 137 | +echo -e "${CYAN}Info:${COLOR_OFF} Re-compressing '${ICEORYX_TAG}' into '${ICEORYX_ARCHIVE}'" |
| 138 | + |
| 139 | +tar -czf ${ICEORYX_ARCHIVE} ${ICEORYX_TAG} |
| 140 | + |
| 141 | +########################## |
| 142 | +# Remove extracted archive # |
| 143 | +########################## |
| 144 | + |
| 145 | +echo -e "${CYAN}Info:${COLOR_OFF} Removing extracted file" |
| 146 | + |
| 147 | +rm -rf ${ICEORYX_TAG} |
0 commit comments