Search in sources :

Example 6 with ComponentInfo

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

the class MergeStorage method loadComponentMetadata.

@Override
public Set<ComponentInfo> loadComponentMetadata(String id) throws IOException {
    Set<ComponentInfo> cis = new HashSet<>();
    for (SoftwareChannel swch : channels) {
        Set<ComponentInfo> newInfos = swch.getStorage().loadComponentMetadata(id);
        if (newInfos == null || newInfos.isEmpty()) {
            continue;
        }
        if (!acceptAllSources) {
            newInfos.removeAll(cis);
        }
        for (ComponentInfo ci : newInfos) {
            ci.setPriority(getChannelPriority(swch));
            channelMap.put(ci, swch);
        }
        cis.addAll(newInfos);
        if (!acceptAllSources) {
            break;
        }
    }
    return cis;
}
Also used : SoftwareChannel(org.graalvm.component.installer.SoftwareChannel) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet)

Example 7 with ComponentInfo

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

the class RemotePropertiesStorage method loadComponentMetadata.

@Override
public Set<ComponentInfo> loadComponentMetadata(String id) throws IOException {
    Properties compProps = filterPropertiesForVersions(id);
    if (compProps == null) {
        return null;
    }
    Map<String, ComponentInfo> infos = new HashMap<>();
    Set<String> processedPrefixes = new HashSet<>();
    for (String s : compProps.stringPropertyNames()) {
        int slashPos = s.indexOf('/');
        int anotherSlashPos = s.indexOf('/', slashPos + 1);
        String vS = s.substring(0, slashPos);
        String identity = anotherSlashPos == -1 ? vS : s.substring(0, anotherSlashPos);
        if (!processedPrefixes.add(identity)) {
            continue;
        }
        try {
            Version.fromString(vS);
        } catch (IllegalArgumentException ex) {
            feedback.verboseOutput("REMOTE_BadComponentVersion", s);
            continue;
        }
        ComponentInfo ci = createVersionedComponent(identity + "/", compProps, id, anotherSlashPos == -1 ? "" : s.substring(slashPos + 1, anotherSlashPos));
        // just in case the catalog info is broken
        if (ci != null) {
            infos.put(identity, ci);
        }
    }
    return new HashSet<>(infos.values());
}
Also used : HashMap(java.util.HashMap) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Properties(java.util.Properties) HashSet(java.util.HashSet)

Example 8 with ComponentInfo

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

the class RemotePropertiesStorage method createVersionedComponent.

private ComponentInfo createVersionedComponent(String versoPrefix, Properties filtered, String id, String tag) throws IOException {
    URL downloadURL;
    String s = filtered.getProperty(versoPrefix + id.toLowerCase());
    if (s == null) {
        return null;
    }
    // try {
    downloadURL = new URL(baseURL, s);
    // NOI18N
    String prefix = versoPrefix + id.toLowerCase() + "-";
    String hashS = filtered.getProperty(prefix + PROPERTY_HASH);
    byte[] hash = hashS == null ? null : toHashBytes(id, hashS);
    ComponentPackageLoader ldr = new ComponentPackageLoader(tag, new PrefixedPropertyReader(prefix, filtered), feedback);
    ComponentInfo info = ldr.createComponentInfo();
    info.setRemoteURL(downloadURL);
    info.setShaDigest(hash);
    info.setOrigin(baseURL.toString());
    return configureComponentInfo(info);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) URL(java.net.URL) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader)

Example 9 with ComponentInfo

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

the class DirectoryStorage method getCoreInfo.

private ComponentInfo getCoreInfo() {
    if (graalCore != null) {
        return graalCore;
    }
    ComponentInfo ci = null;
    try {
        Path cmpFile = registryPath.resolve(SystemUtils.fileName(BundleConstants.GRAAL_COMPONENT_ID + COMPONENT_FILE_SUFFIX));
        if (Files.isReadable(cmpFile)) {
            ci = doLoadComponentMetadata(cmpFile, false);
            if (ci != null && !BundleConstants.GRAAL_COMPONENT_ID.equals(ci.getId())) {
                // invalid definition
                ci = null;
            }
        }
    } catch (IOException ex) {
    // ignore
    }
    if (ci == null) {
        Version v = getGraalVMVersion();
        ci = new ComponentInfo(BundleConstants.GRAAL_COMPONENT_ID, feedback.l10n("NAME_GraalCoreComponent"), v.originalString());
        // set defaults: bundled, supported.
        ci.setStability(StabilityLevel.Supported);
    }
    Path cmpFile = registryPath.resolve(SystemUtils.fileName(BundleConstants.GRAAL_COMPONENT_ID + NATIVE_COMPONENT_FILE_SUFFIX));
    if (Files.exists(cmpFile)) {
        ci.setNativeComponent(true);
    }
    ci.setDistributionType(DistributionType.BUNDLED);
    graalCore = ci;
    return graalCore;
}
Also used : Path(java.nio.file.Path) Version(org.graalvm.component.installer.Version) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 10 with ComponentInfo

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

the class CatalogInstallTest method testInstallDepsOnCommandLineCommon.

private void testInstallDepsOnCommandLineCommon() throws Exception {
    paramIterable = new CatalogIterable(this, this);
    textParams.add("r");
    textParams.add("llvm-toolchain");
    InstallCommand cmd = new InstallCommand();
    cmd.init(this, withBundle(InstallCommand.class));
    cmd.executionInit();
    cmd.executeStep(cmd::prepareInstallation, false);
    cmd.executeStep(cmd::completeInstallers, false);
    List<Installer> instSequence = cmd.getInstallers();
    assertEquals(2, instSequence.size());
    ComponentInfo ci = instSequence.get(0).getComponentInfo();
    assertEquals("org.graalvm.llvm-toolchain", ci.getId());
    ci = instSequence.get(1).getComponentInfo();
    assertEquals("org.graalvm.r", ci.getId());
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) CatalogIterable(org.graalvm.component.installer.remote.CatalogIterable)

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