aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lapis.nim51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/lapis.nim b/src/lapis.nim
index 4a1940c..3a758f3 100644
--- a/src/lapis.nim
+++ b/src/lapis.nim
@@ -101,13 +101,6 @@ macro tessera*(packageName: untyped, body: untyped): untyped =
if result.endsWith(suffix):
result.removeSuffix(suffix)
- proc runCommand(command: string, workingDir: string = ""): string =
- echo "Running command: " & command
- let (output, exitCode) = execCmdEx(command, workingDir=workingDir)
- if exitCode != 0:
- quit("Command failed with exit code: \"" & $exitCode & "\":\n" & $output)
- result = output
-
proc isExecutable(filename: string): bool =
let permissions = getFilePermissions(filename)
result = ((fpUserExec in permissions) or (fpGroupExec in permissions))
@@ -129,9 +122,13 @@ macro tessera*(packageName: untyped, body: untyped): untyped =
if not (fileExists(localInstaller) or isExecutable(localInstaller)):
quit("dependency \"" & $dependency & "\" not defined yet.")
- let output = runCommand("/mosaic/panel/" & $dependency)
- echo output
+ let
+ installProcess = startProcess("/mosaic/panel/" & $dependency)
+
+ for line in installProcess.lines:
+ echo "[CMD] Installing " & $dependency & " | " & line
+ # TODO: Add quits (again) after exitCode != 0
proc `buildIdent`() =
echo "Building " & $pkgName
@@ -156,16 +153,23 @@ macro tessera*(packageName: untyped, body: untyped): untyped =
if not fileExists(sourceFile):
echo "Fetching source: " & $pkgSource & " -> " & sourceFile
+ let
+ wgetCmd = "wget " & $pkgSource
+ # For some reason startProcess fails????????????????????????
+ (wgetOutput, wgetExitCode) = execCmdEx(wgetCmd, workingDir=mosaicSourceFolder)
- let wgetOutput = runCommand(command="wget " & $pkgSource, workingDir=mosaicSourceFolder)
- echo "wget " & wgetOutput
+ echo "[WGET] " & $wgetOutput
else:
echo $sourceFile & " exists. Continuing..."
# Step 3: untar
echo "extracting " & $sourceFile & "..."
- let tarOutput = runCommand(command="tar -xf " & $sourceFile, workingDir=mosaicSourceFolder)
- echo tarOutput
+
+ let
+ tarCmd = "tar -xf " & $sourceFile
+ (tarOutput, tarExitCode) = execCmdEx(tarCmd, workingDir=mosaicSourceFolder)
+
+ echo "[TAR] " & $tarOutput
var untarFolders: seq[string] = @[]
for folder in walkDir(expectedFolder):
@@ -184,9 +188,13 @@ macro tessera*(packageName: untyped, body: untyped): untyped =
let patchFile = extractFilename(url=patchURL)
echo "Fetching patch: " & $patchURL & " -> " & $patchFile
-
- let wgetPatchOutput = runCommand(command="wget " & $patchURL, workingDir=mosaicSourceFolder)
- echo wgetPatchOutput
+
+ let
+ patchWgetCmd = "wget " & $patchURL
+ (patchOutput, patchExitCode) = execCmdEx(patchWgetCmd, workingDir=mosaicSourceFolder)
+
+ echo "[PATCH] " & $patchOutput
+
assert fileExists(patchFile)
# Step 6: Run the build commands:
@@ -194,17 +202,18 @@ macro tessera*(packageName: untyped, body: untyped): untyped =
quit("No commands given to run for " & $pkgName & "... Nothing to do.")
var newWorkingFolder = expectedFolder
- echo newWorkingFolder
for command in pkgBuild:
- echo command
if command.startsWith("cd "):
newWorkingFolder = newWorkingFolder & command[3..^1]
+ echo "[INFO] Working Folder set" & $newWorkingFolder
continue
- let buildOutput = runCommand(command=command, workingDir=newWorkingFolder)
- echo buildOutput
+ let
+ (cmdOutput, cmdExitCode) = execCmdEx(command, workingDir=newWorkingFolder)
+
+ echo "[CMD] " & cmdOutput
- echo "tessera " & $pkgName & "built."
+ echo "tessera " & $pkgName & " built."
when isMainModule:
`buildIdent`()
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.