- Koch update is nearly finished.
-- Checks if libzip is available as a fallback. -- Echos what its doing. -- Actually compiles now.
This commit is contained in:
parent
2e0f9c8bf7
commit
f0ccc2e779
1 changed files with 44 additions and 13 deletions
57
koch.nim
57
koch.nim
|
|
@ -11,7 +11,9 @@ when defined(gcc) and defined(windows):
|
||||||
{.link: "icons/koch.res".}
|
{.link: "icons/koch.res".}
|
||||||
|
|
||||||
import
|
import
|
||||||
os, strutils, parseopt
|
os, strutils, parseopt, osproc, httpclient
|
||||||
|
when defined(haveZipLib):
|
||||||
|
import zipfiles
|
||||||
|
|
||||||
const
|
const
|
||||||
HelpText = """
|
HelpText = """
|
||||||
|
|
@ -80,20 +82,49 @@ proc web(args: string) =
|
||||||
NimrodVersion)
|
NimrodVersion)
|
||||||
|
|
||||||
proc update(args: string) =
|
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
|
# use git to download latest source
|
||||||
exec("git pull")
|
var output = execProcess("git diff origin/master master")
|
||||||
else:
|
if output == "\r\n":
|
||||||
# use dom96's httpclient to download zip
|
# No changes
|
||||||
import httpclient
|
echo("No update. Exiting..")
|
||||||
import zipfiles
|
return
|
||||||
downloadFile("https://github.com/Araq/Nimrod/zipball/master","./update.zip")
|
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
|
||||||
|
|
||||||
var zip :TZipArchive
|
else:
|
||||||
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")
|
exec("./koch boot -d:release")
|
||||||
|
echo("Update complete!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -223,7 +254,7 @@ of cmdArgument:
|
||||||
of "inno": inno(op.cmdLineRest)
|
of "inno": inno(op.cmdLineRest)
|
||||||
of "install": install(op.cmdLineRest)
|
of "install": install(op.cmdLineRest)
|
||||||
of "test", "tests": tests(op.cmdLineRest)
|
of "test", "tests": tests(op.cmdLineRest)
|
||||||
of "update", "up": update(op.cmdLineRest)
|
of "update": update(op.cmdLineRest)
|
||||||
else: showHelp()
|
else: showHelp()
|
||||||
of cmdEnd: showHelp()
|
of cmdEnd: showHelp()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue