From owner-p4-projects@FreeBSD.ORG Sun Nov 2 16:14:28 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9C5CF106567E; Sun, 2 Nov 2008 16:14:28 +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 47DA41065678 for ; Sun, 2 Nov 2008 16:14:28 +0000 (UTC) (envelope-from andenore@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 35C598FC1E for ; Sun, 2 Nov 2008 16:14:28 +0000 (UTC) (envelope-from andenore@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mA2GES4W083407 for ; Sun, 2 Nov 2008 16:14:28 GMT (envelope-from andenore@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mA2GESoa083405 for perforce@freebsd.org; Sun, 2 Nov 2008 16:14:28 GMT (envelope-from andenore@FreeBSD.org) Date: Sun, 2 Nov 2008 16:14:28 GMT Message-Id: <200811021614.mA2GESoa083405@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andenore@FreeBSD.org using -f From: Anders Nore To: Perforce Change Reviews Cc: Subject: PERFORCE change 152360 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Nov 2008 16:14:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=152360 Change 152360 by andenore@andenore_laptop on 2008/11/02 16:13:50 New method in deps that checks conflicts from packinglist. Improved pkg_upgrade a bit so that it upgrades packages that does not depend on other packages. But it does not 'upgrade' +REQUIRED_BY files. Affected files ... .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/deps.c#5 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#18 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/url.c#9 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/upgrade/Makefile#2 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/upgrade/main.c#2 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/upgrade/pkg_upgrade.1#1 add Differences ... ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/deps.c#5 (text+ko) ==== @@ -247,7 +247,7 @@ /* * Fixes dependencies on the package with name pkgname. - * It scans the installed packages, searches for @pkgdep in the +CONTENS file + * It scans the installed packages, searches for @pkgdep in the +CONTENTS file * and see if that matches the given pkgname, if it does then register the * installed package in pkgname's +REQUIRED_BY file. */ @@ -299,3 +299,41 @@ free_plist(&nplist); } } + +/* + * Returns the number of conflicts found from packinglist and prints them out. + * @param Plist A package-list + * @return number of conflicts found + */ +int +checkConflicts(Package Plist) +{ + int conflictsfound = 0; + char *conflict[2]; + char **matched; + int errcode; + PackingList p = NULL; + + for (p = Plist.head; p != NULL; p = p->next) { + if (p->type == PLIST_CONFLICTS) { + int i; + conflict[0] = strdup(p->name); + conflict[1] = NULL; + matched = matchinstalled(MATCH_GLOB, conflict, &errcode); + free(conflict[0]); + if (errcode == 0 && matched != NULL) { + for (i = 0; matched[i] != NULL; i++) { + if (isinstalledpkg(matched[i]) > 0) { + warnx("package '%s' conflicts with %s", Plist.name, + matched[i]); + conflictsfound = 1; + } + } + } + continue; + } + } + + return conflictsfound; +} + ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#18 (text+ko) ==== @@ -250,6 +250,7 @@ int chkifdepends(const char *, const char *); int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean); void fix_dependencies(char *pkgname); +int checkConflicts(Package); /* Version */ int verscmp(Package *, int, int); ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/url.c#9 (text+ko) ==== @@ -40,7 +40,7 @@ char * fileGetURL(const char *base, const char *spec, int keep_package) { - char *cp, *rp, *tmp, *strippedName; + char *rp, *tmp, *strippedName; char fname[FILENAME_MAX]; char pen[FILENAME_MAX]; char pkg[FILENAME_MAX]; @@ -48,7 +48,6 @@ FILE *ftp; pid_t tpid; int pfd[2], pstat, r, w = 0; - char *hint; int fd, pkgfd = 0; struct url_stat ustat; Boolean gotStat = FALSE; ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/upgrade/Makefile#2 (text+ko) ==== @@ -1,9 +1,9 @@ # $FreeBSD: src/usr.sbin/pkg_install/add/Makefile,v 1.21 2004/08/12 20:06:00 ru Exp $ -PROG= pkg_add -SRCS= main.c perform.c futil.c extract.c +PROG= pkg_upgrade +SRCS= perform.c main.c -CFLAGS+= -I${.CURDIR}/../lib -g +CFLAGS+= -I${.CURDIR}/../lib WARNS?= 3 WFORMAT?= 1 ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/upgrade/main.c#2 (text+ko) ==== @@ -1,7 +1,39 @@ +/* + * pkg_upgrade, upgrading packages. + * @author Anders Nore + * @email andenore@FreeBSD.org + */ + #include +#include "lib.h" +#include "upgrade.h" +/* Globals */ +char PkgUpgradeCmd[MAXPATHLEN]; + +/* Prototypes */ +void usage(char *); + int main(int argc, char *argv[]) { + strlcpy(PkgUpgradeCmd, argv[0], sizeof(PkgUpgradeCmd)); + if (argc < 2) { + usage(argv[0]); + exit(1); + } + + openDatabase(O_RDWR); + atexit(closeDatabase); + pkg_do(argv[1]); + + + return 0; } + +/* Print usage */ +void usage(char *run) +{ + printf("Usage: %s pkg-name\n", run); +}