aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authoraethrvmn <me@aethrvmn.gr>2025-10-08 00:22:35 +0000
committeraethrvmn <me@aethrvmn.gr>2025-10-08 00:22:35 +0000
commitfcc76bbc6d5f4b48f2df4adb9f052f5ec8698a36 (patch)
treeac0ed50b84e11d30f84b96d1a4b90c4f58895838 /src/core
parentstarted test via labwc (diff)
cleanup
Diffstat (limited to 'src/core')
-rw-r--r--src/core/locker.nim68
-rw-r--r--src/core/manager.nim7
2 files changed, 45 insertions, 30 deletions
diff --git a/src/core/locker.nim b/src/core/locker.nim
index d52b55d..f4e90e9 100644
--- a/src/core/locker.nim
+++ b/src/core/locker.nim
@@ -1,7 +1,6 @@
import std / [
os,
json,
- hashes,
strformat
]
@@ -31,6 +30,7 @@ proc writeLock*(jsonObject: JsonNode) =
proc updateLock*(
packageName: string,
sourceURL: string,
+ sourceDir: string,
chosenTag: string,
configPath: string
) =
@@ -40,6 +40,7 @@ proc updateLock*(
config: string = readConfigFile(configPath)
jsonObject: JsonNode = %*{
"source": { "url": sourceURL },
+ "sha256": computeSHA256(sourceDir, chosenTag)
"tag": chosenTag,
"config": config
# I should probably add a sha256 thingy
@@ -47,56 +48,65 @@ proc updateLock*(
lock[packageName] = jsonObject
writeLock(lock)
echo "Updated {packageName}".fmt
-
proc needRebuildLock*(
packageName: string,
sourceURL: string,
- chosenTag: string,
+ sourceDir: string,
+ chosenTag: string,
configPath: string
): bool =
## Checks whether the following have changed:\n
## - source (repo url)
+ ## - sha256
## - tag (new release, manually updated, etc)
+ ## - config file of package
result = false
let lockFile = loadLock()
+
if not lockFile.hasKey(packageName):
- echo "{packageName} added to queue"
- result = true
+ echo "{packageName} added to queue".fmt
+ return true
+
else:
let package = lockFile[packageName]
if not package.hasKey("source"):
echo "Could not find source for package {packageName}".fmt
- echo "{packageName} added to queue"
- result = true
-
- if package.hasKey("source") and package["source"].hasKey("url"):
+ echo "{packageName} added to queue".fmt
+ return true
+ if package["source"].hasKey("url"):
let packageSource: string = package["source"]["url"].getStr
if packageSource != sourceURL:
echo "Source URL for package {packageName} has changed".fmt
- echo "{packageName} added to queue"
- result = true
+ echo "{packageName} added to queue".fmt
+ return true
- if not package.hasKey("tag"):
- result = true
- else:
- if package["tag"].getStr != chosenTag:
- echo "Release tag has changed from {package["tag"]} -> {chosenTag}".fmt
- echo "{packageName} added to queue"
- result = true
- if not package.hasKey("config"):
- echo "Configuration file not found for package {packageName}".fmt
- echo "{packageName} added to queue"
- result = true
- else:
- let config: string = readConfigFile(configPath)
- if package["config"].getStr != config:
- echo "Configuration file changed for package {packageName}".fmt
- echo "{packageName} added to queue"
- result = true
+ if not package.hasKey("sha256"):
+ echo "sha256 not found for package {packageName}".fmt
+ echo "{packageName} added to queue".fmt
+ return true
+ if package["sha256"].getStr != computeSHA256(sourceDir, chosenTag):
+ echo "sha256 mismatch for package {packageName}".fmt
+ echo "{packageName} added to queue".fmt
+ return true
+ if not package.hasKey("tag"):
+ echo "Could not find release tag for package {packageName}".fmt
+ echo "{packageName} added to queue".fmt
+ return true
+ if package["tag"].getStr != chosenTag:
+ echo "Release tag has changed from {package["tag"]} -> {chosenTag}".fmt
+ echo "{packageName} added to queue".fmt
+ return true
-
+ if not package.hasKey("config"):
+ echo "Configuration file not found for package {packageName}".fmt
+ echo "{packageName} added to queue"
+ return true
+ if package["config"].getStr != readConfigFile(configPath):
+ echo "Configuration file changed for package {packageName}".fmt
+ echo "{packageName} added to queue".fmt
+ return true
diff --git a/src/core/manager.nim b/src/core/manager.nim
index 0453fa6..106c511 100644
--- a/src/core/manager.nim
+++ b/src/core/manager.nim
@@ -1,4 +1,9 @@
-import std / [ os, strformat, osproc ]
+import std / [
+ os,
+ osproc,
+ hashes,
+ strformat
+]
proc runCommand*(
command: string,
Directive (EU) 2019/790, Article 4(3); all rights regarding Text and Data Mining (TDM) are reserved.