socsvn commit: r257122 - in soc2013/mattbw/backend: . jobs
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Sun Sep 8 13:01:04 UTC 2013
Author: mattbw
Date: Sun Sep 8 13:01:03 2013
New Revision: 257122
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257122
Log:
Fix breakage with valid repos being deemed invalid.
Modified:
soc2013/mattbw/backend/jobs/core.c
soc2013/mattbw/backend/jobs/core.h
soc2013/mattbw/backend/jobs/do.c
soc2013/mattbw/backend/repo.c
soc2013/mattbw/backend/repo.h
Modified: soc2013/mattbw/backend/jobs/core.c
==============================================================================
--- soc2013/mattbw/backend/jobs/core.c Sun Sep 8 12:30:30 2013 (r257121)
+++ soc2013/mattbw/backend/jobs/core.c Sun Sep 8 13:01:03 2013 (r257122)
@@ -85,27 +85,31 @@
return (err == EPKG_OK);
}
-bool
+enum repo_set_status
jobs_set_repo(struct pkg_jobs *jobs, const char *reponame)
{
- bool success;
+ enum repo_set_status status;
enum repo_type type;
assert(jobs != NULL);
- success = true;
-
type = repo_type(reponame);
if (type == REPO_INVALID) {
- success = false;
+ status = REPO_SET_INVALID_REPO;
+ } else if (type == REPO_INVALID) {
+ status = REPO_SET_DISABLED_REPO;
} else if (type == REPO_REMOTE) {
int err;
err = pkg_jobs_set_repository(jobs,
pkg_repo_ident_from_name(reponame));
- success = (err == EPKG_OK);
+ status = (err == EPKG_OK) ? REPO_SET_OK : REPO_SET_FAILURE;
+ } else {
+ /* Ignore any other type of repository. */
+ status = REPO_SET_OK;
}
- return success;
+
+ return status;
}
/*
@@ -136,6 +140,34 @@
return namevers;
}
+/* Converts a repo-set result to a string constant. */
+const char *
+jobs_repo_set_status_to_string(enum repo_set_status status)
+{
+ const char *detail;
+
+#ifndef __clang__
+ detail = "Detail message not set."
+#endif
+
+ switch (status) {
+ case REPO_SET_OK:
+ detail = "This shouldn't happen.";
+ break;
+ case REPO_SET_INVALID_REPO:
+ detail = "This repo doesn't seem to exist.";
+ break;
+ case REPO_SET_DISABLED_REPO:
+ detail = "This repo is disabled.";
+ break;
+ case REPO_SET_FAILURE:
+ detail = "Error while setting repo.";
+ break;
+ }
+
+ return detail;
+}
+
/* Emits each package queued up in a (solved) job. */
void
jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend,
Modified: soc2013/mattbw/backend/jobs/core.h
==============================================================================
--- soc2013/mattbw/backend/jobs/core.h Sun Sep 8 12:30:30 2013 (r257121)
+++ soc2013/mattbw/backend/jobs/core.h Sun Sep 8 13:01:03 2013 (r257122)
@@ -24,11 +24,19 @@
#include <stdbool.h> /* bool */
#include "../pk-backend.h" /* PkBackend */
+enum repo_set_status {
+ REPO_SET_OK,
+ REPO_SET_INVALID_REPO,
+ REPO_SET_DISABLED_REPO,
+ REPO_SET_FAILURE
+};
+
typedef PkInfoEnum(*pkg_info_ptr) (struct pkg *pkg);
bool jobs_apply(struct pkg_jobs *jobs, PkBackend *backend, PkErrorEnum jobs_failed);
-bool jobs_set_repo(struct pkg_jobs *jobs, const char *reponame);
+enum repo_set_status jobs_set_repo(struct pkg_jobs *jobs, const char *reponame);
char **jobs_add_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count);
+const char *jobs_repo_set_status_to_string(enum repo_set_status status);
struct pkg_jobs *jobs_allocate(pkg_jobs_t type, struct pkgdb *db);
void jobs_emit_packages(struct pkg_jobs *jobs, PkBackend *backend, pkg_info_ptr info);
void jobs_free (struct pkg_jobs **jobs_p);
Modified: soc2013/mattbw/backend/jobs/do.c
==============================================================================
--- soc2013/mattbw/backend/jobs/do.c Sun Sep 8 12:30:30 2013 (r257121)
+++ soc2013/mattbw/backend/jobs/do.c Sun Sep 8 13:01:03 2013 (r257122)
@@ -248,18 +248,23 @@
const char *reponame)
{
bool success;
+ enum repo_set_status status;
assert(spec != NULL);
assert(jobs != NULL);
/* reponame can be NULL */
- success = jobs_set_repo(jobs, reponame);
+ status = jobs_set_repo(jobs, reponame);
+ success = (status == REPO_SET_OK);
if (!success) {
char *err_message;
+ const char *detail;
+
+ detail = jobs_repo_set_status_to_string(status);
(void)asprintf(&err_message,
- "Could not set job repository to '%s'.",
- reponame);
+ "Could not set job repository to '%s': %s",
+ reponame, detail);
ERR(spec->backend,
PK_ERROR_ENUM_REPO_NOT_FOUND,
err_message);
Modified: soc2013/mattbw/backend/repo.c
==============================================================================
--- soc2013/mattbw/backend/repo.c Sun Sep 8 12:30:30 2013 (r257121)
+++ soc2013/mattbw/backend/repo.c Sun Sep 8 13:01:03 2013 (r257122)
@@ -45,9 +45,15 @@
type = repo_type_no_remote_check(name);
- if (type == REPO_REMOTE &&
- (pkg_repo_find_ident(pkg_repo_ident_from_name(name)) != NULL)) {
- type = REPO_INVALID;
+ if (type == REPO_REMOTE) {
+ struct pkg_repo *repo;
+ repo = pkg_repo_find_name(name);
+
+ if (repo == NULL) {
+ type = REPO_INVALID;
+ } else if (!pkg_repo_enabled(repo)) {
+ type = REPO_DISABLED;
+ }
}
return type;
}
Modified: soc2013/mattbw/backend/repo.h
==============================================================================
--- soc2013/mattbw/backend/repo.h Sun Sep 8 12:30:30 2013 (r257121)
+++ soc2013/mattbw/backend/repo.h Sun Sep 8 13:01:03 2013 (r257122)
@@ -27,7 +27,8 @@
REPO_INVALID,
REPO_ANY,
REPO_LOCAL,
- REPO_REMOTE
+ REPO_REMOTE,
+ REPO_DISABLED
};
enum repo_type repo_type(const char *name);
More information about the svn-soc-all
mailing list