From 4a8c23b666d566bee5670225e2e16829ea42dee5 Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Tue, 24 May 2022 21:27:59 +0800 Subject: [PATCH] Delete libtorrent source directory when update failed. fix #380 (#382) --- .github/workflows/build_appimage.sh | 20 ++++++++++++++------ .github/workflows/cross_build.sh | 18 +++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_appimage.sh b/.github/workflows/build_appimage.sh index ae3ae2168..3151e5038 100755 --- a/.github/workflows/build_appimage.sh +++ b/.github/workflows/build_appimage.sh @@ -35,7 +35,7 @@ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/0 echo -e 'Acquire::https::Verify-Peer "false";\nAcquire::https::Verify-Host "false";' >/etc/apt/apt.conf.d/99-trust-https # Since cmake 3.23.0 CMAKE_INSTALL_LIBDIR will force set to lib/ on Debian -echo '/usr/local/lib/x86_64-linux-gnu' > /etc/ld.so.conf.d/x86_64-linux-gnu-local.conf +echo '/usr/local/lib/x86_64-linux-gnu' >/etc/ld.so.conf.d/x86_64-linux-gnu-local.conf apt update apt install -y software-properties-common apt-transport-https @@ -274,17 +274,25 @@ fi # build libtorrent-rasterbar echo "libtorrent-rasterbar branch: ${LIBTORRENT_BRANCH}" +libtorrent_git_url="https://github.com/arvidn/libtorrent.git" +if [ x"${USE_CHINA_MIRROR}" = x1 ]; then + libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}" +fi if [ ! -d "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" ]; then - libtorrent_git_url="https://github.com/arvidn/libtorrent.git" - if [ x"${USE_CHINA_MIRROR}" = x1 ]; then - libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}" - fi retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \ "${libtorrent_git_url}" \ "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" fi cd "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" -git pull +if ! git pull; then + # if pull failed, retry clone the repository. + cd / + rm -fr "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" + retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \ + "${libtorrent_git_url}" \ + "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" + cd "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" +fi rm -fr build/CMakeCache.txt cmake \ -B build \ diff --git a/.github/workflows/cross_build.sh b/.github/workflows/cross_build.sh index 3034c0493..c21658228 100755 --- a/.github/workflows/cross_build.sh +++ b/.github/workflows/cross_build.sh @@ -340,17 +340,25 @@ prepare_qt() { prepare_libtorrent() { echo "libtorrent-rasterbar branch: ${LIBTORRENT_BRANCH}" + libtorrent_git_url="https://github.com/arvidn/libtorrent.git" + if [ x"${USE_CHINA_MIRROR}" = x1 ]; then + libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}" + fi if [ ! -d "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" ]; then - libtorrent_git_url="https://github.com/arvidn/libtorrent.git" - if [ x"${USE_CHINA_MIRROR}" = x1 ]; then - libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}" - fi retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \ "${libtorrent_git_url}" \ "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" fi cd "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" - git pull + if ! git pull; then + # if pull failed, retry clone the repository. + cd / + rm -fr "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" + retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \ + "${libtorrent_git_url}" \ + "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" + cd "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" + fi rm -fr build/CMakeCache.txt # TODO: solve mingw build if [ x"${TARGET_HOST}" = xWindows ]; then