[darwinbuild-changes] [1036] trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu May 17 15:57:34 PDT 2012


Revision: 1036
          http://trac.macosforge.org/projects/darwinbuild/changeset/1036
Author:   mww at apple.com
Date:     2012-05-17 15:57:34 -0700 (Thu, 17 May 2012)
Log Message:
-----------
darwinup: Updated trigger for xpchelper cacher rebuild.

Modified Paths:
--------------
    trunk/darwinup/Utils.cpp
    trunk/darwinup/Utils.h
    trunk/darwinup/main.cpp

Property Changed:
----------------
    trunk/


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/PR-10008999:984
/branches/PR-10307836:993-996
/branches/PR-10363375:959-960
/branches/PR-10397485:967
/branches/PR-10412052:973-975
/branches/PR-10412066:974-975
/branches/PR-10428083:994-997
/branches/PR-10431324:979-980
/branches/PR-10821792:1007-1010
/branches/PR-10827653:1021
/branches/PR-10830883:1015
/branches/PR-11042608:1025
/branches/PR-11056762:1031
/branches/PR-4841388:399-419
/branches/PR-6358021:442-443
/branches/PR-6392966:423-427
/branches/PR-6398060:433-434
/branches/PR-6493844:460-461
/branches/PR-6497694:466-468,471
/branches/PR-6634286:632-650
/branches/PR-6688645:479-490
/branches/PR-6722857:495-499
/branches/PR-6729491:655-664
/branches/PR-6973110:804-813
/branches/PR-7250612:635-650
/branches/PR-7341154:682-694
/branches/PR-7431723:660-664
/branches/PR-7461534:650-664
/branches/PR-7482850:670-671
/branches/PR-7489777:676-731
/branches/PR-7529688:692-694
/branches/PR-7593824:739-772
/branches/PR-7598640:703-731
/branches/PR-7748469:777-785
/branches/PR-7765119:790-791
/branches/PR-7798586:796-799
/branches/PR-7872907:830-840
/branches/PR-7935095:819-821
/branches/PR-8116613:849
/branches/PR-8279204:854-862
/branches/PR-8416637:870-880
/branches/PR-8486662:885-889
/branches/PR-8488185:894-898
/branches/PR-8604911:903-905
/branches/PR-8817822:917-933
/branches/PR-8908468:912
/branches/PR-9697169:1004-1008
/branches/PR-9709247:1002-1009
   + /branches/PR-10008999:984
/branches/PR-10307836:993-996
/branches/PR-10363375:959-960
/branches/PR-10397485:967
/branches/PR-10412052:973-975
/branches/PR-10412066:974-975
/branches/PR-10428083:994-997
/branches/PR-10431324:979-980
/branches/PR-10821792:1007-1010
/branches/PR-10827653:1021
/branches/PR-10830883:1015
/branches/PR-11042608:1025
/branches/PR-11056762:1031
/branches/PR-11283366:1035
/branches/PR-4841388:399-419
/branches/PR-6358021:442-443
/branches/PR-6392966:423-427
/branches/PR-6398060:433-434
/branches/PR-6493844:460-461
/branches/PR-6497694:466-468,471
/branches/PR-6634286:632-650
/branches/PR-6688645:479-490
/branches/PR-6722857:495-499
/branches/PR-6729491:655-664
/branches/PR-6973110:804-813
/branches/PR-7250612:635-650
/branches/PR-7341154:682-694
/branches/PR-7431723:660-664
/branches/PR-7461534:650-664
/branches/PR-7482850:670-671
/branches/PR-7489777:676-731
/branches/PR-7529688:692-694
/branches/PR-7593824:739-772
/branches/PR-7598640:703-731
/branches/PR-7748469:777-785
/branches/PR-7765119:790-791
/branches/PR-7798586:796-799
/branches/PR-7872907:830-840
/branches/PR-7935095:819-821
/branches/PR-8116613:849
/branches/PR-8279204:854-862
/branches/PR-8416637:870-880
/branches/PR-8486662:885-889
/branches/PR-8488185:894-898
/branches/PR-8604911:903-905
/branches/PR-8817822:917-933
/branches/PR-8908468:912
/branches/PR-9697169:1004-1008
/branches/PR-9709247:1002-1009

Modified: trunk/darwinup/Utils.cpp
===================================================================
--- trunk/darwinup/Utils.cpp	2012-05-17 22:56:27 UTC (rev 1035)
+++ trunk/darwinup/Utils.cpp	2012-05-17 22:57:34 UTC (rev 1036)
@@ -371,38 +371,60 @@
 	res = find_base_system_path(&base, path);
 	if (res) return res;
 
-	// xpchelper expects the --root value to *not* end in a slash.
-	if (has_suffix(base, "/")) {
-		char *ptr = strrchr(base, '/');
-		if (ptr) {
-			*ptr = '\0';
-		}
-	}
-
-	if (verbosity) {
-		fprintf(stdout, "Updating xpc services cache for %s ...", base);
-		fflush(stdout);
-	}
-
 	char* toolpath;
 	join_path(&toolpath, base, "/usr/libexec/xpchelper");
 
 	struct stat sb;
 	res = stat(toolpath, &sb);
-	if (res) {
-		return 1;
-	}
+	if (res || ((sb.st_mode & S_IXUSR) == 0)) {
+		// no xpchelper
+		char* cachedir;
+		join_path(&cachedir, base, "/System/Library/Caches/com.apple.xpcd");
 
-	const char* args[] = {
-		toolpath,
-		"--rebuild-cache",
-		"--root", base,
-		NULL
-	};
-	res = exec_with_args(args);
+		res = mkdir_p(cachedir);
+		if (!res || errno == EEXIST) {
+			char* cachepath;
+			join_path(&cachepath, cachedir, "xpcd_cache.dylib");
 
-	if (verbosity) fprintf(stdout, "Done updating xpc cache\n");
+			res = open(cachepath, O_APPEND | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+			if (res >= 0) {
+				close(res);
+			} else {
+				fprintf(stderr, "Error: (%d) failed to touch cache file.\n", errno);
+				res = errno;
+			}
+			free(cachepath);
+		} else {
+			res = errno;
+			fprintf(stderr, "Error: (%d) failed to mkdir_p cache directory.\n", res);
+		}
+		if (verbosity) fprintf(stdout, "Touched xpc cache file.\n");
+		free(cachedir);
+	} else {
+		// xpchelper expects the --root value to *not* end in a slash.
+		if (has_suffix(base, "/")) {
+			char *ptr = strrchr(base, '/');
+			if (ptr) {
+				*ptr = '\0';
+			}
+		}
 
+		if (verbosity) {
+			fprintf(stdout, "Updating xpc services cache for %s ...", base);
+			fflush(stdout);
+		}
+
+		const char* args[] = {
+			toolpath,
+			"--rebuild-cache",
+			"--root", base,
+			NULL
+		};
+		res = exec_with_args(args);
+
+		if (verbosity) fprintf(stdout, "Done updating xpc cache\n");
+	}
+
 	free(toolpath);
 	free(base);
 	return res;

Modified: trunk/darwinup/Utils.h
===================================================================
--- trunk/darwinup/Utils.h	2012-05-17 22:56:27 UTC (rev 1035)
+++ trunk/darwinup/Utils.h	2012-05-17 22:57:34 UTC (rev 1036)
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <libgen.h>
 #include <limits.h>
 #include <stdlib.h>

Modified: trunk/darwinup/main.cpp
===================================================================
--- trunk/darwinup/main.cpp	2012-05-17 22:56:27 UTC (rev 1035)
+++ trunk/darwinup/main.cpp	2012-05-17 22:57:34 UTC (rev 1036)
@@ -107,8 +107,8 @@
 int main(int argc, char* argv[]) {
 	char* progname = strdup(basename(argv[0]));      
 	char* path = NULL;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 	bool disable_automation = false;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 	bool restart = false;
 #endif
 	
@@ -119,19 +119,15 @@
 	while ((ch = getopt(argc, argv, "fnp:vh")) != -1) {		
 #endif
 		switch (ch) {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060	
 		case 'd':
 				disable_automation = true;
 				break;
-#endif
 		case 'f':
 				force = 1;
 				break;
 		case 'n':
 				dryrun = 1;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 				disable_automation = true;
-#endif
 				break;
 		case 'p':
 				if (optarg[0] != '/') {
@@ -167,8 +163,8 @@
 
 	if (dryrun) IF_DEBUG("option: dry run\n");
 	if (force)  IF_DEBUG("option: forcing operations\n");
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 	if (disable_automation) IF_DEBUG("option: helpful automation disabled\n");
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     if (restart) IF_DEBUG("option: restart when finished\n");
 #endif
 	
@@ -282,13 +278,11 @@
 			free(sle_path);
 		}
 #endif
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 		if (!disable_automation && depot->has_modified_xpc_services() && res == 0) {
 			res = update_xpc_services_cache(path);
 			if (res) fprintf(stderr, "Warning: could not update xpc services cache.\n");
 			res = 0;
 		}
-#endif
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 		if (restart && res == 0) {
 			res = tell_finder_to_restart();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20120517/7d195cf9/attachment-0001.html>


More information about the darwinbuild-changes mailing list