Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 0261e99

Browse files
committed
Updated as per review comments
1 parent 328d9eb commit 0261e99

File tree

4 files changed

+48
-35
lines changed

4 files changed

+48
-35
lines changed

src/main/java/com/mathworks/ci/tools/MatlabInstallable.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ public MatlabInstallable (String osName) throws InstallationFailedException {
2525
this.batchURL = Message.getValue ("tools.matlab.batch.executable.linux");
2626
break;
2727
case "maci64":
28-
this.url = Message.getValue ("tools.matlab.mpm.installer.mac");
29-
this.batchURL = Message.getValue ("tools.matlab.batch.executable.mac");
28+
this.url = Message.getValue ("tools.matlab.mpm.installer.maci64");
29+
this.batchURL = Message.getValue ("tools.matlab.batch.executable.maci64");
30+
break;
31+
case "maca64":
32+
this.url = Message.getValue ("tools.matlab.mpm.installer.maca64");
33+
this.batchURL = Message.getValue ("tools.matlab.batch.executable.maca64");
3034
break;
3135
default:
3236
throw new InstallationFailedException ("Unsupported OS");

src/main/java/com/mathworks/ci/tools/MatlabInstaller.java

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ public FilePath performInstallation (ToolInstallation tool, Node node, TaskListe
102102
return expectedPath;
103103
}
104104

105-
private int installUsingMpm (Node node, FilePath expectedPath, TaskListener log, FilePath installedProducts)
105+
private int installUsingMpm (Node node, FilePath destination, TaskListener log, FilePath installedProducts)
106106
throws IOException, InterruptedException {
107107

108108
Launcher matlabInstaller = node.createLauncher (log);
109109
ProcStarter installerProc = matlabInstaller.launch ();
110110

111111
ArgumentListBuilder args = new ArgumentListBuilder ();
112-
args.add (expectedPath.getRemote () + getNodeSpecificMPMExecutor (node));
112+
args.add (destination.getRemote () + getNodeSpecificMPMExecutor (node));
113113
args.add ("install");
114114
appendReleaseToArguments (args, log);
115-
args.add ("--destination=" + expectedPath.getRemote ());
115+
args.add ("--destination=" + destination.getRemote ());
116116
addMatlabProductsToArgs (args, installedProducts);
117-
installerProc.pwd (expectedPath).cmds (args).stdout (log);
117+
installerProc.pwd (destination).cmds (args).stdout (log);
118118
int result;
119119
try {
120120
result = installerProc.join ();
@@ -179,28 +179,29 @@ private void updateProductList (FilePath installedProducts)
179179
}
180180

181181
private void appendReleaseToArguments (ArgumentListBuilder args, TaskListener log) {
182-
try {
183-
String trimmedRelease = this.getVersion ().trim ();
184-
String actualRelease = trimmedRelease;
185-
186-
if (trimmedRelease.equalsIgnoreCase ("latest") || trimmedRelease.equalsIgnoreCase (
187-
"latest-including-prerelease")) {
188-
String releaseInfoUrl =
189-
Message.getValue ("matlab.release.info.url") + trimmedRelease;
190-
String releaseVersion = IOUtils.toString (new URL (releaseInfoUrl),
182+
String trimmedRelease = this.getVersion ().trim ();
183+
String actualRelease = trimmedRelease;
184+
185+
if (trimmedRelease.equalsIgnoreCase ("latest") || trimmedRelease.equalsIgnoreCase (
186+
"latest-including-prerelease")) {
187+
String releaseInfoUrl =
188+
Message.getValue ("matlab.release.info.url") + trimmedRelease;
189+
String releaseVersion = null;
190+
try {
191+
releaseVersion = IOUtils.toString (new URL (releaseInfoUrl),
191192
StandardCharsets.UTF_8).trim ();
193+
} catch (IOException e) {
194+
log.getLogger ().println ("Failed to fetch release version: " + e.getMessage ());
195+
}
192196

193-
if (releaseVersion.contains ("prerelease")) {
194-
actualRelease = releaseVersion.replace ("prerelease", "");
195-
args.add ("--release-status=Prerelease");
196-
} else {
197-
actualRelease = releaseVersion;
198-
}
197+
if (releaseVersion != null && releaseVersion.contains ("prerelease")) {
198+
actualRelease = releaseVersion.replace ("prerelease", "");
199+
args.add ("--release-status=Prerelease");
200+
} else {
201+
actualRelease = releaseVersion;
199202
}
200-
args.add ("--release=" + actualRelease);
201-
} catch (IOException e) {
202-
log.getLogger().println("Failed to fetch release version: " + e.getMessage ());
203203
}
204+
args.add ("--release=" + actualRelease);
204205
}
205206

206207
private void getFreshCopyOfExecutables (MatlabInstallable installable, FilePath expectedPath)
@@ -250,21 +251,26 @@ public Installable getInstallable (Node node) throws IOException, InterruptedExc
250251
// Gather properties for the node to install on
251252
String[] properties = node.getChannel ()
252253
.call (new GetSystemProperties ("os.name", "os.arch", "os.version"));
253-
return getInstallCandidate (properties[0]);
254+
return getInstallCandidate (properties[0], properties[1]);
254255
}
255256

256-
public MatlabInstallable getInstallCandidate (String osName)
257+
public MatlabInstallable getInstallCandidate (String osName, String architecture)
257258
throws InstallationFailedException {
258-
String platform = getPlatform (osName);
259+
String platform = getPlatform (osName, architecture);
259260
return new MatlabInstallable (platform);
260261
}
261262

262-
public String getPlatform (String os) throws InstallationFailedException {
263+
public String getPlatform (String os, String architecture) throws InstallationFailedException {
263264
String value = os.toLowerCase (Locale.ENGLISH);
264265
if (value.contains ("linux")) {
265266
return "glnxa64";
266267
} else if (value.contains ("os x")) {
267-
return "maci64";
268+
if (architecture.equalsIgnoreCase ("aarch64") || architecture.equalsIgnoreCase (
269+
"arm64")) {
270+
return "maca64";
271+
} else {
272+
return "maci64";
273+
}
268274
} else if (value.contains ("windows")) {
269275
return "win64";
270276
} else {

src/main/resources/config.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ tools.matlab.mpm.installer.win = https://www.mathworks.com/mpm/win64/mpm
3535
tools.matlab.batch.executable.win = https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v1/win64/matlab-batch.exe
3636
tools.matlab.mpm.installer.linux = https://www.mathworks.com/mpm/glnxa64/mpm
3737
tools.matlab.batch.executable.linux = https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v1/glnxa64/matlab-batch
38-
tools.matlab.mpm.installer.mac = https://www.mathworks.com/mpm/maci64/mpm
39-
tools.matlab.batch.executable.mac = https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v1/maci64/matlab-batch
38+
tools.matlab.mpm.installer.maci64 = https://www.mathworks.com/mpm/maci64/mpm
39+
tools.matlab.batch.executable.maci64 = https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v1/maci64/matlab-batch
40+
tools.matlab.mpm.installer.maca64 = https://www.mathworks.com/mpm/maca64/mpm
41+
tools.matlab.batch.executable.maca64 = https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v1/maca64/matlab-batch
4042
tools.matlab.empty.version.error = MATLAB version is mandatory field.
4143

4244
matlab.release.info.url = https://ssd.mathworks.com/supportfiles/ci/matlab-release/v0/

src/test/java/unit/com/mathworks/ci/tools/MatlabInstallerUnitTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ public void testPerformInstallation () throws Exception {
7171

7272
@Test(expected = InstallationFailedException.class)
7373
public void testUnsupportedOS () throws Exception {
74-
installer.getPlatform ("unsupportedOS");
74+
installer.getPlatform ("unsupportedOS", "unsupportedArch");
7575
}
7676

7777
@Test
7878
public void testGetPlatform () throws InstallationFailedException {
79-
assertEquals ("glnxa64", installer.getPlatform ("Linux"));
80-
assertEquals ("maci64", installer.getPlatform ("Mac OS X"));
81-
assertEquals ("win64", installer.getPlatform ("Windows 10"));
79+
assertEquals ("glnxa64", installer.getPlatform ("Linux", "i686"));
80+
assertEquals ("maci64", installer.getPlatform ("Mac OS X", "amd64"));
81+
assertEquals ("maca64", installer.getPlatform ("Mac OS X", "arm64"));
82+
assertEquals ("win64", installer.getPlatform ("Windows 10", "x86"));
8283
}
8384
}

0 commit comments

Comments
 (0)