continue;
// Add the dependency to the package
- r = pakfire_package_add_dep(pkg, dep->key, string);
+ r = pakfire_package_add_dep(pkg, dep->key, "%s", string);
if (r)
goto ERROR;
}
}
// Add dependency
- r = pakfire_package_add_dep(p->pkg, p->dep, dep);
+ r = pakfire_package_add_dep(p->pkg, p->dep, "%s", dep);
if (r < 0) {
ERROR(ctx, "Could not process dependency '%s': %s\n", dep, strerror(-r));
goto ERROR;
// Walk through the buffer line by line
while (dep) {
// Add the dependency
- r = pakfire_package_add_dep(pkg, key, dep);
+ r = pakfire_package_add_dep(pkg, key, "%s", dep);
if (r)
goto ERROR;
}
int pakfire_package_add_dep(struct pakfire_package* pkg,
- const enum pakfire_package_key key, const char* dep) {
+ const enum pakfire_package_key key, const char* format, ...) {
+ char buffer[PATH_MAX];
+ va_list args;
+ int r;
+
+ // Format the dependency
+ va_start(args, format);
+ r = pakfire_string_vformat(buffer, format, args);
+ va_end(args);
+ if (r < 0)
+ return r;
+
// Ignore comments
- if (pakfire_string_startswith(dep, "#"))
+ if (pakfire_string_startswith(buffer, "#"))
return 0;
// Parse the dependency
- Id id = pakfire_str2dep(pkg->pakfire, dep);
+ Id id = pakfire_str2dep(pkg->pakfire, buffer);
if (!id) {
ERROR(pkg->ctx, "Could not add dependency '%s' to %s\n",
- dep, pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA));
+ buffer, pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA));
return -EINVAL;
}
// Dependencies
int pakfire_package_add_dep(struct pakfire_package* pkg,
- const enum pakfire_package_key key, const char* dep);
+ const enum pakfire_package_key key, const char* format, ...)
+ __attribute__((format(printf, 3, 4)));
int pakfire_package_has_rich_deps(struct pakfire_package* pkg);
int pakfire_package_matches_dep(struct pakfire_package* pkg,