diff options
Diffstat (limited to 'src/spm.c')
-rw-r--r-- | src/spm.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/spm.c b/src/spm.c new file mode 100644 index 0000000..3607117 --- /dev/null +++ b/src/spm.c @@ -0,0 +1,60 @@ +/** + * SPM - Simple Package Manager + * @file spm.c + */ +#include "spm.h" + +int main(int argc, char *argv[]) { + // not much to see here yet + // at the moment this will all be random tests, for better or worse + // everything here is subject to change without notice + + // Initialize configuration data + init_config_global(); + show_global_config(); + + // Ensure external programs are available for use. + check_runtime_environment(); + + // Install a package to test things out + char *match; + char *package; + const char *root = "/tmp/root"; + if ((match = find_package("python")) == NULL) { + fprintf(SYSERROR); + exit(1); + } + if ((package = basename(match)) == NULL) { + fprintf(stderr, "Unable to derive package name from package path:\n\t-> %s\n", match); + exit(1); + } + + Dependencies *deps = NULL; + dep_init(&deps); + + if (dep_all(&deps, package) < 0) { + dep_free(&deps); + free_global_config(); + exit(1); + } + + printf("%s requires:\n", package); + dep_show(&deps); + + // Install dependencies first + for (int i = 0; i < deps->records; i++) { + if (install(root, deps->list[i]) < 0) { + fprintf(SYSERROR); + exit(errno); + } + } + // Install package + if (install(root, package) < 0) { + fprintf(SYSERROR); + exit(errno); + } + + dep_free(&deps); + free_global_config(); + return 0; +} |