From: Michael Tremer Date: Mon, 30 Dec 2024 14:39:03 +0000 (+0000) Subject: stripper: Extract sources in the main process again X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=265ed2ff968117cbe5d57caf3c1bfd10f337a447;p=people%2Fric9%2Fpakfire.git stripper: Extract sources in the main process again Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/stripper.c b/src/libpakfire/stripper.c index 3dcde4620..cb3e7db08 100644 --- a/src/libpakfire/stripper.c +++ b/src/libpakfire/stripper.c @@ -203,41 +203,41 @@ ERROR: static int pakfire_stripper_copy_source_file( struct pakfire_stripper* stripper, const char* filename) { + char srcpath[PATH_MAX]; + char dstpath[PATH_MAX]; struct stat st = {}; - char path[PATH_MAX]; int r; FILE* src = NULL; FILE* dst = NULL; - const char* buildroot = pakfire_relpath(stripper->pakfire, stripper->path); + // Make the source path absolute + r = pakfire_path(stripper->pakfire, srcpath, "%s", filename); + if (r < 0) + goto ERROR; // Remove the original source path - r = pakfire_path_relative(path, BUILD_SRC_DIR, filename); + r = pakfire_path_relative(dstpath, BUILD_SRC_DIR, filename); if (r < 0) goto ERROR; // Add the debug directory source path - r = pakfire_path_append(path, DEBUG_SRC_DIR, path); + r = pakfire_path_append(dstpath, DEBUG_SRC_DIR, dstpath); if (r < 0) goto ERROR; // Add the buildroot - r = pakfire_path_append(path, buildroot, path); + r = pakfire_path_append(dstpath, stripper->path, dstpath); if (r < 0) goto ERROR; - // Nothing to do if the file has already been copied - if (pakfire_path_exists(path)) - return 0; - // Create all directories - r = pakfire_mkparentdir(path, 0755); + r = pakfire_mkparentdir(dstpath, 0755); if (r < 0) goto ERROR; // Open the destination file - dst = fopen(path, "wx"); + dst = fopen(dstpath, "wx"); if (!dst) { switch (errno) { // If the file exist already, we are done @@ -245,14 +245,14 @@ static int pakfire_stripper_copy_source_file( goto ERROR; default: - ERROR(stripper->ctx, "Could not open %s: %m\n", path); + ERROR(stripper->ctx, "Could not open %s: %m\n", dstpath); r = -errno; goto ERROR; } } // Open the source file - src = fopen(filename, "r"); + src = fopen(srcpath, "r"); if (!src) { ERROR(stripper->ctx, "Could not open %s: %m\n", filename); r = -errno; @@ -278,7 +278,7 @@ static int pakfire_stripper_copy_source_file( // Change permissions r = fchmod(fileno(dst), 0444); if (r < 0) { - ERROR(stripper->ctx, "Could not change permissions of %s: %m\n", path); + ERROR(stripper->ctx, "Could not change permissions of %s: %m\n", dstpath); r = -errno; goto ERROR; } @@ -420,14 +420,6 @@ ERROR: return r; } -static int __pakfire_stripper_run(struct pakfire_ctx* ctx, void* data) { - struct pakfire_stripper* stripper = data; - - // Strip all files - return pakfire_filelist_walk(stripper->filelist, pakfire_stripper_strip, - stripper, PAKFIRE_FILELIST_SHOW_PROGRESS, _("Stripping Files...")); -} - int pakfire_stripper_run(struct pakfire_stripper* stripper) { int r; @@ -440,6 +432,7 @@ int pakfire_stripper_run(struct pakfire_stripper* stripper) { if (pakfire_filelist_is_empty(stripper->filelist)) return 0; - // Run the rest inside the jail - return pakfire_jail_exec(stripper->jail, __pakfire_stripper_run, stripper, 0); + // Strip all files + return pakfire_filelist_walk(stripper->filelist, pakfire_stripper_strip, + stripper, PAKFIRE_FILELIST_SHOW_PROGRESS, _("Stripping Files...")); }