diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-10 09:49:00 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-10 09:49:00 -0500 |
commit | e9e16cc286ae1bd89af50d0c29e00866e1826b6f (patch) | |
tree | a0d8509615645d19b26b1214fd1fb5e0114ee058 | |
parent | 27a91e38de51c40662eb91b8b992b0c052d417f6 (diff) | |
download | spmc-e9e16cc286ae1bd89af50d0c29e00866e1826b6f.tar.gz |
clean up a bit
-rw-r--r-- | spm.c | 18 | ||||
-rw-r--r-- | spm.h | 9 |
2 files changed, 22 insertions, 5 deletions
@@ -189,18 +189,28 @@ int tar_extract_file(const char *archive, const char* filename, const char *dest return status; } -int tar_extract_archive(const char *archive, const char *destination) { +int tar_extract_archive(const char *_archive, const char *_destination) { Process *proc = NULL; int status; char cmd[PATH_MAX]; + char *archive = strdup(_archive); + if (!archive) { + fprintf(SYSERROR); + return -1; + } + char *destination = strdup(_destination); + if (!destination) { + fprintf(SYSERROR); + return -1; + } + // sanitize archive strchrdel(archive, "&;|"); // sanitize destination strchrdel(destination, "&;|"); sprintf(cmd, "tar xf %s -C %s 2>&1", archive, destination); - printf("Executing: %s\n", cmd); shell(&proc, SHELL_OUTPUT, cmd); if (!proc) { fprintf(SYSERROR); @@ -920,7 +930,6 @@ int mkdirs(const char *_path, mode_t mode) { strcat(tmp, parts[i]); strcat(tmp, sep); if (access(tmp, F_OK) != 0) { - printf("doesn't exist: %s\n", tmp); result = mkdir(tmp, mode); } } @@ -1177,7 +1186,6 @@ int install(const char *destroot, const char *_package) { sprintf(template, "%s%c%s", ucd, DIRSEP, suffix); char *tmpdir = mkdtemp(template); tar_extract_archive(package, tmpdir); - getchar(); rmdirs(tmpdir); free(package); free(ucd); @@ -1238,7 +1246,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "RPATH assignment failed\n"); } - install("/tmp/root", "python-*"); + install("/tmp/root", "python"); free(test_path); free(rpath); return 0; @@ -36,6 +36,14 @@ #define SHELL_BENCHMARK 1 << 2 typedef struct { + char *platform; + char *arch; + char *package_dir; + char *user_config_basedir; + char *user_config_file; +} spm_vars; + +typedef struct { int count; char **paths; } Dirwalk; @@ -49,6 +57,7 @@ typedef struct { void shell(Process **proc_info, u_int64_t option, const char *fmt, ...); void shell_free(Process *proc_info); +int tar_extract_archive(const char *_archive, const char *_destination); int tar_extract_file(const char *archive, const char* filename, const char *destination); int errglob(const char *epath, int eerrno); |