if (!arch)
arch = pakfire_arch_native();
- // Check if the architecture is supported
- if (!pakfire_arch_supported(arch)) {
- errno = EINVAL;
- return 1;
- }
-
- // Path must be absolute
- if (path && !pakfire_string_startswith(path, "/")) {
- errno = EINVAL;
- return 1;
- }
-
struct pakfire* p = calloc(1, sizeof(*p));
if (!p)
return 1;
p->nrefs = 1;
p->flags = flags;
- // Set architecture
- pakfire_string_set(p->arch, arch);
-
// Setup logging
if (log_callback)
pakfire_set_log_callback(p, log_callback, log_data);
pakfire_log_set_priority(p, log_priority(env));
}
+
+ // Check if the architecture is supported
+ if (!pakfire_arch_supported(arch)) {
+ ERROR(p, "Unsupported architecture: %s\n", arch);
+ errno = EINVAL;
+ goto ERROR;
+ }
+
+ // Set architecture
+ pakfire_string_set(p->arch, arch);
+
+ // Path must be absolute
+ if (path && !pakfire_string_startswith(path, "/")) {
+ ERROR(p, "Invalid path: %s\n", path);
+ errno = EINVAL;
+ goto ERROR;
+ }
+
// Generate a random path if none is set
if (!path) {
path = pakfire_mkdtemp(tempdir);