diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-06-28 05:56:56 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-06-28 05:56:56 +0000 |
| commit | 64e61e9b5de7546dc3bcbca577a029629774e108 (patch) | |
| tree | 846bf2bf5f1dbfdd00e6f841454d6ed748770671 | |
| parent | 0cc8a1c0faa2743acc6bc38ee8a0c6e2af4f64b1 (diff) | |
fixed --quiet without a matching quiet target edgecase
| -rw-r--r-- | src/create_pkg.c | 187 | ||||
| -rw-r--r-- | src/declare.c | 12 | ||||
| -rw-r--r-- | src/fetch_git.c | 69 | ||||
| -rw-r--r-- | src/fetch_pwd.c | 63 | ||||
| -rw-r--r-- | src/fetch_src.c | 74 | ||||
| -rw-r--r-- | src/help.c | 58 | ||||
| -rw-r--r-- | src/install_pkg.c | 166 | ||||
| -rw-r--r-- | src/lua_state.c | 6 |
8 files changed, 329 insertions, 306 deletions
diff --git a/src/create_pkg.c b/src/create_pkg.c index 8221233..12b6a63 100644 --- a/src/create_pkg.c +++ b/src/create_pkg.c @@ -29,114 +29,115 @@ #include "vars.h" bool is_in_repos(char *arg) { - for (size_t i = 0; i < cached_repos_count; i++) - if (strcmp(arg, cached_repos[i].source_key) == 0) return true; - return false; + for (size_t i = 0; i < cached_repos_count; i++) + if (strcmp(arg, cached_repos[i].source_key) == 0) + return true; + return false; } Pkg pkg_from_repo(char* arg) { - Pkg pkg = {0}; - for (size_t i = 0; i < cached_repos_count; i++) { - if (strcmp(arg, cached_repos[i].source_key) == 0) { - pkg.url = strdup(cached_repos[i].source_value); - break; - } - } - pkg.name = arg; - return pkg; + Pkg pkg = {0}; + for (size_t i = 0; i < cached_repos_count; i++) { + if (strcmp(arg, cached_repos[i].source_key) == 0) { + pkg.url = strdup(cached_repos[i].source_value); + break; + } + } + pkg.name = arg; + return pkg; } char* get_destdir(char* cwd, char* arg) { - char dest_dir[MAX_PATH_LEN]; - if (arg[0] == '.') { - snprintf(dest_dir, sizeof(dest_dir), "%s/%s", - get_install_dir("src"), name_from_url(cwd)); - } else { - snprintf(dest_dir, sizeof(dest_dir), "%s/%s", - get_install_dir("src"), arg); - } - return strdup(dest_dir); + char dest_dir[MAX_PATH_LEN]; + if (arg[0] == '.') { + snprintf(dest_dir, sizeof(dest_dir), "%s/%s", + get_install_dir("src"), name_from_url(cwd)); + } else { + snprintf(dest_dir, sizeof(dest_dir), "%s/%s", + get_install_dir("src"), arg); + } + return strdup(dest_dir); } void rmdotgit(Pkg pkg) { - if (strlen(pkg.name) > 4 && - strncmp(pkg.name + strlen(pkg.name) - 4, ".git", 4) == 0) - pkg.name[strlen(pkg.name) - 4] = '\0'; + if ( + strlen(pkg.name) > 4 && + strncmp(pkg.name + strlen(pkg.name) - 4, ".git", 4) == 0 + ) pkg.name[strlen(pkg.name) - 4] = '\0'; } char* get_pkgsrc(Pkg pkg) { - char src_dir[MAX_PATH_LEN]; - if (pkg.is_local) { - snprintf(src_dir, sizeof(src_dir), "%s/%s", - get_install_dir("src"), pkg.name); - } else { - snprintf(src_dir, sizeof(src_dir), "%s/%s/%s", - get_install_dir("src"), pkg.name, pkg.ver); - } - return strdup(src_dir); + char src_dir[MAX_PATH_LEN]; + if (pkg.is_local) { + snprintf(src_dir, sizeof(src_dir), "%s/%s", + get_install_dir("src"), pkg.name); + } else { + snprintf(src_dir, sizeof(src_dir), "%s/%s/%s", + get_install_dir("src"), pkg.name, pkg.ver); + } + return strdup(src_dir); } Pkg create_pkg(const char *arg) { - Pkg pkg = {0}; - pkg.ver = "HEAD"; - pkg.is_local = false; + Pkg pkg = {0}; + pkg.ver = "HEAD"; + pkg.is_local = false; char cwd[MAX_PATH_LEN]; getcwd(cwd, MAX_PATH_LEN); - char *new_arg = strdup(arg); - if (!new_arg) exit(EXIT_FAILURE); - char* dest_dir = get_destdir(cwd, new_arg); - bool is_installed_locally = false; - if (is_directory(dest_dir)) is_installed_locally = true; - - char *verptr = strchr(new_arg, '@'); - char *trgptr = strchr(new_arg, ','); - for (size_t i = 0; i < cached_repos_count; i++) { - if (strcmp(cached_repos[i].source_key, new_arg) != 0) continue; - pkg.ver = cached_repos[i].version; - } - if (verptr) { - pkg.ver = verptr + 1; - *verptr = '\0'; - } - if (trgptr) { - pkg.target = trgptr + 1; - *trgptr = '\0'; - } else { - pkg.target = is_verbose ? "default" : "quiet"; - } - - bool is_in_repos = false; - for (size_t i = 0; i < cached_repos_count; i++) { - if (strcmp(new_arg, cached_repos[i].source_key) == 0) { - is_in_repos = true; - break; - } - } - - if (strncmp(new_arg, "http", 4) == 0 || strncmp(new_arg, "ssh", 3) == 0) { - pkg.url = strdup(new_arg); - pkg.name = name_from_url(new_arg); - } else if (strcmp(new_arg, ".") == 0) { - pkg.url = ""; - pkg.name = name_from_url(cwd); - pkg.is_local = true; - } else if (is_in_repos) { - for (size_t i = 0; i < cached_repos_count; i++) { - if (strcmp(new_arg, cached_repos[i].source_key) == 0) { - pkg.url = strdup(cached_repos[i].source_value); - break; - } - } - pkg.name = new_arg; - } else if (is_installed_locally) { - pkg.url = ""; - pkg.name = name_from_url(dest_dir); - pkg.is_local = true; - } else { - printf("%s '%s' is not a valid package\n", print_error, new_arg); - exit(EXIT_FAILURE); - } - rmdotgit(pkg); - snprintf(pkg.src, MAX_PATH_LEN, "%s", get_pkgsrc(pkg)); - return pkg; + char *new_arg = strdup(arg); + if (!new_arg) exit(EXIT_FAILURE); + char* dest_dir = get_destdir(cwd, new_arg); + bool is_installed_locally = is_directory(dest_dir); + + char *verptr = strchr(new_arg, '@'); + char *trgptr = strchr(new_arg, ','); + for (size_t i = 0; i < cached_repos_count; i++) { + if (strcmp(cached_repos[i].source_key, new_arg) != 0) continue; + pkg.ver = cached_repos[i].version; + } + if (verptr) { + pkg.ver = verptr + 1; + *verptr = '\0'; + } + if (trgptr) { + pkg.target = trgptr + 1; + *trgptr = '\0'; + } else { + pkg.target = is_verbose ? "default" : "quiet"; + } + + bool is_in_repos = false; + for (size_t i = 0; i < cached_repos_count; i++) { + if (strcmp(new_arg, cached_repos[i].source_key) == 0) { + is_in_repos = true; + break; + } + } + + if (strncmp(new_arg, "http", 4) == 0 || strncmp(new_arg, "ssh", 3) == 0) { + pkg.url = strdup(new_arg); + pkg.name = name_from_url(new_arg); + } else if (strcmp(new_arg, ".") == 0) { + pkg.url = ""; + pkg.name = name_from_url(cwd); + pkg.is_local = true; + } else if (is_in_repos) { + for (size_t i = 0; i < cached_repos_count; i++) { + if (strcmp(new_arg, cached_repos[i].source_key) == 0) { + pkg.url = strdup(cached_repos[i].source_value); + break; + } + } + pkg.name = new_arg; + } else if (is_installed_locally) { + pkg.url = ""; + pkg.name = name_from_url(dest_dir); + pkg.is_local = true; + } else { + printf("%s '%s' is not a valid package\n", print_error, new_arg); + exit(EXIT_FAILURE); + } + rmdotgit(pkg); + snprintf(pkg.src, MAX_PATH_LEN, "%s", get_pkgsrc(pkg)); + return pkg; }
\ No newline at end of file diff --git a/src/declare.c b/src/declare.c index 4974c22..2841cf9 100644 --- a/src/declare.c +++ b/src/declare.c @@ -28,10 +28,10 @@ #include "lua_state.h" void declare(void) { - init_lua_state(); - cache_repos(); - for (size_t i = 0; i < cached_repos_count; i++) { - Pkg pkg = create_pkg(cached_repos[i].source_value); - update_pkg(pkg); - } + init_lua_state(); + cache_repos(); + for (size_t i = 0; i < cached_repos_count; i++) { + Pkg pkg = create_pkg(cached_repos[i].source_value); + update_pkg(pkg); + } } diff --git a/src/fetch_git.c b/src/fetch_git.c index 7116e9e..3184cca 100644 --- a/src/fetch_git.c +++ b/src/fetch_git.c @@ -28,40 +28,41 @@ #include "vars.h" int fetch_git(Pkg pkg) { - pid_t pid = fork(); - if (pid == 0) { - if (!is_verbose) { - int nullfd = open("/dev/null", O_WRONLY); - if (nullfd >= 0) { - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); - close(nullfd); - } - } - const char *argv[10]; - int i = 0; - argv[i++] = "git"; - argv[i++] = "-c"; - argv[i++] = "advice.detachedHead=false"; - argv[i++] = "clone"; - if (strcmp(pkg.ver, "HEAD") != 0) { - argv[i++] = "--branch"; - argv[i++] = pkg.ver; - } - argv[i++] = "--recursive"; - argv[i++] = pkg.url; - argv[i++] = pkg.src; - argv[i] = NULL; - execvp("git", (char *const *)argv); - _exit(127); - } + pid_t pid = fork(); + if (pid == 0) { + if (!is_verbose) { + int nullfd = open("/dev/null", O_WRONLY); + if (nullfd >= 0) { + dup2(nullfd, STDOUT_FILENO); + dup2(nullfd, STDERR_FILENO); + close(nullfd); + } + } + const char *argv[10]; + int i = 0; + argv[i++] = "git"; + argv[i++] = "-c"; + argv[i++] = "advice.detachedHead=false"; + argv[i++] = "clone"; + if (strcmp(pkg.ver, "HEAD") != 0) { + argv[i++] = "--branch"; + argv[i++] = pkg.ver; + } + argv[i++] = "--recursive"; + argv[i++] = pkg.url; + argv[i++] = pkg.src; + argv[i] = NULL; + execvp("git", (char *const *)argv); + _exit(127); + } - int status; - waitpid(pid, &status, 0); - int result = WIFEXITED(status) ? WEXITSTATUS(status) : -1; - if (result != 0) { - printf("%s git clone failed: %d\n", print_warning, result); - } + int status; + waitpid(pid, &status, 0); + int result = WIFEXITED(status) ? WEXITSTATUS(status) : -1; + if (result != 0) printf( + "%s git clone failed: %d\n", + print_warning, result + ); - return result; + return result; }
\ No newline at end of file diff --git a/src/fetch_pwd.c b/src/fetch_pwd.c index e04bb31..32edd79 100644 --- a/src/fetch_pwd.c +++ b/src/fetch_pwd.c @@ -29,42 +29,45 @@ static const char *pwd_dst; -static int copy_entry(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) { - (void)ftwbuf; - const char *rel = fpath; - if (rel[0] == '.' && rel[1] == '/') rel += 2; - if (rel[0] == '\0') return 0; +static int copy_entry( + const char *fpath, const struct stat *sb, + int typeflag, struct FTW *ftwbuf +) { + (void)ftwbuf; + const char *rel = fpath; + if (rel[0] == '.' && rel[1] == '/') rel += 2; + if (rel[0] == '\0') return 0; - char dst[MAX_PATH_LEN]; - snprintf(dst, sizeof(dst), "%s/%s", pwd_dst, rel); + char dst[MAX_PATH_LEN]; + snprintf(dst, sizeof(dst), "%s/%s", pwd_dst, rel); - if (typeflag == FTW_D) { - mkdir(dst, 0755); - } else if (typeflag == FTW_F) { - int src_fd = open(fpath, O_RDONLY); - if (src_fd < 0) return -1; + if (typeflag == FTW_D) { + mkdir(dst, 0755); + } else if (typeflag == FTW_F) { + int src_fd = open(fpath, O_RDONLY); + if (src_fd < 0) return -1; - int dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, sb->st_mode & 07777); - if (dst_fd < 0) { close(src_fd); return -1; } + int dst_fd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, sb->st_mode & 07777); + if (dst_fd < 0) { close(src_fd); return -1; } - char buf[8192]; - ssize_t n; - while ((n = read(src_fd, buf, sizeof(buf))) > 0) { - ssize_t written = 0; - while (written < n) { - ssize_t ret = write(dst_fd, buf + written, n - written); - if (ret < 0) { close(src_fd); close(dst_fd); return -1; } - written += ret; - } - } + char buf[8192]; + ssize_t n; + while ((n = read(src_fd, buf, sizeof(buf))) > 0) { + ssize_t written = 0; + while (written < n) { + ssize_t ret = write(dst_fd, buf + written, n - written); + if (ret < 0) { close(src_fd); close(dst_fd); return -1; } + written += ret; + } + } - close(src_fd); - close(dst_fd); - } - return 0; + close(src_fd); + close(dst_fd); + } + return 0; } void fetch_pwd(Pkg pkg) { - pwd_dst = pkg.src; - nftw(".", copy_entry, 64, FTW_PHYS); + pwd_dst = pkg.src; + nftw(".", copy_entry, 64, FTW_PHYS); }
\ No newline at end of file diff --git a/src/fetch_src.c b/src/fetch_src.c index d3698db..69b1ec9 100644 --- a/src/fetch_src.c +++ b/src/fetch_src.c @@ -30,39 +30,51 @@ #include "vars.h" static int remove_tree( - const char *fpath, const struct stat *sb, - int typeflag, struct FTW *ftwbuf + const char *fpath, const struct stat *sb, + int typeflag, struct FTW *ftwbuf ) { - (void)sb; - (void)ftwbuf; - if (typeflag == FTW_F || typeflag == FTW_SL) { - unlink(fpath); - } else if (typeflag == FTW_DP) { - rmdir(fpath); - } - return 0; + (void)sb; + (void)ftwbuf; + if (typeflag == FTW_F || typeflag == FTW_SL) { + unlink(fpath); + } else if (typeflag == FTW_DP) { + rmdir(fpath); + } + return 0; } void fetch_src(Pkg pkg) { - if (is_verbose) - printf("%s target source directory: %s\n", print_pkgit, pkg.src); - if (file_exists(pkg.src)) { - if (is_verbose) - printf("%s %s already exists. deleting...\n", print_pkgit, pkg.src); - chdir(".."); - nftw(pkg.src, remove_tree, 64, FTW_DEPTH | FTW_PHYS); - } - if (strcmp(pkg.url, "") == 0) { - if (is_verbose) - printf("%s creating directory %s...\n", print_pkgit, pkg.src); - mkdir_p(pkg.src); - return; - } - if (fetch_git(pkg) == 0) { - if (is_verbose) - printf("%s cloned into %s\n", print_pkgit, pkg.src); - return; - } - printf("%s no fetch methods worked.\n", print_error); - exit(EXIT_FAILURE); + if (is_verbose) + printf( + "%s target source directory: %s\n", + print_pkgit, pkg.src + ); + if (file_exists(pkg.src)) { + if (is_verbose) printf( + "%s %s already exists. deleting...\n", + print_pkgit, pkg.src + ); + chdir(".."); + nftw(pkg.src, remove_tree, 64, FTW_DEPTH | FTW_PHYS); + } + if (strcmp(pkg.url, "") == 0) { + if (is_verbose) printf( + "%s creating directory %s...\n", + print_pkgit, pkg.src + ); + mkdir_p(pkg.src); + return; + } + if (fetch_git(pkg) == 0) { + if (is_verbose) printf( + "%s cloned into %s\n", + print_pkgit, pkg.src + ); + return; + } + printf( + "%s no fetch methods worked.\n", + print_error + ); + exit(EXIT_FAILURE); }
\ No newline at end of file @@ -24,33 +24,33 @@ #include "vars.h" void help(void) { - if (is_verbose) { - printf("%s , \n", bold_magenta); - printf("%s / \\ \n", bold_magenta); - printf("%s_.--' '--._ \n", bold_magenta); - printf("%s`'--, ,--'` %spkgit %s%s- package it!%s\n", bold_magenta, color_reset, italic, gray, color_reset); - printf("%s _- %s\\ /%s -_ %s%s%s\n", bold_yellow, bold_magenta, bold_yellow, magenta, version, color_reset); - printf("%s'-_ %s'%s _-' \n", bold_yellow, bold_magenta, bold_yellow); - printf("%s `'-.-'` %s\n", bold_yellow, color_reset); - } else { - printf("pkgit %s%s- package it!%s\n", italic, gray, color_reset); - printf("%s%s%s\n", magenta, version, color_reset); - } - printf("\n"); - printf("%ssubcommand flags%s:\n", red, color_reset); - printf("%s %s-a%s, %s--add %s[url] %s# add a repo\n", color_reset, green, color_reset, yellow, blue, gray); - printf("%s %s-b%s, %s--build %s[path] %s# build a package\n", color_reset, green, color_reset, yellow, blue, gray); - printf("%s %s-d%s, %s--declare %s# install all packages\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-s%s, %s--search %s[pkgs] %s# find a package from your repos\n", color_reset, green, color_reset, yellow, blue, gray); - printf("%s %s-i%s, %s--install %s[pkgs, urls] %s# install a package/repo\n", color_reset, green, color_reset, yellow, blue, gray); - printf("%s %s-r%s, %s--remove %s[pkgs] %s# remove an installed package\n", color_reset, green, color_reset, yellow, blue, gray); - printf("%s %s-l%s, %s--list %s# list all installed packages\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-u%s, %s--update %s# update all installed packages\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-h%s, %s--help %s# display this help message\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-v%s, %s--version %s# display version number\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-c%s, %s--check %s# run package checks\n", color_reset, green, color_reset, yellow, gray); - printf("\n"); - printf("%smodifier flags%s:\n", red, color_reset); - printf("%s %s-q%s, %s--quiet %s# run without logging to terminal\n", color_reset, green, color_reset, yellow, gray); - printf("%s %s-f%s, %s--force %s# force an operation like 'install'\n", color_reset, green, color_reset, yellow, gray); + if (is_verbose) { + printf("%s , \n", bold_magenta); + printf("%s / \\ \n", bold_magenta); + printf("%s_.--' '--._ \n", bold_magenta); + printf("%s`'--, ,--'` %spkgit %s%s- package it!%s\n", bold_magenta, color_reset, italic, gray, color_reset); + printf("%s _- %s\\ /%s -_ %s%s%s\n", bold_yellow, bold_magenta, bold_yellow, magenta, version, color_reset); + printf("%s'-_ %s'%s _-' \n", bold_yellow, bold_magenta, bold_yellow); + printf("%s `'-.-'` %s\n", bold_yellow, color_reset); + } else { + printf("pkgit %s%s- package it!%s\n", italic, gray, color_reset); + printf("%s%s%s\n", magenta, version, color_reset); + } + printf("\n"); + printf("%ssubcommand flags%s:\n", red, color_reset); + printf("%s %s-a%s, %s--add %s[url] %s# add a repo\n", color_reset, green, color_reset, yellow, blue, gray); + printf("%s %s-b%s, %s--build %s[path] %s# build a package\n", color_reset, green, color_reset, yellow, blue, gray); + printf("%s %s-d%s, %s--declare %s# install all packages\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-s%s, %s--search %s[pkgs] %s# find a package from your repos\n", color_reset, green, color_reset, yellow, blue, gray); + printf("%s %s-i%s, %s--install %s[pkgs, urls] %s# install a package/repo\n", color_reset, green, color_reset, yellow, blue, gray); + printf("%s %s-r%s, %s--remove %s[pkgs] %s# remove an installed package\n", color_reset, green, color_reset, yellow, blue, gray); + printf("%s %s-l%s, %s--list %s# list all installed packages\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-u%s, %s--update %s# update all installed packages\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-h%s, %s--help %s# display this help message\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-v%s, %s--version %s# display version number\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-c%s, %s--check %s# run package checks\n", color_reset, green, color_reset, yellow, gray); + printf("\n"); + printf("%smodifier flags%s:\n", red, color_reset); + printf("%s %s-q%s, %s--quiet %s# run without logging to terminal\n", color_reset, green, color_reset, yellow, gray); + printf("%s %s-f%s, %s--force %s# force an operation like 'install'\n", color_reset, green, color_reset, yellow, gray); } diff --git a/src/install_pkg.c b/src/install_pkg.c index 80c6fd9..c233976 100644 --- a/src/install_pkg.c +++ b/src/install_pkg.c @@ -33,94 +33,94 @@ #include "vars.h" void install_pkg(Pkg pkg) { - if (is_directory(pkg.src)) { - if (!is_forced) { - if (is_verbose) printf( - "%s %s is already installed.\n", - print_skipped, pkg.name - ); - return; - } else { - if (is_verbose) printf( - "%s %s is already installed.\n", - print_warning, pkg.name - ); - } - } - char cwd[MAX_PATH_LEN]; - getcwd(cwd, MAX_PATH_LEN); - if (strcmp(pkg.src, cwd) != 0) chdir(pkg.src); + if (is_directory(pkg.src)) { + if (!is_forced) { + if (is_verbose) printf( + "%s %s is already installed.\n", + print_skipped, pkg.name + ); + return; + } else { + if (is_verbose) printf( + "%s %s is already installed.\n", + print_warning, pkg.name + ); + } + } + char cwd[MAX_PATH_LEN]; + getcwd(cwd, MAX_PATH_LEN); + if (strcmp(pkg.src, cwd) != 0) chdir(pkg.src); if (pkg.is_local) { - cpdir(cwd, pkg.src); + cpdir(cwd, pkg.src); } else { - printf( - "%s fetching %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - fetch_src(pkg); - if (is_verbose) - printf( - "%s fetched %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - } + printf( + "%s fetching %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + fetch_src(pkg); + if (is_verbose) printf( + "%s fetched %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + } - printf( - "%s building %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - build(pkg); - if (is_verbose) - printf( - "%s built %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); + printf( + "%s building %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + build(pkg); + if (is_verbose) printf( + "%s built %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); - printf( - "%s installing %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - bool install_success = false; - if (!install_success && repo_install(pkg.name, pkg.target)) - install_success = true; - if (!install_success && bldit_install(pkg.target)) - install_success = true; - if (!install_success && config_install(pkg.src, pkg.target)) - install_success = true; - if (!install_success) { - printf( - "%s no install function availible for package: %s\n", - print_error, pkg.name - ); - return; - } - printf( - "%s installed %s%s%s\n", - print_success, green, pkg.name, color_reset - ); + printf( + "%s installing %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + bool install_success = false; + if (!install_success && repo_install(pkg.name, pkg.target)) + install_success = true; + if (!install_success && bldit_install(pkg.target)) + install_success = true; + if (!install_success && config_install(pkg.src, pkg.target)) + install_success = true; + if (!install_success) { + printf( + "%s no install function availible for package: %s\n", + print_error, pkg.name + ); + return; + } + printf( + "%s installed %s%s%s\n", + print_success, green, pkg.name, color_reset + ); - bool repo_exists = false; - for (size_t i = 0; i < cached_repos_count; i++) { - char *repo_name = name_from_url(cached_repos[i].source_key); - if (strcmp(repo_name, pkg.name) == 0) { repo_exists = true; } - free(repo_name); - } + bool repo_exists = false; + for (size_t i = 0; i < cached_repos_count; i++) { + char *repo_name = name_from_url(cached_repos[i].source_key); + if (strcmp(repo_name, pkg.name) == 0) { repo_exists = true; } + free(repo_name); + } - if (!repo_exists) { - printf( - "%s adding %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - if (pkg.url && strlen(pkg.url) > 0) { - add_repo(pkg.url, pkg.name); - } - printf( - "%s added %s%s%s\n", - print_pkgit, green, pkg.name, color_reset - ); - } else { - if (is_verbose) - printf("%s repo already exists, done\n", print_pkgit); - } + if (!repo_exists) { + printf( + "%s adding %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + if (pkg.url && strlen(pkg.url) > 0) { + add_repo(pkg.url, pkg.name); + } + printf( + "%s added %s%s%s\n", + print_pkgit, green, pkg.name, color_reset + ); + } else { + if (is_verbose) printf( + "%s repo already exists, done\n", + print_pkgit + ); + } }
\ No newline at end of file diff --git a/src/lua_state.c b/src/lua_state.c index a91cd62..10820f4 100644 --- a/src/lua_state.c +++ b/src/lua_state.c @@ -174,6 +174,8 @@ bool target_loop_build( print_warning, lua_file, target ); lua_pop(L, 1); + if (strcmp(target, "quiet") == 0) + target_loop_build(L, lua_file, "default"); return false; } lua_getfield(L, -1, "dependencies"); @@ -222,6 +224,8 @@ bool target_loop_install( print_warning, lua_file, target ); lua_pop(L, 1); + if (strcmp(target, "quiet") == 0) + target_loop_install(L, lua_file, "default"); return false; } lua_getfield(L, -1, "pre_install"); @@ -300,6 +304,8 @@ bool target_loop_uninstall(lua_State *L, const char *lua_file, const char *targe print_warning, lua_file, target ); lua_pop(L, 1); + if (strcmp(target, "quiet") == 0) + target_loop_uninstall(L, lua_file, "default"); return false; } lua_getfield(L, -1, "uninstall"); |
