From 3c99fe22d36655d4bc92a62d5fab91974b83eb6a Mon Sep 17 00:00:00 2001 From: Magesh K <47920326+mahee96@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:23:57 +0530 Subject: [PATCH] [fetch-prebuilt.sh]: force download when libs are missing locally and skip file is absent (#796) * [fetch-prebuilt.sh] - retain checked-in files from minimuxer repo (assuming minimuxer repo was cloned) * [fetch-prebuilt.sh]: force download when libs are missing locally and skip file is absent --- Dependencies/fetch-prebuilt.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Dependencies/fetch-prebuilt.sh b/Dependencies/fetch-prebuilt.sh index e9c09189..d2e902b0 100755 --- a/Dependencies/fetch-prebuilt.sh +++ b/Dependencies/fetch-prebuilt.sh @@ -44,16 +44,36 @@ check_for_update() { LAST_FETCH=`cat .last-prebuilt-fetch-$1 | perl -n -e '/([0-9]*),([^ ]*)$/ && print $1'` LAST_COMMIT=`cat .last-prebuilt-fetch-$1 | perl -n -e '/([0-9]*),([^ ]*)$/ && print $2'` - # fetch if last fetch was over 1 hour ago - if [[ $LAST_FETCH -lt $(expr $(date +%s) - 3600) ]] || [[ "$2" == "force" ]]; then + # Check if required library files exist + FORCE_DOWNLOAD=false + if [ ! -f "$1/lib$1-sim.a" ] || [ ! -f "$1/lib$1-ios.a" ]; then + echo "Required libraries missing for $1, forcing download..." + FORCE_DOWNLOAD=true + fi + + # Download if: + # 1. Libraries are missing (FORCE_DOWNLOAD), or + # 2. Last fetch was over 1 hour ago, or + # 3. Force flag was passed + if [ "$FORCE_DOWNLOAD" = true ] || [[ $LAST_FETCH -lt $(expr $(date +%s) - 3600) ]] || [[ "$2" == "force" ]]; then echo "Checking $1 for update" echo LATEST_COMMIT=`curl https://api.github.com/repos/SideStore/$1/releases/latest | perl -n -e '/Commit: https:\\/\\/github\\.com\\/[^\\/]*\\/[^\\/]*\\/commit\\/([^"]*)/ && print $1'` echo echo "Last commit: $LAST_COMMIT" echo "Latest commit: $LATEST_COMMIT" + + NOT_UPTODATE=false if [[ "$LAST_COMMIT" != "$LATEST_COMMIT" ]]; then - echo "Found update, downloading binaries" + echo "Found update on the remote: https://api.github.com/repos/SideStore/$1/releases/latest" + NOT_UPTODATE=true + fi + + # Download if: + # 1. Libraries are missing (FORCE_DOWNLOAD), or + # 2. New commit is available + if [ "$FORCE_DOWNLOAD" = true ] || [ "$NOT_UPTODATE" = true ] ;then + echo "downloading binaries" echo wget -O "$1/lib$1-sim.a" "https://github.com/SideStore/$1/releases/latest/download/lib$1-sim.a" if [[ "$1" != "minimuxer" ]]; then