libmpm

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

commit 52b26f4b52b37fa02f9b1fd96f7654e97bd4acf0
parent fdc3af628b40c2040a6810e8b5ca6d34b6741c5a
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 21 Apr 2017 19:15:22 +0200

Fix(Packer): Rework of the function write_package_sources, in order to be called with any argument

Diffstat:
Msrc/packer.c | 6+++---
Atests/packer/right/patches/awesome_patch.patch | 10++++++++++
Atests/packer/right/scripts/after.sh | 2++
Atests/packer/right/scripts/before.sh | 2++
Dtests/packer/right/srcs/directory/something | 1-
5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/packer.c b/src/packer.c @@ -591,7 +591,7 @@ error: return false; } -static bool write_package_sources(FILE *fd, packer_t *ctx) { +static bool write_packer_sources(FILE *fd, packer_t *ctx, const char *dir_name) { mlist_t *files_list = NULL; mlist_t *dirs = NULL; mlist_t *tmp = NULL; @@ -606,7 +606,7 @@ static bool write_package_sources(FILE *fd, packer_t *ctx) { assert(old_pwd != NULL); chdir(ctx->str); - list_add(dirs, PACKER_SRC_DIR, sizeof(PACKER_SRC_DIR)); + list_add(dirs, dir_name, strlen(dir_name) + 1); list_for_each(dirs, tmp, dir) { if (read_files_from_dir(dir, &files_list, &dirs) == false) @@ -650,7 +650,7 @@ bool packer_create_archive(packer_t *ctx, const char *archive_path) { return false; write_package_header(fd, ctx); - if (write_package_sources(fd, ctx) == false) + if (write_packer_sources(fd, ctx, PACKER_SRC_DIR) == false) goto error; fclose(fd); diff --git a/tests/packer/right/patches/awesome_patch.patch b/tests/packer/right/patches/awesome_patch.patch @@ -0,0 +1,10 @@ +--- main.c.orig 2017-04-21 19:08:47.207443526 +0200 ++++ main.c 2017-04-21 19:08:52.499450888 +0200 +@@ -1,6 +1,6 @@ + #include <stdio.h> + + int main(void) { +- printf("Hello World !\n"); ++ printf("Hello World!\n"); + return 0; + } diff --git a/tests/packer/right/scripts/after.sh b/tests/packer/right/scripts/after.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "After !"; diff --git a/tests/packer/right/scripts/before.sh b/tests/packer/right/scripts/before.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Before !"; diff --git a/tests/packer/right/srcs/directory/something b/tests/packer/right/srcs/directory/something @@ -1 +0,0 @@ -Somewhat