return 0;
}
-static int pakfire_build_package(struct pakfire* pakfire, struct pakfire_parser* makefile,
- uuid_t* build_id, const char* buildroot, const char* namespace, const char* target) {
+static int pakfire_build_package(struct pakfire_build* build, struct pakfire_parser* makefile,
+ const char* buildroot, const char* namespace) {
struct pakfire_package* pkg = NULL;
struct pakfire_packager* packager = NULL;
// Expand the handle into the package name
char* name = pakfire_parser_expand(makefile, "packages", namespace);
if (!name) {
- ERROR(pakfire, "Could not get package name: %m\n");
+ ERROR(build->pakfire, "Could not get package name: %m\n");
goto ERROR;
}
- INFO(pakfire, "Building package '%s'...\n", name);
+ INFO(build->pakfire, "Building package '%s'...\n", name);
// Fetch build architecture
- const char* arch = pakfire_get_arch(pakfire);
+ const char* arch = pakfire_get_arch(build->pakfire);
if (!arch)
goto ERROR;
// Fetch package from makefile
r = pakfire_parser_create_package(makefile, &pkg, NULL, namespace, arch);
if (r) {
- ERROR(pakfire, "Could not create package from makefile: %m\n");
+ ERROR(build->pakfire, "Could not create package from makefile: %m\n");
goto ERROR;
}
pakfire_package_set_distribution(pkg, distribution);
// Set build ID
- pakfire_package_set_build_id_from_uuid(pkg, build_id);
+ pakfire_package_set_build_id_from_uuid(pkg, &build->id);
// Set source package
const char* source_name = pakfire_parser_get(makefile, NULL, "name");
pakfire_package_set_source_arch(pkg, "src");
// Create a packager
- r = pakfire_packager_create(&packager, pakfire, pkg);
+ r = pakfire_packager_create(&packager, build->pakfire, pkg);
if (r)
goto ERROR;
// Add files
- r = pakfire_build_package_add_files(pakfire, makefile, buildroot, namespace,
+ r = pakfire_build_package_add_files(build->pakfire, makefile, buildroot, namespace,
pkg, packager);
if (r)
goto ERROR;
// Add scriptlets
- r = pakfire_build_package_add_scriptlets(pakfire, makefile, namespace, pkg, packager);
+ r = pakfire_build_package_add_scriptlets(build->pakfire, makefile, namespace,
+ pkg, packager);
if (r)
goto ERROR;
// Write the finished package
- r = pakfire_packager_finish_to_directory(packager, target, NULL);
+ r = pakfire_packager_finish_to_directory(packager, build->target, NULL);
if (r) {
- ERROR(pakfire, "pakfire_packager_finish() failed: %m\n");
+ ERROR(build->pakfire, "pakfire_packager_finish() failed: %m\n");
goto ERROR;
}
#ifdef ENABLE_DEBUG
char* dump = pakfire_package_dump(pkg, PAKFIRE_PKG_DUMP_LONG);
if (dump) {
- DEBUG(pakfire, "%s\n", dump);
+ DEBUG(build->pakfire, "%s\n", dump);
free(dump);
}
#endif
return r;
}
-static int pakfire_build_packages(struct pakfire* pakfire, struct pakfire_parser* makefile,
- uuid_t* build_id, const char* buildroot, const char* target) {
- DEBUG(pakfire, "Creating packages...");
+static int pakfire_build_packages(struct pakfire_build* build,
+ struct pakfire_parser* makefile, const char* buildroot) {
+ DEBUG(build->pakfire, "Creating packages...");
int r = 1;
// Fetch a list all all packages
char** packages = pakfire_parser_list_namespaces(makefile, "packages.package:*");
if (!packages) {
- ERROR(pakfire, "Could not find any packages: %m\n");
+ ERROR(build->pakfire, "Could not find any packages: %m\n");
goto ERROR;
}
for (char** package = packages; *package; package++)
num_packages++;
- DEBUG(pakfire, "Found %d package(s)\n", num_packages);
+ DEBUG(build->pakfire, "Found %d package(s)\n", num_packages);
// Build packages in reverse order
for (int i = num_packages - 1; i >= 0; i--) {
- r = pakfire_build_package(pakfire, makefile, build_id, buildroot, packages[i], target);
+ r = pakfire_build_package(build, makefile, buildroot, packages[i]);
if (r)
goto ERROR;
}
goto ERROR;
// Create the packages
- r = pakfire_build_packages(build->pakfire, makefile, &build->id,
- buildroot_rel, build->target);
+ r = pakfire_build_packages(build, makefile, buildroot_rel);
if (r) {
ERROR(build->pakfire, "Could not create packages: %m\n");
goto ERROR;