2021-07-12 21:06:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2021-07-12 22:46:21 +00:00
|
|
|
cacheDir=$1
|
|
|
|
|
branchName=$2
|
|
|
|
|
libDir=$3
|
|
|
|
|
purgeRemoteBuilderCache=$4
|
2021-07-12 21:06:03 +00:00
|
|
|
|
2021-07-27 20:45:49 +00:00
|
|
|
# handle library cache
|
|
|
|
|
if [ ! -d $cacheFolderFull ]; then
|
|
|
|
|
mkdir $cacheFolderFull
|
2021-07-27 22:23:02 +00:00
|
|
|
echo "creating new cache folder $cacheFolderFull"
|
|
|
|
|
else
|
|
|
|
|
echo "cache folder already exists $cacheFolderFull"
|
2021-07-27 20:45:49 +00:00
|
|
|
fi
|
2021-07-27 22:23:02 +00:00
|
|
|
|
|
|
|
|
if [ ! -d "$cacheFolderFull/$branchName" ]; then
|
2021-07-27 20:45:49 +00:00
|
|
|
mkdir $cacheFolderFull/$branchName
|
2021-07-27 22:23:02 +00:00
|
|
|
echo "creating new cache branch folder for: $cacheFolderFull/$branchName"
|
|
|
|
|
else
|
|
|
|
|
echo "cache branch folder already exists for: $cacheFolderFull/$branchName"
|
2021-07-27 20:45:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Library cache for branch: $branchName"
|
|
|
|
|
ls $cacheFolderFull/$branchName
|
|
|
|
|
echo ''
|
|
|
|
|
|
|
|
|
|
if [ -d $libraryFolderFull ]; then
|
|
|
|
|
rm -r $libraryFolderFull
|
|
|
|
|
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'
|
|
|
|
|
mkdir $libDir
|
|
|
|
|
unzip -q $latest -d $libDir
|
|
|
|
|
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
|
|
|
|
|
rm -r $libDir
|
|
|
|
|
fi
|
|
|
|
|
|