Search in sources :

Example 61 with ComponentInfo

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

the class CatalogIterableTest method testCreateFileLoader.

@Test
public void testCreateFileLoader() throws Exception {
    initRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", "testComponent", "test");
    MetadataLoader ldr = param.createFileLoader();
    ldr.setNoVerifySymlinks(false);
    ldr.loadPaths();
    ldr.loadPermissions();
    ldr.loadSymlinks();
    ComponentInfo meta = ldr.getComponentInfo();
    assertEquals("ruby", meta.getId());
    assertNull(meta.getInfoPath());
    assertFalse(meta.getPaths().isEmpty());
    assertEquals("TruffleRuby 0.33-dev", meta.getName());
    assertEquals("0.33-dev", meta.getVersionString());
    assertTrue(Handler.isVisited(url));
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 62 with ComponentInfo

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

the class InstallCommand method printComponentList.

String printComponentList(Collection<ComponentInfo> requestors) {
    if (requestors == null || requestors.isEmpty()) {
        // NOI18N
        return "";
    }
    StringBuilder sb = new StringBuilder();
    List<ComponentInfo> infos = new ArrayList<>(requestors);
    Collections.sort(infos, (c1, c2) -> c1.getId().compareTo(c2.getId()));
    for (ComponentInfo i : infos) {
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(feedback.l10n("INSTALL_RequiredDependencyItem", i.getName(), i.getId()));
    }
    return feedback.l10n("INSTALL_RequiredDependencySuffix", sb.toString());
}
Also used : ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 63 with ComponentInfo

use of org.graalvm.component.installer.model.ComponentInfo 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 64 with ComponentInfo

use of org.graalvm.component.installer.model.ComponentInfo 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 65 with ComponentInfo

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

the class RemoteStorageTest method testLoadMetadata.

@Test
public void testLoadMetadata() throws Exception {
    ComponentInfo rInfo = loadLastComponent("r");
    assertEquals("FastR 0.33-dev", rInfo.getName());
    assertEquals("R", rInfo.getId());
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Aggregations

ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)149 Test (org.junit.Test)94 Path (java.nio.file.Path)36 Version (org.graalvm.component.installer.Version)28 HashSet (java.util.HashSet)20 ArrayList (java.util.ArrayList)19 ComponentParam (org.graalvm.component.installer.ComponentParam)19 IOException (java.io.IOException)13 URL (java.net.URL)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)10 InputStream (java.io.InputStream)9 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 List (java.util.List)8 Properties (java.util.Properties)8 Map (java.util.Map)7 Set (java.util.Set)7 Collections (java.util.Collections)6 FailedOperationException (org.graalvm.component.installer.FailedOperationException)6 SystemUtils (org.graalvm.component.installer.SystemUtils)6