socsvn commit: r254219 - in soc2013/mattbw/backend: . actions
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Sat Jul 6 07:38:41 UTC 2013
Author: mattbw
Date: Sat Jul 6 07:38:41 2013
New Revision: 254219
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254219
Log:
bash simulate-install-packages to the point where it sometimes shows the correct information
Modified:
soc2013/mattbw/backend/actions/actions.h
soc2013/mattbw/backend/actions/install-packages.c
soc2013/mattbw/backend/pk-backend-pkgng.c
soc2013/mattbw/backend/query.c
Modified: soc2013/mattbw/backend/actions/actions.h
==============================================================================
--- soc2013/mattbw/backend/actions/actions.h Sat Jul 6 07:09:02 2013 (r254218)
+++ soc2013/mattbw/backend/actions/actions.h Sat Jul 6 07:38:41 2013 (r254219)
@@ -24,10 +24,14 @@
#include <glib.h> /* gboolean */
#include "../pk-backend.h" /* PkBackend */
-/* Each thread is implemented in its namesake C file. */
+/*
+ * Each thread is implemented in its namesake C file, except simulations
+ * which are stored with their non-simulated counterparts.
+ */
gboolean get_details_thread(PkBackend *backend);
gboolean get_files_thread(PkBackend *backend);
gboolean get_repo_list_thread(PkBackend *backend);
gboolean install_packages_thread(PkBackend *backend);
+gboolean simulate_install_packages_thread(PkBackend *backend);
#endif /* !_PKGNG_BACKEND_ACTIONS_H_ */
Modified: soc2013/mattbw/backend/actions/install-packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 07:09:02 2013 (r254218)
+++ soc2013/mattbw/backend/actions/install-packages.c Sat Jul 6 07:38:41 2013 (r254219)
@@ -29,12 +29,17 @@
#include "actions.h" /* install_packages_thread prototype */
static gboolean body(struct query *q);
+static gboolean sim_body(struct query *q);
+static void do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate);
static void emit(struct pkg *pkg, const gchar *id, struct query *q);
-static void job(struct pkg_jobs *jobs, struct query *q);
+static void job (struct pkg_jobs *jobs, struct query *q);
+static void sim_emit(struct pkg *pkg, const gchar *id, struct query *q);
+static void sim_job(struct pkg_jobs *jobs, struct query *q);
+
/*
- * The thread that performs an InstallPackages operation. Should be invoked by
- * the pk_backend_install_packages hook.
+ * The thread that performs an InstallPackages operation. Should be invoked
+ * by the pk_backend_install_packages hook.
*/
gboolean
install_packages_thread(PkBackend *backend)
@@ -44,6 +49,17 @@
}
/*
+ * The thread that performs a Simulate InstallPackages operation. Should be
+ * invoked by the pk_backend_simulate_install_packages hook.
+ */
+gboolean
+simulate_install_packages_thread(PkBackend *backend)
+{
+
+ return query_for_all_ids(backend, PKG_LOAD_BASIC, sim_body);
+}
+
+/*
* Look up and attempt to install the given PackageID, if it can be found.
*/
static gboolean
@@ -54,46 +70,99 @@
}
/*
- * Tries to install the given package.
+ * Look up and attempt to simulate installing the given PackageID, if it can
+ * be found.
*/
-static void
-emit(struct pkg *pkg, const gchar *id, struct query *q)
+static gboolean
+sim_body(struct query *q)
{
- INTENTIONALLY_IGNORE(id);
- return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job);
+ return query_emit_match(q, sim_emit);
}
-/*
- * Tries to install the given package.
- */
static void
-job(struct pkg_jobs *jobs, struct query *q)
+do_install_packages(struct pkg_jobs *jobs, struct query *q, gboolean simulate)
{
- int err;
- PkBackend *backend;
+ int err;
+ PkBackend *backend;
backend = query_backend(q);
+ pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE);
err = pkg_jobs_solve(jobs);
if (err == EPKG_OK) {
- char *desc;
- gchar *id;
- struct pkg *pkg;
+ char *desc;
+ gchar *id;
+ struct pkg *pkg;
pkg = NULL;
id = NULL;
- for (HASH_FOR(err, pkg_jobs, jobs, &pkg)) {
- pkg_get(pkg, PKG_DESC, &desc);
- query_pkg_to_id(pkg, &id);
- pk_backend_package(backend,
- PK_INFO_ENUM_INSTALLING,
- id,
- desc);
+ if (pkg_jobs_count(jobs) == 0)
+ pk_backend_error_code(backend,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ "job contains no packages");
+ else {
+ while (pkg_jobs(jobs, &pkg) == EPKG_OK) {
+ pkg_get(pkg, PKG_COMMENT, &desc);
+ query_pkg_to_id(pkg, &id);
+ pk_backend_package(backend,
+ PK_INFO_ENUM_INSTALLING,
+ id,
+ desc);
+ }
+ g_free(id);
}
- g_free(id);
} else
pk_backend_error_code(backend,
- PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
- "could not solve the job");
+ PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
+ "could not solve the job");
+
+ /* TODO: actual install */
+ if (err == EPKG_OK && simulate == FALSE)
+ pk_backend_error_code(backend,
+ PK_ERROR_ENUM_NOT_SUPPORTED,
+ "not implemented yet");
+
+}
+
+/*
+ * Tries to install the given package.
+ */
+static void
+emit(struct pkg *pkg, const gchar *id, struct query *q)
+{
+
+ INTENTIONALLY_IGNORE(id);
+ return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, job);
+}
+
+/*
+ * Tries to process the given solved installation jobs.
+ */
+static void
+job(struct pkg_jobs *jobs, struct query *q)
+{
+
+ do_install_packages(jobs, q, FALSE);
+}
+
+/*
+ * Tries to install the given package.
+ */
+static void
+sim_emit(struct pkg *pkg, const gchar *id, struct query *q)
+{
+
+ INTENTIONALLY_IGNORE(id);
+ return query_emit_to_job(pkg, q, PKG_JOBS_INSTALL, sim_job);
+}
+
+/*
+ * Tries to simulate processing the given installation jobs.
+ */
+static void
+sim_job(struct pkg_jobs *jobs, struct query *q)
+{
+
+ do_install_packages(jobs, q, TRUE);
}
Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 07:09:02 2013 (r254218)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c Sat Jul 6 07:38:41 2013 (r254219)
@@ -367,7 +367,6 @@
pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
pk_backend_thread_create(backend, install_packages_thread);
- pk_backend_finished(backend);
}
/**
@@ -1142,35 +1141,13 @@
void
pk_backend_simulate_install_packages(PkBackend *backend, gchar **package_ids)
{
- INTENTIONALLY_IGNORE(package_ids);
-
- pk_backend_set_status(backend, PK_STATUS_ENUM_DEP_RESOLVE);
-
- pk_backend_package(backend, PK_INFO_ENUM_REMOVING,
- "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor");
-
- pk_backend_package(backend, PK_INFO_ENUM_INSTALLING,
- "gtk2;2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
-
- pk_backend_package(backend, PK_INFO_ENUM_UPDATING,
- "lib7;7.0.1-6.fc13;i386;fedora", "C Libraries");
-
- pk_backend_package(backend, PK_INFO_ENUM_REINSTALLING,
- "libssl;3.5.7-2.fc13;i386;fedora", "SSL Libraries");
- pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
- "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package.");
-
- pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
- "glib2;2.14.0;i386;fedora", "The GLib library");
-
- pk_backend_package(backend, PK_INFO_ENUM_DOWNGRADING,
- "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)");
+ INTENTIONALLY_IGNORE(package_ids);
- pk_backend_package(backend, PK_INFO_ENUM_UPDATING,
- "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
+ pk_backend_set_status(backend, PK_STATUS_ENUM_RUNNING);
+ pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
- pk_backend_finished(backend);
+ pk_backend_thread_create(backend, simulate_install_packages_thread);
}
Modified: soc2013/mattbw/backend/query.c
==============================================================================
--- soc2013/mattbw/backend/query.c Sat Jul 6 07:09:02 2013 (r254218)
+++ soc2013/mattbw/backend/query.c Sat Jul 6 07:38:41 2013 (r254219)
@@ -208,7 +208,8 @@
jobs = NULL;
err = pkg_jobs_new(&jobs, type, q->db);
if (err == EPKG_OK) {
- err = pkg_jobs_set_repository(jobs, q->data);
+ if (q->data != NULL)
+ err = pkg_jobs_set_repository(jobs, q->data);
if (err == EPKG_OK) {
err = jobs_add_pkg(jobs, MATCH_EXACT, pkg);
if (err == EPKG_OK)
@@ -217,10 +218,9 @@
pk_backend_error_code(q->backend,
PK_ERROR_ENUM_INTERNAL_ERROR,
"could not add to job");
-
} else
pk_backend_error_code(q->backend,
- PK_ERROR_ENUM_INTERNAL_ERROR,
+ PK_ERROR_ENUM_REPO_NOT_FOUND,
"could not set repo");
} else
@@ -427,6 +427,7 @@
{
char *name;
+ name = NULL;
pkg_get(pkg, PKG_NAME, &name);
return pkg_jobs_add(jobs, type, &name, 1);
}
More information about the svn-soc-all
mailing list