Skip site navigation (1)Skip section navigation (2)
Date:      02 Jul 2000 03:19:46 -0700
From:      asami@FreeBSD.ORG (Satoshi - Ports Wraith - Asami)
To:        "Scot W. Hetzel" <hetzels@westbend.net>
Cc:        "FreeBSD Ports" <ports@FreeBSD.ORG>
Subject:   Re: NOPORTDOCS handling
Message-ID:  <vqcn1k07s1p.fsf@silvia.hip.berkeley.edu>
In-Reply-To: "Scot W. Hetzel"'s message of "Wed, 7 Jun 2000 20:36:55 -0500 (CDT)"
References:  <200006080136.UAA19272@wbiw01.westbend.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Has anyone tried or reviewed this patch?  I'd like to get some reports
before I decide whether I go with this one or with my mini-patch to
bsd.port.mk.  My version obviously won't fix the pkg_* tools so this
one, if it works as advertised, is preferable.

Satoshi
-------
Delivered-To: asami@freebsd.org
Date: Wed, 7 Jun 2000 20:36:55 -0500 (CDT)
From: "Scot W. Hetzel" <hetzels@westbend.net>
Cc: "FreeBSD Ports" <ports@FreeBSD.ORG>
Sender: hetzels@wbiw01.westbend.net
X-UIDL: 4d7affa78938206ffc2205eee3f02759
Lines: 642

From: "Satoshi - Ports Wraith - Asami" <asami@FreeBSD.ORG>
> * From: lioux@uol.com.br
> 
>  * What about adding direct support to PLIST preprocessing.
>  * Sort of @document.
>  * Sort of adding Satoshi's script to PLIST handling.
> 
> Well, if someone can come up with necessary patches to pkg_* for this,
> I'm all ears.  Otherwise, I'll commit my little patch..
> 


OK, heres a start of a patch for the pkg_* tools that suposed to handle the
@doc, @configext, and @config directives.

@doc       - depends on a environment variable (NOPORTDOCS)  being defined or
    "@option noportdocs" in PLIST, when deciding if port documents are to be
    packaged or installed. NOTE: When deleteing a port, we only obey "@option
    noportdocs" in the +CONTENTS file when deciding wheter to delete the port
    documentation.

@configext - Config file extention, defaults to "-dist".  Note: @configex
    changes the default config extentions for all proceeding @config
    directives.

@config    - Specifies the name of the config file without the extention.  The
    @configext is automatically appended to the @config filename when packaging
    (NOTE:  If config extentions is not "-dist", then @configext must be defined
    before the @config directive."

I haven't had the time to test these new pkg_* tools to see if they work as
planed.

Also, I'm not sure if I have the install_file routine correct in add/extract.c.
Will the "where_count", "where_args", "perm_count", "perm_args" variables need
to be passed back/forth between the install_file and extract_plist routines?

I also cheated a little with "case PLIST_CONFIG" check in extract_plist, I
borrowed from "case PLIST_EXEC" the ability to run a script.  This builtin
script gets executed ( "[ ! -f \%B/\%f ] && cp \%B/\%f%s \%B/\%f", ConfigExt )
during a pkg_add to determine if the config file already exists, this probably
should be changed.

Scot

PS.  I'll probablly test this patch on saturday, unless someone beats me too it.


NOTE: These patches are for CURRENT as of today (6/7/2000).

diff -ruN --exclude=CVS pkg_install.orig/add/extract.c pkg_install/add/extract.c
--- pkg_install.orig/add/extract.c	Wed Jun  7 19:04:39 2000
+++ pkg_install/add/extract.c	Sat Jun  3 20:22:35 2000
@@ -82,8 +82,10 @@
     PackingList p = pkg->head;
     char *last_file;
     char *where_args, *perm_args, *last_chdir;
-    int maxargs, where_count = 0, perm_count = 0, add_count;
+    char *ConfigExt = "-dist";
+    int maxargs, where_count = 0, perm_count = 0;
     Boolean preserve;
+    Boolean noportdocs;
 
     maxargs = sysconf(_SC_ARG_MAX) / 2;	/* Just use half the argument space */
     where_args = alloca(maxargs);
@@ -103,6 +105,7 @@
 
     last_chdir = 0;
     preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE;
+    noportdocs = find_plist_option(pkg, "noportdocs") ? TRUE : getenv("NOPORTDOCS") != NULL ? TRUE : FALSE;
 
     /* Reset the world */
     Owner = NULL;
@@ -122,79 +125,55 @@
 		printf("extract: Package name is %s\n", p->name);
 	    break;
 
-	case PLIST_FILE:
+	case PLIST_CONFIGEXT:
+	    ConfigExt = p->name;
+	    break;
+
+	case PLIST_CONFIG:
+	    {
+	    char configfile[FILENAME_MAX];
+	    char tmp[FILENAME_MAX];
+
 	    last_file = p->name;
+	    snprintf(configfile, FILENAME_MAX, "%s%s", p->name, ConfigExt);
 	    if (Verbose)
-		printf("extract: %s/%s\n", Directory, p->name);
-	    if (!Fake) {
-		char try[FILENAME_MAX];
+		printf("extract: %s/%s\n", Directory, configfile);
+	    if (installfile(p, configfile, Directory, where_count, where_args, perm_count, perm_args, preserve, last_chdir)) {
+		rollback(PkgName, home, pkg->head, p);
+		return;
+	    }
+	    snprintf(tmp, FILENAME_MAX, "[ ! -f \%B/\%f ] && cp \%B/\%f%s \%B/\%f", ConfigExt);
+            format_cmd(cmd, tmp, Directory, last_file);
+            PUSHOUT(Directory);
+            if (Verbose)
+                printf("extract: execute '%s'\n", cmd);
+            if (!Fake && system(cmd))
+                warnx("command '%s' failed", cmd);
+	    }
+            break;
 
-		if (strrchr(p->name,'\'')) {
-		  cleanup(0);
-		  errx(2, "Bogus filename \"%s\"", p->name);
-		}
-		
-		/* first try to rename it into place */
-		snprintf(try, FILENAME_MAX, "%s/%s", Directory, p->name);
-		if (fexists(try)) {
-		    (void)chflags(try, 0);	/* XXX hack - if truly immutable, rename fails */
-		    if (preserve && PkgName) {
-			char pf[FILENAME_MAX];
-
-			if (make_preserve_name(pf, FILENAME_MAX, PkgName, try)) {
-			    if (rename(try, pf)) {
-				warnx(
-				"unable to back up %s to %s, aborting pkg_add",
-				try, pf);
-				rollback(PkgName, home, pkg->head, p);
-				return;
-			    }
-			}
-		    }
-		}
-		if (rename(p->name, try) == 0) {
-		    /* try to add to list of perms to be changed and run in bulk. */
-		    if (p->name[0] == '/' || TOOBIG(p->name)) {
-			PUSHOUT(Directory);
-		    }
-		    add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", p->name);
-		    if (add_count > maxargs - perm_count) {
-			cleanup(0);
-			errx(2, "oops, miscounted strings!");
-		    }
-		    perm_count += add_count;
-		}
-		else {
-		    /* rename failed, try copying with a big tar command */
-		    if (last_chdir != Directory) {
-			if (last_chdir == NULL) {
-			    PUSHOUT(Directory);
-			} else {
-			    PUSHOUT(last_chdir);
-			}
-			last_chdir = Directory;
-		    }
-		    else if (p->name[0] == '/' || TOOBIG(p->name)) {
-			PUSHOUT(Directory);
-		    }
-		    add_count = snprintf(&where_args[where_count], maxargs - where_count, " '%s'", p->name);
-		    if (add_count > maxargs - where_count) {
-			cleanup(0);
-			errx(2, "oops, miscounted strings!");
-		    }
-		    where_count += add_count;
-		    add_count = snprintf(&perm_args[perm_count],
-					 maxargs - perm_count,
-					 "'%s' ", p->name);
-		    if (add_count > maxargs - perm_count) {
-			cleanup(0);
-			errx(2, "oops, miscounted strings!");
-		    }
-		    perm_count += add_count;
+	case PLIST_DOC:
+	    if (!noportdocs) {
+		last_file = p->name;
+		if (Verbose)
+		    printf("extract: %s/%s\n", Directory, p->name);
+		if (installfile(p, p->name, Directory, where_count, where_args, perm_count, perm_args, preserve, &last_chdir)) {
+		    rollback(PkgName, home, pkg->head, p);
+		    return;
 		}
 	    }
 	    break;
 
+	case PLIST_FILE:
+	    last_file = p->name;
+	    if (Verbose)
+		printf("extract: %s/%s\n", Directory, p->name);
+	    if (installfile(p, p->name, Directory, where_count, where_args, perm_count, perm_args, preserve, &last_chdir)) {
+		rollback(PkgName, home, pkg->head, p);
+		return;
+	    }
+	    break;
+
 	case PLIST_CWD:
 	    if (Verbose)
 		printf("extract: CWD to %s\n", p->name);
@@ -253,4 +232,82 @@
 	p = p->next;
     }
     PUSHOUT(Directory);
+}
+
+
+int
+installfile(PackingList p, char *file, char* Directory, int where_count, char *where_args, int perm_count, char *perm_args, Boolean preserve, char **last_chdir)
+{
+    int add_count;
+    int maxargs;
+
+    maxargs = sysconf(_SC_ARG_MAX) / 2;
+
+    if (!Fake) {
+	char try[FILENAME_MAX];
+
+	if (strrchr(file,'\'')) {
+	  cleanup(0);
+	  errx(2, "Bogus filename \"%s\"", file);
+	}
+		
+	/* first try to rename it into place */
+	snprintf(try, FILENAME_MAX, "%s/%s", Directory, file);
+	if (fexists(try)) {
+	    (void)chflags(try, 0);	/* XXX hack - if truly immutable, rename fails */
+	    if (preserve && PkgName) {
+		char pf[FILENAME_MAX];
+
+		if (make_preserve_name(pf, FILENAME_MAX, PkgName, try)) {
+		    if (rename(try, pf)) {
+			warnx(
+			"unable to back up %s to %s, aborting pkg_add",
+			try, pf);
+			return FAIL;
+		    }
+		}
+	    }
+	}
+	if (rename(file, try) == 0) {
+	    /* try to add to list of perms to be changed and run in bulk. */
+	    if (file[0] == '/' || TOOBIG(file)) {
+		PUSHOUT(Directory);
+	    }
+	    add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", file);
+	    if (add_count > maxargs - perm_count) {
+		cleanup(0);
+		errx(2, "oops, miscounted strings!");
+	    }
+	    perm_count += add_count;
+	}
+	else {
+	    /* rename failed, try copying with a big tar command */
+	    if ( *last_chdir != Directory) {
+		if (last_chdir == NULL) {
+		    PUSHOUT(Directory);
+		} else {
+		    PUSHOUT(*last_chdir);
+		}
+		*last_chdir = Directory;
+	    }
+	    else if (file[0] == '/' || TOOBIG(file)) {
+		PUSHOUT(Directory);
+	    }
+	    add_count = snprintf(&where_args[where_count], maxargs - where_count, " '%s'", file);
+	    if (add_count > maxargs - where_count) {
+		cleanup(0);
+		errx(2, "oops, miscounted strings!");
+	    }
+	    where_count += add_count;
+	    add_count = snprintf(&perm_args[perm_count],
+				 maxargs - perm_count,
+				 "'%s' ", file);
+	    if (add_count > maxargs - perm_count) {
+		cleanup(0);
+		errx(2, "oops, miscounted strings!");
+	    }
+	    perm_count += add_count;
+	}
+    }
+    return SUCCESS;
 }
diff -ruN --exclude=CVS pkg_install.orig/create/create.h pkg_install/create/create.h
--- pkg_install.orig/create/create.h	Wed Jun  7 19:04:40 2000
+++ pkg_install/create/create.h	Sat Jun  3 20:27:48 2000
@@ -44,5 +44,6 @@
 void		check_list(char *, Package *);
 int		pkg_perform(char **);
 void		copy_plist(char *, Package *);
+void		md5comment(char *, PackingList );
 
 #endif	/* _INST_CREATE_H_INCLUDE */
diff -ruN --exclude=CVS pkg_install.orig/create/perform.c pkg_install/create/perform.c
--- pkg_install.orig/create/perform.c	Wed Jun  7 19:04:40 2000
+++ pkg_install/create/perform.c	Sat Jun  3 20:25:16 2000
@@ -108,6 +108,11 @@
 	add_plist(&plist, PLIST_SRC, SrcDir);
     }
 
+    if (getenv("NOPORTDOCS") != NULL) {
+	printf("Ignoring Port Documents\n");
+	add_plist(&plist, PLIST_OPTION, "noportdocs");
+    }
+
     /* Slurp in the packing list */
     read_plist(&plist, pkg_in);
 
@@ -220,6 +225,7 @@
     PackingList p;
     int ret;
     char *args[50];	/* Much more than enough. */
+    char *ConfigExt = "-dist";
     int nargs = 0;
     int pipefds[2];
     FILE *totar;
@@ -296,6 +302,12 @@
 
     for (p = plist->head; p; p = p->next) {
 	if (p->type == PLIST_FILE)
+	    fprintf(totar, "%s\n", p->name);
+	else if (p->type == PLIST_CONFIGEXT)
+	    ConfigExt = p->name;
+	else if (p->type == PLIST_CONFIG)
+	    fprintf(totar, "%s%s\n", p->name, ConfigExt);
+	else if ((p->type == PLIST_DOC) && (getenv("NOPORTDOCS") == NULL))
 	    fprintf(totar, "%s\n", p->name);
 	else if (p->type == PLIST_CWD || p->type == PLIST_SRC)
 	    fprintf(totar, "-C\n%s\n", p->name);
diff -ruN --exclude=CVS pkg_install.orig/create/pl.c pkg_install/create/pl.c
--- pkg_install.orig/create/pl.c	Wed Jun  7 19:04:40 2000
+++ pkg_install/create/pl.c	Sat Jun  3 17:41:35 2000
@@ -35,6 +35,8 @@
 {
     char *where = home;
     char *there = NULL;
+    char *ConfigExt = "-dist";
+    char name[FILENAME_MAX];
     PackingList p = pkg->head;
 
     while (p) {
@@ -42,25 +44,40 @@
 	    where = p->name;
 	else if (p->type == PLIST_IGNORE)
 	    p = p->next;
-	else if (p->type == PLIST_SRC) {
+	else if (p->type == PLIST_SRC)
 	    there = p->name;
+	else if (p->type == PLIST_CONFIGEXT)
+	    ConfigExt = p->name;
+	else if (p->type == PLIST_CONFIG) {
+	    sprintf(name, "%s/%s%s", there ? there : where, p->name, ConfigExt);
+	    md5comment(name, p);
+	}
+	else if ((p->type == PLIST_DOC) && (getenv("NOPORTDOCS") == NULL)) {
+	    sprintf(name, "%s/%s", there ? there : where, p->name);
+	    md5comment(name, p);
 	}
 	else if (p->type == PLIST_FILE) {
-	    char *cp, name[FILENAME_MAX], buf[33];
-
 	    sprintf(name, "%s/%s", there ? there : where, p->name);
-	    if ((cp = MD5File(name, buf)) != NULL) {
-		PackingList tmp = new_plist_entry();
-
-		tmp->name = copy_string(strconcat("MD5:", cp));
-		tmp->type = PLIST_COMMENT;
-		tmp->next = p->next;
-		tmp->prev = p;
-		p->next = tmp;
-		p = tmp;
-	    }
+	    md5comment(name, p);
 	}
 	p = p->next;
+    }
+}
+
+void
+md5comment(char *file, PackingList p)
+{
+    char *cp, buf[33];
+
+    if ((cp = MD5File(file, buf)) != NULL) {
+	PackingList tmp = new_plist_entry();
+
+	tmp->name = copy_string(strconcat("MD5:", cp));
+	tmp->type = PLIST_COMMENT;
+	tmp->next = p->next;
+	tmp->prev = p;
+	p->next = tmp;
+	p = tmp;
     }
 }
 
diff -ruN --exclude=CVS pkg_install.orig/info/show.c pkg_install/info/show.c
--- pkg_install.orig/info/show.c	Wed Jun  7 19:04:40 2000
+++ pkg_install/info/show.c	Sat Jun  3 19:40:25 2000
@@ -86,6 +86,18 @@
 	    continue;
 	}
 	switch(p->type) {
+        case PLIST_CONFIGEXT:
+	    printf(Quiet ? "@configext %s\n" : "\tConfigExt: %s\n", p->name);
+	    break;
+
+	case PLIST_CONFIG:
+	    printf(Quiet ? "@config %s\n" : "\tConfig: %s\n", p->name);
+	    break;
+
+	case PLIST_DOC:
+	    printf(Quiet ? "@doc %s\n" : "\tDOC: %s\n", p->name);
+	    break;
+
 	case PLIST_FILE:
 	    if (ign) {
 		printf(Quiet ? "%s\n" : "File: %s (ignored)\n", p->name);
@@ -175,13 +187,25 @@
 {
     PackingList p;
     Boolean ign = FALSE;
-    char *dir = ".";
+    char *dir = ".", *ConfigExt = "-dist";
 
     if (!Quiet)
 	printf("%s%s", InfoPrefix, title);
     p = plist->head;
     while (p) {
 	switch(p->type) {
+	case PLIST_CONFIGEXT:
+	    ConfigExt = p->name;
+	    break;
+
+	case PLIST_CONFIG:
+	    printf("%s/%s%s\n", dir, p->name, ConfigExt);
+	    break;
+
+	case PLIST_DOC:
+	    printf("%s/%s\n", dir, p->name);
+	    break;
+
 	case PLIST_FILE:
 	    if (!ign)
 		printf("%s/%s\n", dir, p->name);
diff -ruN --exclude=CVS pkg_install.orig/lib/lib.h pkg_install/lib/lib.h
--- pkg_install.orig/lib/lib.h	Wed Jun  7 19:04:40 2000
+++ pkg_install/lib/lib.h	Sat Jun  3 19:55:09 2000
@@ -84,7 +84,7 @@
     PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE,
     PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
     PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST,
-    PLIST_OPTION
+    PLIST_OPTION, PLIST_CONFIGEXT, PLIST_CONFIG, PLIST_DOC
 };
 typedef enum _plist_t plist_t;
 
@@ -139,6 +139,7 @@
 void		copy_file(char *, char *, char *);
 void		move_file(char *, char *, char *);
 void		copy_hierarchy(char *, char *, Boolean);
+int		delete_file(char *, PackingList , char *, Boolean, Boolean, Boolean);
 int		delete_hierarchy(char *, Boolean, Boolean);
 int		unpack(char *, char *);
 void		format_cmd(char *, char *, char *, char *);
diff -ruN --exclude=CVS pkg_install.orig/lib/plist.c pkg_install/lib/plist.c
--- pkg_install.orig/lib/plist.c	Wed Jun  7 19:04:40 2000
+++ pkg_install/lib/plist.c	Sat Jun  3 19:56:21 2000
@@ -229,6 +229,12 @@
 	return PLIST_DIR_RM;
     else if (!strcmp(cmd, "option"))
 	return PLIST_OPTION;
+    else if (!strcmp(cmd, "configext"))
+	return PLIST_CONFIGEXT;
+    else if (!strcmp(cmd, "config"))
+	return PLIST_CONFIG;
+    else if (!strcmp(cmd, "doc") || !strcmp(cmd, "document"))
+	return PLIST_DOC;
     else
 	return FAIL;
 }
@@ -336,6 +342,18 @@
 	    fprintf(fp, "%coption %s\n", CMD_CHAR, plist->name);
 	    break;
 
+	case PLIST_CONFIGEXT:
+	    fprintf(fp, "%cconfigext %s\n", CMD_CHAR, plist->name);
+	    break;
+
+	case PLIST_CONFIG:
+	    fprintf(fp, "%cconfig %s\n", CMD_CHAR, plist->name);
+	    break;
+
+	case PLIST_DOC:
+	    fprintf(fp, "%cdoc %s\n", CMD_CHAR, plist->name);
+	    break;
+
 	default:
 	    cleanup(0);
 	    errx(2, "unknown command type %d (%s)", plist->type, plist->name);
@@ -355,12 +373,13 @@
 delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
 {
     PackingList p;
-    char *Where = ".", *last_file = "";
+    char *Where = ".", *last_file = "", *ConfigExt = "-dist";
     Boolean fail = SUCCESS;
-    Boolean preserve;
+    Boolean preserve, noportdocs;
     char tmp[FILENAME_MAX], *name = NULL;
 
     preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE;
+    noportdocs= find_plist_option(pkg, "noportdocs") ? TRUE : FALSE;
     for (p = pkg->head; p; p = p->next) {
 	switch (p->type)  {
 	case PLIST_NAME:
@@ -387,50 +406,39 @@
 	    }
 	    break;
 
-	case PLIST_FILE:
+	case PLIST_CONFIGEXT:
+	    ConfigExt = p->name;
+	    if (Verbose)
+		printf("Using %s as extention to config files.\n", ConfigExt);
+	    break;
+
+	case PLIST_CONFIG:
 	    last_file = p->name;
-	    sprintf(tmp, "%s/%s", Where, p->name);
-	    if (isdir(tmp) && fexists(tmp)) {
-		warnx("cannot delete specified file `%s' - it is a directory!\n"
-	   "this packing list is incorrect - ignoring delete request", tmp);
+	    sprintf(tmp, "%s/%s%s", Where, p->name, ConfigExt);
+	    if (delete_file(tmp, p, name, ign_err, nukedirs, preserve)) {
+		sprintf(tmp, "%s/%s", Where, p->name);
+		delete_file(tmp, p, name, ign_err, nukedirs, preserve);
 	    }
-	    else {
-		if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) {
-		    char *cp, buf[33];
+	    else
+		fail = FAIL;
+	    break;
 
-		    if ((cp = MD5File(tmp, buf)) != NULL) {
-			/* Mismatch? */
-			if (strcmp(cp, p->next->name + 4)) {
-			    if (Verbose)
-				printf("%s fails original MD5 checksum - %s\n",
-				       tmp, Force ? "deleted anyway." : "not deleted.");
-			    if (!Force) {
-				fail = FAIL;
-				continue;
-			    }
-			}
-		    }
-		}
-		if (Verbose)
-		    printf("Delete file %s\n", tmp);
-		if (!Fake) {
-		    if (delete_hierarchy(tmp, ign_err, nukedirs))
-			fail = FAIL;
-		    if (preserve && name) {
-			char tmp2[FILENAME_MAX];
-			    
-			if (make_preserve_name(tmp2, FILENAME_MAX, name, tmp)) {
-			    if (fexists(tmp2)) {
-				if (rename(tmp2, tmp))
-				   warn("preserve: unable to restore %s as %s",
-					tmp2, tmp);
-			    }
-			}
-		    }
-		}
+	case PLIST_DOC:
+	    if (!noportdocs) {
+		last_file = p->name;
+		sprintf(tmp, "%s/%s", Where, p->name);
+		if (!delete_file(tmp, p, name, ign_err, nukedirs,  preserve))
+		    fail = FAIL;
 	    }
 	    break;
 
+	case PLIST_FILE:
+	    last_file = p->name;
+	    sprintf(tmp, "%s/%s", Where, p->name);
+	    if (!delete_file(tmp, p, name, ign_err, nukedirs, preserve))
+		fail = FAIL;
+	    break;
+
 	case PLIST_DIR_RM:
 	    sprintf(tmp, "%s/%s", Where, p->name);
 	    if (!isdir(tmp) && fexists(tmp)) {
@@ -447,6 +455,52 @@
 	    }
 	    last_file = p->name;
 	    break;
+	}
+    }
+    return fail;
+}
+
+int
+delete_file(char *file, PackingList p, char *name, Boolean ign_err, Boolean nukedirs, Boolean preserve)
+{
+    Boolean fail = SUCCESS;
+
+    if (isdir(file) && fexists(file)) {
+	warnx("cannot delete specified file `%s' - it is a directory!\n"
+   "this packing list is incorrect - ignoring delete request", file);
+    }
+    else {
+	if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) {
+	    char *cp, buf[33];
+
+	    if ((cp = MD5File(file, buf)) != NULL) {
+		/* Mismatch? */
+		if (strcmp(cp, p->next->name + 4)) {
+		    if (Verbose)
+			printf("%s fails original MD5 checksum - %s\n",
+			       file, Force ? "deleted anyway." : "not deleted.");
+		    if (!Force) {
+			return FAIL;
+		    }
+		}
+	    }
+	}
+	if (Verbose)
+	    printf("Delete file %s\n", file);
+	if (!Fake) {
+	    if (delete_hierarchy(file, ign_err, nukedirs))
+		fail = FAIL;
+	    if (preserve && name) {
+		char tmp2[FILENAME_MAX];
+		    
+		if (make_preserve_name(tmp2, FILENAME_MAX, name, file)) {
+		    if (fexists(tmp2)) {
+			if (rename(tmp2, file))
+			   warn("preserve: unable to restore %s as %s",
+				tmp2, file);
+		    }
+		}
+	    }
 	}
     }
     return fail;




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?vqcn1k07s1p.fsf>