-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import sequtils | ||
|
||
proc checkAll(repo: string, backend = "repology", autoUpdate = true, autoBuild = true, jsonPath = "chkupd.json") = | ||
## Checks all packages, and updates them automatically. | ||
var failedUpdPackages: seq[string] | ||
var failedBuildPackages: seq[string] | ||
var pkgCount: int | ||
|
||
case backend: | ||
of "repology": | ||
# this sounds stupid but i couldnt think of anything else lol | ||
var pkgFailed = true | ||
|
||
for i in toSeq(walkDirs(repo&"/*")): | ||
|
||
if i == ".git" or i == ".github": | ||
continue | ||
|
||
echo "trying to update "&i | ||
try: | ||
repologyCheck(package = i, repo = repo, autoUpdate = autoUpdate, skipIfDownloadFails = false) | ||
pkgFailed = false | ||
echo "updating "&i&" successful" | ||
except CatchableError: | ||
failedUpdPackages = failedUpdPackages&i | ||
echo "couldnt update "&i | ||
|
||
if not pkgFailed and autoBuild: | ||
echo "docker run -v ./"&repo&":/etc/kpkg/repos/main -it ghcr.io/kreatolinux/builder:latest kpkg build "&lastPathPart(i) | ||
if execShellCmd("docker run -v "&repo&":/etc/kpkg/repos/main -v /var/cache/kpkg/archives:/var/cache/kpkg/archives -it ghcr.io/kreatolinux/builder:latest kpkg build -u -y "&lastPathPart(i)) != 0: | ||
failedBuildPackages = failedBuildPackages&i | ||
echo "couldnt build "&i | ||
else: | ||
echo "Not supported" | ||
|
||
var json = %* | ||
[ | ||
{ | ||
"successfulPkgCount": pkgCount, | ||
"failedPkgCount": failedBuildPackages.len+failedUpdPackages.len, | ||
"failedBuildPackages": failedBuildPackages, | ||
"failedUpdPackages": failedUpdPackages | ||
} | ||
] | ||
|
||
writeFile(jsonPath, $json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters