Skip to content

Commit 2448387

Browse files
committed
Merge pull request #8 in ~SVATOPLUK.DEDIC_ORACLE.COM/graal from bugfix/installer_upgrade_noreinst to feature/installer_multi_versions
* commit '3d88cff9280198329edde52258c33f0a7aa366a9': [GR-15468] Do not reinstall modules into the same installation
2 parents cbb101c + 3d88cff commit 2448387

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

vm/src/org.graalvm.component.installer.test/src/org/graalvm/component/installer/commands/UpgradeTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
import java.io.IOException;
2828
import java.nio.file.Files;
2929
import java.nio.file.Path;
30+
import java.util.List;
3031
import org.graalvm.component.installer.BundleConstants;
3132
import org.graalvm.component.installer.CommandTestBase;
3233
import org.graalvm.component.installer.Commands;
34+
import org.graalvm.component.installer.ComponentParam;
3335
import org.graalvm.component.installer.FailedOperationException;
3436
import org.graalvm.component.installer.Version;
3537
import org.graalvm.component.installer.model.CatalogContents;
@@ -250,6 +252,36 @@ public void testInstallWithoutCoreUpgrade() throws Exception {
250252
assertFalse(inst);
251253
}
252254

255+
/**
256+
* Upgrade command is used to install a new component, but the core is most recent one and need
257+
* not to be upgraded. Component must go to the existing install.
258+
*
259+
* @throws Exception
260+
*/
261+
@Test
262+
public void testInstallNewWithoutCoreUpgrade() throws Exception {
263+
initVersion("1.0.1.0");
264+
textParams.add("ruby");
265+
266+
UpgradeCommand cmd = new UpgradeCommand();
267+
cmd.init(this, this);
268+
helper = cmd.getProcess();
269+
270+
ComponentInfo info = cmd.configureProcess();
271+
assertNotNull(info);
272+
// will not install core
273+
assertFalse(helper.installGraalCore(info));
274+
assertNull(helper.getTargetInfo());
275+
276+
// found the current graalvm:
277+
assertEquals(getLocalRegistry().getGraalVersion(), info.getVersion());
278+
List<ComponentParam> toDownload = helper.allComponents();
279+
280+
// no component (e.g. migration) was added, requested ruby is in there
281+
assertEquals(1, toDownload.size());
282+
assertEquals("org.graalvm.ruby", toDownload.get(0).getShortName());
283+
}
284+
253285
/**
254286
* Checks that "gu update r" will only update to a minor update, not to the next major.
255287
*

vm/src/org.graalvm.component.installer.test/src/org/graalvm/component/installer/remote/RemoteCatalogDownloaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private void setupJoinedCatalog(String firstPart) throws IOException {
153153

154154
private static ComponentInfo findComponent(ComponentCollection col, String id) {
155155
Collection<ComponentInfo> infos = col.loadComponents(id, Version.NO_VERSION.match(Version.Match.Type.GREATER), false);
156-
return infos == null ? null : infos.iterator().next();
156+
return infos == null || infos.isEmpty() ? null : infos.iterator().next();
157157
}
158158

159159
/**

vm/src/org.graalvm.component.installer/src/org/graalvm/component/installer/commands/Bundle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ UNINSTALL_NativeComponent={0} is a native component, use system tools to remove
275275
UNINSTALL_CoreComponent={0} is a core component and cannot be uninstalled.
276276

277277
# {0} - the current version
278-
UPGRADE_NoUpdateFound=No upgrade is found for the version {0}
279-
UPGRADE_NoUpdateLatestVersion=No upgrade is necessary, {0} is the latest version.
278+
UPGRADE_NoUpdateFound=No GraalVM VCore upgrade is found for the version {0}
279+
UPGRADE_NoUpdateLatestVersion=No upgrade of GraalVM core is necessary, {0} is the latest version.
280280
# {0} - directory where a new installation should be created
281281
UPGRADE_DirectoryNotWritable=New GraalVM installation cannot be created: directory {0} is not writable.
282282
# {0} - directory where a new installation should be created

vm/src/org.graalvm.component.installer/src/org/graalvm/component/installer/commands/UpgradeProcess.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ boolean prepareInstall(ComponentInfo info) throws IOException {
202202
}
203203
if (min.compareTo(info.getVersion()) >= 0) {
204204
feedback.message("UPGRADE_NoUpdateLatestVersion", min);
205+
migrated.clear();
205206
return false;
206207
}
207208

@@ -297,7 +298,7 @@ public ComponentInfo findGraalVersion(Version.Match minimum) throws IOException
297298
}
298299
Collection<ComponentInfo> graals = catalog.loadComponents(BundleConstants.GRAAL_COMPONENT_ID,
299300
filter, false);
300-
if (graals.isEmpty()) {
301+
if (graals == null || graals.isEmpty()) {
301302
return null;
302303
}
303304
List<ComponentInfo> versions = new ArrayList<>(graals);
@@ -340,8 +341,12 @@ public ComponentInfo findGraalVersion(Version.Match minimum) throws IOException
340341
installables = first;
341342
}
342343
migrated.clear();
343-
migrated.addAll(installables);
344-
return targetInfo = result;
344+
// if the result GraalVM is identical to current, do not migrate anything.
345+
if (result != null && !input.getLocalRegistry().getGraalVersion().equals(result.getVersion())) {
346+
migrated.addAll(installables);
347+
targetInfo = result;
348+
}
349+
return result;
345350
}
346351

347352
public boolean didUpgrade() {

0 commit comments

Comments
 (0)