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
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;
// 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;
}
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;
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..."));
}