return r;
}
-static int pakfire_dist_add_files(struct pakfire* pakfire, struct pakfire_packager* packager,
- const char* path) {
+static const char* pakfire_dist_find_root(struct pakfire* pakfire, const char* file) {
+ char path[PATH_MAX];
+
+ // Find the absolute path of the makefile
+ char* p = realpath(file, path);
+ if (!p) {
+ ERROR(pakfire, "realpath(%s) failed: %m\n", file);
+ return NULL;
+ }
+
+ // Return the parent directory
+ return pakfire_dirname(p);
+}
+
+static int pakfire_dist_add_files(struct pakfire* pakfire,
+ struct pakfire_packager* packager, const char* file) {
struct pakfire_filelist* filelist = NULL;
int r = 1;
- // Find the parent directory
- const char* dirname = pakfire_dirname(path);
- if (!dirname)
+ // Find the package directory
+ const char* root = pakfire_dist_find_root(pakfire, file);
+ if (!root)
return 1;
- DEBUG(pakfire, "Adding all files in '%s' to package...\n", dirname);
+ DEBUG(pakfire, "Adding all files in '%s' to package...\n", root);
// Create a new filelist
r = pakfire_filelist_create(&filelist, pakfire);
goto ERROR;
// Scan for any files
- r = pakfire_filelist_scan(filelist, dirname, NULL, pakfire_dist_excludes);
+ r = pakfire_filelist_scan(filelist, root, NULL, pakfire_dist_excludes);
if (r)
goto ERROR;