2021-07-12 21:06:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2021-07-31 20:44:53 +00:00
|
|
|
cacheFolderFull=$1
|
2021-07-12 22:46:21 +00:00
|
|
|
branchName=$2
|
2021-07-31 20:44:53 +00:00
|
|
|
libraryFolderFull=$3
|
2021-07-12 22:46:21 +00:00
|
|
|
purgeRemoteBuilderCache=$4
|
2021-07-12 21:06:03 +00:00
|
|
|
|
2021-07-31 20:41:26 +00:00
|
|
|
echo ""
|
|
|
|
|
echo "Caching starting, parameters:"
|
2021-07-31 20:44:53 +00:00
|
|
|
echo "$cacheFolderFull"
|
2021-07-31 20:41:26 +00:00
|
|
|
echo "$branchName"
|
2021-07-31 20:44:53 +00:00
|
|
|
echo "$libraryFolderFull"
|
2021-07-31 20:41:26 +00:00
|
|
|
echo "$purgeRemoteBuilderCache"
|
|
|
|
|
|
|
|
|
|
echo ""
|
2021-07-27 20:45:49 +00:00
|
|
|
# handle library cache
|
2021-07-27 22:40:48 +00:00
|
|
|
if [ ! -d "$cacheFolderFull" ]; then
|
2021-07-27 22:23:02 +00:00
|
|
|
echo "creating new cache folder $cacheFolderFull"
|
2021-07-31 20:44:53 +00:00
|
|
|
mkdir "$cacheFolderFull"
|
2021-07-27 22:40:48 +00:00
|
|
|
if [ ! -d "$cacheFolderFull/$branchName" ]; then
|
|
|
|
|
echo "creating new cache branch folder for: $cacheFolderFull/$branchName"
|
2021-07-31 20:44:53 +00:00
|
|
|
mkdir "$cacheFolderFull/$branchName"
|
2021-07-27 22:40:48 +00:00
|
|
|
else
|
|
|
|
|
echo "cache branch folder already exists for: $cacheFolderFull/$branchName"
|
|
|
|
|
fi
|
2021-07-27 22:23:02 +00:00
|
|
|
else
|
|
|
|
|
echo "cache folder already exists $cacheFolderFull"
|
2021-07-27 20:45:49 +00:00
|
|
|
fi
|
2021-07-27 22:23:02 +00:00
|
|
|
|
2021-07-27 20:45:49 +00:00
|
|
|
echo "Library cache for branch: $branchName"
|
2021-07-31 20:44:53 +00:00
|
|
|
ls "$cacheFolderFull/$branchName"
|
2021-07-27 20:45:49 +00:00
|
|
|
echo ''
|
|
|
|
|
|
2021-07-27 22:40:48 +00:00
|
|
|
if [ -d "$libraryFolderFull" ]; then
|
2021-07-31 20:44:53 +00:00
|
|
|
rm -r "$libraryFolderFull"
|
2021-07-27 20:45:49 +00:00
|
|
|
echo "Git must ignore the Library folder"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2021-07-12 21:06:03 +00:00
|
|
|
echo "Checking cache"
|
|
|
|
|
|
2021-07-12 22:36:40 +00:00
|
|
|
# Restore library cache
|
2021-07-12 22:46:21 +00:00
|
|
|
latest=$(ls -t $cacheDir | head -1)
|
2021-07-12 21:06:03 +00:00
|
|
|
if [ ! -z "$latest" ]; then
|
|
|
|
|
echo "Library cache exists from build $latest from $branchName"
|
|
|
|
|
echo 'Creating empty Library folder for cache'
|
2021-07-31 20:44:53 +00:00
|
|
|
mkdir "$libraryFolderFull"
|
|
|
|
|
unzip -q "$latest" -d "$libraryFolderFull"
|
2021-07-12 21:06:03 +00:00
|
|
|
else
|
|
|
|
|
echo 'Cache does not exist'
|
|
|
|
|
fi
|
|
|
|
|
|
2021-07-12 22:36:40 +00:00
|
|
|
# Restore LFS cache
|
|
|
|
|
|
2021-07-12 21:06:03 +00:00
|
|
|
# purge cache
|
|
|
|
|
if [ "$purgeRemoteBuilderCache" == "true" ]; then
|
2021-07-31 20:44:53 +00:00
|
|
|
rm -r "$libraryFolderFull"
|
2021-07-12 21:06:03 +00:00
|
|
|
fi
|
|
|
|
|
|