use of org.graalvm.component.installer.Version in project graal by oracle.
the class GDSChannel method loadArtifacts.
/**
* Loads the release index. Must be loaded from a local file.
*
* @param releasesIndexPath path to the downloaded releases index.
* @return list of entries in the index
* @throws IOException in case of I/O error.
*/
List<ComponentInfo> loadArtifacts(Path releasesIndexPath) throws IOException {
if (edition == null) {
edition = localRegistry.getGraalCapabilities().get(CommonConstants.CAP_EDITION);
}
List<ComponentInfo> result = new ArrayList<>();
try (InputStreamReader urlReader = new InputStreamReader(new GZIPInputStream(Files.newInputStream(releasesIndexPath)))) {
JSONTokener tokener = new JSONTokener(urlReader);
JSONObject obj = new JSONObject(tokener);
JSONArray releases = obj.getJSONArray(JSON_ITEMS);
if (releases == null) {
// malformed releases file;
throw new IncompatibleException(fb.l10n("OLDS_InvalidReleasesFile"));
}
Version v = localRegistry.getGraalVersion();
for (Object k : releases) {
JSONObject jo = (JSONObject) k;
ArtifactParser e;
try {
e = new ArtifactParser(jo);
} catch (JSONException | IllegalArgumentException ex) {
fb.error("OLDS_ErrorReadingRelease", ex, k, ex.getLocalizedMessage());
continue;
}
if (!OS.get().equals(OS.fromName(e.getOs()))) {
LOG.log(Level.FINER, "Incorrect OS: {0}", k);
} else if (!ARCH.get().equals(ARCH.fromName(e.getArch()))) {
LOG.log(Level.FINER, "Incorrect Arch: {0}", k);
} else if (!localRegistry.getJavaVersion().equals(e.getJava())) {
LOG.log(Level.FINER, "Incorrect Java: {0}", k);
} else if (edition != null && !edition.equals(e.getEdition())) {
LOG.log(Level.FINER, "Incorrect edition: {0}", k);
} else if (!acceptsVersion(v, Version.fromString(e.getVersion()))) {
LOG.log(Level.FINER, "Old version: {0} != {1}", new Object[] { v, Version.fromString(e.getVersion()), e.getVersion() });
} else {
result.add(e.asComponentInfo(gdsConnector, fb));
}
}
}
return result;
}
use of org.graalvm.component.installer.Version 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;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class CatalogContents method compatibleComponent.
private ComponentInfo compatibleComponent(List<ComponentInfo> cis, Version.Match versionSelect, boolean fallback) {
if (cis == null) {
return null;
}
ComponentInfo first = null;
Version.Match vm = versionMatch(versionSelect, cis);
boolean explicit = versionSelect != null && versionSelect.getType() != Version.Match.Type.MOSTRECENT;
for (int i = cis.size() - 1; i >= 0; i--) {
ComponentInfo ci = cis.get(i);
if (first == null) {
first = ci;
}
Version v = ci.getVersion();
if (!vm.test(v)) {
continue;
}
if (verifier.validateRequirements(ci).hasErrors()) {
continue;
}
if (explicit || compatibleVersion(ci)) {
return ci;
}
}
return fallback ? first : null;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class InstallVersionsTest method initVersion.
private Version initVersion(String s) throws IOException {
Version v = Version.fromString(s);
storage.graalInfo.put(BundleConstants.GRAAL_VERSION, s);
Path catalogPath = dataFile("../repo/catalog.properties");
RemoteCatalogDownloader downloader = new RemoteCatalogDownloader(this, this, catalogPath.toUri().toURL());
registry = new CatalogContents(this, downloader.getStorage(), localRegistry);
paramIterable = new CatalogIterable(this, this);
return v;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class ListTest method testListSpecifiedNewerComponentsExplicit.
/**
* Checks that compatible components will be listed if 1st parameter is the version.
*/
@Test
public void testListSpecifiedNewerComponentsExplicit() throws Exception {
Version v = Version.fromString("1.0.0");
storage.graalInfo.put(BundleConstants.GRAAL_VERSION, v.originalString());
textParams.add("+1.1.0");
assert110Components(v, Version.fromString("1.1.0"));
}
Aggregations