diff options
author | Tony Theodore <tonyt@logyst.com> | 2016-05-03 04:20:05 (GMT) |
---|---|---|
committer | Tony Theodore <tonyt@logyst.com> | 2016-05-03 04:20:05 (GMT) |
commit | a79de325a6fcd09778b425715d9190554059818f (patch) | |
tree | 91c01bd42b920b6435de22e3d7a35d2eef652c4a | |
parent | 3d816111a9caa185acef50f2c1c692d64e69edcd (diff) | |
parent | 3ee3445f9020c4395cdf2219dbf1067686166700 (diff) | |
download | mxe-a79de325a6fcd09778b425715d9190554059818f.zip mxe-a79de325a6fcd09778b425715d9190554059818f.tar.gz mxe-a79de325a6fcd09778b425715d9190554059818f.tar.bz2 |
Merge pull request #1325 from LuaAndC/build-pkg-max-download-tries
build-pkg: limit number of retries of downloading
-rwxr-xr-x | tools/build-pkg.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/build-pkg.lua b/tools/build-pkg.lua index 0af1d33..9cda06f 100755 --- a/tools/build-pkg.lua +++ b/tools/build-pkg.lua @@ -39,6 +39,8 @@ local no_second_pass = os.getenv('MXE_NO_SECOND_PASS') local TODAY = os.date("%Y%m%d") +local MAX_TRIES = 10 + local GIT = 'git --work-tree=./usr/ --git-dir=./usr/.git ' local GIT_USER = '-c user.name="build-pkg" ' .. '-c user.email="build-pkg@mxe" ' @@ -1027,6 +1029,20 @@ local function makeMxeSourcePackage() makePackage(name, files, deps, ver, d1, d2) end +local function downloadPackages() + local cmd = ('%s download -j 6 -k'):format(tool 'make') + for i = 1, MAX_TRIES do + log("Downloading packages. Attempt %d.", i) + if execute(cmd) then + log("All packages were downloaded.") + return + end + log("Some packages failed to download.") + end + log("%d downloading attempts failed. Giving up.", MAX_TRIES) + error('downloading failed') +end + local function main() assert(not io.open('usr/.git'), 'Remove usr/') local MXE_DIR_EXPECTED = '/usr/lib/mxe' @@ -1038,8 +1054,7 @@ local function main() assert(execute(("%s check-requirements MXE_TARGETS=%q"):format( tool 'make', table.concat(TARGETS, ' ')))) if not max_items then - local cmd = ('%s download -j 6 -k'):format(tool 'make') - while not execute(cmd) do end + downloadPackages() end gitAdd() gitCommit('Initial commit') |