PERFORCE change 152360 for review

Anders Nore andenore at FreeBSD.org
Sun Nov 2 08:14:28 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=152360

Change 152360 by andenore at 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 at FreeBSD.org
+ */
+
 
 #include <stdio.h>
+#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);
+}


More information about the p4-projects mailing list