From owner-p4-projects@FreeBSD.ORG Wed Aug 4 21:23:25 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 518EF1065676; Wed, 4 Aug 2010 21:23:25 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F20011065670 for ; Wed, 4 Aug 2010 21:23:24 +0000 (UTC) (envelope-from jlaffaye@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id DE9288FC12 for ; Wed, 4 Aug 2010 21:23:24 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id o74LNO4o060882 for ; Wed, 4 Aug 2010 21:23:24 GMT (envelope-from jlaffaye@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id o74LNO3d060880 for perforce@freebsd.org; Wed, 4 Aug 2010 21:23:24 GMT (envelope-from jlaffaye@FreeBSD.org) Date: Wed, 4 Aug 2010 21:23:24 GMT Message-Id: <201008042123.o74LNO3d060880@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jlaffaye@FreeBSD.org using -f From: Julien Laffaye To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 181848 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2010 21:23:25 -0000 http://p4web.freebsd.org/@@181848?ac=10 Change 181848 by jlaffaye@jlaffaye-chulak on 2010/08/04 21:23:05 Abort a complete package installation if a package in the set failed to install. A 'already installed with the same version' error is not a valid justification to abort a complete package installation. Thus, extract_archive() returns a special error code in this case. Affected files ... .. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/complete.c#2 edit .. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/extract.c#14 edit .. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#13 edit Differences ... ==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/complete.c#2 (text+ko) ==== @@ -49,14 +49,19 @@ archive_read_finish(a); return (1); } - retcode += extract_package(a, &pkg, data->fname); + retcode = extract_package(a, &pkg, data->fname); free_plist(&pkg); + if (retcode == 1) { + warnx("aborting complete package installation."); + archive_read_finish(a); + return (1); + } } archive_read_finish(a); } - return (retcode); + return (0); } static ssize_t ==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/extract.c#14 (text+ko) ==== @@ -36,8 +36,17 @@ char db_dir_tmp[FILENAME_MAX]; char db_dir[FILENAME_MAX]; +/* + * Extract and parse the plist of a package archive. + * The archive `a' must be opened by libarchive, with its internal iterator + * at CONTENTS_FNAME position. `archive_entry' must be a valid libarchive + * representation of this entry. + * The plist is stored in `pkg'. + * Returns 0 on success, 1 otherwise. + */ int -extract_plist(struct archive *a, struct archive_entry *entry, Package *pkg) { +extract_plist(struct archive *a, struct archive_entry *entry, Package *pkg) +{ char *plist_buf; ssize_t s; int retcode; @@ -65,6 +74,12 @@ return (0); } +/* + * Extract a package `fname' already opened via libarchive in `a'. + * The internal libarchive iterator of `a' must be at the plist entry position. + * Returns 0 on success, 1 on error, 2 if the package is already installed with + * the same version. + */ int extract_package(struct archive *a, Package *pkg, const char *fname) { @@ -111,10 +126,14 @@ * See if we're already registered either with the same name (the same * version) or some other version with the same origin. */ - if ((isinstalledpkg(pkg->name) > 0 || - matchbyorigin(pkg->origin, NULL) != NULL) && !Force) { - warnx("package '%s' or its older version already installed%s", - pkg->name, FailOnAlreadyInstalled ? "" : " (ignored)"); + if (!Force && isinstalledpkg(pkg->name) > 0) { + warnx("package '%s' already installed%s", pkg->name, + FailOnAlreadyInstalled ? "!" : " (ignored)"); + if (FailOnAlreadyInstalled == TRUE) + return (2); + } else if (!Force && matchbyorigin(pkg->origin, NULL) != NULL) { + warnx("an other version of '%s' is already installed%s", + pkg->origin, FailOnAlreadyInstalled ? "!" : " (ignored)"); if (FailOnAlreadyInstalled == TRUE) return (1); } ==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#13 (text+ko) ==== @@ -110,7 +110,8 @@ retcode = 1; goto cleanup; } - retcode = extract_package(a, &pkg, fname); + if (extract_package(a, &pkg, fname) != 0) + retcode = 1; free_plist(&pkg); } else if (strcmp(pathname, PKG_COMPLETE_FNAME) == 0) { if (Verbose)