Search in sources :

Example 6 with ComponentParam

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

the class UpgradeTest method testInstallNewWithoutCoreUpgrade.

/**
 * Upgrade command is used to install a new component, but the core is most recent one and need
 * not to be upgraded. Component must go to the existing install.
 *
 * @throws Exception
 */
@Test
public void testInstallNewWithoutCoreUpgrade() throws Exception {
    initVersion("1.0.1.0");
    textParams.add("ruby");
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    helper = cmd.getProcess();
    ComponentInfo info = cmd.configureProcess();
    assertNotNull(info);
    // will not install core
    assertFalse(helper.installGraalCore(info));
    assertNull(helper.getTargetInfo());
    // found the current graalvm:
    assertEquals(getLocalRegistry().getGraalVersion(), info.getVersion());
    List<ComponentParam> toDownload = helper.allComponents();
    // no component (e.g. migration) was added, requested ruby is in there
    assertEquals(1, toDownload.size());
    assertEquals("org.graalvm.ruby", toDownload.get(0).getShortName());
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 7 with ComponentParam

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

the class UpgradeTest method testUpgradeFromDevToSpecificVersion2.

/**
 * Checks that upgrade will install graal for the specific Component.
 */
@Test
public void testUpgradeFromDevToSpecificVersion2() throws Exception {
    initVersion("1.0.0-dev");
    textParams.add("python=1.0.1");
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    ComponentInfo graalInfo = cmd.configureProcess();
    assertNotNull(graalInfo);
    // check that GraalVM appropriate for 1.0.1 component is selected
    assertEquals("1.0.1.0", graalInfo.getVersion().toString());
    assertEquals(1, cmd.getProcess().addedComponents().size());
    ComponentParam p = cmd.getProcess().addedComponents().iterator().next();
    ComponentInfo ci = p.createMetaLoader().getComponentInfo();
    // check that component 1.0.1 will be installed
    assertEquals("1.0.1.0", ci.getVersion().toString());
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 8 with ComponentParam

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

the class InstallCommand method addDependencies.

void addDependencies(ComponentInfo ci) {
    if (input.hasOption(Commands.OPTION_NO_DEPENDENCIES)) {
        return;
    }
    // dependencies are scanned breadth-first; so the deeper dependencies are
    // later in the iterator order. Installers from dependencies will be reversed
    // in registerComponent
    Set<ComponentInfo> deps = new LinkedHashSet<>();
    LOG.log(Level.FINE, "Inspecting dependencies of {0}", ci);
    Set<String> errors = input.getRegistry().findDependencies(ci, true, Boolean.FALSE, deps);
    LOG.log(Level.FINE, "Direct dependencies: {0}, errors: {1}", new Object[] { deps, errors });
    if (errors != null) {
        unresolvedDependencies.addAll(errors);
        for (String s : errors) {
            dependencyMap.computeIfAbsent(s, (id) -> new HashSet<>()).add(ci);
        }
    }
    for (ComponentInfo i : deps) {
        // will be sorted later, when converting to Installers.
        if (!knownDeps.add(i)) {
            continue;
        }
        ComponentParam p = input.existingFiles().createParam(i.getId(), i);
        dependencies.add(p);
        dependencyMap.computeIfAbsent(i.getId(), (id) -> new HashSet<>()).add(ci);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) URL(java.net.URL) MessageDigest(java.security.MessageDigest) InstallerStopException(org.graalvm.component.installer.InstallerStopException) Commands(org.graalvm.component.installer.Commands) Verifier(org.graalvm.component.installer.model.Verifier) HashMap(java.util.HashMap) ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) Feedback(org.graalvm.component.installer.Feedback) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) UserAbortException(org.graalvm.component.installer.UserAbortException) Map(java.util.Map) LinkedHashSet(java.util.LinkedHashSet) CommandInput(org.graalvm.component.installer.CommandInput) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) Version(org.graalvm.component.installer.Version) Iterator(java.util.Iterator) ZipException(java.util.zip.ZipException) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) Logger(java.util.logging.Logger) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) DependencyException(org.graalvm.component.installer.DependencyException) SystemUtils(org.graalvm.component.installer.SystemUtils) List(java.util.List) DistributionType(org.graalvm.component.installer.model.DistributionType) ComponentParam(org.graalvm.component.installer.ComponentParam) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Pattern(java.util.regex.Pattern) InstallerCommand(org.graalvm.component.installer.InstallerCommand) Archive(org.graalvm.component.installer.Archive) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Collections(java.util.Collections) ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 9 with ComponentParam

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

the class InfoCommand method execute.

@Override
public int execute() throws IOException {
    if (input.optValue(Commands.OPTION_HELP) != null) {
        feedback.output("INFO_Help");
        return 0;
    }
    if (!input.hasParameter()) {
        feedback.error("INFO_MissingFilename", null);
        return 1;
    }
    try {
        collectComponents();
        printTable = getComponents().size() > 1 && !isVerbose() && !suppressTable;
        super.printComponents();
    } finally {
        for (ComponentParam c : components) {
            try {
                c.close();
            } catch (IOException ex) {
                ComponentInfo ci = c.createMetaLoader().getComponentInfo();
                feedback.error("INFO_ClosingComponent", ex, ci == null ? c.getSpecification() : shortenComponentId(ci), ex.getLocalizedMessage());
            }
        }
    }
    return 0;
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) IOException(java.io.IOException) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 10 with ComponentParam

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

the class InstallCommand method completeInstallers0.

void completeInstallers0(List<ComponentParam> in) throws IOException {
    // now fileName real installers for parameters which were omitted
    for (ComponentParam p : in) {
        Installer i = realInstallers.get(p);
        if (i == null) {
            MetadataLoader floader = p.createFileLoader();
            ComponentInfo initialInfo = parameterInfos.get(p);
            ComponentInfo finfo = floader.getComponentInfo();
            if (initialInfo != null && (!initialInfo.getId().equals(finfo.getId()) || !initialInfo.getVersion().equals(finfo.getVersion()))) {
                String msg = String.format(feedback.l10n("@INSTALL_Error_ComponentDiffers_Report"), initialInfo.getId(), finfo.getId(), initialInfo.getVersionString(), finfo.getVersionString());
                feedback.verbatimPart(msg, true, false);
                throw feedback.failure("INSTALL_Error_ComponentDiffers", null);
            }
            i = createInstaller(p, floader);
            if (!verifyInstaller(i)) {
                continue;
            }
            addLicenseToAccept(i, floader);
            registerComponent(i, p);
            if (validateBeforeInstall) {
                current = i.getComponentInfo().getName();
                i.validateAll();
            } else {
                if (!force) {
                    i.validateRequirements();
                }
            }
            realInstallers.put(p, i);
        }
    }
}
Also used : ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

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