#include <pakfire/execute.h>
#include <pakfire/dist.h>
#include <pakfire/logging.h>
+#include <pakfire/package.h>
#include <pakfire/parser.h>
#include <pakfire/private.h>
#include <pakfire/types.h>
"\n" \
"exit 0\n"
-static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const char* handle) {
+static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const char* namespace) {
+ PakfireRepo repo = NULL;
+ PakfirePackage pkg = NULL;
int r = 1;
// Expand the handle into the package name
- char* name = pakfire_parser_expand(makefile, "packages", handle);
+ char* name = pakfire_parser_expand(makefile, "packages", namespace);
if (!name) {
ERROR(pakfire, "Could not get package name: %s\n", strerror(errno));
goto ERROR;
INFO(pakfire, "Building package '%s'...\n", name);
- // XXX actually do all the work
+ // Fetch build architecture
+ const char* arch = pakfire_get_arch(pakfire);
+ if (!arch)
+ goto ERROR;
+
+ // Fetch the dummy repository
+ repo = pakfire_get_repo(pakfire, "@dummy");
+ if (!repo)
+ goto ERROR;
+
+ // Fetch package from makefile
+ r = pakfire_parser_create_package(makefile, &pkg, repo, namespace, arch);
+ if (r) {
+ ERROR(pakfire, "Could not create package from makefile: %s\n", strerror(errno));
+ goto ERROR;
+ }
+
+#ifdef ENABLE_DEBUG
+ char* dump = pakfire_package_dump(pkg, 0);
+ if (dump) {
+ DEBUG(pakfire, "%s\n", dump);
+ free(dump);
+ }
+#endif
// Success
r = 0;
ERROR:
+ if (repo)
+ pakfire_repo_unref(repo);
+ if (pkg)
+ pakfire_package_unref(pkg);
if (name)
free(name);
// Build packages in reverse order
for (int i = num_packages - 1; i >= 0; i--) {
- r = pakfire_build_package(pakfire, makefile,
- packages[i] + strlen("packages.package:"));
+ r = pakfire_build_package(pakfire, makefile, packages[i]);
if (r)
goto ERROR;
}