[darwinbuild-changes] [812] branches/PR-6973110/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 19 14:25:37 PDT 2010


Revision: 812
          http://trac.macosforge.org/projects/darwinbuild/changeset/812
Author:   wsiegrist at apple.com
Date:     2010-04-19 14:25:32 -0700 (Mon, 19 Apr 2010)
Log Message:
-----------
Clean up remote user-host URLs so we get consistent behavior from rsync. Also add --delete to rsync invocation so similarly named roots do not collide.

Modified Paths:
--------------
    branches/PR-6973110/darwinup/Archive.cpp
    branches/PR-6973110/darwinup/Utils.cpp

Modified: branches/PR-6973110/darwinup/Archive.cpp
===================================================================
--- branches/PR-6973110/darwinup/Archive.cpp	2010-04-16 18:26:18 UTC (rev 811)
+++ branches/PR-6973110/darwinup/Archive.cpp	2010-04-19 21:25:32 UTC (rev 812)
@@ -281,16 +281,26 @@
 			return NULL;
 		}
 	} else if (is_userhost_path(path)) {
-		actpath = fetch_userhost(path, tmppath);
+		char* cleanpath;
+		// join with / to ensure all single slashes and a single trailing slash
+		int res = join_path(&cleanpath, path, "/");
+		assert(res==0);
+		size_t pathlen = strlen(cleanpath);
+		// remove trailing slash so rsync behavior is predictable
+		cleanpath[pathlen - 1] = '\0';
+	
+		IF_DEBUG("fetching userhost path from: %s to: %s \n", cleanpath, tmppath);
+		actpath = fetch_userhost(cleanpath, tmppath);
+		IF_DEBUG("fetched %s \n", actpath);
 		if (!actpath) {
 			fprintf(stderr, "Error: could not fetch remote file from: %s \n", path);
 			return NULL;
 		}
+		free(cleanpath);
 	} else {
 		actpath = (char *)path;
 	}
 
-	
 	// make sure the archive exists
 	struct stat sb;
 	int res = stat(actpath, &sb);
@@ -328,7 +338,7 @@
 	} else {
 		fprintf(stderr, "Error: unknown archive type: %s\n", path);
 	}
-	
+
 	if (actpath && actpath != path) free(actpath);
 	return archive;
 }

Modified: branches/PR-6973110/darwinup/Utils.cpp
===================================================================
--- branches/PR-6973110/darwinup/Utils.cpp	2010-04-16 18:26:18 UTC (rev 811)
+++ branches/PR-6973110/darwinup/Utils.cpp	2010-04-19 21:25:32 UTC (rev 812)
@@ -257,18 +257,28 @@
 
 char* fetch_userhost(const char* srcpath, const char* dstpath) {
 	extern uint32_t verbosity;
+
 	char* localfile;
 	int res = join_path(&localfile, dstpath, basename((char*)srcpath));
 	if (!localfile) return NULL;
+	
+	// make sure dstpath has a trailing slash
+	char* cleanpath;
+	res = join_path(&cleanpath, dstpath, "/");
+	if (!cleanpath) return NULL;
 		
+	IF_DEBUG("rsync %s %s %s \n", (verbosity ? "-v" : "-q"), srcpath, cleanpath);
+	
 	const char* args[] = {
 		"/usr/bin/rsync",
 		(verbosity ? "-v" : "-q"),
-		"-a", srcpath,
-		localfile,
+		"-a", "--delete",
+		srcpath,
+		cleanpath,
 		NULL
 	};
 
+	free(cleanpath);
 	if (res == 0) res = exec_with_args(args);
 	if (res == 0) return localfile;
 	return NULL;	
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100419/11207500/attachment.html>


More information about the darwinbuild-changes mailing list