Remove package sources and host only the expected SHA-256 (#3)
Some checks failed
sgraves/cpp-build-system_mac/pipeline/head There was a failure building this commit
sgraves/cpp-build-system/pipeline/head There was a failure building this commit
sgraves/cpp-build-system_msys2/pipeline/head There was a failure building this commit

Reviewed-on: #3
Co-authored-by: Scott E. Graves <scott.e.graves@protonmail.com>
Co-committed-by: Scott E. Graves <scott.e.graves@protonmail.com>
This commit was merged in pull request #3.
This commit is contained in:
2025-12-13 09:35:33 -06:00
committed by sgraves76
parent 5cf3d1661b
commit ba5f4d1625
73 changed files with 496 additions and 209 deletions

View File

@@ -6,66 +6,34 @@ CURRENT_DIR=$(dirname "${CURRENT_DIR}")
. "${CURRENT_DIR}/src/scripts/versions.sh"
. "${CURRENT_DIR}/src/scripts/libraries.sh"
function check_should_update() {
function download_package() {
local NAME=$1
local ITEM_LIST=(${PROJECT_DOWNLOADS[${NAME}]//;/ })
if [ ! -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}" ] ||
[ ! -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}.sha256" ]; then
return 0
fi
return 1
}
function download_and_update_hash() {
local NAME=$1
local ITEM_LIST=(${PROJECT_DOWNLOADS[${NAME}]//;/ })
if [ ! -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}" ] ||
[ ! -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}.sha256" ]; then
local CLEANUP_LIST=(${PROJECT_CLEANUP[${NAME}]//:/ })
if [ "${NAME}" == "GTEST" ]; then
CLEANUP_LIST=(${PROJECT_CLEANUP["TESTING"]//:/ })
fi
if [ "${NAME}" != "BOOST" ] && [ "${NAME}" != "BOOST2" ] && [ "${CLEANUP_LIST[0]}" != "" ]; then
rm -r ${CURRENT_DIR}/support/${CLEANUP_LIST[0]}
fi
if [ ! -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}" ]; then
rm -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}"
rm -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}.sha256"
if ! wget ${ITEM_LIST[0]} -O "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}"; then
echo "failed $NAME"
rm -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}"
exit 1
fi
pushd "${CURRENT_DIR}/support/${ITEM_LIST[2]}"
sha256sum ${ITEM_LIST[1]} >${ITEM_LIST[1]}.sha256
pushd "${CURRENT_DIR}/support/${ITEM_LIST[2]}/"
if ! sha256sum -c "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}.sha256"; then
rm -f "${CURRENT_DIR}/support/${ITEM_LIST[2]}/${ITEM_LIST[1]}"
echo "failed sha256 validation: $NAME"
exit 1
fi
popd
fi
local HASH=$(cat support/${ITEM_LIST[2]}/${ITEM_LIST[1]}.sha256 | awk '{print $1}')
HASH_LIST+=("set(${NAME}_HASH ${HASH})")
}
function create_hashes_cmake() {
function download_packages() {
for NAME in "${!PROJECT_DOWNLOADS[@]}"; do
if [ "${NAME}" != "BOOST" ] && [ "${NAME}" != "BOOST2" ]; then
download_and_update_hash $NAME
fi
download_package $NAME
done
}
pushd "${CURRENT_DIR}"
HASH_LIST=()
create_hashes_cmake
if check_should_update BOOST || check_should_update BOOST2; then
rm -f support/3rd_party/boost_*
fi
download_and_update_hash BOOST
download_and_update_hash BOOST2
(printf "%s\n" "${HASH_LIST[@]}" | sort) >${CURRENT_DIR}/cmake/hashes.cmake
download_packages
popd