--- pacman-2.9.8/src/pacman.c.ori	2006-05-10 20:58:27.000000000 +0200
+++ pacman-2.9.8/src/pacman.c	2006-05-11 18:48:44.000000000 +0200
@@ -1936,7 +1936,7 @@
 				/* file already exists */
 				if(is_in(pathname, pmo_noupgrade)) {
 					notouch = 1;
-				} else {
+				}
 					if(!pmo_upgrade || oldpkg == NULL) {
 						nb = is_in(pathname, info->backup) ? 1 : 0;
 					} else {
@@ -1947,7 +1947,6 @@
 						}
 					}
 				}
-			}
 
 			if(nb) {
 				char *temp;
@@ -1990,6 +1989,43 @@
 					vprint("  original: %s\n", md5_orig);
 				}
 
+				if(notouch) {
+					/* The config file is in NoUpgrade, so we don't touch it,
+					 * and only extract it as .pacnew when needed */
+					int newconfig = 0;
+					vprint("%s is a config file in NoUpgrade\n", expath);
+				if(!pmo_upgrade) {
+					/* PM_ADD */
+
+					/* if a file already exists with a different md5 hash,
+					 * then we will extract the config */
+					if(!strcmp(md5_local, md5_pkg)) {
+						vprint("config file is the same as current one, not extracting...\n");
+					} else {
+						newconfig = 1;
+					}
+				} else if(md5_orig) {					
+					/* PM_UPGRADE */
+
+					/* If the config file has changed since the old one,
+					 * then we extract it */
+					if(!strcmp(md5_orig, md5_pkg)) {
+						vprint("config file is the same as the previous one, not extracting...\n");
+					} else {
+						newconfig = 1;
+					}
+				}
+					if(newconfig) {
+						vprint("  action: leaving file in place, installing new one as .pacnew\n");
+						strncat(expath, ".pacnew", PATH_MAX);
+						logaction(stderr, "warning: extracting %s%s as %s", pmo_root, pathname, expath);
+						if(copyfile(temp, expath)) {
+							fprintf(stderr, "error: could not copy %s to %s: %s\n", temp, expath, strerror(errno));
+							errors++;
+						}
+					}
+				} else {
+					/* The config file isn't in NoUpgrade, thus default config handling */
 				if(!pmo_upgrade) {
 					/* PM_ADD */
 
@@ -2041,6 +2077,7 @@
 						}
 					}
 				}
+				}
 
 				FREE(md5_local);
 				FREE(md5_pkg);
