unity-builder/dist/remote-builder/handleCaching.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/sh
cacheFolderFull=$1
2021-07-12 22:46:21 +00:00
branchName=$2
libraryFolderFull=$3
2021-07-31 21:41:55 +00:00
gitLFSDestinationFolder=$4
purgeRemoteBuilderCache=$5
cacheFolderWithBranch="$cacheFolderFull/$branchName"
2021-07-31 20:52:37 +00:00
echo " "
2021-07-31 21:41:55 +00:00
mkdir -p "$cacheFolderWithBranch/lib"
mkdir -p "$cacheFolderWithBranch/lfs"
2021-07-27 22:23:02 +00:00
2021-07-27 20:45:49 +00:00
echo "Library cache for branch: $branchName"
ls -lh "$cacheFolderWithBranch"
2021-07-31 21:41:55 +00:00
ls -lh "$cacheFolderWithBranch/lib"
ls -lh "$cacheFolderWithBranch/lfs"
2021-07-27 20:45:49 +00:00
echo ''
2021-07-27 22:40:48 +00:00
if [ -d "$libraryFolderFull" ]; then
rm -r "$libraryFolderFull"
2021-07-27 20:45:49 +00:00
echo "Git must ignore the Library folder"
fi
echo "Checking cache"
2021-07-12 22:36:40 +00:00
# Restore library cache
2021-07-31 21:41:55 +00:00
latest=$(ls -t "$cacheFolderWithBranch/lib" | egrep -i -e '\\.zip$' | head -1)
if [ ! -z "$latest" ]; then
echo "Library cache exists from build $latest from $branchName"
echo 'Creating empty Library folder for cache'
mkdir "$libraryFolderFull"
2021-07-31 21:41:55 +00:00
unzip -q "$cacheFolderWithBranch/lib/$latest" -d "$libraryFolderFull"
fi
2021-07-12 22:36:40 +00:00
# Restore LFS cache
2021-07-31 21:41:55 +00:00
latest=$(ls -t "$cacheFolderWithBranch/lfs" | egrep -i -e '\\.zip$' | head -1)
if [ ! -z "$latest" ]; then
echo "Library cache exists from build $latest from $branchName"
echo 'Creating empty Library folder for cache'
mkdir "$libraryFolderFull"
unzip -q "$cacheFolderWithBranch/lfs/$latest" -d "$gitLFSDestinationFolder"
fi
2021-07-12 22:36:40 +00:00
# purge cache
if [ "$purgeRemoteBuilderCache" == "true" ]; then
2021-07-31 21:48:02 +00:00
rm -r "$cacheFolderFull"
fi