aboutsummaryrefslogtreecommitdiff
path: root/src/install_pkg.c
diff options
context:
space:
mode:
authordacctal <dacctal@symlinx.net>2026-05-24 10:23:38 +0000
committerdacctal <dacctal@symlinx.net>2026-05-24 10:23:38 +0000
commitaa0d78815004ae6b0c4a42b0e024f5c4ef555ae2 (patch)
tree62f97b4c5acfdb98003568466f878fbd3d6b9dfb /src/install_pkg.c
parent83d471f2c1d1b1fa6be51f41e4f1c36ab19d7094 (diff)
c rewrite
Diffstat (limited to 'src/install_pkg.c')
-rw-r--r--src/install_pkg.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/install_pkg.c b/src/install_pkg.c
new file mode 100644
index 0000000..d599de0
--- /dev/null
+++ b/src/install_pkg.c
@@ -0,0 +1,53 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "install_pkg.h"
+#include "add_repo.h"
+#include "fetch_src.h"
+#include "build.h"
+#include "copy_install.h"
+#include "link_install.h"
+#include "lua_state.h"
+#include "name_from_url.h"
+#include "vars.h"
+
+void install_pkg(Pkg pkg) {
+ if (!pkg.is_local) {
+ printf("%sfetching source...\n", print_pkgit);
+ fetch_src(pkg);
+ printf("%ssource fetched!\n", print_pkgit);
+ }
+
+ printf("%sbuilding...\n", print_pkgit);
+ build(pkg);
+ printf("%sbuild complete!\n", print_pkgit);
+
+ printf("%sinstalling...\n", print_pkgit);
+ if (is_symlink_install) {
+ link_install(pkg.src);
+ } else {
+ copy_install(pkg.src);
+ }
+ printf("%sinstalled!\n", print_pkgit);
+
+ bool repo_exists = false;
+ for (size_t i = 0; i < cached_repos_count; i++) {
+ char *repo_name = name_from_url(cached_repos[i].source_value);
+ if (strcmp(repo_name, pkg.name) == 0) {
+ repo_exists = true;
+ }
+ free(repo_name);
+ }
+
+ if (!repo_exists) {
+ printf("%sadding repository...\n", print_pkgit);
+ if (pkg.url && strlen(pkg.url) > 0) {
+ add_repo(pkg.url, pkg.name);
+ }
+ printf("%sdone!\n", print_pkgit);
+ } else {
+ printf("%srepo already exists, done!\n", print_pkgit);
+ }
+} \ No newline at end of file