}
int pakfire_repo_write_config(struct pakfire_repo* repo, FILE* f) {
+ struct pakfire_config* config = NULL;
+ struct pakfire_key* key = NULL;
+ char* section = NULL;
+ char* buffer = NULL;
+ size_t length = 0;
int r;
// Do nothing for the installed repository
if (pakfire_repo_is_installed_repo(repo))
return 0;
- struct pakfire_config* config = NULL;
- char* section = NULL;
-
- struct pakfire_key* key = NULL;
- char* buffer = NULL;
- size_t length = 0;
-
// Create section name
r = asprintf(§ion, "repo:%s", pakfire_repo_get_name(repo));
if (r < 0)
// Create a new configuration
r = pakfire_config_create(&config);
- if (r)
+ if (r < 0)
goto ERROR;
// Description
const char* description = pakfire_repo_get_description(repo);
if (description) {
r = pakfire_config_set(config, section, "description", description);
- if (r) {
- ERROR(repo->ctx, "Could not set description: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set description: %s\n", strerror(-r));
goto ERROR;
}
}
// Disabled?
if (!pakfire_repo_get_enabled(repo)) {
r = pakfire_config_set(config, section, "enabled", "0");
- if (r) {
- ERROR(repo->ctx, "Could not set enabled: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set enabled: %s\n", strerror(-r));
goto ERROR;
}
}
const char* baseurl = pakfire_repo_get_baseurl(repo);
if (baseurl) {
r = pakfire_config_set(config, section, "baseurl", baseurl);
- if (r) {
- ERROR(repo->ctx, "Could not set base URL: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set base URL: %s\n", strerror(-r));
goto ERROR;
}
}
r = pakfire_config_set(config, section, "refresh", refresh);
free(refresh);
- if (r) {
- ERROR(repo->ctx, "Could not set refresh interval: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set refresh interval: %s\n", strerror(-r));
goto ERROR;
}
}
const char* mirrorlist = pakfire_repo_get_mirrorlist_url(repo);
if (mirrorlist) {
r = pakfire_config_set(config, section, "mirrors", mirrorlist);
- if (r) {
- ERROR(repo->ctx, "Could not set mirrors: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set mirrors: %s\n", strerror(-r));
goto ERROR;
}
}
unsigned int priority = pakfire_repo_get_priority(repo);
if (priority) {
r = pakfire_config_set_format(config, section, "priority", "%u", priority);
- if (r) {
- ERROR(repo->ctx, "Could not set priority: %m\n");
+ if (r < 0) {
+ ERROR(repo->ctx, "Could not set priority: %s\n", strerror(-r));
goto ERROR;
}
}