downloader changes

This commit is contained in:
Araq 2017-02-07 23:46:51 +01:00
commit 4ef86042f2
2 changed files with 17 additions and 14 deletions

View file

@ -94,7 +94,7 @@ Files: "bin/vccexe.exe"
Files: "koch.exe" Files: "koch.exe"
Files: "finish.exe" Files: "finish.exe"
Files: "downloader.exe" Files: "bin/downloader.exe"
; Files: "dist/mingw" ; Files: "dist/mingw"
Files: r"tools\start.bat" Files: r"tools\start.bat"

View file

@ -1,4 +1,15 @@
# Helper that is run after Nim's installation. ## Helper that is run after Nim's installation.
## We download mirror'ed mingw packages. The originals came from:
##
## https://sourceforge.net/projects/mingw-w64/files/Toolchains%20
## targetting%20Win32/Personal%20Builds/mingw-builds/6.3.0/threads-win32/
## dwarf/i686-6.3.0-release-win32-dwarf-rt_v5-rev1.7z/download
## https://sourceforge.net/projects/mingw-w64/files/Toolchains%20
## targetting%20Win64/Personal%20Builds/mingw-builds/6.3.0/threads-win32/
## seh/x86_64-6.3.0-release-win32-seh-rt_v5-rev1.7z/download
##
import import
ui, asyncdispatch, httpclient, os, finish, registry, strutils ui, asyncdispatch, httpclient, os, finish, registry, strutils
@ -22,30 +33,22 @@ proc download(pkg: string; c: Controls) {.async.} =
client.onProgressChanged = onProgressChanged client.onProgressChanged = onProgressChanged
# XXX give a destination filename instead # XXX give a destination filename instead
let contents = await client.getContent("https://nim-lang.org/download/" & pkg & ".zip") let contents = await client.getContent("https://nim-lang.org/download/" & pkg & ".7z")
let z = "dist" / pkg & ".zip" let z = r"..\dist" / pkg & ".7z"
# XXX make this async somehow: # XXX make this async somehow:
writeFile(z, contents) writeFile(z, contents)
c.bar.value = 100 c.bar.value = 100
let olddir = getCurrentDir() let olddir = getCurrentDir()
try: try:
setCurrentDir(olddir / "dist") setCurrentDir(olddir / "dist")
if os.execShellCmd("bin\\7zG.exe x " & pkg & ".zip") != 0: if os.execShellCmd("7zG.exe x " & pkg & ".7z") != 0:
c.lab.text = "Unpacking failed: " & z c.lab.text = "Unpacking failed: " & z
finally: finally:
setCurrentdir(olddir) setCurrentdir(olddir)
when false:
var a: ZipArchive
if open(a, z, fmRead):
extractAll(a, "dist")
close(a)
else:
c.lab.text = "Error: cannot open: " & z
proc apply(a: Actions; c: Controls) {.async.} = proc apply(a: Actions; c: Controls) {.async.} =
if a.mingw: if a.mingw:
await download("mingw" & arch, c) await download("mingw" & arch & "-6.3.0", c)
if a.aporia: if a.aporia:
await download("aporia-0.4.0", c) await download("aporia-0.4.0", c)