[darwinbuild-changes] [839] branches/PR-7872907/darwinup

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 14 13:54:37 PDT 2010


Revision: 839
          http://trac.macosforge.org/projects/darwinbuild/changeset/839
Author:   wsiegrist at apple.com
Date:     2010-06-14 13:54:32 -0700 (Mon, 14 Jun 2010)
Log Message:
-----------
Add -r option to tell finder to restart when finished.

Modified Paths:
--------------
    branches/PR-7872907/darwinup/Utils.cpp
    branches/PR-7872907/darwinup/Utils.h
    branches/PR-7872907/darwinup/darwinup.1
    branches/PR-7872907/darwinup/main.cpp

Modified: branches/PR-7872907/darwinup/Utils.cpp
===================================================================
--- branches/PR-7872907/darwinup/Utils.cpp	2010-06-14 19:13:53 UTC (rev 838)
+++ branches/PR-7872907/darwinup/Utils.cpp	2010-06-14 20:54:32 UTC (rev 839)
@@ -402,6 +402,20 @@
 
 	return -1;
 }
+
+int tell_finder_to_restart() {
+	int res = 0;
+	
+	const char *args[] = {
+		"/usr/bin/osascript", "-e",
+		"tell app \"Finder\" to restart",
+		NULL,
+	};
+	
+	res = exec_with_args(args);
+	
+	return res;
+}
 #endif
 
 void __data_hex(FILE* f, uint8_t* data, uint32_t size) {
@@ -425,4 +439,3 @@
 	fprintf(stdout, "=============================================="
 			"=======================================\n");	
 }
-

Modified: branches/PR-7872907/darwinup/Utils.h
===================================================================
--- branches/PR-7872907/darwinup/Utils.h	2010-06-14 19:13:53 UTC (rev 838)
+++ branches/PR-7872907/darwinup/Utils.h	2010-06-14 20:54:32 UTC (rev 839)
@@ -82,6 +82,7 @@
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 int build_number_for_path(char** build, const char* path);
+int tell_finder_to_restart();
 #endif
 
 void __data_hex(FILE* f, uint8_t* data, uint32_t size);

Modified: branches/PR-7872907/darwinup/darwinup.1
===================================================================
--- branches/PR-7872907/darwinup/darwinup.1	2010-06-14 19:13:53 UTC (rev 838)
+++ branches/PR-7872907/darwinup/darwinup.1	2010-06-14 20:54:32 UTC (rev 839)
@@ -61,6 +61,9 @@
 Prefix path. Normally, darwinup will operate on the boot partition. You
 can use the -p option to have darwinup work on another partition. You
 can provide any arbitrary path, it does not need to be a mount point.
+.It \-r
+Restart. Gracefully restart after all operations are complete by telling
+Finder to restart. 
 .It \-v
 Verbose. This option causes darwinup to print extra information. You can
 pass 2 or 3 v's for even more information, but that is usually only needed

Modified: branches/PR-7872907/darwinup/main.cpp
===================================================================
--- branches/PR-7872907/darwinup/main.cpp	2010-06-14 19:13:53 UTC (rev 838)
+++ branches/PR-7872907/darwinup/main.cpp	2010-06-14 20:54:32 UTC (rev 839)
@@ -56,6 +56,9 @@
 	fprintf(stderr, "          -f        force operation to succeed at all costs    \n");
 	fprintf(stderr, "          -n        dry run                                    \n");
 	fprintf(stderr, "          -p DIR    operate on roots under DIR (default: /)    \n");
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+	fprintf(stderr, "          -r        gracefully restart when finished           \n");	
+#endif
 	fprintf(stderr, "          -v        verbose (use -vv for extra verbosity)      \n");
 	fprintf(stderr, "                                                               \n");
 	fprintf(stderr, "commands:                                                      \n");
@@ -106,11 +109,12 @@
 	char* path = NULL;
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 	bool disable_automation = false;
+	bool restart = false;
 #endif
 	
 	int ch;
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-	while ((ch = getopt(argc, argv, "dfnp:vh")) != -1) {
+	while ((ch = getopt(argc, argv, "dfnp:rvh")) != -1) {
 #else
 	while ((ch = getopt(argc, argv, "fnp:vh")) != -1) {		
 #endif
@@ -140,6 +144,11 @@
 				}
 				join_path(&path, optarg, "/");
 				break;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060	
+		case 'r':
+				restart = true;
+				break;
+#endif
 		case 'v':
 				verbosity <<= 1;
 				verbosity |= VERBOSE;
@@ -159,7 +168,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 (disable_automation) IF_DEBUG("option: helpful automation disabled\n");
+    if (restart) IF_DEBUG("option: restart when finished\n");
 #endif
 	
 	if (!path) {
@@ -254,6 +264,12 @@
 			}
 			free(sle_path);
 		}
+		if (restart && res == 0) {
+			res = tell_finder_to_restart();
+			if (res) fprintf(stderr, "Warning: tried to tell Finder to restart"
+							         "but failed.\n");
+			res = 0;
+		}
 #endif
 	}
 	
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20100614/1ca3b095/attachment.html>


More information about the darwinbuild-changes mailing list