Search in sources :

Example 31 with Version

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

the class QueryCommandBase method findRequiredGraalVMVersion.

protected String findRequiredGraalVMVersion(ComponentInfo info) {
    String s = info.getRequiredGraalValues().get(CAP_GRAALVM_VERSION);
    if (s == null) {
        return val(s);
    }
    Version v = Version.fromString(s);
    return v.displayString();
}
Also used : Version(org.graalvm.component.installer.Version)

Example 32 with Version

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

the class UpgradeCommand method configureProcess.

ComponentInfo configureProcess() throws IOException {
    input.existingFiles().setVerifyJars(verifyJars);
    Version min = input.getLocalRegistry().getGraalVersion();
    String s = input.peekParameter();
    Version v = min;
    Version.Match filter = min.match(allowDistUpgrades() ? Version.Match.Type.MOSTRECENT : Version.Match.Type.COMPATIBLE);
    if (s != null) {
        try {
            Version.Match.Type mt = Version.Match.Type.COMPATIBLE;
            if (s.startsWith("=")) {
                mt = Version.Match.Type.EXACT;
                s = s.substring(1);
            } else if (s.startsWith("+")) {
                mt = Version.Match.Type.INSTALLABLE;
                s = s.substring(1);
            }
            v = Version.fromUserString(s);
            // cannot just compare user vs. graal, must match the user to the list of Graals to
            // resolve the
            // uncertaint parts (-x and possible suffix)
            filter = v.match(mt);
            if (min.compareTo(v) > 0) {
                throw feedback.failure("UPGRADE_CannotDowngrade", null, v.displayString());
            }
            input.nextParameter();
            input.existingFiles().matchVersion(filter);
        } catch (IllegalArgumentException ex) {
        // not a version, continue with component upgrade
        }
    }
    // allow dist upgrade when searching for components
    for (ComponentParam p : input.existingFiles()) {
        helper.addComponent(p);
    }
    ComponentInfo info = helper.findGraalVersion(filter);
    return info;
}
Also used : Version(org.graalvm.component.installer.Version) ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 33 with Version

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

the class InstallCommand method verifyInstaller.

boolean verifyInstaller(Installer inst) {
    ComponentInfo info = inst.getComponentInfo();
    Verifier vrf = inst.createVerifier();
    vrf.setVersionMatch(matchInstallVesion());
    vrf.validateRequirements(info);
    boolean keep = force || vrf.shouldInstall(info);
    if (!keep) {
        // component will be skipped, do not bother with validation
        feedback.output("INSTALL_ComponentAlreadyInstalled", inst.getComponentInfo().getName(), inst.getComponentInfo().getId());
        return false;
    }
    ComponentInfo existing = input.getLocalRegistry().findComponent(info.getId());
    if (existing != null) {
        // will refuse to install existing bundled components:
        if (existing.getDistributionType() != DistributionType.OPTIONAL) {
            throw new DependencyException.Conflict(existing.getId(), info.getVersionString(), existing.getVersionString(), feedback.l10n("INSTALL_CannotReplaceBundledComponent", existing.getName(), existing, existing.getVersionString()));
        }
    }
    Version minV = vrf.getMinVersion();
    if (minV != null && minV.compareTo(this.minRequiredGraalVersion) > 0) {
        minRequiredGraalVersion = minV;
    }
    addDependencies(info);
    return true;
}
Also used : Version(org.graalvm.component.installer.Version) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Verifier(org.graalvm.component.installer.model.Verifier)

Example 34 with Version

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

the class AvailableCommand method filterDisplayedVersions.

@Override
protected List<ComponentInfo> filterDisplayedVersions(String id, Collection<ComponentInfo> infos) {
    if (input.optValue(Commands.OPTION_ALL) != null) {
        return super.filterDisplayedVersions(id, infos);
    }
    Set<Version> seen = new HashSet<>();
    Collection<ComponentInfo> filtered = new ArrayList<>();
    Verifier vrf = new Verifier(feedback, input.getLocalRegistry(), input.getRegistry());
    vrf.setCollectErrors(true);
    vrf.setSilent(true);
    vrf.ignoreExisting(true);
    if (showUpdates) {
        vrf.setVersionMatch(getRegistry().getGraalVersion().match(Version.Match.Type.INSTALLABLE));
    } else {
        vrf.setVersionMatch(getRegistry().getGraalVersion().match(Version.Match.Type.SATISFIES_COMPATIBLE));
    }
    if (defaultFilter) {
        List<ComponentInfo> sorted = new ArrayList<>(infos);
        Collections.sort(sorted, ComponentInfo.versionComparator().reversed());
        for (ComponentInfo ci : sorted) {
            // for non-core components, only display those compatible with the current release.
            if (vrf.validateRequirements(ci).hasErrors()) {
                continue;
            }
            if (CommonConstants.GRAALVM_CORE_PREFIX.equals(ci.getId())) {
                if (!showCore || // graalvm core does not depend on anything:
                !vrf.getVersionMatch().test(ci.getVersion())) {
                    // filter out graalvm core by default
                    continue;
                }
            }
            // select just the most recent version
            filtered.add(ci);
            break;
        }
    } else {
        for (ComponentInfo ci : infos) {
            if (seen.add(ci.getVersion().installVersion())) {
                filtered.add(ci);
            }
        }
    }
    return super.filterDisplayedVersions(id, filtered);
}
Also used : Version(org.graalvm.component.installer.Version) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Verifier(org.graalvm.component.installer.model.Verifier) HashSet(java.util.HashSet)

Example 35 with Version

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

the class RemoteStorageTest method checkMultipleGraalVMDependencies.

@Test
public void checkMultipleGraalVMDependencies() throws Exception {
    loadCatalog("catalogMultiVersions.properties");
    Set<ComponentInfo> rubies = remStorage.loadComponentMetadata("ruby");
    Set<Version> versions = new HashSet<>();
    for (ComponentInfo ci : rubies) {
        Version compVersion = ci.getVersion();
        assertTrue(versions.add(compVersion));
        String gv = ci.getRequiredGraalValues().get(BundleConstants.GRAAL_VERSION);
        assertEquals(gv, compVersion.toString());
    }
}
Also used : Version(org.graalvm.component.installer.Version) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Version (org.graalvm.component.installer.Version)44 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)21 Test (org.junit.Test)19 Path (java.nio.file.Path)10 ArrayList (java.util.ArrayList)7 URL (java.net.URL)5 HashSet (java.util.HashSet)5 Properties (java.util.Properties)5 RemotePropertiesStorage (org.graalvm.component.installer.remote.RemotePropertiesStorage)4 JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 ComponentParam (org.graalvm.component.installer.ComponentParam)3 IncompatibleException (org.graalvm.component.installer.IncompatibleException)3 CatalogContents (org.graalvm.component.installer.model.CatalogContents)3 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)3 CatalogIterable (org.graalvm.component.installer.remote.CatalogIterable)3 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)3 JSONException (com.oracle.truffle.tools.utils.json.JSONException)2 JSONTokener (com.oracle.truffle.tools.utils.json.JSONTokener)2