Search in sources :

Example 1 with ComponentParam

use of org.graalvm.component.installer.ComponentParam in project graal by oracle.

the class UpgradeProcess method prepareInstall.

/**
 * Prepares the installation of the core Component. Returns {@code false} if the upgrade is not
 * necessary or not found.
 *
 * @param info
 * @return true, if the graalvm should be updated.
 * @throws IOException
 */
boolean prepareInstall(ComponentInfo info) throws IOException {
    Version min = input.getLocalRegistry().getGraalVersion();
    if (info == null) {
        feedback.message("UPGRADE_NoUpdateFound", min.displayString());
        return false;
    }
    int cmp = min.compareTo(info.getVersion());
    if ((cmp > 0) || ((editionUpgrade == null) && (cmp == 0))) {
        feedback.message("UPGRADE_NoUpdateLatestVersion", min.displayString());
        migrated.clear();
        return false;
    }
    Path reported = createInstallName(info);
    // there's a slight chance this will be different from the final name ...
    feedback.output("UPGRADE_PreparingInstall", info.getVersion().displayString(), reported);
    failIfDirectotyExistsNotEmpty(reported);
    ComponentParam coreParam = createGraalComponentParam(info);
    // reuse License logic from the installer command:
    InstallCommand cmd = new InstallCommand();
    cmd.init(input, feedback);
    // ask the InstallCommand to process/accept the licenses, if there are any.
    MetadataLoader ldr = coreParam.createMetaLoader();
    cmd.addLicenseToAccept(ldr);
    cmd.acceptLicenses();
    acceptedLicenseIDs = cmd.getProcessedLicenses();
    // force download
    ComponentParam param = input.existingFiles().createParam("core", info);
    metaLoader = param.createFileLoader();
    ComponentInfo completeInfo = metaLoader.completeMetadata();
    newInstallPath = createInstallName(completeInfo);
    newGraalHomePath = newInstallPath;
    failIfDirectotyExistsNotEmpty(newInstallPath);
    if (!reported.equals(newInstallPath)) {
        feedback.error("UPGRADE_WarningEditionDifferent", null, info.getVersion().displayString(), newInstallPath);
    }
    existingComponents.addAll(input.getLocalRegistry().getComponentIDs());
    existingComponents.remove(BundleConstants.GRAAL_COMPONENT_ID);
    return true;
}
Also used : Path(java.nio.file.Path) Version(org.graalvm.component.installer.Version) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 2 with ComponentParam

use of org.graalvm.component.installer.ComponentParam in project graal by oracle.

the class UpgradeProcess method allComponents.

public List<ComponentParam> allComponents() throws IOException {
    Set<String> ids = new HashSet<>();
    ArrayList<ComponentParam> allComps = new ArrayList<>(addedComponents());
    for (ComponentParam p : allComps) {
        ids.add(p.createMetaLoader().getComponentInfo().getId());
    }
    for (ComponentInfo mig : migrated) {
        if (ids.contains(mig.getId())) {
            continue;
        }
        allComps.add(input.existingFiles().createParam(mig.getId(), mig));
    }
    return allComps;
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet)

Example 3 with ComponentParam

use of org.graalvm.component.installer.ComponentParam in project graal by oracle.

the class CatalogInstallTest method testRejectNewerInstallVersion.

/**
 * Version 20.3.0 should not accept 20.3.1 (20.3.1.2, 20.3.1.3, ...) components.
 *
 * @throws Exception
 */
@Test
public void testRejectNewerInstallVersion() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "20.3.0");
    setupCatalog("data/catalog21patch.properties");
    textParams.add("llvm-toolchain");
    paramIterable = new CatalogIterable(this, this);
    Iterator<ComponentParam> params = paramIterable.iterator();
    assertTrue(params.hasNext());
    ComponentParam toolchainParam = params.next();
    ComponentInfo toolchainInfo = toolchainParam.createMetaLoader().getComponentInfo();
    assertNotNull(toolchainInfo);
    assertEquals("org.graalvm.llvm-toolchain", toolchainInfo.getId());
    assertEquals("Only release is compatible", "20.3.0", toolchainInfo.getVersion().displayString());
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) CatalogIterable(org.graalvm.component.installer.remote.CatalogIterable) Test(org.junit.Test)

Example 4 with ComponentParam

use of org.graalvm.component.installer.ComponentParam in project graal by oracle.

the class CatalogInstallTest method testAcceptCompatibleOlders.

/**
 * Checks that older versions are acceptable.
 *
 * @throws Exception
 */
@Test
public void testAcceptCompatibleOlders() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "21.0.0.2");
    setupCatalog("data/catalog21patch.properties");
    Collection<ComponentInfo> infos;
    infos = registry.loadComponents("r", localRegistry.getGraalVersion().match(Version.Match.Type.INSTALLABLE), false);
    assertEquals("1 older version ", 1, infos.size());
    assertEquals("21.0.0", infos.iterator().next().getVersion().displayString());
    infos = registry.loadComponents("python", localRegistry.getGraalVersion().match(Version.Match.Type.INSTALLABLE), false);
    assertEquals("2 older and current versions ", 2, infos.size());
    assertNotNull("21.0.0.2 present", findVersion(infos, "21.0.0.2"));
    assertNotNull("21.0.0.0 present", findVersion(infos, "21.0.0.0"));
    textParams.add("python");
    paramIterable = new CatalogIterable(this, this);
    Iterator<ComponentParam> params = paramIterable.iterator();
    ComponentParam pythonParam = params.next();
    ComponentInfo pythonInfo = pythonParam.createMetaLoader().getComponentInfo();
    assertNotNull(pythonInfo);
    assertEquals("Current version offered", "21.0.0.2", pythonInfo.getVersion().toString());
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) CatalogIterable(org.graalvm.component.installer.remote.CatalogIterable) Test(org.junit.Test)

Example 5 with ComponentParam

use of org.graalvm.component.installer.ComponentParam in project graal by oracle.

the class CatalogInstallTest method testAcceptsNewerPatchInstallVersion.

@Test
public void testAcceptsNewerPatchInstallVersion() throws Exception {
    storage.graalInfo.put(CommonConstants.CAP_GRAALVM_VERSION, "21.0.0.0");
    setupCatalog("data/catalog21patch.properties");
    textParams.add("ruby");
    textParams.add("python");
    Collection<ComponentInfo> infos = registry.loadComponents("ruby", localRegistry.getGraalVersion().match(Version.Match.Type.COMPATIBLE), false);
    assertEquals("Release and patch ruby available", 2, infos.size());
    paramIterable = new CatalogIterable(this, this);
    Iterator<ComponentParam> params = paramIterable.iterator();
    assertTrue(params.hasNext());
    ComponentParam rubyParam = params.next();
    ComponentInfo rubyInfo = rubyParam.createMetaLoader().getComponentInfo();
    assertNotNull(rubyInfo);
    assertEquals("org.graalvm.ruby", rubyInfo.getId());
    assertEquals("Only release is compatible", "21.0.0", rubyInfo.getVersion().displayString());
    ComponentParam pythonParam = params.next();
    ComponentInfo pythonInfo = pythonParam.createMetaLoader().getComponentInfo();
    assertNotNull(pythonInfo);
    assertEquals("org.graalvm.python", pythonInfo.getId());
    assertEquals("Patch can be installed", "21.0.0.2", pythonInfo.getVersion().displayString());
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) CatalogIterable(org.graalvm.component.installer.remote.CatalogIterable) Test(org.junit.Test)

Aggregations

ComponentParam (org.graalvm.component.installer.ComponentParam)24 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)19 Test (org.junit.Test)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)6 CatalogIterable (org.graalvm.component.installer.remote.CatalogIterable)5 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)4 Version (org.graalvm.component.installer.Version)4 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Archive (org.graalvm.component.installer.Archive)2 CommandInput (org.graalvm.component.installer.CommandInput)2 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Path (java.nio.file.Path)1