PERFORCE change 145423 for review
Anders Nore
andenore at FreeBSD.org
Fri Jul 18 11:35:42 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=145423
Change 145423 by andenore at andenore_laptop on 2008/07/18 11:35:39
Made function fix_dependencies(pkgname) in lib/deps.c and pkg_create -O
now fixes dependencies.
Affected files ...
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/add/perform.c#6 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/perform.c#7 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/Makefile#2 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/deps.c#3 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#10 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/plist.c#6 edit
Differences ...
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/add/perform.c#6 (text+ko) ====
@@ -492,47 +492,7 @@
* Reconstructs +REQUIRED_BY file for the package to be installed in
* case it has been removed earlier (e.g. pkg_delete -f)
*/
- if (Verbose)
- printf("Recording existing dependency's on %s\n", Plist.name);
- int errcode;
- matched = matchinstalled(MATCH_ALL, NULL, &errcode);
- for (i = 0; matched[i] != NULL; i++) {
- FILE *fp;
- Package nplist;
- char path[PATH_MAX];
-
- /* Skip this package */
- if (strcmp(matched[i], Plist.name) == 0)
- continue;
-
- snprintf(path, sizeof(path), "%s/%s/%s", LOG_DIR, matched[i], CONTENTS_FNAME);
- if ((fp = fopen(path, "r")) == NULL) {
- warn("Could not open %s for reading", path);
- continue;
- }
- read_plist(&nplist, fp);
- fclose(fp);
-
- for (p = nplist.head; p != nplist.tail; p = p->next) {
- if (p->type != PLIST_PKGDEP)
- continue;
- if (strcmp(p->name, Plist.name) == 0) {
- /* Register this package in REQUIRED_BY_FNAME */
- snprintf(path, sizeof(path), "%s/%s/%s", LOG_DIR, Plist.name, REQUIRED_BY_FNAME);
- if ((fp = fopen(path, "a")) == NULL) {
- warn("Could not open %s", path);
- continue;
- }
- fprintf(fp, "%s\n", nplist.name);
- fclose(fp);
- if (Verbose)
- printf("\t %s depends on %s (REGISTERED)\n", p->name, Plist.name);
- }
- }
- free_plist(&nplist);
- free(matched[i]);
- }
- free(matched);
+ fix_dependencies(Plist.name);
/* Make sure pkg_info can read the entry */
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/create/perform.c#7 (text+ko) ====
@@ -244,9 +244,13 @@
if (PlistOnly) {
if (openDatabase(O_CREAT | O_RDWR))
err("Could not open database: %s", DBCACHE_FILE);
-
- plist_add_installtime(&plist);
- check_list(home, &plist);
+ Boolean v = Verbose;
+ Verbose = FALSE;
+ fix_dependencies(plist.name);
+ Verbose = v;
+
+ plist_add_installtime(&plist);
+ check_list(home, &plist);
write_plist(&plist, stdout);
int retval = cache_plist(&plist, FALSE);
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/Makefile#2 (text+ko) ====
@@ -2,8 +2,9 @@
LIB= install
INTERNALLIB=
-SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \
- deps.c version.c pkgwrap.c url.c
+SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c database.c match.c \
+ deps.c version.c pkgwrap.c url.c
+CFLAGS= -g
WARNS?= 3
WFORMAT?= 1
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/deps.c#3 (text+ko) ====
@@ -244,3 +244,59 @@
return retval;
}
+
+/*
+ * Fixes dependencies on the package with name pkgname.
+ * It scans the installed packages, searches for @pkgdep in the +CONTENS file
+ * and see if that matches the given pkgname, if it does then register the
+ * installed package in pkgname's +REQUIRED_BY file.
+ */
+void
+fix_dependencies(char *pkgname)
+{
+ int i;
+ char **matched;
+ PackingList p = NULL;
+ if (Verbose)
+ printf("Recording existing dependency's on %s\n", pkgname);
+ int errcode;
+ matched = matchinstalled(MATCH_ALL, NULL, &errcode);
+ for (i = 0; matched[i] != NULL; i++) {
+ FILE *fp;
+ Package nplist;
+ char path[PATH_MAX];
+
+ bzero(&nplist, sizeof(nplist));
+ /* Skip this package */
+ if (strcmp(matched[i], pkgname) == 0)
+ continue;
+
+ snprintf(path, sizeof(path), "%s/%s/%s", LOG_DIR, matched[i], CONTENTS_FNAME);
+ if ((fp = fopen(path, "r")) == NULL) {
+ warn("fix_dependencies: Could not open %s for reading", path);
+ continue;
+ }
+ read_plist(&nplist, fp);
+ fclose(fp);
+
+ for (p = nplist.head; p != nplist.tail; p = p->next) {
+ if (p->type != PLIST_PKGDEP)
+ continue;
+ if (strcmp(p->name, pkgname) == 0) {
+ /* Register this package in REQUIRED_BY_FNAME */
+ snprintf(path, sizeof(path), "%s/%s/%s", LOG_DIR, pkgname, REQUIRED_BY_FNAME);
+ if ((fp = fopen(path, "a")) == NULL) {
+ warn("fix_dependencies: Could not open %s", path);
+ continue;
+ }
+ fprintf(fp, "%s\n", nplist.name);
+ fclose(fp);
+ if (Verbose)
+ printf("\t %s depends on %s\n", nplist.name, pkgname);
+ }
+ }
+ free_plist(&nplist);
+ free(matched[i]);
+ }
+ free(matched);
+}
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#10 (text+ko) ====
@@ -246,6 +246,7 @@
int sortdeps(char **);
int chkifdepends(const char *, const char *);
int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean);
+void fix_dependencies(char *pkgname);
/* Version */
int verscmp(Package *, int, int);
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/plist.c#6 (text+ko) ====
@@ -310,10 +310,11 @@
}
if (cmd == PLIST_COMMENT && sscanf(cp, "DATE:%d\n", &date) == 1) {
pkg->datetime = date;
+ goto bottom;
}
bottom:
- add_plist(pkg, cmd, cp);
+ add_plist(pkg, cmd, cp);
}
}
@@ -437,7 +438,7 @@
switch (p->type) {
case PLIST_NAME:
name = p->name;
- if (dbRemove(name) != 0)
+ if (dbRemove(name) == -1)
warnx("%s: Failed to remove entry %s from db\n", __func__, name);
break;
More information about the p4-projects
mailing list