use of org.graalvm.component.installer.Version in project graal by oracle.
the class UpgradeProcess method satisfiedAddedComponents.
/**
* Checks if the candidate GraalVM satisfies all dependencies of added components. Added
* components are those specified on the commandline;
*
* @param candidate candidate GraalVM component
* @return broken components
*/
Collection<ComponentInfo> satisfiedAddedComponents(ComponentInfo candidate) throws IOException {
List<ComponentInfo> broken = new ArrayList<>();
Version gv = candidate.getVersion();
Version.Match satisfies = gv.match(Version.Match.Type.COMPATIBLE);
for (ComponentParam param : addComponents) {
ComponentInfo in = param.createMetaLoader().getComponentInfo();
String vs = in.getRequiredGraalValues().get(BundleConstants.GRAAL_VERSION);
Version cv = Version.fromString(vs);
if (!satisfies.test(cv)) {
broken.add(in);
if (minVersion.compareTo(cv) < 0) {
minVersion = cv;
}
}
}
return broken;
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class UpgradeProcess method failIfDirectotyExistsNotEmpty.
void failIfDirectotyExistsNotEmpty(Path target) throws IOException {
if (!Files.exists(target)) {
return;
}
if (!Files.isDirectory(target)) {
throw feedback.failure("UPGRADE_TargetExistsNotDirectory", null, target);
}
Path ghome = target.resolve(SystemUtils.getGraalVMJDKRoot(input.getLocalRegistry()));
Path relFile = ghome.resolve("release");
if (Files.isReadable(relFile)) {
Version targetVersion = null;
try {
ComponentRegistry reg = createRegistryFor(ghome);
targetVersion = reg.getGraalVersion();
} catch (FailedOperationException ex) {
// ignore
}
if (targetVersion != null) {
throw feedback.failure("UPGRADE_TargetExistsContainsGraalVM", null, target, targetVersion.displayString());
}
}
if (Files.list(target).findFirst().isPresent()) {
throw feedback.failure("UPGRADE_TargetExistsNotEmpty", null, target);
}
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class GraalChannel method jsonToRelease.
/**
* Reads JSON object into {@link ReleaseEntry}.
*
* @param rk release id in the index; diagnostics.
* @param jo the JSON object to convert
* @return Release entry or {@code null} if the entry is for a different release / os / arch
* @throws IOException in case of I/O error or a malformed JSON.
*/
ReleaseEntry jsonToRelease(String rk, JSONObject jo) throws IOException {
String licenseString;
String catalogString;
JSONObject bases;
String name;
String versionString;
name = jo.getString(KEY_RELEASE_NAME);
licenseString = jo.has(KEY_RELEASE_LICENSE) ? jo.getString(KEY_RELEASE_LICENSE) : null;
catalogString = jo.getString(KEY_RELEASE_CATALOG);
bases = jo.getJSONObject(KEY_RELEASE_BASES);
if (catalogString == null || catalogString.isEmpty()) {
return null;
}
versionString = jo.getString(KEY_RELEASE_VRESION);
String javaString = jo.getString(KEY_RELEASE_JAVA);
String editionString = jo.getString(KEY_RELEASE_EDITION);
String licenseLabel = jo.has(KEY_RELEASE_LICENSE_LABEL) ? jo.getString(KEY_RELEASE_LICENSE_LABEL) : null;
Version v = Version.fromString(versionString);
String jv;
if (javaString.startsWith("jdk")) {
// NOI18N
// NOI18N
jv = "" + SystemUtils.interpretJavaMajorVersion(javaString.substring(3));
} else if (javaString.startsWith("java")) {
// NOI18N
// NOI18N
jv = "" + SystemUtils.interpretJavaMajorVersion(javaString.substring(4));
} else {
return null;
}
String u = null;
try {
u = licenseString;
URL licenseURL = licenseString == null || licenseString.isEmpty() ? null : resolveURL(licenseString);
u = catalogString;
URL catalogURL = resolveURL(catalogString);
ReleaseEntry e = new ReleaseEntry(rk, name, v, licenseURL, catalogURL);
e.setEdition(editionString);
e.setJavaVersion(jv);
e.setLicenseLabel(licenseLabel);
LOG.log(Level.FINEST, "Reading: {0}", rk);
if (bases == null) {
LOG.log(Level.FINER, "Release {0} has no bases.", rk);
return null;
}
for (String k : bases.keySet()) {
ReleaseEntry.BasePackage bp = jsonToBase(k, bases.getJSONObject(k));
if (bp == null) {
LOG.log(Level.FINER, "Invalid base: {0}", k);
continue;
}
if (verifyOsArch(rk + "-" + k, bp)) {
e.addBasePackage(bp);
}
}
return e;
} catch (MalformedURLException ex) {
invalidURLs.add(u);
return null;
}
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class CatalogContents method compatibleVersion.
public boolean compatibleVersion(ComponentInfo info) {
// excludes components that depend on obsolete versions
// excludes components that depend on
Version v = info.getVersion();
Version gv = graalVersion;
if (allowDistUpdate) {
return gv.updatable().compareTo(v.updatable()) <= 0;
} else {
Version giv = gv.installVersion();
Version civ = v.installVersion();
return giv.equals(civ);
}
}
use of org.graalvm.component.installer.Version in project graal by oracle.
the class RemotePropertiesStorage method splitPropertiesToComponents.
private void splitPropertiesToComponents() {
if (filteredComponents != null) {
return;
}
filteredComponents = new HashMap<>();
// known prefixes. Version will not be parsed again for therse.
Set<String> knownPrefixes = new HashSet<>();
// already accepted prefixes
Set<String> acceptedPrefixes = new HashSet<>();
Pattern flavourPattern = Pattern.compile("^" + flavourRegex, Pattern.CASE_INSENSITIVE);
Pattern singlePattern = Pattern.compile("^" + singleRegex, Pattern.CASE_INSENSITIVE);
for (String s : catalogProperties.stringPropertyNames()) {
String cid;
String pn;
int slashPos = s.indexOf('/');
int secondSlashPos = s.indexOf('/', slashPos + 1);
int l;
if (slashPos != -1 && secondSlashPos != -1) {
if (!flavourPattern.matcher(s).find()) {
continue;
}
pn = s.substring(slashPos + 1);
String pref = s.substring(0, secondSlashPos);
int lastSlashPos = s.indexOf('/', secondSlashPos + 1);
if (lastSlashPos == -1) {
lastSlashPos = secondSlashPos;
}
l = lastSlashPos + 1;
if (knownPrefixes.add(pref)) {
try {
Version vn = Version.fromString(s.substring(slashPos + 1, secondSlashPos));
if (acceptsVersion(vn)) {
acceptedPrefixes.add(pref);
}
} catch (IllegalArgumentException ex) {
feedback.verboseOutput("REMOTE_BadComponentVersion", pn);
}
}
if (!acceptedPrefixes.contains(pref)) {
// ignore obsolete versions
continue;
}
} else {
Matcher m = singlePattern.matcher(s);
if (!m.find()) {
continue;
}
// versionless component
l = m.end();
// normalized version
pn = graalVersion.toString() + "/" + s.substring(l);
}
int dashPos = s.indexOf("-", l);
if (dashPos == -1) {
dashPos = s.length();
}
cid = s.substring(l, dashPos);
String patchedCid = cid.replace("_", "-");
String patchedPn = pn.replace(cid, patchedCid);
filteredComponents.computeIfAbsent(patchedCid, (unused) -> new Properties()).setProperty(patchedPn, catalogProperties.getProperty(s));
}
}
Aggregations