15
15
# limitations under the License.
16
16
"""Module responsible for download of openshift-install binary"""
17
17
from shutil import copyfileobj
18
- from sys import platform
19
18
from tempfile import NamedTemporaryFile
20
19
from pathlib import Path
21
20
from typing import Tuple , Optional
21
+ import platform
22
22
23
23
import logging
24
24
import re
35
35
BUILD_ROOT = "https://openshift-release-artifacts.svc.ci.openshift.org/"
36
36
PREVIEW_ROOT = "http://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/"
37
37
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" )
39
39
EXTRACTION_RE = re .compile (r'.*Extracting tools for .*, may take up to a minute.*' )
40
40
41
41
42
42
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 ()} " )
48
50
49
51
50
52
def get_url (directory : str ) -> Tuple [Optional [str ], Optional [str ]]:
@@ -55,9 +57,12 @@ def get_url(directory: str) -> Tuple[Optional[str], Optional[str]]:
55
57
tree = BeautifulSoup (lst .content , 'html.parser' )
56
58
links = tree .find_all ('a' )
57
59
installer , version = None , None
60
+ os_name , arch = _current_platform ()
58
61
for k in links :
59
62
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
61
66
installer = lst .url + k .get ('href' )
62
67
version = match .group ('version' )
63
68
return installer , version
0 commit comments