1#!/bin/csh
2
3# This file is part of BOINC.
4# http://boinc.berkeley.edu
5# Copyright (C) 2017 University of California
6#
7# BOINC is free software; you can redistribute it and/or modify it
8# under the terms of the GNU Lesser General Public License
9# as published by the Free Software Foundation,
10# either version 3 of the License, or (at your option) any later version.
11#
12# BOINC is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15# See the GNU Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public License
18# along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
19
20##
21# Release Script for Macintosh BOINC Manager 10/31/07 by Charlie Fenton
22## updated 11/18/09 by Charlie Fenton for OS 10.6 Snow Leopard
23## updated 9/28/10 by Charlie Fenton for new BOINC skins
24## updated 12/2/10 by Charlie Fenton to remove obsolete items
25## updated 1/18/11 by Charlie Fenton to remove BOINC skins
26## updated 11/9/11 by Charlie Fenton for XCode 4.1 and OS 10.7
27## updated 11/26/11 by Charlie Fenton for new Default skin
28## updated 11/27/11 by Charlie Fenton for new virtualbox directory
29## updated 12/2/11 by Charlie Fenton to restore wrapper and reboot if needed
30## updated 1/6/12 by Charlie Fenton to also install VirtualBox
31## updated 6/22/12 by Charlie Fenton to code sign the installer and uninstaller
32## updated 7/5/12 by Charlie Fenton to avoid using PackageMaker
33## updated 7/31/12 by Charlie Fenton for Liberation font in boincscr
34## updated 6/11/13 by Charlie Fenton for BOINC.mpkg, "BOINC + VirtualBox.mpkg"
35## updated 6/18/13 by Charlie Fenton for localizable uninstaller
36## updated 8/15/13 by Charlie Fenton to fix bug in localizable uninstaller
37## updated 10/30/13 by Charlie Fenton to build a flat package
38## updated 11/1/13 by Charlie Fenton to build installers both with and without VBox
39## updated 11/18/13 by Charlie Fenton for Xcode 5.0.2
40## updated 1/22/14 by Charlie Fenton: embed VBox uninstaller in BOINC uninstaller
41## updated 9/30/14 by Charlie Fenton to code sign the BOINC client and Manager
42## updated 12/16/14 by Charlie Fenton to name folders "x86_64" not "i686"
43## updated 12/16/14 by Charlie Fenton to also code sign the installer package
44## updated 12/17/14 by Charlie Fenton to fix typo in build of BOINC+VBox installer
45## updated 4/7/15 by Charlie Fenton to comment on problem with BOINC+VBox installer
46## updated 7/1/15 by Charlie Fenton for compatibility with OS 10.11
47## updated 6/4/17 by Charlie Fenton for compatibility with Xcode versions > 5.0.2
48##
49## NOTE: This script requires Mac OS 10.6 or later, and uses XCode developer
50##   tools.  So you must have installed XCode Developer Tools on the Mac
51##   before running this script.  You must code sign using OS 10.9 or later
52##   for compatibility with Gatekeeper on OS 10.10 or later.
53##
54##
55
56## NOTE: To build the executables under Lion and XCode 4, select from XCode's
57## menu: "Product/Buildfor/Build for Archiving", NOT "Product/Archive"
58## Under Mavericks and Xcode 5, select "Product/Build For/Profiling"
59
60## To have this script build the combined BOINC+VirtualBox installer:
61## * Create a directory named "VirtualBox Installer" in the same
62##   directory which contains he root directory of the boinc tree.
63## * Copy VirtualBox.pkg from the VirtualBox installer disk image (.dmg)
64##   into this "VirtualBox Installer" directory.
65## * Copy VirtualBox_Uninstall.tool from the VirtualBox installer disk
66##   image (.dmg) into this "VirtualBox Installer" directory.
67##
68## NOTE: As of 5/7/15, I recommend against releasing the combined Macintosh
69## BOINC+VirtualBox installer because each version of VirtualBox comes with
70## its own uninsall script included as a separate command-line utility.
71## Using the uninstall script from a previous version of VirtualBox may not
72## work correctly, so we can't just add the current script to our "Uninstall
73## BOINC" utility because the user may later upgrade to a newer version of
74## VirtualBox.  We should not install VirtualBox as part of the BOINC install
75## unless our BOINC uninstaller will uninstall it.  We can't expect BOINC users
76## to be comfortable finding and running a command-line utility.
77##
78## We have asked Oracle to include their uninstall script inside the VirtualBox
79## bundle, or some other standard place where our BOINC uninstaller can find
80## the current version, but they have not yet done so.
81
82## Usage:
83##
84## If you wish to code sign the client, manager, installer and uninstaller,
85## create a file ~/BOINCCodeSignIdentities.txt whose first line is the code
86## signing identity.
87## If you wish to also code sign the installer package, add a second line
88## to ~/BOINCCodeSignIdentities.txt with the installer code signing identity.
89
90##
91## cd to the root directory of the boinc tree, for example:
92##     cd [path]/boinc
93##
94## Invoke this script with the three parts of version number as arguments.
95## For example, if the version is 3.2.1:
96##     source [path_to_this_script] 3 2 1
97##
98## This will create a director "BOINC_Installer" in the parent directory of
99## the current directory
100##
101## For testing only, you can use the development build by adding a fourth argument -dev
102## For example, if the version is 3.2.1:
103##     source [path_to_this_script] 3 2 1 -dev
104
105if [ $# -lt 3 ]; then
106echo "Usage:"
107echo "   cd [path]/boinc"
108echo "   source [path_to_this_script] major_version minor_version revision_number"
109return 1
110fi
111
112#pushd ./
113BOINCPath=$PWD
114
115DarwinVersion=`uname -r`;
116DarwinMajorVersion=`echo $DarwinVersion | sed 's/\([0-9]*\)[.].*/\1/' `;
117# DarwinMinorVersion=`echo $version | sed 's/[0-9]*[.]\([0-9]*\).*/\1/' `;
118#
119# echo "major = $DarwinMajorVersion"
120# echo "minor = $DarwinMinorVersion"
121#
122# Darwin version 11.x.y corresponds to OS 10.7.x
123# Darwin version 10.x.y corresponds to OS 10.6.x
124# Darwin version 8.x.y corresponds to OS 10.4.x
125# Darwin version 7.x.y corresponds to OS 10.3.x
126# Darwin version 6.x corresponds to OS 10.2.x
127
128if [ "$DarwinMajorVersion" -gt 10 ]; then
129    # XCode 4.1 on OS 10.7 builds only Intel binaries
130    arch="x86_64"
131
132    # XCode 3.x and 4.x use different paths for their build products.
133    # Our scripts in XCode's script build phase write those paths to
134    # files to help this release script find the build products.
135    if [ "$4" = "-dev" ]; then
136        exec 7<"mac_build/Build_Development_Dir"
137        read -u 7 BUILDPATH
138    else
139        exec 7<"mac_build/Build_Deployment_Dir"
140        read -u 7 BUILDPATH
141    fi
142
143else
144    # XCode 3.2 on OS 10.6 does sbuild Intel and PowerPC Universal binaries
145    arch="universal"
146
147    # XCode 3.x and 4.x use different paths for their build products.
148    if [ "$4" = "-dev" ]; then
149        if [ -d mac_build/build/Development/ ]; then
150            BUILDPATH="mac_build/build/Development"
151        else
152            BUILDPATH="mac_build/build"
153        fi
154    else
155        if [ -d mac_build/build/Deployment/ ]; then
156            BUILDPATH="mac_build/build/Deployment"
157        else
158            BUILDPATH="mac_build/build"
159        fi
160    fi
161fi
162
163sudo rm -dfR ../BOINC_Installer/Installer\ Resources/
164sudo rm -dfR ../BOINC_Installer/Installer\ Scripts/
165sudo rm -dfR ../BOINC_Installer/Pkg_Root
166sudo rm -dfR ../BOINC_Installer/locale
167sudo rm -dfR ../BOINC_Installer/Installer\ templates
168sudo rm -dfR ../BOINC_Installer/expandedVBox
169
170mkdir -p ../BOINC_Installer/Installer\ Resources/
171mkdir -p ../BOINC_Installer/Installer\ Scripts/
172mkdir -p ../BOINC_Installer/Installer\ templates
173
174cp -fp mac_installer/License.rtf ../BOINC_Installer/Installer\ Resources/
175cp -fp mac_installer/ReadMe.rtf ../BOINC_Installer/Installer\ Resources/
176
177cp -fp mac_installer/complist.plist ../BOINC_Installer/Installer\ templates
178cp -fp mac_installer/myDistribution ../BOINC_Installer/Installer\ templates
179
180# Update version number
181sed -i "" s/"<VER_NUM>"/"$1.$2.$3"/g ../BOINC_Installer/Installer\ Resources/ReadMe.rtf
182sed -i "" s/"x.y.z"/"$1.$2.$3"/g ../BOINC_Installer/Installer\ templates/myDistribution
183
184#### We don't customize BOINC Data directory name for branding
185cp -fp mac_installer/preinstall ../BOINC_Installer/Installer\ Scripts/
186cp -fp mac_installer/preinstall ../BOINC_Installer/Installer\ Scripts/preupgrade
187cp -fp mac_installer/postinstall ../BOINC_Installer/Installer\ Scripts/
188cp -fp mac_installer/postupgrade ../BOINC_Installer/Installer\ Scripts/
189
190mkdir -p ../BOINC_Installer/Pkg_Root
191mkdir -p ../BOINC_Installer/Pkg_Root/Applications
192mkdir -p ../BOINC_Installer/Pkg_Root/Library
193mkdir -p ../BOINC_Installer/Pkg_Root/Library/Screen\ Savers
194mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support
195mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data
196mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/locale
197mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/switcher
198mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/skins
199
200# We must create virtualbox directory so installer will set up its
201# ownership and permissions correctly, because vboxwrapper won't
202# have permission to set owner to boinc_master.
203mkdir -p ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/projects/virtualbox
204
205##cp -fpR $BUILDPATH/WaitPermissions.app ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/
206
207cp -fpRL $BUILDPATH/switcher ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/switcher/
208cp -fpRL $BUILDPATH/setprojectgrp ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/switcher/
209## cp -fpRL $BUILDPATH/AppStats ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/switcher/
210
211cd "${BOINCPath}/clientgui/skins"
212cp -fpRL Default ../../../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/skins/
213cd "${BOINCPath}"
214
215cp -fp curl/ca-bundle.crt ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/
216
217cp -fp win_build/installerv2/redist/all_projects_list.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/installer_projects_list.xml
218
219cp -fp doc/logo/boinc_logo_black.jpg ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/
220cp -fp api/ttf/liberation-fonts-ttf-2.00.0/LiberationSans-Regular.ttf ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/LiberationSans-Regular.ttf
221cp -fp clientscr/ss_config.xml ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/
222cp -fpRL $BUILDPATH/boincscr ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/
223
224cp -fpRL $BUILDPATH/BOINCManager.app ../BOINC_Installer/Pkg_Root/Applications/
225
226## OS 10.6 and OS10.7 require screensavers built with Garbage Collection, but Xcode 5.0.2
227## was the last version of Xcode which supported building with Garbage Collection, so we
228## have saved the screensaver executable with GC as a binary. Add it to the screen saver
229## passed to the BOINC installer. At install time, he BOINC installer will select the
230## correct binary for the version of OS X and delete the other one. This scripy assumes
231## that $BUILDPATH/BOINCSaver.saver was built to use Automatic Reference Counting (ARC)
232## and not built to use GC.
233cp -fpRL $BUILDPATH/BOINCSaver.saver ../BOINC_Installer/Pkg_Root/Library/Screen\ Savers/
234ditto -xk ./clientscr/BOINCSaver_MacOS10_6_7.zip ../BOINC_Installer/Pkg_Root/Library/Screen\ Savers/BOINCSaver.saver/Contents/MacOS
235
236## Copy the localization files into the installer tree
237## Old way copies CVS and *.po files which are not needed
238## cp -fpRL locale/ ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/locale
239## sudo rm -dfR ../BOINC_Installer/Pkg_Root/Library/Application\ Support/BOINC\ Data/locale/CVS
240## New way copies only *.mo files (adapted from boinc/sea/make-tar.sh)
241find locale -name '*.mo' | cut -d '/' -f 2 | awk '{print "\"../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/locale/"$0"\""}' | xargs mkdir -p
242find locale -name '*.mo' | cut -d '/' -f 2,3 | awk '{print "cp \"locale/"$0"\" \"../BOINC_Installer/Pkg_Root/Library/Application Support/BOINC Data/locale/"$0"\""}' | bash
243
244## Fix up ownership and permissions
245sudo chown -R root:admin ../BOINC_Installer/Pkg_Root/*
246sudo chmod -R u+rw,g+rw,o+r-w ../BOINC_Installer/Pkg_Root/*
247sudo chmod 1775 ../BOINC_Installer/Pkg_Root/Library
248
249sudo chown -R 501:admin ../BOINC_Installer/Pkg_Root/Library/Application\ Support/*
250sudo chmod -R u+rw,g+r-w,o+r-w ../BOINC_Installer/Pkg_Root/Library/Application\ Support/*
251
252sudo chown -R root:admin ../BOINC_Installer/Installer\ Resources/*
253sudo chown -R root:admin ../BOINC_Installer/Installer\ Scripts/*
254sudo chmod -R u+rw,g+r-w,o+r-w ../BOINC_Installer/Installer\ Resources/*
255sudo chmod -R u+rw,g+r-w,o+r-w ../BOINC_Installer/Installer\ Scripts/*
256
257
258## If you wish to code sign the client, manager, installer and uninstaller,
259## create a file ~/BOINCCodeSignIdentities.txt whose first line is the
260## application code signing identity and whose second line is the installer
261## code signing identity.
262## If you wish to also code sign the installer package, add a second line
263## to ~/BOINCCodeSignIdentities.txt with the installer code signing identity.
264##
265## Code signing using a registered Apple Developer ID is necessary for GateKeeper
266## with default settings to allow running downloaded applications under OS 10.8
267## Although code signing the installer application is sufficient to satisfy
268## GateKeeper, OS X's software firewall can interfere with RPCs between the
269## client and manager.  Signing them may make this less likely to be a problem.
270if [ -e "${HOME}/BOINCCodeSignIdentities.txt" ]; then
271    exec 8<"${HOME}/BOINCCodeSignIdentities.txt"
272    read APPSIGNINGIDENTITY <&8
273    read INSTALLERSIGNINGIDENTITY <&8
274
275    # Code Sign the BOINC client if we have a signing identity
276    sudo codesign -f -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Applications/BOINCManager.app/Contents/Resources/boinc"
277
278    # Code Sign the BOINC Manager if we have a signing identity
279    sudo codesign -f -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/Pkg_Root/Applications/BOINCManager.app"
280fi
281
282sudo rm -dfR ../BOINC_Installer/New_Release_$1_$2_$3/
283
284mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/
285mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch
286mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras
287mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin
288mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_SymbolTables
289
290cp -fp ../BOINC_Installer/Installer\ Resources/ReadMe.rtf ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch
291sudo chown -R 501:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/ReadMe.rtf
292sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/ReadMe.rtf
293
294cp -fp COPYING ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.txt
295sudo chown -R 501:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.txt
296sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.txt
297
298cp -fp COPYING.LESSER ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.LESSER.txt
299sudo chown -R 501:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.LESSER.txt
300sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYING.LESSER.txt
301
302cp -fp COPYRIGHT ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYRIGHT.txt
303sudo chown -R 501:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYRIGHT.txt
304sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/COPYRIGHT.txt
305
306cp -fpRL $BUILDPATH/Uninstall\ BOINC.app ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras
307# Copy the localization files for the uninstaller into its bundle
308find locale -name 'BOINC-Setup.mo' | cut -d '/' -f 2 | awk '{print "\"../BOINC_Installer/locale/"$0"\""}' | xargs mkdir -p
309
310find locale -name 'BOINC-Setup.mo' | cut -d '/' -f 2,3 | awk '{print "cp \"locale/"$0"\" \"../BOINC_Installer/locale/"$0"\""}' | bash
311
312sudo cp -fpRL ../BOINC_Installer/locale "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/Uninstall BOINC.app/Contents/Resources"
313
314sudo chown -R root:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/Uninstall\ BOINC.app
315sudo chmod -R u+r-w,g+r-w,o+r-w ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/Uninstall\ BOINC.app
316
317# Copy the installer wrapper application "BOINC Installer.app"
318cp -fpRL $BUILDPATH/BOINC\ Installer.app ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/
319
320cp -fpR $BUILDPATH/PostInstall.app "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/BOINC Installer.app/Contents/Resources"
321
322# Prepare to build the BOINC+VirtualBox installer if VirtualBox.pkg exists
323VirtualBoxPackageName="VirtualBox.pkg"
324if [ -f "../VirtualBox Installer/${VirtualBoxPackageName}" ]; then
325    # Make a copy of the  BOINC installer app without the installer package
326    sudo cp -fpRL "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox"
327
328    # Copy the VirtualBox uninstall tool into the extras directory
329    sudo cp -fpRL "../VirtualBox Installer/VirtualBox_Uninstall.tool" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/"
330
331    sudo chown -R root:admin "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/VirtualBox_Uninstall.tool"
332    sudo chmod -R u+r-w,g+r-w,o+r-w "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/VirtualBox_Uninstall.tool"
333
334    # Copy the VirtualBox uninstall tool into the BOINC uninstaller
335    sudo cp -fpRL "../VirtualBox Installer/VirtualBox_Uninstall.tool" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/Uninstall BOINC.app/Contents/Resources"
336
337    sudo chown -R root:admin "../VirtualBox Installer/VirtualBox_Uninstall.tool" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/Uninstall BOINC.app/Contents/Resources/VirtualBox_Uninstall.tool"
338    sudo chmod -R u+r-w,g+r-w,o+r-w "../VirtualBox Installer/VirtualBox_Uninstall.tool" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/extras/Uninstall BOINC.app/Contents/Resources/VirtualBox_Uninstall.tool"
339fi
340
341# Build the installer package inside the wrapper application's bundle
342
343cd "../BOINC_Installer/Installer templates"
344
345pkgbuild --quiet --scripts "../Installer Scripts" --ownership recommended --identifier edu.berkeley.boinc --root "../Pkg_Root" --component-plist "./complist.plist" "./BOINC.pkg"
346
347if [ -n "${INSTALLERSIGNINGIDENTITY}" ]; then
348    productbuild --sign "${INSTALLERSIGNINGIDENTITY}" --quiet --resources "../Installer Resources/" --version "BOINC Manager $1.$2.$3" --distribution "./myDistribution" "../New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/BOINC Installer.app/Contents/Resources/BOINC.pkg"
349else
350    productbuild --quiet --resources "../Installer Resources/" --version "BOINC Manager $1.$2.$3" --distribution "./myDistribution" "../New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/BOINC Installer.app/Contents/Resources/BOINC.pkg"
351fi
352cd "${BOINCPath}"
353
354# Build the BOINC+VirtualBox installer if VirtualBox.pkg exists
355if [ -f "../VirtualBox Installer/${VirtualBoxPackageName}" ]; then
356    cp -fpRL "mac_installer/V+BDistribution" "../BOINC_Installer/Installer templates/V+BDistribution"
357
358    mkdir -p "../BOINC_Installer/expandedVBox/"
359
360    pkgutil --expand "../VirtualBox Installer/${VirtualBoxPackageName}" "../BOINC_Installer/expandedVBox/VBox.pkg"
361
362    pkgutil --flatten "../BOINC_Installer/expandedVBox/VBox.pkg/VBoxKEXTs.pkg" "../BOINC_Installer/Installer templates/VBoxKEXTs.pkg"
363
364    pkgutil --flatten "../BOINC_Installer/expandedVBox/VBox.pkg/VBoxStartupItems.pkg" "../BOINC_Installer/Installer templates/VBoxStartupItems.pkg"
365
366    pkgutil --flatten "../BOINC_Installer/expandedVBox/VBox.pkg/VirtualBox.pkg" "../BOINC_Installer/Installer templates/VirtualBox.pkg"
367
368    pkgutil --flatten "../BOINC_Installer/expandedVBox/VBox.pkg/VirtualBoxCLI.pkg" "../BOINC_Installer/Installer templates/VirtualBoxCLI.pkg"
369
370    cp -fpRL "../BOINC_Installer/expandedVBox/VBox.pkg/Resources/en.lproj" "../BOINC_Installer/Installer Resources"
371
372    sudo rm -dfR "../BOINC_Installer/expandedVBox"
373
374    cp -fp mac_installer/V+BDistribution "../BOINC_Installer/Installer templates"
375
376    # Update version number
377    sed -i "" s/"x.y.z"/"$1.$2.$3"/g "../BOINC_Installer/Installer templates/V+BDistribution"
378
379    cd "../BOINC_Installer/Installer templates"
380
381## TODO: Find a way to automatically set the VirtualBox version
382    if [ -n "${INSTALLERSIGNINGIDENTITY}" ]; then
383        productbuild --sign "${INSTALLERSIGNINGIDENTITY}" --quiet --resources "../Installer Resources" --version "BOINC Manager $1.$2.$3 + VirtualBox 4.3.12" --distribution "./V+BDistribution" "../New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/BOINC Installer.app/Contents/Resources/BOINC.pkg"
384    else
385        productbuild --quiet --resources "../Installer Resources" --version "BOINC Manager $1.$2.$3 + VirtualBox 4.3.12" --distribution "./V+BDistribution" "../New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_${arch}_vbox/BOINC Installer.app/Contents/Resources/BOINC.pkg"
386    fi
387
388    cd "${BOINCPath}"
389fi
390
391# Build the stand-alone client distribution
392cp -fpRL mac_build/Mac_SA_Insecure.sh ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/
393cp -fpRL mac_build/Mac_SA_Secure.sh ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/
394cp -fpRL COPYING ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/COPYING.txt
395cp -fpRL COPYING.LESSER ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/COPYING.LESSER.txt
396cp -fpRL COPYRIGHT ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/COPYRIGHT.txt
397cp -fp mac_installer/License.rtf ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/
398sudo chown -R 501:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/*
399sudo chmod -R 644 ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/*
400
401mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir
402cp -fpRL $BUILDPATH/boinc ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/
403cp -fpRL $BUILDPATH/boinccmd ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/
404cp -fpRL curl/ca-bundle.crt ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/
405
406mkdir -p ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher
407cp -fpRL $BUILDPATH/switcher ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/
408cp -fpRL $BUILDPATH/setprojectgrp ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/switcher/
409
410sudo chown -R root:admin ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/*
411sudo chmod -R u+rw-s,g+r-ws,o+r-w ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_$arch-apple-darwin/move_to_boinc_dir/*
412
413cp -fpRL $BUILDPATH/SymbolTables/ ../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_SymbolTables/
414
415## If you wish to code sign the installer and uninstaller, create a file
416## ~/BOINCCodeSignIdentities.txt whose first line is the code signing identity
417##
418## Code signing using a registered Apple Developer ID is necessary for GateKeeper
419## with default settings to allow running downloaded applications under OS 10.8
420if [ -n "${APPSIGNINGIDENTITY}" ]; then
421    # Code Sign the BOINC installer application if we have a signing identity
422    sudo codesign -f -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/BOINC Installer.app"
423
424    # Code Sign the BOINC uninstaller application if we have a signing identity
425    sudo codesign -f -s "${APPSIGNINGIDENTITY}" "../BOINC_Installer/New_Release_$1_$2_$3/boinc_$1.$2.$3_macOSX_$arch/extras/Uninstall BOINC.app"
426fi
427
428cd ../BOINC_Installer/New_Release_$1_$2_$3
429## Use ditto instead of zip utility to preserve resource forks and Finder attributes (custom icon, hide extension)
430ditto -ck --sequesterRsrc --keepParent boinc_$1.$2.$3_macOSX_$arch boinc_$1.$2.$3_macOSX_$arch.zip
431ditto -ck --sequesterRsrc --keepParent boinc_$1.$2.$3_$arch-apple-darwin boinc_$1.$2.$3_$arch-apple-darwin.zip
432ditto -ck --sequesterRsrc --keepParent boinc_$1.$2.$3_macOSX_SymbolTables boinc_$1.$2.$3_macOSX_SymbolTables.zip
433if [ -d boinc_$1.$2.$3_macOSX_${arch}_vbox ]; then
434    ditto -ck --sequesterRsrc --keepParent boinc_$1.$2.$3_macOSX_${arch}_vbox boinc_$1.$2.$3_macOSX_${arch}_vbox.zip
435fi
436
437#popd
438cd "${BOINCPath}"
439
440sudo rm -dfR ../BOINC_Installer/Installer\ Resources/
441sudo rm -dfR ../BOINC_Installer/Installer\ Scripts/
442sudo rm -dfR ../BOINC_Installer/Pkg_Root
443sudo rm -dfR ../BOINC_Installer/locale
444sudo rm -dfR ../BOINC_Installer/Installer\ templates
445sudo rm -dfR ../BOINC_Installer/expandedVBox
446
447return 0
448