Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Aug 2010 02:19:49 GMT
From:      Ivan Voras <ivoras@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 181995 for review
Message-ID:  <201008070219.o772JnQj001091@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@181995?ac=10

Change 181995 by ivoras@ursaminor on 2010/08/07 02:19:45

	Iron out some rough edges for link and directory handling during
	patch creation.

Affected files ...

.. //depot/projects/soc2010/pkg_patch/src/patch/Makefile#31 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#21 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/applypatch.h#21 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#30 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#30 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/main.c#31 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#29 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#29 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.c#14 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.h#13 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#29 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/support.c#28 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/updateweb.c#9 edit
.. //depot/projects/soc2010/pkg_patch/src/patch/updateweb.h#9 edit

Differences ...

==== //depot/projects/soc2010/pkg_patch/src/patch/Makefile#31 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/applypatch.c#21 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/applypatch.h#21 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.c#30 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/hashjob.h#30 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/main.c#31 (text+ko) ====

@@ -125,7 +125,10 @@
 static void
 atexit_handler(void)
 {
-	rm_rf(my_tmp);
+	if (Verbose < 2)
+		rm_rf(my_tmp);
+	else
+		printf("Leaving temp directory behind: %s\n", my_tmp);
 }
 
 

==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.c#29 (text+ko) ====

@@ -66,12 +66,18 @@
 		err(1, "Access error reading file: %s", fnew);
 	
 	snprintf(dold, PATH_MAX, "%s/old", my_tmp);
+	if (access(dold, F_OK) == 0)
+		rm_rf(dold); /* Obliterate any existing temp directories */
 	if (mkdir(dold, 0700) != 0)
 		err(1, "Cannot create directory: %s", dold); 
 	snprintf(dnew, PATH_MAX, "%s/new", my_tmp);
+	if (access(dnew, F_OK) == 0)
+		rm_rf(dnew);
 	if (mkdir(dnew, 0700) != 0)
 		err(1, "Cannot create directory: %s", dnew);
 	snprintf(dpatch, PATH_MAX, "%s/patch", my_tmp);
+	if (access(dpatch, F_OK) == 0) 
+		rm_rf(dpatch);
 	if (mkdir(dpatch, 0700) != 0)
 		err(1, "Cannot create directory: %s", dpatch);
 	
@@ -203,7 +209,7 @@
 			snprintf(tmp, PATH_MAX, "%s/%s", dnew, fl->filename);
 			snprintf(tmp2, PATH_MAX, "%s/%s", dpatch, fl->filename);
 			if (copy_file_absolute(tmp, tmp2) != 0)
-				err(1, "Cannot copy file: %s to file: %s",
+				err(1, "[1] Cannot copy file: %s to file: %s",
 				   tmp, tmp2);
 		}
 	}
@@ -217,7 +223,7 @@
 		snprintf(tmp, PATH_MAX, "%s/%s", dnew, fl->filename);
 		snprintf(tmp2, PATH_MAX, "%s/%s", dpatch, fl->filename);
 		if (copy_file_absolute(tmp, tmp2) != 0)
-			err(1, "Cannot copy file: %s to file: %s", tmp, tmp2);
+			err(1, "[2] Cannot copy file: %s to file: %s", tmp, tmp2);
 	}
 	
 	/* Handle changed files */
@@ -228,7 +234,7 @@
 			snprintf(tmp, PATH_MAX, "%s/%s", dnew, fl->filename);
 			snprintf(tmp2, PATH_MAX, "%s/%s", dpatch, fl->filename);
 			if (copy_file_absolute(tmp, tmp2) != 0)
-				err(1, "Cannot copy file: %s to file: %s", tmp,
+				err(1, "[3] Cannot copy file: %s to file: %s", tmp,
 				    tmp2);
 		}
 	} else {

==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatch.h#29 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.c#14 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/mkpatchdir.h#13 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/pkg_patch.h#29 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/support.c#28 (text+ko) ====

@@ -403,9 +403,18 @@
 	if (lstat(from, &st) != 0)
 		return (errno);
 	
-	if (S_ISLNK(st.st_mode)) {
+	if (S_ISDIR(st.st_mode)) {
+		if (mkdir(to, 0600) != 0) {
+			if (errno != EEXIST)
+				return (-errno);
+		}
+		if (copy_file_attrs(from, &st, to) != 0)
+			return (-errno);
+		return (0);
+	} else if (S_ISLNK(st.st_mode)) {
 		char tmp[PATH_MAX];
 		
+		memset(tmp, 0, sizeof(tmp));
 		if (readlink(from, tmp, PATH_MAX) < 0)
 			return (-errno);
 		if (symlink(tmp, to) < 0)
@@ -778,6 +787,8 @@
 				if (match == CMP_BASE_MATCH) {
 					if (best == CMP_FULL_MATCH)
 						best = CMP_BASE_MATCH;
+					warnx("Expecting %s but found %s",
+					    pl->name, pkglist[i]);
 					found = 1;
 					break;
 				} else if (match == CMP_FULL_MATCH) {

==== //depot/projects/soc2010/pkg_patch/src/patch/updateweb.c#9 (text+ko) ====


==== //depot/projects/soc2010/pkg_patch/src/patch/updateweb.h#9 (text+ko) ====




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