提交 ee308a68 编写于 作者: A Andy Gocke

Merge pull request #5127 from agocke/AddPosixSemaphoreForNuGetRestore

Add a semaphore to NuGet and Mono restore
......@@ -56,14 +56,36 @@ do
esac
done
acquire_sem_or_wait()
{
local lockpath="/tmp/${1}.lock.d"
echo "Acquiring ${lockpath}"
while true; do
mkdir "${lockpath}" 2>/dev/null
if [ $? -eq 0 ]; then
break;
fi
echo "Waiting for lock $1"
sleep 10
done
}
release_sem()
{
rmdir "/tmp/${1}.lock.d"
}
restore_nuget()
{
acquire_sem_or_wait "restore_nuget"
local package_name="nuget.9.zip"
local target="/tmp/$package_name"
echo "Installing NuGet Packages $target"
if [ -f $target ]; then
if [ "$USE_CACHE" = "true" ]; then
echo "Already installed"
release_sem "restore_nuget"
return
fi
fi
......@@ -75,10 +97,13 @@ restore_nuget()
unzip -uoq $package_name -d ~/
if [ $? -ne 0 ]; then
echo "Unable to download NuGet packages"
release_sem "restore_nuget"
exit 1
fi
popd
release_sem "restore_nuget"
}
run_msbuild()
......@@ -176,9 +201,13 @@ install_mono_toolset()
{
local target=/tmp/$1
echo "Installing Mono toolset $1"
acquire_sem_or_wait "$1"
if [ -d $target ]; then
if [ "$USE_CACHE" = "true" ]; then
echo "Already installed"
release_sem "$1"
return
fi
fi
......@@ -191,10 +220,12 @@ install_mono_toolset()
tar -jxf $1.tar.bz2
if [ $? -ne 0 ]; then
echo "Unable to download toolset"
release_sem "$1"
exit 1
fi
popd
release_sem "$1"
}
# This function will update the PATH variable to put the desired
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册