36
36
PREVIEW_ROOT = "http://mirror.openshift.com/pub/openshift-v4/{}/clients/ocp-dev-preview/"
37
37
38
38
VERSION_RE = re .compile (r"^openshift-install-(?P<platform>\w+)"
39
- r"(?P<architecture>- \w+)?-(?P<version>\d+.*)\.tar\.gz" )
39
+ r"(-( ?P<architecture>\w+) )?-(?P<version>\d+.*)\.tar\.gz" )
40
40
EXTRACTION_RE = re .compile (r'.*Extracting tools for .*, may take up to a minute.*' )
41
41
42
42
43
43
def _current_platform ():
44
44
if platform .system () == "Linux" and platform .machine () == "x86_64" :
45
45
return "linux" , "amd64"
46
+ if platform .system () == "Linux" and platform .machine () == "arm64" :
47
+ return "linux" , "arm64"
46
48
if platform .system () == "Darwin" and platform .machine () == "arm64" :
47
49
return "mac" , "arm64"
48
50
if platform .system () == "Darwin" and platform .machine () == "x86_64" :
49
- return "mac" , None
51
+ return "mac" , "amd64"
50
52
raise Exception (f"Unrecognized platform { platform .system ()} { platform .machine ()} " )
51
53
52
54
53
- def get_url (directory : str ) -> Tuple [Optional [str ], Optional [str ]]:
55
+ def get_url (directory : str , arch : str ) -> Tuple [Optional [str ], Optional [str ]]:
54
56
"""Searches the http directory and returns both url to installer
55
57
and version.
56
58
"""
57
59
lst = requests .get (directory , allow_redirects = True )
58
60
tree = BeautifulSoup (lst .content , 'html.parser' )
59
61
links = tree .find_all ('a' )
60
62
installer , version = None , None
61
- os_name , arch = _current_platform ()
63
+ os_name , local_arch = _current_platform ()
62
64
for k in links :
63
65
match = VERSION_RE .match (k .get ('href' ))
64
66
if match and match .group ('platform' ) == os_name :
65
- if (arch and not match .group ('architecture' )) \
66
- or (not arch and match .group ('architecture' )):
67
- continue
68
- installer = lst . url + k . get ( 'href ' )
69
- version = match . group ( 'version' )
67
+ if (local_arch == match .group ('architecture' )) \
68
+ or (local_arch == arch and not match .group ('architecture' )):
69
+ installer = lst . url + k . get ( 'href' )
70
+ version = match . group ( 'version ' )
71
+ break
70
72
return installer , version
71
73
72
74
73
- def get_devel_url (version : str ) -> str :
75
+ def get_devel_url (version : str , arch : str ) -> Tuple [ Optional [ str ], Optional [ str ]] :
74
76
"""
75
77
Searches developement sources and returns url to installer
76
78
"""
@@ -83,17 +85,17 @@ def get_devel_url(version: str) -> str:
83
85
req = requests .get (BUILD_ROOT + version , allow_redirects = True )
84
86
ast = BeautifulSoup (req .content , 'html.parser' )
85
87
logging .debug ('Installer found on page, continuing' )
86
- return get_url (req .url )
88
+ return get_url (req .url , arch )
87
89
88
90
89
- def get_prev_url (version , arch ) :
91
+ def get_prev_url (version : str , arch : str ) -> Tuple [ Optional [ str ], Optional [ str ]] :
90
92
"""Returns installer url from dev-preview sources"""
91
- return get_url (PREVIEW_ROOT .format (arch ) + version )
93
+ return get_url (PREVIEW_ROOT .format (arch ) + version , arch )
92
94
93
95
94
- def get_prod_url (version , arch ) :
96
+ def get_prod_url (version : str , arch : str ) -> Tuple [ Optional [ str ], Optional [ str ]] :
95
97
"""Returns installer url from production sources"""
96
- return get_url (PROD_ROOT .format (arch ) + version )
98
+ return get_url (PROD_ROOT .format (arch ) + version , arch )
97
99
98
100
99
101
def _get_storage_path (version : str , install_base : str ) -> str :
0 commit comments