From owner-svn-soc-all@FreeBSD.ORG Thu Jul 18 13:20:10 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3D2D320B for ; Thu, 18 Jul 2013 13:20:10 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 2EDF8DD0 for ; Thu, 18 Jul 2013 13:20:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IDKA7O032627 for ; Thu, 18 Jul 2013 13:20:10 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6IDKAHV032605 for svn-soc-all@FreeBSD.org; Thu, 18 Jul 2013 13:20:10 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 18 Jul 2013 13:20:10 GMT Message-Id: <201307181320.r6IDKAHV032605@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: r254915 - in 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, 18 Jul 2013 13:20:10 -0000 Author: mattbw Date: Thu Jul 18 13:20:09 2013 New Revision: 254915 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254915 Log: coded RefreshCache; not sure how to proceed to test it Modified: soc2013/mattbw/backend/actions/refresh_cache.c soc2013/mattbw/backend/pk-backend-pkgng.c Modified: soc2013/mattbw/backend/actions/refresh_cache.c ============================================================================== --- soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 12:48:13 2013 (r254914) +++ soc2013/mattbw/backend/actions/refresh_cache.c Thu Jul 18 13:20:09 2013 (r254915) @@ -16,6 +16,35 @@ * 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. + * + * This file contains code from the PKGNG source code (pkg/update.c); + * its copyright notice is as follows: + * + * Copyright (c) 2011-2012 Baptiste Daroussin + * Copyright (c) 2011-2012 Julien Laffaye + * Copyright (c) 2011-2012 Marin Atanasov Nikolov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include /* gboolean */ @@ -26,6 +55,7 @@ #include "../actions.h" /* refresh_cache_thread prototype */ #include "../pkgutils.h" /* pkgutils_... */ #include "../query.h" /* query_... */ +#include "../utils.h" /* STATUS */ /* * The thread that performs a RefreshCache operation. Should be invoked @@ -34,9 +64,26 @@ gboolean refresh_cache_thread(PkBackend *backend) { - bool success; + gboolean force; + int err; + struct pkg_repo *repo; + + err = EPKG_FATAL; + + STATUS(backend, PK_STATUS_ENUM_QUERY); + + force = pk_backend_get_bool(backend, "force"); + + repo = NULL; + while (pkg_repos(&repo) == EPKG_OK) { + err = pkg_update(repo, force); + /* Intentionally silence already-up-to-date errors. */ + if (err == EPKG_UPTODATE) + err = EPKG_OK; + else if (err != EPKG_OK) + break; + } - success = false; pk_backend_finished(backend); - return success ? TRUE : FALSE; + return (err == EPKG_OK) ? TRUE : FALSE; } Modified: soc2013/mattbw/backend/pk-backend-pkgng.c ============================================================================== --- soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 12:48:13 2013 (r254914) +++ soc2013/mattbw/backend/pk-backend-pkgng.c Thu Jul 18 13:20:09 2013 (r254915) @@ -169,7 +169,7 @@ pk_backend_refresh_cache(PkBackend *backend, gboolean force) { - INTENTIONALLY_IGNORE(force); /* not yet supported */ + (void)pk_backend_set_bool(backend, "force", force); THREAD(backend, refresh_cache_thread); }