Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit e1c688a

Browse files
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.
1 parent 2158cb4 commit e1c688a

File tree

4 files changed

+128
-2
lines changed

4 files changed

+128
-2
lines changed

Installer/osx-installer-stub.gyp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
'includes':
3+
[
4+
'../common.gypi',
5+
],
6+
7+
'targets':
8+
[
9+
{
10+
'target_name': 'osx-installer-stub',
11+
'product_name': 'installer-stub',
12+
'type': 'executable',
13+
'mac_bundle': '0',
14+
15+
'sources':
16+
[
17+
'osx-installer-stub.mm',
18+
],
19+
20+
'all_dependent_settings':
21+
{
22+
'variables':
23+
{
24+
'dist_files': [ '<(PRODUCT_DIR)/<(_product_name)>(exe_suffix)' ],
25+
},
26+
},
27+
},
28+
],
29+
}
30+

Installer/osx-installer-stub.mm

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* Copyright (C) 2016 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
18+
19+
#import <Foundation/Foundation.h>
20+
21+
22+
// This file is a simple stub executable for launching the AppleScript that
23+
// opens a Finder window showing the contents of the DMG. It is used by the
24+
// auto-updater to display the contents of the DMG so the user can copy the new
25+
// app bundle to their Applications folder.
26+
//
27+
// Previously, we used a shell script to do the launching. However, as of OSX
28+
// 10.11.4, the `codesign` tool generates signatures that cannot be verified on
29+
// earlier versions of OSX when asked to sign a non-MachO executable as code.
30+
//
31+
// Therefore, we use this executable in place of the shell script so that the
32+
// object being signed is one that doesn't cause problems.
33+
34+
35+
int main(int argc, char* argv[])
36+
{
37+
// Get the main bundle for the application
38+
NSBundle* mainBundle = [NSBundle mainBundle];
39+
40+
// Path to the subdirectory containing the bundle's resources
41+
NSString* resourcePath = [mainBundle resourcePath];
42+
43+
// Append the path to the AppleScript that opens a Finder window
44+
NSString* scriptPath = [resourcePath stringByAppendingPathComponent:@"Installer/ShowDmgWindow.scpt"];
45+
46+
// Turn the path into a URL and load it into an AppleScript object
47+
NSURL* scriptURL = [[NSURL alloc] initFileURLWithPath:scriptPath];
48+
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:scriptURL error:nil];
49+
50+
// Generate the "run" AppleEvent to send to the script. It needs to be given
51+
// an array containing 1 item which is the POSIX path to the DMG folder.
52+
NSString* dmgPath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
53+
NSAppleEventDescriptor* pathDescriptor = [NSAppleEventDescriptor descriptorWithString:dmgPath];
54+
NSAppleEventDescriptor* argvList = [NSAppleEventDescriptor listDescriptor];
55+
NSAppleEventDescriptor* appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
56+
eventID:kAEOpenApplication
57+
targetDescriptor:nil
58+
returnID:kAutoGenerateReturnID
59+
transactionID:kAnyTransactionID ];
60+
[argvList insertDescriptor:pathDescriptor atIndex:1];
61+
[appleEvent setParamDescriptor:argvList forKeyword:keyDirectObject];
62+
63+
// Execute the script
64+
[appleScript executeAppleEvent:appleEvent error:nil];
65+
66+
// Cleanup
67+
[appleEvent release];
68+
[argvList release];
69+
[pathDescriptor release];
70+
[dmgPath release];
71+
[appleScript release];
72+
[scriptURL release];
73+
[scriptPath release];
74+
[resourcePath release];
75+
[mainBundle release];
76+
77+
// All done
78+
return 0;
79+
}

builder/tools_builder.livecodescript

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,21 @@ command toolsBuilderMakeAppBundle pVersion, pEdition, pPlatform
510510

511511
-- Copy a shell script and AppleScript into the app bundle to catch attempts
512512
-- from old auto-updaters to launch the installer
513+
local tEngineFolder
514+
builderFetchEngine empty, "macosx"
515+
put the result into tEngineFolder
513516
builderLog "message", "Adding installer shim to app bundle"
514-
get shell ("install -m755" && escapeArg(builderCommunityResourceFolder() & "/dmg/fake-installer.sh") && escapeArg(tAppBundle & "/Contents/MacOS/installer"))
517+
get shell ("install -m755" && escapeArg(tEngineFolder & "/installer-stub") && escapeArg(tAppBundle & "/Contents/MacOS/installer"))
515518
if the result is not zero then
516519
builderLog "error", "Failed to copy installer stub shell script:" && it
517520
throw "failure"
518521
end if
519-
get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/MacOS/installer.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript"))
522+
get shell ("mkdir -p" && escapeArg(tAppBundle & "/Contents/Resources/Installer"))
523+
if the result is not zero then
524+
builderLog "error", "Failed to create installer resources directory:" && it
525+
throw "failure"
526+
end if
527+
get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/Resources/Installer/ShowDmgWindow.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript"))
520528
if the result is not zero then
521529
builderLog "error", "Failed to compile installer stub AppleScript:" && it
522530
throw "failure"

livecode.gyp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@
5353
],
5454
},
5555
],
56+
[
57+
'OS == "mac"',
58+
{
59+
'dependencies':
60+
[
61+
'Installer/osx-installer-stub.gyp:osx-installer-stub',
62+
],
63+
},
64+
],
5665
[
5766
'OS == "mac" or OS == "win"',
5867
{

0 commit comments

Comments
 (0)