diff options
author | Amrykid <amrykid@gmail.com> | 2011-12-24 16:45:28 -0600 |
---|---|---|
committer | Amrykid <amrykid@gmail.com> | 2011-12-24 16:45:28 -0600 |
commit | f0ccc2e779bb6e5db15b7a19efe90d99b6518b3e (patch) | |
tree | 486b273713d3d60a4a04357424a17a4b900fb8dc /koch.nim | |
parent | 2e0f9c8bf77a4baad539bfa162866f324ee94225 (diff) | |
download | Nim-f0ccc2e779bb6e5db15b7a19efe90d99b6518b3e.tar.gz |
- Koch update is nearly finished.
-- Checks if libzip is available as a fallback. -- Echos what its doing. -- Actually compiles now.
Diffstat (limited to 'koch.nim')
-rwxr-xr-x | koch.nim | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/koch.nim b/koch.nim index 2e67cd3d4..1af3a4d86 100755 --- a/koch.nim +++ b/koch.nim @@ -11,7 +11,9 @@ when defined(gcc) and defined(windows): {.link: "icons/koch.res".} import - os, strutils, parseopt + os, strutils, parseopt, osproc, httpclient +when defined(haveZipLib): + import zipfiles const HelpText = """ @@ -80,20 +82,49 @@ proc web(args: string) = NimrodVersion) proc update(args: string) = - if ExistFile("./.git"): + var thisDir = getAppDir() + echo("Checking for git repo...") + if existsDir(thisDir & "/.git"): + echo("Git repo found!") # use git to download latest source - exec("git pull") + var output = execProcess("git diff origin/master master") + if output == "\r\n": + # No changes + echo("No update. Exiting..") + return + else: + echo("Fetching updates from repo...") + var pullout = execCmdEx("git pull origin master") + if pullout[1] != 0: + echo("An error has occured.") + return + else: + if pullout[0] == "Already up-to-date.\r\n": + echo("No new changes fetched from the repo. Local branch must be ahead of it. Exiting...") + return + else: - # use dom96's httpclient to download zip - import httpclient - import zipfiles - downloadFile("https://github.com/Araq/Nimrod/zipball/master","./update.zip") - var zip :TZipArchive - discard open(zip,fmRead) # will add error checking later - extractAll(zip,"./") - + when defined(haveZipLib): + echo("Falling back.. Downloading source code from repo...") + # use dom96's httpclient to download zip + downloadFile("https://github.com/Araq/Nimrod/zipball/master",thisDir & "/update.zip") + + try: + echo("Extracting source code from archive...") + var zip :TZipArchive + discard open(zip,thisDir & "/update.zip", fmRead) # will add error checking later + extractAll(zip, thisDir & "/") + except: + echo("Error reading archive.") + return + else: + echo("No failback available. Exiting...") + return + + echo("Starting update...") exec("./koch boot -d:release") + echo("Update complete!") @@ -223,7 +254,7 @@ of cmdArgument: of "inno": inno(op.cmdLineRest) of "install": install(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest) - of "update", "up": update(op.cmdLineRest) + of "update": update(op.cmdLineRest) else: showHelp() of cmdEnd: showHelp() |