Skip to content

Commit 0a25388

Browse files
committed
Add support for m1 processors and fix behaviour on mac
1 parent 52bb36c commit 0a25388

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

Diff for: osia/installer/downloader/install.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# limitations under the License.
1616
"""Module responsible for download of openshift-install binary"""
1717
from shutil import copyfileobj
18-
from sys import platform
1918
from tempfile import NamedTemporaryFile
2019
from pathlib import Path
2120
from typing import Tuple, Optional
21+
import platform
2222

2323
import logging
2424
import re
@@ -35,16 +35,18 @@
3535
BUILD_ROOT = "https://openshift-release-artifacts.svc.ci.openshift.org/"
3636
PREVIEW_ROOT = "http://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/"
3737

38-
VERSION_RE = re.compile(r"^openshift-install-(?P<platform>\w+)-(?P<version>.*)\.tar\.gz")
38+
VERSION_RE = re.compile(r"^openshift-install-(?P<platform>\w+)(?P<architecture>-\w+)?-(?P<version>\d+.*)\.tar\.gz")
3939
EXTRACTION_RE = re.compile(r'.*Extracting tools for .*, may take up to a minute.*')
4040

4141

4242
def _current_platform():
43-
if platform == "linux":
44-
return platform
45-
if platform == "darwin":
46-
return "mac"
47-
raise Exception(f"Unrecognized platform {platform}")
43+
if platform.system() == "Linux" and platform.machine() == "x86_64":
44+
return "linux", None
45+
if platform.system() == "Darwin" and platform.machine() == "arm64":
46+
return "mac", "arm64"
47+
if platform.system() == "Darwin" and platform.machine() == "x86_64":
48+
return "mac", None
49+
raise Exception(f"Unrecognized platform {platform.system()} {platform.machine()}")
4850

4951

5052
def get_url(directory: str) -> Tuple[Optional[str], Optional[str]]:
@@ -55,9 +57,12 @@ def get_url(directory: str) -> Tuple[Optional[str], Optional[str]]:
5557
tree = BeautifulSoup(lst.content, 'html.parser')
5658
links = tree.find_all('a')
5759
installer, version = None, None
60+
os_name, arch = _current_platform()
5861
for k in links:
5962
match = VERSION_RE.match(k.get('href'))
60-
if match and match.group('platform') == _current_platform():
63+
if match and match.group('platform') == os_name:
64+
if (arch and not match.group('architecture')) or (not arch and match.group('architecture')):
65+
continue
6166
installer = lst.url + k.get('href')
6267
version = match.group('version')
6368
return installer, version
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2022 Osia authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

0 commit comments

Comments
 (0)