From 955819a9895ea6007510de307d7568675df104f1 Mon Sep 17 00:00:00 2001 From: sharpcdf Date: Sun, 7 Aug 2022 17:22:53 -0400 Subject: [PATCH] add self update and add executable perms to binaries --- config.nims | 2 +- jitter.nim | 26 ++++++++++++++++++-------- jitter.nimble | 2 +- jitter/extract.nim | 4 +++- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/config.nims b/config.nims index d36fd06..3d85a53 100644 --- a/config.nims +++ b/config.nims @@ -1,7 +1,7 @@ import os var mainfile = "jitter.nim" -var version = "0.2.5" +var version = "0.4.2-dev" var nimble = getHomeDir() & ".nimble/pkgs" diff --git a/jitter.nim b/jitter.nim index b849d9e..406bcdd 100644 --- a/jitter.nim +++ b/jitter.nim @@ -142,13 +142,23 @@ proc remove(input: string) = pkg.remove() success "Done" - -proc update(input: string, make = true) = - let input = - if input.toLowerAscii() in ["this", "jtr", "jitter"]: - "sharpcdf/jitter" - else: - input +proc selfUpdate() = + ghDownload("sharpcdf/jitter", true) + var downloaded = false + var pkg: string + for p in getInstalledPkgs(): + if p.owner == "sharpcdf" and p.repo == "jitter": + downloaded = true + pkg = p.pkgFormat() + break + if not downloaded: + fatal "Failed to update Jitter to latest version" + copyFile(nerveDir / pkg, getAppDir() / getAppFilename()) + success "Successfully updated Jitter to the latest version!" +proc update(input: string, make = true) = + if input.toLowerAscii() in ["this", "jtr", "jitter"]: + selfUpdate() + return if input.toLowerAscii() == "all": for pkg in getInstalledPkgs(): pkg.remove() @@ -187,7 +197,7 @@ const parser = newParser: run: opts.input.install(not opts.parentOpts.nomake) command("update"): ## Create an update command - help("Updates the specified packages, or all packages if none are specified. user/repo[@tag]") ## Help message + help("Updates the specified package, Jitter itself, or all packages if specified. [user/repo[@tag]][all][this|jitter|jtr]") ## Help message arg("input") ## Positional argument called input run: opts.input.update(not opts.parentOpts.nomake) diff --git a/jitter.nimble b/jitter.nimble index c581b93..3167aec 100644 --- a/jitter.nimble +++ b/jitter.nimble @@ -1,6 +1,6 @@ # Package -version = "0.3.0" +version = "0.4.0" author = "sharpcdf" description = "A git-based binary manager for linux." license = "MIT" diff --git a/jitter/extract.nim b/jitter/extract.nim index aed76d3..de20c7d 100644 --- a/jitter/extract.nim +++ b/jitter/extract.nim @@ -39,9 +39,11 @@ 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.hasExecPerms() and not symlinkExists(binDir / file.splitFile().name): + if not symlinkExists(binDir / file.splitFile().name): case file.splitFile().ext: of "": + if not file.hasExecPerms(): + file.setFilePermissions({fpUserExec, fpOthersExec}) file.createSymlink(binDir / file.splitFile().name) success fmt"Created symlink {file.splitFile().name}" of ".AppImage":