From owner-svn-soc-all@FreeBSD.ORG Thu Jul 25 10:02:03 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DBECE46E for ; Thu, 25 Jul 2013 10:02:02 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C8B152D1C for ; Thu, 25 Jul 2013 10:02:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6PA2281063823 for ; Thu, 25 Jul 2013 10:02:02 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6PA22Xs063815 for svn-soc-all@FreeBSD.org; Thu, 25 Jul 2013 10:02:02 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 25 Jul 2013 10:02:02 GMT Message-Id: <201307251002.r6PA22Xs063815@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255153 - soc2013/mattbw/backend/actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jul 2013 10:02:03 -0000 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 + * + * 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 */ +#include /* gboolean */ +#include /* 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); +}