From ed320e3a643b03c56304b5602bec50a540d71dc5 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 13 Dec 2025 08:49:42 -0600 Subject: [PATCH] fixed grab_packages.sh --- .gitignore | 5 ++++ create_packages.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++ grab_packages.sh | 56 ++++++++---------------------------- 3 files changed, 88 insertions(+), 44 deletions(-) create mode 100755 create_packages.sh diff --git a/.gitignore b/.gitignore index 610c9d8..5208291 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,8 @@ support/Dockerfile version.cpp version.rc .DS_Store +*.tar.gz +*.bz2 +*.xz +*.zip +*.msi diff --git a/create_packages.sh b/create_packages.sh new file mode 100755 index 0000000..f0afa07 --- /dev/null +++ b/create_packages.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +CURRENT_DIR=$(realpath "$0") +CURRENT_DIR=$(dirname "${CURRENT_DIR}") + +. "${CURRENT_DIR}/src/scripts/versions.sh" +. "${CURRENT_DIR}/src/scripts/libraries.sh" + +function check_should_update() { + 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 + + 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 + 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() { + for NAME in "${!PROJECT_DOWNLOADS[@]}"; do + if [ "${NAME}" != "BOOST" ] && [ "${NAME}" != "BOOST2" ]; then + download_and_update_hash $NAME + fi + 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 +popd diff --git a/grab_packages.sh b/grab_packages.sh index f0afa07..39e1ea3 100755 --- a/grab_packages.sh +++ b/grab_packages.sh @@ -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