This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
make_installer.sh
executable file
·108 lines (87 loc) · 3.48 KB
/
make_installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
#
# make_installer.sh
#
# Copyright (C) 2018 - 2020 James Joseph Balamuta <balamut2@illinois.edu>
#
# Version 4.0.0 -- 2020-05-27
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#### Build Installer
echo "[setup] Creating an environment for the installer..."
# Make sure file permissions for postinstall is set
chmod a+x scripts/*
# Version of installer
INSTALLER_VERSION=4.0.0
# Previously, we created a payload-free package due to downloading
# components as needed. We used a read receipt trick of including an empty
# directory for this purpose.
echo "[setup] Creating an empty staging directory..."
# Now, we're aiming to create a payload package with pre-defined components.
# In particular, we merge together clang 7.0.0 and gfortran 6.1
mkdir empty
echo "[build] Creating a temporary macos installer package..."
# Build macOS installer
pkgbuild --root empty \
--scripts scripts \
--identifier com.rbinaries.rtools \
--version $INSTALLER_VERSION \
macos-rtools-temp.pkg
# Create a distribution file to allow for customization
productbuild --synthesize --package ./macos-rtools-temp.pkg distribution.xml
echo "[build] Writing in additional configuration options..."
# Helper function that adds a line 1 before the last one
#1 New XML contents
#2 Path to distribution.xml file
add_line_1before_last(){
# TODO:
# Figure out a better way to remove the last line of the file....
sed -i '' '/<\/installer-gui-script>/d' $2
# TODO:
# Figure out a way to tab the first contents
cat << EOF >> $2
$1
</installer-gui-script>
EOF
}
# Add title
add_line_1before_last '<title>macOS R toolchain</title>' distribution.xml
# Add background
add_line_1before_last '<background file="Rlogo.png" mime-type="image/png" />' distribution.xml
# Add a welcome screen
add_line_1before_last '<welcome file="WELCOME_DISPLAY.rtf"/>' distribution.xml
# Add a license file for LLVM
add_line_1before_last '<license file="LICENSE.rtf"/>' distribution.xml
# Enforce a minimum standard for the installer.
# R CRAN Binaries use macOS High Sierra 10.13
# Docs: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW33
MINVERSION=$(cat <<-END
<allowed-os-versions>
<os-version min="10.13.0" />
</allowed-os-versions>
END
)
# Write the standard to the distribution file.
add_line_1before_last "${MINVERSION}" distribution.xml
echo "[build] Rebuilding the package archive..."
# Rebuild package with distribution hacks
productbuild --distribution distribution.xml \
--resources ./build_files \
--sign "Developer ID Installer: James Balamuta" \
--package-path ./macos-rtools-temp.pkg macos-rtools-${INSTALLER_VERSION}.pkg
echo "[cleanup] Removing the temporary package archive..."
rm macos-rtools-temp.pkg
echo "[finish] Installer created successfully..."