From 1275f77dd7d2ea6452a29520d93b2fafea38dd40 Mon Sep 17 00:00:00 2001 From: sharpcdf Date: Thu, 15 Sep 2022 20:49:00 -0400 Subject: [PATCH] screaming --- jitter/extract.nim | 10 ++++------ jitter/github.nim | 9 +++++---- jitter/parse.nim | 10 ++++++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/jitter/extract.nim b/jitter/extract.nim index 0804391..8f66059 100644 --- a/jitter/extract.nim +++ b/jitter/extract.nim @@ -60,18 +60,16 @@ proc extract*(pkg: Package, path, toDir: string, make = true) = #Creates symlinks for executables and adds them to the bin for file in walkDirRec(nerveDir / toDir): - if file.splitFile().name == "odin": - echo file if not symlinkExists(binDir / file.splitFile().name): case file.splitFile().ext: of "": if not file.hasExecPerms() and file.splitFile().name.isExecFile(): file.setFilePermissions({fpUserExec, fpOthersExec, fpUserRead, fpUserWrite, fpOthersRead, fpOthersWrite}) if file.hasExecPerms() and file.splitFile().name.isExecFile(): - if not duplicate: - file.createSymlink(binDir / file.splitFile().name) - else: - file.createSymlink(binDir / fmt"{file.splitFile().name}-{pkg.tag}") + #if not duplicate: + file.createSymlink(binDir / file.splitFile().name) + #else: + # file.createSymlink(binDir / fmt"{file.splitFile().name}-{pkg.tag}") success fmt"Created symlink {file.splitFile().name}" of ".AppImage": file.createSymlink(binDir / pkg.repo) diff --git a/jitter/github.nim b/jitter/github.nim index 70b4bdb..a164ea8 100644 --- a/jitter/github.nim +++ b/jitter/github.nim @@ -89,7 +89,7 @@ proc downloadRelease(pkg: Package, make = true) = if name.isCompatibleExt() and name.isCompatibleCPU() and name.isCompatibleOS(): downloadUrl = asset["browser_download_url"].getStr() downloadPath = name - + #TODO: fix download proceeding despite 'no' response success fmt"Archive found: {name}" ask "Are you sure you want to download this archive? There might be other compatible assets. [Y/n]" var answer = stdin.readLine().strip() @@ -101,12 +101,13 @@ proc downloadRelease(pkg: Package, make = true) = if downloadUrl.len == 0: fatal fmt"No archives found for {pkg.gitFormat()}" - + for f in walkDir(nerveDir): + if f.path.splitFile().name == pkg.pkgFormat(): + fatal "Repository is already installed, exiting" info fmt"Downloading {downloadUrl}" #downloadPath should be ~/.jitter/nerve/repo-release.tar.gz or similar client.downloadFile(downloadUrl, nerveDir / downloadPath) - success fmt"Downloaded {pkg.gitFormat()}" - + success fmt"Downloaded {pkg.gitFormat}" pkg.extract(nerveDir / downloadPath, pkg.pkgFormat(), make) proc ghDownload*(pkg: Package, make = true) = diff --git a/jitter/parse.nim b/jitter/parse.nim index 0249e9c..d7a7149 100644 --- a/jitter/parse.nim +++ b/jitter/parse.nim @@ -54,10 +54,16 @@ proc isCompatibleOS*(file: string): bool = return false proc isExecFile*(file:string): bool = - return file.startsWith(".") or file.toLowerAscii() == "makefile" or "license" in file.toLowerAscii() + if file.startsWith(".") or file.toLowerAscii() == "makefile" or "license" in file.toLowerAscii(): + return false + else: + return true proc hasExecPerms*(file: string): bool = let perms = getFilePermissions(file) - return fpUserExec in perms or fpGroupExec in perms or fpOthersExec in perms + if fpUserExec in perms or fpGroupExec in perms or fpOthersExec in perms: + return true + else: + return false proc validIdent(input: string, strVal: var string, start: int, validChars = IdentChars + {'.', '-'}): int = while start + result < input.len and input[start + result] in validChars: