From 84e23a44edb84af31dee64e67d44b35edbc6f44a Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Thu, 24 Aug 2017 09:01:18 +0900 Subject: [PATCH] Retry 3 times if dotnet process is exited with error code Change-Id: If27f2a3ea4746f3e1c052ea29b1b1ea6356bddd6 --- .../Tizen.GBS.ImportAfter.targets | 11 ------- Tools/dotnet-build.sh | 32 ++++++------------- Tools/retry.sh | 21 ++++++++++++ packaging/dotnet-build-tools.spec | 6 +--- packaging/macros.dotnet-build-tools | 5 ++- 5 files changed, 33 insertions(+), 42 deletions(-) delete mode 100644 Tizen.GBS.BuildTasks/Tizen.GBS.ImportAfter.targets create mode 100755 Tools/retry.sh diff --git a/Tizen.GBS.BuildTasks/Tizen.GBS.ImportAfter.targets b/Tizen.GBS.BuildTasks/Tizen.GBS.ImportAfter.targets deleted file mode 100644 index d8aab8d8..00000000 --- a/Tizen.GBS.BuildTasks/Tizen.GBS.ImportAfter.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(NoWarn);1591 - $(OutputPath)$(AssemblyName).xml - - - - diff --git a/Tools/dotnet-build.sh b/Tools/dotnet-build.sh index 2b32b29e..24f29aec 100755 --- a/Tools/dotnet-build.sh +++ b/Tools/dotnet-build.sh @@ -1,5 +1,11 @@ #!/bin/bash +SCRIPT_FILE=$(readlink -f $0) +SCRIPT_DIR=$(dirname $SCRIPT_FILE) + +TIMEOUT_CMD="$SCRIPT_DIR/timeout.sh" +RETRY_CMD="$SCRIPT_DIR/retry.sh" + usage() { echo "usage: " echo " $0 restore [-s ] ..." @@ -15,29 +21,9 @@ exit_on_error() { fi } -retry() { - local CMD=$1; shift - local RETRY=$1; shift - local RET=0 - local n=0 - until [ $n -ge $RETRY ]; do - if [ $n -gt 0 ]; then - sleep 2 - echo "Retry $n ....." - fi - echo "+ $CMD $@" - $CMD $@ - RET=$? - if [ $RET -eq 0 ]; then - break - fi - n=$[$n+1] - done - exit_on_error $RET -} - run_nuget() { - retry nuget 3 $@ + $RETRY_CMD nuget $@ + exit_on_error $? } run_xbuild() { @@ -48,7 +34,7 @@ run_xbuild() { run_dotnet() { echo "+ dotnet $@" - timeout 3600 dotnet $@ + $RETRY_CMD $TIMEOUT_CMD 600 dotnet $@ exit_on_error $? } diff --git a/Tools/retry.sh b/Tools/retry.sh new file mode 100755 index 00000000..b6add9dc --- /dev/null +++ b/Tools/retry.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +retry_count=3 +cmd="${@}" + +n=0 +until [ $n -ge $retry_count ]; do + if [ $n -gt 0 ]; then + echo "(Failed! Retry $[$n+1]/$retry_count) $cmd" + sleep 2 + fi + $cmd + RET=$? + if [ $RET -eq 0 ]; then + break + else + n=$[$n+1] + fi +done + +exit $RET diff --git a/packaging/dotnet-build-tools.spec b/packaging/dotnet-build-tools.spec index 23fd3c76..c28b70fa 100644 --- a/packaging/dotnet-build-tools.spec +++ b/packaging/dotnet-build-tools.spec @@ -3,7 +3,7 @@ Name: dotnet-build-tools Summary: Tools for building C# API projects -Version: 1.3.0 +Version: 1.3.1 Release: 1 Group: Development/Libraries License: MIT and Apache-2.0 @@ -58,16 +58,12 @@ mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{TOOLS_PATH} install -p -m 755 Tools/* %{buildroot}%{TOOLS_PATH} ln -s %{TOOLS_PATH}/dotnet-build.sh %{buildroot}%{_bindir}/dotnet-build -ln -s %{TOOLS_PATH}/timeout.sh %{buildroot}%{_bindir}/timeout # dotnet-cli mkdir -p %{buildroot}%{CLI_PATH} cp -fr ./dotnet/* %{buildroot}%{CLI_PATH} ln -s %{CLI_PATH}/dotnet %{buildroot}%{_bindir}/dotnet -# Tizen.GBS.BuildTasks -install -p -m 644 Tizen.GBS.BuildTasks/Tizen.GBS.ImportAfter.targets %{buildroot}%{CLI_PATH}/sdk/*/15.0/Microsoft.Common.targets/ImportAfter - # NuGet mkdir -p %{buildroot}%{NUGET_PATH} install -p -m 755 NuGet/* %{buildroot}%{NUGET_PATH} diff --git a/packaging/macros.dotnet-build-tools b/packaging/macros.dotnet-build-tools index 140e41b4..a40fd665 100644 --- a/packaging/macros.dotnet-build-tools +++ b/packaging/macros.dotnet-build-tools @@ -14,7 +14,6 @@ %dotnet_assembly_files %{_dotnet_assembly_path}/*.dll %dotnet_nuget_source %{_dotnet_nuget_source} -# %_dotnet_build_conf %{lua:if tonumber(rpm.expand("0%{?tizen_build_devel_mode}")) == 1 then print "Debug" else print "Release" end} %_dotnet_build_conf Release %dotnet_nuget_package(n:f:)\ @@ -47,11 +46,11 @@ dotnet-build -s %{-s:%{-s*}}%{!-s:%{_dotnet_nuget_source}} restore %{1} %{?2} %{ %{nil} %dotnet_build(s:) \ -dotnet-build -c %{_dotnet_build_conf} -s %{-s:%{-s*}}%{!-s:%{_dotnet_nuget_source}} build %{1} /p:UsingRPMMacro=true %{?2} %{?3} %{?4} %{?5} %{?6} \ +dotnet-build -c %{_dotnet_build_conf} -s %{-s:%{-s*}}%{!-s:%{_dotnet_nuget_source}} build %{1} %{?2} %{?3} %{?4} %{?5} %{?6} \ %{nil} %dotnet_pack() \ -dotnet-build -c %{_dotnet_build_conf} %{?2:-v %{2}} pack %{1} /p:UsingRPMMacro=true %{?3} %{?4} %{?5} %{?6} %{?7} \ +dotnet-build -c %{_dotnet_build_conf} %{?2:-v %{2}} pack %{1} %{?3} %{?4} %{?5} %{?6} %{?7} \ %{nil} %dotnet_install_assembly() \ -- 2.34.1