Search in sources :

Example 1 with SoftwareChannelSource

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

the class GraalChannel method loadStorage.

@Override
protected ComponentStorage loadStorage() throws IOException {
    FileDownloader dn = new FileDownloader(fb.l10n("OLDS_ReleaseFile"), getIndexURL(), fb);
    dn.download();
    Path storagePath = dn.getLocalFile().toPath();
    List<ReleaseEntry> releases = loadReleasesIndex(storagePath);
    if (releases.isEmpty()) {
        return throwEmptyStorage();
    }
    MergeStorage store = new MergeStorage(localRegistry, fb);
    store.setAcceptAllSources(true);
    for (ReleaseEntry en : releases) {
        URL catURL = en.getCatalogURL();
        Version v = Version.fromString(en.getVersion().displayString());
        SoftwareChannelSource src = new SoftwareChannelSource(catURL.toString(), en.getLabel());
        WebCatalog cata = new WebCatalog(src.getLocationURL(), src) {

            @Override
            protected RemotePropertiesStorage createPropertiesStorage(Feedback aFeedback, ComponentRegistry aLocal, Properties props, String selector, URL baseURL) {
                return new RemotePropertiesStorage(aFeedback, aLocal, props, selector, v, baseURL);
            }
        };
        cata.init(localRegistry, fb);
        cata.setMatchVersion(en.getVersion().match(Version.Match.Type.EXACT));
        cata.setRemoteProcessor((i) -> configureLicense(i, en));
        store.addChannel(src, cata);
    }
    return store;
}
Also used : Path(java.nio.file.Path) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) WebCatalog(org.graalvm.component.installer.ce.WebCatalog) RemotePropertiesStorage(org.graalvm.component.installer.remote.RemotePropertiesStorage) MergeStorage(org.graalvm.component.installer.remote.MergeStorage) Properties(java.util.Properties) URL(java.net.URL) Version(org.graalvm.component.installer.Version) Feedback(org.graalvm.component.installer.Feedback) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) FileDownloader(org.graalvm.component.installer.remote.FileDownloader)

Example 2 with SoftwareChannelSource

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

the class GraalEditionList method readChannelSources.

List<SoftwareChannelSource> readChannelSources(String id, String pref, Map<String, String> graalCaps) {
    List<SoftwareChannelSource> sources = new ArrayList<>();
    if (!remoteSourcesAllowed) {
        return sources;
    }
    String prefix = pref + CommonConstants.CAP_CATALOG_PREFIX;
    List<String> orderedKeys = graalCaps.keySet().stream().filter((k) -> {
        String lk = k.toLowerCase(Locale.ENGLISH);
        return lk.startsWith(prefix) && lk.endsWith(CAP_CATALOG_URL_SUFFIX);
    }).map((k) -> k.substring(0, k.length() - CAP_CATALOG_URL_SUFFIX.length())).collect(Collectors.toList());
    Collections.sort(orderedKeys, CHANNEL_KEY_COMPARATOR);
    int priority = 0;
    for (String key : orderedKeys) {
        String url = graalCaps.get(key + CAP_CATALOG_URL_SUFFIX);
        String lab = graalCaps.get(key + "_" + CommonConstants.CAP_CATALOG_LABEL);
        if (url == null) {
            continue;
        }
        SoftwareChannelSource s = new SoftwareChannelSource(url, lab);
        s.setPriority(priority);
        for (String a : graalCaps.keySet()) {
            if (!(a.startsWith(key) && a.length() > key.length() + 1)) {
                continue;
            }
            String k = a.substring(key.length() + 1).toLowerCase(Locale.ENGLISH);
            switch(k) {
                case CommonConstants.CAP_CATALOG_LABEL:
                case CommonConstants.CAP_CATALOG_URL:
                    continue;
            }
            s.setParameter(k, graalCaps.get(a));
        }
        if (s.getParameter("edition") == null) {
            s.setParameter("edition", id != null ? id : targetGraal.getGraalCapabilities().get(CommonConstants.CAP_EDITION));
        }
        sources.add(s);
        priority++;
    }
    return sources;
}
Also used : ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) SoftwareChannel(org.graalvm.component.installer.SoftwareChannel) CommonConstants(org.graalvm.component.installer.CommonConstants) DirectoryStorage(org.graalvm.component.installer.persist.DirectoryStorage) ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) Commands(org.graalvm.component.installer.Commands) HashMap(java.util.HashMap) Feedback(org.graalvm.component.installer.Feedback) CatalogContents(org.graalvm.component.installer.model.CatalogContents) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) FailedOperationException(org.graalvm.component.installer.FailedOperationException) List(java.util.List) Matcher(java.util.regex.Matcher) Stream(java.util.stream.Stream) GraalEdition(org.graalvm.component.installer.model.GraalEdition) Locale(java.util.Locale) Map(java.util.Map) Pattern(java.util.regex.Pattern) Comparator(java.util.Comparator) CatalogFactory(org.graalvm.component.installer.CommandInput.CatalogFactory) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Collections(java.util.Collections) CommandInput(org.graalvm.component.installer.CommandInput) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) ArrayList(java.util.ArrayList)

Example 3 with SoftwareChannelSource

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

the class RemoteCatalogDownloader method parseChannelSources.

@SuppressWarnings("ThrowableResultIgnored")
List<SoftwareChannelSource> parseChannelSources(String overrideSpec) {
    List<SoftwareChannelSource> sources = new ArrayList<>();
    if (overrideSpec == null) {
        return sources;
    }
    // NOI18N
    String[] parts = overrideSpec.split("\\|");
    for (String s : parts) {
        // NOI18N
        sources.add(new SoftwareChannelSource(s));
    }
    return sources;
}
Also used : SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) ArrayList(java.util.ArrayList)

Example 4 with SoftwareChannelSource

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

the class RemoteCatalogDownloader method mergeChannels.

private MergeStorage mergeChannels() {
    if (mergedStorage != null) {
        return mergedStorage;
    }
    mergedStorage = new MergeStorage(input.getLocalRegistry(), feedback);
    mergedStorage.setIgnoreCatalogErrors(input.hasOption(Commands.OPTION_IGNORE_CATALOG_ERRORS));
    for (SoftwareChannelSource spec : getChannelSources()) {
        SoftwareChannel ch = null;
        for (SoftwareChannel.Factory f : factories) {
            ch = f.createChannel(spec, input, feedback);
            if (ch != null) {
                break;
            }
        }
        if (ch != null) {
            mergedStorage.addChannel(spec, ch);
        }
    }
    return mergedStorage;
}
Also used : SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) SoftwareChannel(org.graalvm.component.installer.SoftwareChannel)

Example 5 with SoftwareChannelSource

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

the class CatalogInstallTest method testInstallDependencyFromSameDirectory.

/**
 * Checks that dependencies can be loaded from the same directory as the installed Component.
 */
@Test
public void testInstallDependencyFromSameDirectory() throws Exception {
    Path ruby193Source = dataFile("../repo/19.3.0.0/r");
    Path llvm193Source = dataFile("../repo/19.3.0.0/llvm-toolchain");
    // they should be next to eah other
    assertEquals(ruby193Source.getParent(), llvm193Source.getParent());
    files.add(ruby193Source.toFile());
    setupVersion("19.3.0.0");
    // no external catalog
    downloader = new RemoteCatalogDownloader(this, this, (URL) null);
    downloader.addLocalChannelSource(new SoftwareChannelSource(ruby193Source.getParent().toFile().toURI().toString()));
    catalogFactory = new CatalogFactory() {

        @Override
        public ComponentCatalog createComponentCatalog(CommandInput input) {
            return new CatalogContents(CatalogInstallTest.this, downloader.getStorage(), input.getLocalRegistry());
        }

        @Override
        public List<GraalEdition> listEditions(ComponentRegistry targetGraalVM) {
            return Collections.emptyList();
        }
    };
    FileIterable fit = new FileIterable(this, this);
    fit.setCatalogFactory(catalogFactory);
    paramIterable = fit;
    InstallCommand cmd = new InstallCommand();
    cmd.init(this, withBundle(InstallCommand.class));
    cmd.executionInit();
    cmd.executeStep(cmd::prepareInstallation, false);
    assertFalse(cmd.getDependencies().isEmpty());
}
Also used : Path(java.nio.file.Path) ComponentCatalog(org.graalvm.component.installer.ComponentCatalog) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) URL(java.net.URL) CommandInput(org.graalvm.component.installer.CommandInput) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) CatalogContents(org.graalvm.component.installer.model.CatalogContents) RemoteCatalogDownloader(org.graalvm.component.installer.remote.RemoteCatalogDownloader) List(java.util.List) FileIterable(org.graalvm.component.installer.FileIterable) Test(org.junit.Test)

Aggregations

SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)19 Test (org.junit.Test)10 GraalEdition (org.graalvm.component.installer.model.GraalEdition)8 URL (java.net.URL)6 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CommandInput (org.graalvm.component.installer.CommandInput)3 CommonConstants (org.graalvm.component.installer.CommonConstants)3 Feedback (org.graalvm.component.installer.Feedback)3 SoftwareChannel (org.graalvm.component.installer.SoftwareChannel)3 CatalogContents (org.graalvm.component.installer.model.CatalogContents)3 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)3 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)3 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)3 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 Map (java.util.Map)2