From fa4344e5dedff14af2bce55d29a272495dd6bbb5 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Thu, 23 Jul 2026 12:23:40 -0400 Subject: cache downloads and cleaning --- snag/src/package_db.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'snag/src/package_db.c') diff --git a/snag/src/package_db.c b/snag/src/package_db.c index 04705e4..e0d7e8a 100644 --- a/snag/src/package_db.c +++ b/snag/src/package_db.c @@ -9,7 +9,6 @@ #include #define PKG_INFO_CMD "./scripts/get_pkg_attrs.sh" -#define PKG_INST_CMD "./scripts/run_pkg_install.sh" // note: fixed location of package database for now const char pkg_db[] = "./var/snag/packages"; @@ -117,45 +116,3 @@ bool load_package_info(char* pkgid, package_info_t* info) { return true; } - -void run_package_install(const package_info_t* info) { - - // PIPE and FORK to run install script - int pipefds[2] = {0}; - if (pipe(pipefds) < 0) die("failed to pipe: %s", strerror(errno)); - pid_t pid = fork(); - if (pid < 0) die("failed to fork: %s", strerror(errno)); - - if (pid == 0) { - // child proc - // connect my stdout and stderr to the pipe - close(pipefds[0]); - dup2(pipefds[1], STDOUT_FILENO); - dup2(pipefds[1], STDERR_FILENO); - close(pipefds[1]); - // exec into install script - char* argv[] = { PKG_INST_CMD, info->script_path, NULL }; - char* envp[] = { NULL }; - execve(PKG_INST_CMD, argv, envp); - // what are you still doing here? - die("CHILD - execve to %s failed: %s", PKG_INST_CMD, strerror(errno)); - } else { - // parent proc, close write end of pipe - close(pipefds[1]); - } - - // read from the pipe until EOF - char buf[4096]; - ssize_t bytes_read = 0; - while ((bytes_read = read(pipefds[0], buf, sizeof(buf))) > 0) { - // print build out, can log and stuff in future - printf("%.*s", (int)bytes_read, buf); - } - if (bytes_read < 0) die("failed to read from pipe: %s", strerror(errno)); - close(pipefds[0]); - - // reap the child to finish - int wstatus; - if (waitpid(pid, &wstatus, 0) < 0) die("waitpid failed: %s", strerror(errno)); - if (WEXITSTATUS(wstatus) != 0) die("the child failed to execute install script"); -} -- cgit v1.2.3