socsvn commit: r255153 - soc2013/mattbw/backend/actions
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Thu Jul 25 10:02:03 UTC 2013
Author: mattbw
Date: Thu Jul 25 10:02:02 2013
New Revision: 255153
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255153
Log:
(untested) actually add the update_packages unit
Added:
soc2013/mattbw/backend/actions/update_packages.c
Added: soc2013/mattbw/backend/actions/update_packages.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2013/mattbw/backend/actions/update_packages.c Thu Jul 25 10:02:02 2013 (r255153)
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (C) 2013 Matt Windsor <mattbw at FreeBSD.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <assert.h> /* assert */
+#include <glib.h> /* gboolean */
+#include <stdbool.h> /* bool, true, false */
+#include "../pk-backend.h" /* pk..., Pk... */
+#include "pkg.h" /* pkg... */
+
+#include "../actions.h" /* update_packages_thread prototype */
+#include "../pkgutils.h" /* pkgutils_... */
+#include "../query.h" /* query_... */
+
+static bool job(struct pkg_jobs *jobs, struct query *q);
+static bool sim_job(struct pkg_jobs *jobs, struct query *q);
+
+/*
+ * The thread that performs an UpdatePackages operation. Should be invoked
+ * by the pk_backend_update_packages hook.
+ */
+gboolean
+update_packages_thread(PkBackend *backend)
+{
+ bool success;
+
+ assert(backend != NULL);
+
+ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+ success = query_match_id_to_job(backend, PKG_JOBS_INSTALL, job);
+
+ (void)pk_backend_finished(backend);
+ return success ? TRUE : FALSE;
+}
+
+/*
+ * The thread that performs a SimulateUpdatePackages operation. Should be
+ * invoked by the pk_backend_simulate_update_packages hook.
+ */
+gboolean
+simulate_update_packages_thread(PkBackend *backend)
+{
+ bool success;
+
+ assert(backend != NULL);
+
+ (void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+ success = query_match_id_to_job(backend, PKG_JOBS_UPGRADE, sim_job);
+
+ (void)pk_backend_finished(backend);
+ return success ? TRUE : FALSE;
+}
+
+/*
+ * Tries to process the given solved installation jobs.
+ */
+static bool
+job(struct pkg_jobs *jobs, struct query *q)
+{
+
+ assert(jobs != NULL);
+ assert(q != NULL);
+
+ return query_jobs_apply_emitter(jobs,
+ q,
+ PK_STATUS_ENUM_UPDATE,
+ PK_ERROR_ENUM_NO_PACKAGES_TO_UPDATE,
+ PK_ERROR_ENUM_PACKAGE_FAILED_TO_INSTALL);
+}
+
+/*
+ * Tries to simulate processing the given installation jobs.
+ */
+static bool
+sim_job(struct pkg_jobs *jobs, struct query *q)
+{
+
+ assert(jobs != NULL);
+ assert(q != NULL);
+
+ return query_jobs_simulate_emitter(jobs,
+ q,
+ pkgutils_pkg_install_state);
+}
More information about the svn-soc-all
mailing list