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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations