]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
stripper: Create a unified stripping function
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Dec 2024 18:58:19 +0000 (18:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Dec 2024 18:58:19 +0000 (18:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/stripper.c

index a9e31376fd1df494ca5af0b93a78aee0362bc268..9218fcc6b072d44c3138935ad0d5e9c6ef7d7dc2 100644 (file)
@@ -263,8 +263,7 @@ ERROR:
 #endif
 
 static int pakfire_stripper_copy_sources(
-               struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) {
-       struct pakfire_stripper* stripper = data;
+               struct pakfire_stripper* stripper, struct pakfire_file* file) {
        const char* filename = NULL;
        char basename[PATH_MAX];
        Dwarf* dwarf = NULL;
@@ -295,7 +294,7 @@ static int pakfire_stripper_copy_sources(
                                goto ERROR;
 
                        default:
-                               ERROR(ctx, "Could not initialize DWARF context: %s\n", dwarf_errmsg(-1));
+                               ERROR(stripper->ctx, "Could not initialize DWARF context: %s\n", dwarf_errmsg(-1));
                                r = -errno;
                                goto ERROR;
                }
@@ -315,7 +314,7 @@ static int pakfire_stripper_copy_sources(
                // Fetch the source files
                r = dwarf_getsrcfiles(die, &files, &count);
                if (r < 0) {
-                       ERROR(ctx, "Could not fetch the source files: %s\n", dwarf_errmsg(-1));
+                       ERROR(stripper->ctx, "Could not fetch the source files: %s\n", dwarf_errmsg(-1));
                        r = -errno;
                        goto ERROR;
                }
@@ -338,12 +337,12 @@ static int pakfire_stripper_copy_sources(
                        if (pakfire_string_startswith(basename, "<") && pakfire_string_endswith(basename, ">"))
                                continue;
 
-                       DEBUG(ctx, "Found source file: %s\n", filename);
+                       DEBUG(stripper->ctx, "Found source file: %s\n", filename);
 
                        // Copy the file
                        r = pakfire_stripper_copy_source_file(stripper, filename);
                        if (r < 0) {
-                               ERROR(ctx, "Could not copy source file %s: %s\n", filename, strerror(-r));
+                               ERROR(stripper->ctx, "Could not copy source file %s: %s\n", filename, strerror(-r));
                                goto ERROR;
                        }
                }
@@ -360,19 +359,27 @@ ERROR:
        return r;
 }
 
-static int __pakfire_stripper_run(struct pakfire_ctx* ctx, void* data) {
+static int pakfire_stripper_strip(
+               struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) {
        struct pakfire_stripper* stripper = data;
        int r;
 
        // Copy sources
-       r = pakfire_filelist_walk(stripper->filelist, pakfire_stripper_copy_sources,
-                       stripper, PAKFIRE_FILELIST_SHOW_PROGRESS, _("Stripping Files..."));
+       r = pakfire_stripper_copy_sources(stripper, file);
        if (r < 0)
                return r;
 
        return 0;
 }
 
+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;