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

Commit c98e9ef

Browse files
committed
Merge remote-tracking branch 'upstream/develop-6.7' into merge-develop-6.7_31.03.2016
2 parents 16955eb + cfee4aa commit c98e9ef

6 files changed

Lines changed: 195 additions & 3 deletions

File tree

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/generate-dmg.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
# If this script is not run as root, the DMG will have incorrect ownership
6+
if [ $EUID -ne 0 ] ; then
7+
echo >&2 "WARNING: not building DMG as root; app will have incorrect ownership"
8+
fi
9+
10+
# Arguments are the name of the volume to create, the input folder and the output filename
11+
if [ $# -ne 3 ] ; then
12+
echo >&2 "ERROR: usage: ./generate-dmg.sh volname srcfolder output"
13+
fi
14+
15+
volname="$1"
16+
srcfolder="$2"
17+
output="$3"
18+
19+
# Make the DMG
20+
# UID and GID 99 are magical - they are needed to ensure ownership is correct
21+
# when the app bundle is copied out of the DMG. They are also the reason that
22+
# this script needs to be run with root permissions.
23+
#
24+
if [ $EUID -eq 0 ] ; then
25+
ids="-uid 99 -gid 99"
26+
fi
27+
28+
hdiutil create -fs HFS+ -format UDRW -scrub ${ids} -attach -volname "${volname}" -srcfolder "${srcfolder}" "${output}"
29+
30+
# Exit on failure
31+
result=$?
32+
if [ $result -ne 0 ] ; then exit $result ; fi
33+
34+
# Ensure the ownership of the output image is correct
35+
user=$(who am i | awk '{print $1}')
36+
group=$(id -g -n "${user}")
37+
chown ${user}:${group} "${output}"

builder/tools_builder.livecodescript

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,18 +533,30 @@ command toolsBuilderMakeAppBundle pVersion, pEdition, pPlatform
533533

534534
-- Copy a shell script and AppleScript into the app bundle to catch attempts
535535
-- from old auto-updaters to launch the installer
536+
local tEngineFolder
537+
builderFetchEngine empty, "macosx"
538+
put the result into tEngineFolder
536539
builderLog "message", "Adding installer shim to app bundle"
537-
get shell ("install -m755" && escapeArg(builderCommunityResourceFolder() & "/dmg/fake-installer.sh") && escapeArg(tAppBundle & "/Contents/MacOS/installer"))
540+
get shell ("install -m755" && escapeArg(tEngineFolder & "/installer-stub") && escapeArg(tAppBundle & "/Contents/MacOS/installer"))
538541
if the result is not zero then
539542
builderLog "error", "Failed to copy installer stub shell script:" && it
540543
throw "failure"
541544
end if
542-
get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/MacOS/installer.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript"))
545+
get shell ("mkdir -p" && escapeArg(tAppBundle & "/Contents/Resources/Installer"))
546+
if the result is not zero then
547+
builderLog "error", "Failed to create installer resources directory:" && it
548+
throw "failure"
549+
end if
550+
get shell ("osacompile" && "-o" && escapeArg(tAppBundle & "/Contents/Resources/Installer/ShowDmgWindow.scpt") && escapeArg(builderCommunityResourceFolder() & "/dmg/open-dmg.applescript"))
543551
if the result is not zero then
544552
builderLog "error", "Failed to compile installer stub AppleScript:" && it
545553
throw "failure"
546554
end if
547555

556+
-- Remove a problematic (but un-neccessary) file from the CEF framework bundle
557+
-- Doing it here is ugly, but is temporary (only needed in 6.7 and 7.1).
558+
get shell ("rm -f" && escapeArg(tAppBundle & "/Contents/Frameworks/Chromium Embedded Framework.framework/Manifest"))
559+
548560
-- Find the signing identity and sign the app bundle
549561
get findSigningIdentity()
550562
if it is not empty then
@@ -622,8 +634,31 @@ command toolsBuilderMakeDisk pVersion, pEdition, pPlatform
622634
get shell ("hdiutil detach" && escapeArg(tVolumeName))
623635

624636
-- Generate an initial read-write DMG and mount it
637+
-- This needs to be run with root privileges to get the ownership correct
638+
-- If the $GENERATE_DMG_SCRIPT env var is set, the script identified by
639+
-- that path will be used instead of the one stored in the repo
625640
builderLog "message", "Generating initial DMG"
626-
get shell ("hdiutil create -fs HFS+ -format UDRW -attach -volname" && escapeArg(tVolumeName) && "-srcfolder" && escapeArg(tDmgFolder) && escapeArg(tTempDmg))
641+
local tGenerateScript
642+
if $GENERATE_DMG_SCRIPT is not empty then
643+
-- Check that the generate script is identical to the in-repo copy
644+
-- so it is kept up-to-date
645+
local tLocalScript
646+
local tRepoScript
647+
get shell("which" && escapeArg($GENERATE_DMG_SCRIPT))
648+
put url("file:" & line 1 of it) into tLocalScript
649+
put url("file:" & builderSystemFolder() & "/generate-dmg.sh") into tRepoScript
650+
if tLocalScript is not tRepoScript then
651+
builderLog "error", "Local DMG generation script differs from the repo copy (please update)"
652+
throw "failure"
653+
end if
654+
655+
put $GENERATE_DMG_SCRIPT into tGenerateScript
656+
else if $GENERATE_DMG_SUDO is not empty and $GENERATE_DMG_SUDO is not 0 then
657+
put "sudo -n" && escapeArg(builderSystemFolder() & "/generate-dmg.sh") into tGenerateScript
658+
else
659+
put escapeArg(builderSystemFolder() & "/generate-dmg.sh") into tGenerateScript
660+
end if
661+
get shell (tGenerateScript && escapeArg(tVolumeName) && escapeArg(tDmgFolder) && escapeArg(tTempDmg))
627662
if "created:" is not in it then
628663
builderLog "error", "Failed to create initial DMG:" && it
629664
throw "failure"

docs/notes/bugfix-17195.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Fix permissions on apps dragged from LiveCode DMG
2+

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)