return 0;
}
+static int pakfire_build_read_makefile(struct pakfire_build* build,
+ struct pakfire_parser** parser, struct pakfire_package* package) {
+ char makefile[PATH_MAX];
+ char path[PATH_MAX];
+ int r;
+
+ struct pakfire_parser_error* error = NULL;
+
+ const char* nevra = pakfire_package_get_nevra(package);
+ const char* name = pakfire_package_get_name(package);
+
+ // Compose path to makefile
+ r = pakfire_string_format(makefile, "/usr/src/packages/%s/%s.nm", nevra, name);
+ if (r < 0)
+ return 1;
+
+ // Make it absolute
+ r = pakfire_make_path(build->pakfire, path, makefile);
+ if (r < 0)
+ return 1;
+
+ // Read makefile
+ r = pakfire_read_makefile(parser, build->pakfire, path, &error);
+ if (r) {
+ if (error) {
+ ERROR(build->pakfire, "Could not parse makefile %s: %s\n", path,
+ pakfire_parser_error_get_message(error));
+ } else {
+ ERROR(build->pakfire, "Could not parse makefile %s: %m\n", path);
+ }
+
+ goto ERROR;
+ }
+
+ERROR:
+ if (error)
+ pakfire_parser_error_unref(error);
+
+ return r;
+}
+
PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) {
struct pakfire_archive* archive = NULL;
struct pakfire_package* package = NULL;
-
- char makefile[PATH_MAX];
+ struct pakfire_parser* makefile = NULL;
int r;
// Open source archive
goto ERROR;
}
- // Fetch some information
const char* nevra = pakfire_package_get_nevra(package);
- const char* name = pakfire_package_get_name(package);
INFO(build->pakfire, "Building %s...\n", nevra);
goto ERROR;
}
- // Compose path to makefile
- r = pakfire_string_format(makefile, "/usr/src/packages/%s/%s.nm", nevra, name);
- if (r < 0) {
- ERROR(build->pakfire, "Could not compose makefile path: %m\n");
+ // Open the makefile
+ r = pakfire_build_read_makefile(build, &makefile, package);
+ if (r)
goto ERROR;
- }
+#if 0
// Run build
r = pakfire_build_makefile(build, makefile);
if (r) {
ERROR(build->pakfire, "Could not build %s: %m\n", nevra);
goto ERROR;
}
+#endif
ERROR:
+ if (makefile)
+ pakfire_parser_unref(makefile);
if (archive)
pakfire_archive_unref(archive);
if (package)