From e1c688ab87334062bb3ff2bd4e379e4f9c1207e0 Mon Sep 17 00:00:00 2001 From: "Fraser J. Gordon" Date: Thu, 31 Mar 2016 12:41:58 +0100 Subject: [PATCH 1/2] Use a binary executable for the OSX installer stub OSX 10.11.4 uses a different method for signing non-MachO files as code which causes signature verification to fail on earlier versions of OSX. This commit removes the text files from the Contents/MacOS directory and uses a MachO executable to launch the AppleScript that opens a Finder window on the installer DMG root. The script has been moved to the resource directory. --- Installer/osx-installer-stub.gyp | 30 +++++++++++ Installer/osx-installer-stub.mm | 79 ++++++++++++++++++++++++++++ builder/tools_builder.livecodescript | 12 ++++- livecode.gyp | 9 ++++ 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 Installer/osx-installer-stub.gyp create mode 100644 Installer/osx-installer-stub.mm diff --git a/Installer/osx-installer-stub.gyp b/Installer/osx-installer-stub.gyp new file mode 100644 index 00000000000..7fd1eb6b07b --- /dev/null +++ b/Installer/osx-installer-stub.gyp @@ -0,0 +1,30 @@ +{ + 'includes': + [ + '../common.gypi', + ], + + 'targets': + [ + { + 'target_name': 'osx-installer-stub', + 'product_name': 'installer-stub', + 'type': 'executable', + 'mac_bundle': '0', + + 'sources': + [ + 'osx-installer-stub.mm', + ], + + 'all_dependent_settings': + { + 'variables': + { + 'dist_files': [ '<(PRODUCT_DIR)/<(_product_name)>(exe_suffix)' ], + }, + }, + }, + ], +} + diff --git a/Installer/osx-installer-stub.mm b/Installer/osx-installer-stub.mm new file mode 100644 index 00000000000..84bef0f8ff3 --- /dev/null +++ b/Installer/osx-installer-stub.mm @@ -0,0 +1,79 @@ +/* Copyright (C) 2016 LiveCode Ltd. + + This file is part of LiveCode. + + LiveCode is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License v3 as published by the Free + Software Foundation. + + LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with LiveCode. If not see . */ + + + +#import + + +// This file is a simple stub executable for launching the AppleScript that +// opens a Finder window showing the contents of the DMG. It is used by the +// auto-updater to display the contents of the DMG so the user can copy the new +// app bundle to their Applications folder. +// +// Previously, we used a shell script to do the launching. However, as of OSX +// 10.11.4, the `codesign` tool generates signatures that cannot be verified on +// earlier versions of OSX when asked to sign a non-MachO executable as code. +// +// Therefore, we use this executable in place of the shell script so that the +// object being signed is one that doesn't cause problems. + + +int main(int argc, char* argv[]) +{ + // Get the main bundle for the application + NSBundle* mainBundle = [NSBundle mainBundle]; + + // Path to the subdirectory containing the bundle's resources + NSString* resourcePath = [mainBundle resourcePath]; + + // Append the path to the AppleScript that opens a Finder window + NSString* scriptPath = [resourcePath stringByAppendingPathComponent:@"Installer/ShowDmgWindow.scpt"]; + + // Turn the path into a URL and load it into an AppleScript object + NSURL* scriptURL = [[NSURL alloc] initFileURLWithPath:scriptPath]; + NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:scriptURL error:nil]; + + // Generate the "run" AppleEvent to send to the script. It needs to be given + // an array containing 1 item which is the POSIX path to the DMG folder. + NSString* dmgPath = [[mainBundle bundlePath] stringByDeletingLastPathComponent]; + NSAppleEventDescriptor* pathDescriptor = [NSAppleEventDescriptor descriptorWithString:dmgPath]; + NSAppleEventDescriptor* argvList = [NSAppleEventDescriptor listDescriptor]; + NSAppleEventDescriptor* appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass + eventID:kAEOpenApplication + targetDescriptor:nil + returnID:kAutoGenerateReturnID + transactionID:kAnyTransactionID ]; + [argvList insertDescriptor:pathDescriptor atIndex:1]; + [appleEvent setParamDescriptor:argvList forKeyword:keyDirectObject]; + + // Execute the script + [appleScript executeAppleEvent:appleEvent error:nil]; + + // Cleanup + [appleEvent release]; + [argvList release]; + [pathDescriptor release]; + [dmgPath release]; + [appleScript release]; + [scriptURL release]; + [scriptPath release]; + [resourcePath release]; + [mainBundle release]; + + // All done + return 0; +} diff --git a/builder/tools_builder.livecodescript b/builder/tools_builder.livecodescript index 484eb799613..a79e34461e5 100644 --- a/builder/tools_builder.livecodescript +++ b/builder/tools_builder.livecodescript @@ -510,13 +510,21 @@ command toolsBuilderMakeAppBundle pVersion, pEdition, pPlatform -- Copy a shell script and AppleScript into the app bundle to catch attempts -- from old auto-updaters to launch the installer + local tEngineFolder + builderFetchEngine empty, "macosx" + put the result into tEngineFolder builderLog "message", "Adding installer shim to app bundle" - get shell ("install -m755" && escapeArg(builderCommunityResourceFolder() & "/dmg/fake-installer.sh") && escapeArg(tAppBundle & "/Contents/MacOS/installer")) + get shell ("install -m755" && escapeArg(tEngineFolder & "/installer-stub") && escapeArg(tAppBundle & "/Contents/MacOS/installer")) if the result is not zero then builderLog "error", "Failed to copy installer stub shell script:" && it throw "failure" end if - get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/MacOS/installer.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript")) + get shell ("mkdir -p" && escapeArg(tAppBundle & "/Contents/Resources/Installer")) + if the result is not zero then + builderLog "error", "Failed to create installer resources directory:" && it + throw "failure" + end if + get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/Resources/Installer/ShowDmgWindow.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript")) if the result is not zero then builderLog "error", "Failed to compile installer stub AppleScript:" && it throw "failure" diff --git a/livecode.gyp b/livecode.gyp index 83cead7359d..e008ef80f27 100644 --- a/livecode.gyp +++ b/livecode.gyp @@ -53,6 +53,15 @@ ], }, ], + [ + 'OS == "mac"', + { + 'dependencies': + [ + 'Installer/osx-installer-stub.gyp:osx-installer-stub', + ], + }, + ], [ 'OS == "mac" or OS == "win"', { From 610925ee04ed635c6d501c99c6aafba02be279d5 Mon Sep 17 00:00:00 2001 From: "Fraser J. Gordon" Date: Thu, 31 Mar 2016 12:59:51 +0100 Subject: [PATCH 2/2] Remove an un-necessary text file from the OSX CEF framework --- builder/tools_builder.livecodescript | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builder/tools_builder.livecodescript b/builder/tools_builder.livecodescript index a79e34461e5..c817bd02701 100644 --- a/builder/tools_builder.livecodescript +++ b/builder/tools_builder.livecodescript @@ -530,6 +530,10 @@ command toolsBuilderMakeAppBundle pVersion, pEdition, pPlatform throw "failure" end if + -- Remove a problematic (but un-neccessary) file from the CEF framework bundle + -- Doing it here is ugly, but is temporary (only needed in 6.7 and 7.1). + get shell ("rm -f" && escapeArg(tAppBundle & "/Contents/Frameworks/Chromium Embedded Framework.framework/Manifest")) + -- Find the signing identity and sign the app bundle get findSigningIdentity() if it is not empty then