update process for windows
This commit is contained in:
parent
c8ddbf3243
commit
4590b0ce7a
1 changed files with 16 additions and 13 deletions
|
@ -11,12 +11,18 @@ import os
|
||||||
import ../model/log_type
|
import ../model/log_type
|
||||||
import version
|
import version
|
||||||
|
|
||||||
const sh = """
|
const SH = """
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
mv {new} {old}
|
mv {new} {old}
|
||||||
{old} --version
|
{old} --version
|
||||||
rm -r tmp
|
rm -r tmp
|
||||||
"""
|
"""
|
||||||
|
const BAT = """
|
||||||
|
move {new} {old}
|
||||||
|
{old} --version
|
||||||
|
rmdir /s tmp
|
||||||
|
"""
|
||||||
|
|
||||||
proc extractUpdate(name, file: string) =
|
proc extractUpdate(name, file: string) =
|
||||||
var client = newHttpClient()
|
var client = newHttpClient()
|
||||||
try:
|
try:
|
||||||
|
@ -24,22 +30,19 @@ proc extractUpdate(name, file: string) =
|
||||||
client.downloadFile(file,fmt"tmp/{name}")
|
client.downloadFile(file,fmt"tmp/{name}")
|
||||||
let cwd = getAppDir()
|
let cwd = getAppDir()
|
||||||
let cwf = getAppFilename()
|
let cwf = getAppFilename()
|
||||||
case hostOS
|
let ok = osproc.execCmd(fmt"tar xf tmp/{name} -C tmp/")
|
||||||
of "linux":
|
copyFile(cwf,fmt"{cwd}/norg_backup")
|
||||||
let ok = osproc.execCmd(fmt"tar xf tmp/{name} -C tmp/")
|
if ok == 0:
|
||||||
if ok == 0:
|
case hostOS
|
||||||
copyFile(cwf,fmt"{cwd}/norg_backup")
|
of "linux","freebsd":
|
||||||
let content = sh.replace("{new}", "tmp/norg").replace("{old}", cwf)
|
let content = SH.replace("{new}", "tmp/norg").replace("{old}", cwf)
|
||||||
writeFile("tmp/norg_update", content)
|
writeFile("tmp/norg_update", content)
|
||||||
discard osproc.execCmd("sh tmp/norg_update")
|
discard osproc.execCmd("sh tmp/norg_update")
|
||||||
quit(0)
|
quit(0)
|
||||||
of "windows":
|
of "windows":
|
||||||
let ok = osproc.execCmd(fmt"decompress tmp/{name} -C tmp/")
|
let content = BAT.replace("{new}", "tmp/norg").replace("{old}", cwf)
|
||||||
if ok == 0:
|
|
||||||
copyFile(cwf,fmt"{cwd}/norg_backup")
|
|
||||||
let content = sh.replace("{new}", "tmp/norg").replace("{old}", cwf)
|
|
||||||
writeFile("tmp/norg_update", content)
|
writeFile("tmp/norg_update", content)
|
||||||
discard osproc.execCmd("sh tmp/norg_update")
|
discard osproc.execCmd("tmp/norg_update")
|
||||||
quit(0)
|
quit(0)
|
||||||
except:
|
except:
|
||||||
error getCurrentExceptionMsg()
|
error getCurrentExceptionMsg()
|
||||||
|
|
Loading…
Reference in a new issue