Search in sources :

Example 1 with Verifier

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

the class InfoCommand method printDetails.

@Override
void printDetails(ComponentParam param, ComponentInfo info) {
    if (printTable) {
        String line;
        if (fullPath) {
            line = String.format(feedback.l10n("INFO_ComponentLongList"), shortenComponentId(info), val(info.getVersion().displayString()), val(info.getName()), filePath(info), info.getStability().displayName(feedback));
        } else {
            line = String.format(feedback.l10n(noComponentPath ? "INFO_ComponentShortListNoFile" : "INFO_ComponentShortList"), shortenComponentId(info), val(info.getVersion().displayString()), val(info.getName()), filePath(info), info.getStability().displayName(feedback));
        }
        feedback.verbatimOut(line, false);
        return;
    } else {
        feedback.output("INFO_ComponentBasicInfo", shortenComponentId(info), val(info.getVersion().displayString()), val(info.getName()), param.getFullPath(), findRequiredGraalVMVersion(info), info.getStability().displayName(feedback));
        List<String> keys = new ArrayList<>(info.getRequiredGraalValues().keySet());
        keys.remove(CommonConstants.CAP_GRAALVM_VERSION);
        if (!keys.isEmpty() && feedback.verboseOutput("INFO_ComponentRequirementsHeader")) {
            Collections.sort(keys);
            for (String cap : keys) {
                feedback.verboseOutput("INFO_ComponentRequirement", getRegistry().localizeCapabilityName(cap), info.getRequiredGraalValues().get(cap));
            }
        }
        MetadataLoader ldr = map.get(info);
        List<InstallerStopException> errs = ldr.getErrors();
        if (!errs.isEmpty()) {
            feedback.message("INFO_ComponentBroken", files.get(info));
            for (InstallerStopException ex : errs) {
                feedback.message("INFO_ComponentErrorIndent", ex.getLocalizedMessage());
            }
        }
        Verifier vfy = new Verifier(feedback, input.getLocalRegistry(), catalog).collect(true).validateRequirements(info);
        if (vfy.hasErrors()) {
            feedback.message("INFO_ComponentWillNotInstall", shortenComponentId(info));
            for (DependencyException ex : vfy.getErrors()) {
                feedback.message("INFO_ComponentDependencyIndent", ex.getLocalizedMessage());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) Verifier(org.graalvm.component.installer.model.Verifier) DependencyException(org.graalvm.component.installer.DependencyException) InstallerStopException(org.graalvm.component.installer.InstallerStopException)

Example 2 with Verifier

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

the class Installer method validateAll.

/**
 * Validates requirements, decides whether to install. Returns false if the component should be
 * skipped.
 *
 * @return true, if the component should be installed
 * @throws IOException
 */
@Override
public boolean validateAll() throws IOException {
    Verifier veri = validateRequirements();
    ComponentInfo existing = registry.findComponent(componentInfo.getId());
    if (existing != null) {
        if (!veri.shouldInstall(componentInfo)) {
            return false;
        }
    }
    validateFiles();
    validateSymlinks();
    return true;
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Verifier(org.graalvm.component.installer.model.Verifier)

Example 3 with Verifier

use of org.graalvm.component.installer.model.Verifier 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 4 with Verifier

use of org.graalvm.component.installer.model.Verifier 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)

Aggregations

Verifier (org.graalvm.component.installer.model.Verifier)4 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)3 ArrayList (java.util.ArrayList)2 Version (org.graalvm.component.installer.Version)2 HashSet (java.util.HashSet)1 DependencyException (org.graalvm.component.installer.DependencyException)1 InstallerStopException (org.graalvm.component.installer.InstallerStopException)1 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)1