Skip to content

Commit 2e5768d

Browse files
authored
Add architecture checks for macOS installers (#1153)
* Add arm64 checks for SH installers * Add architecture check to PKG installers * Add news * Add missing template parameter to shellcheck test * Fix architecture name for Intel PKG installers
1 parent 8336f18 commit 2e5768d

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

constructor/header.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,21 @@ then
246246
exit 2
247247
fi
248248
fi
249+
{%- elif arm64 %}
250+
if [ "$(uname -m)" != "arm64" ]; then
251+
printf "WARNING:\\n"
252+
printf " Your machine hardware does not appear to be arm64, \\n"
253+
printf " but you are trying to install an arm64 version of %s.\\n" "${INSTALLER_NAME}"
254+
printf " Are sure you want to continue the installation? [yes|no]\\n"
255+
printf "[no] >>> "
256+
read -r ans
257+
ans=$(echo "${ans}" | tr '[:lower:]' '[:upper:]')
258+
if [ "$ans" != "YES" ] && [ "$ans" != "Y" ]
259+
then
260+
printf "Aborting installation\\n"
261+
exit 2
262+
fi
263+
fi
249264
{%- elif ppc64le %}
250265
if [ "$(uname -m)" != "ppc64le" ]; then
251266
printf "WARNING:\\n"
@@ -280,7 +295,7 @@ then
280295
if [ "$(uname -m)" != "aarch64" ]; then
281296
printf "WARNING:\\n"
282297
printf " Your machine hardware does not appear to be aarch64, \\n"
283-
printf " but you are trying to install a aarch64 version of %s.\\n" "${INSTALLER_NAME}"
298+
printf " but you are trying to install an aarch64 version of %s.\\n" "${INSTALLER_NAME}"
284299
printf " Are sure you want to continue the installation? [yes|no]\\n"
285300
printf "[no] >>> "
286301
read -r ans

constructor/osxpkg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def modify_xml(xml_path, info):
213213
options.set("customize", "allow")
214214
options.set("customLocation", "/")
215215

216+
arch = "arm64" if info["_platform"] == "osx-arm64" else "x86_64"
217+
arch_key = ET.Element("options", hostArchitectures=arch)
218+
root.append(arch_key)
219+
216220
# By default, the package builder puts all of our options under
217221
# a single master choice. This deletes that master choice and
218222
# allows the user to see all options without effort.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* Add architecture checks to macOS SH and PKG installers. (#1153)
4+
5+
### Bug fixes
6+
7+
* <news item>
8+
9+
### Deprecations
10+
11+
* <news item>
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

tests/test_header.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_osxpkg_scripts_shellcheck(arch, check_path_spaces, script):
9191
@pytest.mark.parametrize("initialize_by_default", [True])
9292
@pytest.mark.parametrize("has_post_install", [True])
9393
@pytest.mark.parametrize("has_pre_install", [False])
94-
@pytest.mark.parametrize("arch", ["x86_64", "aarch64"])
94+
@pytest.mark.parametrize("arch", ["x86_64", "aarch64", "arm64"])
9595
@pytest.mark.parametrize("check_path_spaces", [True])
9696
@pytest.mark.parametrize("enable_shortcuts", ["true"])
9797
@pytest.mark.parametrize("min_glibc_version", ["2.17"])
@@ -130,6 +130,7 @@ def test_template_shellcheck(
130130
"ppc64le": arch == "ppc64le",
131131
"s390x": arch == "s390x",
132132
"aarch64": arch == "aarch64",
133+
"arm64": arch == "arm64",
133134
"linux": not osx,
134135
"has_pre_install": has_pre_install,
135136
"direct_execute_pre_install": direct_execute_pre_install,

0 commit comments

Comments
 (0)