libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 7cbb1d66d0d70ec90f19246c5904eacb5ab0b166
parent 52b26f4b52b37fa02f9b1fd96f7654e97bd4acf0
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sat, 22 Apr 2017 17:29:34 +0200

Fix(Packer): Now reading patches and scripts

Diffstat:
Minc/packer.h | 2++
Msrc/packer.c | 16++++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/inc/packer.h b/inc/packer.h @@ -33,6 +33,8 @@ # define PACKER_MPX_MAGIC "MPX" # define PACKER_SRC_DIR "srcs/" +# define PACKER_PATCH_DIR "patches/" +# define PACKER_SCRIPT_DIR "scripts/" # define PACKER_MAKE_DEF "make" # define PACKER_TEST_DEF "test" diff --git a/src/packer.c b/src/packer.c @@ -414,6 +414,7 @@ bool packer_read_dir(packer_t *ctx) { if (ctx->type != PACKER_TYPE_DIRECTORY) goto error; + if (chdir(ctx->str) == -1) goto error; @@ -546,8 +547,9 @@ static bool read_files_from_dir(const char *dir_name, mlist_t **files, mlist_t * struct dirent *dinfo = NULL; packer_file_t *file = NULL; + /* Directory not here is okay */ if (dir == NULL) - return false; + return true; while ((dinfo = readdir(dir))) { @@ -606,7 +608,7 @@ static bool write_packer_sources(FILE *fd, packer_t *ctx, const char *dir_name) assert(old_pwd != NULL); chdir(ctx->str); - list_add(dirs, dir_name, strlen(dir_name) + 1); + list_add(dirs, (void *)dir_name, strlen(dir_name) + 1); list_for_each(dirs, tmp, dir) { if (read_files_from_dir(dir, &files_list, &dirs) == false) @@ -615,6 +617,10 @@ static bool write_packer_sources(FILE *fd, packer_t *ctx, const char *dir_name) list_free(dirs, NULL); + /* No file to process, all good */ + if (list_size(files_list) == 0) + return true; + packer_file_t *file; list_for_each(files_list, tmp, file) { fprintf(fd, "%s%c", file->fn, 0); @@ -653,6 +659,12 @@ bool packer_create_archive(packer_t *ctx, const char *archive_path) { if (write_packer_sources(fd, ctx, PACKER_SRC_DIR) == false) goto error; + if (write_packer_sources(fd, ctx, PACKER_PATCH_DIR) == false) + goto error; + + if (write_packer_sources(fd, ctx, PACKER_SCRIPT_DIR) == false) + goto error; + fclose(fd); return true;