nkiss

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nkiss
Log | Files | Refs

commit dcbadc5504795b1249a1a181f0eed800309b1227
parent 90d9b38b296c350ce27091f2cf8c5ccade02c3cc
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Thu, 18 Feb 2021 18:29:58 -0600

kiss.c: add kiss_download_names

This downloads sources for a list of packages

Diffstat:
Mkiss.c | 28++++++++++++++++++++++++++++
1 file changed, 28 insertions(+), 0 deletions(-)

diff --git a/kiss.c b/kiss.c @@ -1,3 +1,5 @@ +#define _BSD_SOURCE + #include <dirent.h> #include <fnmatch.h> #include <stdlib.h> @@ -10,6 +12,27 @@ char *argv0; void +kiss_download_names(char *kiss_path, char *names[], int len) +{ + char *repo, path[strlen(kiss_path)]; + + memccpy(path, kiss_path, '\0', strlen(kiss_path)); + + if ((repo = strtok(path, ":")) == NULL) + die("Invalid KISS_PATH."); + + /* iterate through KISS_PATH */ + do { + path[0] = '\0'; + for (int i = 0; i < len; i++) { + if (pkg_exists(repo, names[i], path)) { + pkg_download(repo, names[i]); + } + } + } while ((repo = strtok(NULL, ":")) != NULL); +} + +void kiss_list_all() { DIR *db; @@ -118,6 +141,11 @@ int main(int argc, char *argv[]) goto end; } + if (strcmp(argv[1], "download") == 0 && argc > 2) { + kiss_download_names(kiss_path, &argv[2], argc-2); + goto end; + } + end: return 0; }