Commit 00e6e7fe authored by Nong Hoang Tu's avatar Nong Hoang Tu

Merge branch 'master' of git.parrot.sh:dmknght/source-updater

parents b671288f 94c9fbf1
Pipeline #2107 canceled with stages
......@@ -26,6 +26,10 @@ proc updateProject(prjName, sessionLog: string): int =
var updater = initProject(srcPath, sessionLog, prjName)
if not dirExists(updater.path):
updater.logError("Can't find source code folder")
return ERR
updater.logNoti("Start working")
setCurrentDir(updater.path)
# TODO check this logic later. It must be true by default
......@@ -33,10 +37,6 @@ proc updateProject(prjName, sessionLog: string): int =
# return false
discard updater.srcPull()
if not dirExists(updater.path):
updater.logError("Can't find source code folder")
return ERR
if fileExists(updater.path & "/debian/watch"):
var version: string
let cmpResult = cmpVersionWatch(updater, version)
......@@ -116,11 +116,65 @@ proc processUpdateAll() =
logResult.retError(prjName)
proc pullProject(prjName, logPath: string) =
let
srcPath = dirName(sourceFolder)
var updater = initProject(srcPath, sessionLog, prjName)
updater.logNoti("Start working")
if not dirExists(updater.path):
updater.logError("Can't find source code folder")
return ERR
setCurrentDir(updater.path)
discard updater.srcPull()
return true
proc processPull(packages: seq[string]) =
let
rootLogFolder = dirName(conf["log"].getStr())
logPath = initLogFolder(rootLogFolder)
if logPath == "":
echo "[x] Failed to create log folder"
return
let logResult = initLogResult(dirName(logPath))
for prjName in packages:
let path = dirName(sourceFolder) & prjName
if not dirExists(path):
discard
else:
pullProject(prjName, logPath)
proc processPullAll() =
let
rootLogFolder = dirName(conf["log"].getStr())
logPath = initLogFolder(rootLogFolder)
if logPath == "":
echo "[x] Failed to create log folder"
return
let logResult = initLogResult(dirName(logPath))
for kind, path in walkDir(sourceFolder):
if kind == pcDir:
let
prjName = splitPath(path).tail
discard pullProject(prjName, logPath)
proc help() =
echo "Usage: ./updater [options]"
echo "Options:"
echo " update Update the debian packages from config"
echo " clone <package1> <packages 2> Clone project from Parrot's repository"
echo " clone <package1> <package 2> Clone project from Parrot's repository"
echo " pull <package1> <package 2> Pull project from Parrot's repository"
proc main() =
......@@ -138,6 +192,8 @@ proc main() =
elif paramStr(1) == "clone":
echo "[!] Need packages name to clone"
help()
elif paramStr(1) == "pull":
processPullAll()
else:
echo "[!] Don't know command ", paramStr(1)
help()
......@@ -149,11 +205,14 @@ proc main() =
cloneResult = doClone(prjName, sourceFolder)
if cloneResult != 0:
echo "[x] Failed to clone ", prjName
elif paramStr(1) == "update":
elif paramStr(1) == "update" or paramStr(1) == "pull":
var packages: seq[string]
for i in 2 .. paramCount():
packages.add(paramStr(i))
processUpdate(packages)
if paramStr(1) == "update":
processUpdate(packages)
else:
processPull(packages)
else:
echo "[!] Don't know command ", paramStr(1)
help()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment