Skip to content

Commit

Permalink
add config support to install and upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreato committed Dec 16, 2022
1 parent 80a0f8f commit e54f239
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

2 changes: 0 additions & 2 deletions src/nyaa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ dispatchMulti(
"root": "The directory the package is gonna be installed to",
"yes": "Automatically say 'yes' to every question",
"no": "Automatically say 'no' to every question",
"repo": "The nyaa binary repository",
"binrepo": "The nyaa binary mirror",
}
],
Expand All @@ -75,7 +74,6 @@ dispatchMulti(

[
upgrade, help = {
"repo": "Set nyaa repository",
"root": "The directory the packages are gonna be upgraded on",
"builddir": "Set a custom build directory",
"srcdir": "Set a custom source directory"
Expand Down
7 changes: 5 additions & 2 deletions src/nyaa/install.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ proc install_pkg(repo: string, package: string, root: string, binary = false) =
"tar -xvf"&tarball&" -C "&root))

proc install(packages: seq[string], root = "/", yes = false, no = false,
binrepo = "mirror.kreato.dev", repo = "/etc/nyaa-bin"): string =
binrepo = "mirror.kreato.dev"): string =
## Download and install a package through a binary repository
if packages.len == 0:
err("please enter a package name", false)
Expand All @@ -42,8 +42,10 @@ proc install(packages: seq[string], root = "/", yes = false, no = false,

var deps: seq[string]
var res: string

var repo: string

for i in packages:
repo = findPkgRepo(i&"-bin")
if not dirExists(repo&"/"&i&"-bin"):
err("package `"&i&"` does not exist", false)

Expand All @@ -63,6 +65,7 @@ proc install(packages: seq[string], root = "/", yes = false, no = false,
return "nyaa: exiting"

for i in packages:
repo = findPkgRepo(i&"-bin")
parse_runfile(repo&"/"&i&"-bin")
discard existsOrCreateDir("/etc/nyaa.tarballs")
let tarball = "nyaa-tarball-"&i&"-"&version&"-"&release&".tar.gz"
Expand Down
4 changes: 2 additions & 2 deletions src/nyaa/modules/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ proc initializeConfig(configpath = "/etc/nyaa.conf") =
dict.setSectionKey("Options", "cc", "gcc") # GCC works the best right now

# [Repositories]
dict.setSectionKey("Repositories", "RepoDirs", "/etc/nyaa") # Seperate by space
dict.setSectionKey("Repositories", "RepoDirs", "/etc/nyaa /etc/nyaa-bin") # Seperate by space
dict.setSectionKey("Repositories", "RepoLinks",
"https://github.com/kreatolinux/nyaa-repo.git") # Seperate by space, must match RepoDirs
"https://github.com/kreatolinux/nyaa-repo.git https://github.com/kreatolinux/nyaa-repo-bin.git") # Seperate by space, must match RepoDirs

# [Upgrade]
dict.setSectionKey("Upgrade", "buildByDefault", "yes") # Build packages by default
Expand Down
5 changes: 4 additions & 1 deletion src/nyaa/upgrade.nim
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
include modules/removeInternal

proc upgrade(repo = "/etc/nyaa", root = "/",
proc upgrade(root = "/",
builddir = "/tmp/nyaa_build", srcdir = "/tmp/nyaa_srcdir"): string =
## Upgrade packages
var repo: string
for i in walkDir("/etc/nyaa.installed"):
if i.kind == pcDir:
let epoch = ""
Expand All @@ -15,6 +16,8 @@ proc upgrade(repo = "/etc/nyaa", root = "/",
let release_local = release
when declared(epoch):
let epoch_local = epoch

repo = findPkgRepo(lastPathPart(i.path))

parse_runfile(repo&"/"&lastPathPart(i.path))

Expand Down

0 comments on commit e54f239

Please sign in to comment.