Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 61 lines 2.2 kB view raw
1When the X / Xquartz server initializes, it starts the XQuartz.app and 2hands-off the display FD. To start the XQuartz.app, Xquartz normally uses some 3system calls to get the path of the application by app bundle id, and then 4executes the Contents/MacOS/X11 script contained inside, which in turn executes 5Contents/MacOS/X11.bin (the actual app). 6 7This patch replaces that discovery technique with a simple call to 8`getenv' and a hardcoded default. In order to make Xquartz work if the 9app is moved, we'll need another wrapper that sets the `XQUARTZ_X11' 10environment variable to point to the `X11' script. 11 12diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c 13index 83252e805..f1974215b 100644 14--- a/hw/xquartz/mach-startup/stub.c 15+++ b/hw/xquartz/mach-startup/stub.c 16@@ -52,7 +52,6 @@ 17 18 #include "launchd_fd.h" 19 20-static CFURLRef x11appURL; 21 static FSRef x11_appRef; 22 static pid_t x11app_pid = 0; 23 aslclient aslc; 24@@ -60,29 +59,21 @@ aslclient aslc; 25 static void 26 set_x11_path(void) 27 { 28- OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 29- nil, &x11_appRef, &x11appURL); 30+ unsigned char *xquartzApp = getenv("XQUARTZ_APP"); 31+ if (!xquartzApp) { 32+ xquartzApp = "@XQUARTZ_APP@"; 33+ } 34+ 35+ OSStatus osstatus = FSPathMakeRef(xquartzApp, &x11_appRef, NULL); 36 37 switch (osstatus) { 38 case noErr: 39- if (x11appURL == NULL) { 40- asl_log(aslc, NULL, ASL_LEVEL_ERR, 41- "Xquartz: Invalid response from LSFindApplicationForInfo(%s)", 42- kX11AppBundleId); 43- exit(1); 44- } 45 break; 46 47- case kLSApplicationNotFoundErr: 48- asl_log(aslc, NULL, ASL_LEVEL_ERR, 49- "Xquartz: Unable to find application for %s", 50- kX11AppBundleId); 51- exit(10); 52- 53 default: 54 asl_log(aslc, NULL, ASL_LEVEL_ERR, 55- "Xquartz: Unable to find application for %s, error code = %d", 56- kX11AppBundleId, (int)osstatus); 57+ "Xquartz: Unable to find FSRef for %s, error code = %d", 58+ xquartzApp, (int)osstatus); 59 exit(11); 60 } 61 }