From e54f239894b3dad60b68c1db021f519b596779c4 Mon Sep 17 00:00:00 2001 From: Kreato Date: Fri, 16 Dec 2022 22:52:44 +0300 Subject: [PATCH] add config support to install and upgrade --- TODO.md | 4 ---- src/nyaa.nim | 2 -- src/nyaa/install.nim | 7 +++++-- src/nyaa/modules/config.nim | 4 ++-- src/nyaa/upgrade.nim | 5 ++++- 5 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 TODO.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 4001fd72..00000000 --- a/TODO.md +++ /dev/null @@ -1,4 +0,0 @@ -# TODO -* upgrade doesnt comply to repo path -* install doesnt comply to repo path - diff --git a/src/nyaa.nim b/src/nyaa.nim index 6f45e7a4..015558f8 100644 --- a/src/nyaa.nim +++ b/src/nyaa.nim @@ -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", } ], @@ -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" diff --git a/src/nyaa/install.nim b/src/nyaa/install.nim index ad40085b..a5ab4535 100644 --- a/src/nyaa/install.nim +++ b/src/nyaa/install.nim @@ -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) @@ -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) @@ -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" diff --git a/src/nyaa/modules/config.nim b/src/nyaa/modules/config.nim index c29c4639..ab4ac3fd 100644 --- a/src/nyaa/modules/config.nim +++ b/src/nyaa/modules/config.nim @@ -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 diff --git a/src/nyaa/upgrade.nim b/src/nyaa/upgrade.nim index 43e84661..75dde741 100644 --- a/src/nyaa/upgrade.nim +++ b/src/nyaa/upgrade.nim @@ -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 = "" @@ -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))