Search in sources :

Example 71 with ComponentInfo

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

the class LicensePresenter method filterAcceptedLicenses.

public void filterAcceptedLicenses() {
    for (String licId : new ArrayList<>(licensesToAccept.keySet())) {
        Collection<MetadataLoader> loaders = licensesToAccept.get(licId);
        for (MetadataLoader ldr : new ArrayList<>(loaders)) {
            ComponentInfo ci = ldr.getComponentInfo();
            // query the metadata loader (possibly delegates to original software channel
            // provider).
            Date accepted = ldr.isLicenseAccepted(ci, licId);
            if (accepted == null) {
                accepted = localRegistry.isLicenseAccepted(ci, licId);
            }
            if (accepted != null) {
                feedback.verboseOutput("INSTALL_LicenseAcceptedAt", ldr.getLicenseType(), accepted, ci.getId(), ci.getName());
                loaders.remove(ldr);
            }
        }
        if (loaders.isEmpty()) {
            licensesToAccept.remove(licId);
        }
    }
    multiLicenses = licensesToAccept.size() > 1;
}
Also used : ArrayList(java.util.ArrayList) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Date(java.util.Date)

Example 72 with ComponentInfo

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

the class PreRemoveCommand method execute.

@Override
public int execute() throws IOException {
    String compId;
    PreRemoveProcess pp = new PreRemoveProcess(input.getGraalHomePath(), input.getFileOperations(), feedback);
    while ((compId = input.nextParameter()) != null) {
        ComponentInfo info = input.getLocalRegistry().loadSingleComponent(compId.toLowerCase(), true);
        if (info != null) {
            pp.addComponentInfo(info);
        }
    }
    pp.run();
    return 0;
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 73 with ComponentInfo

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

the class InstallCommand method completeInstallers0.

void completeInstallers0(List<ComponentParam> in) throws IOException {
    // now fileName real installers for parameters which were omitted
    for (ComponentParam p : in) {
        Installer i = realInstallers.get(p);
        if (i == null) {
            MetadataLoader floader = p.createFileLoader();
            ComponentInfo initialInfo = parameterInfos.get(p);
            ComponentInfo finfo = floader.getComponentInfo();
            if (initialInfo != null && (!initialInfo.getId().equals(finfo.getId()) || !initialInfo.getVersion().equals(finfo.getVersion()))) {
                String msg = String.format(feedback.l10n("@INSTALL_Error_ComponentDiffers_Report"), initialInfo.getId(), finfo.getId(), initialInfo.getVersionString(), finfo.getVersionString());
                feedback.verbatimPart(msg, true, false);
                throw feedback.failure("INSTALL_Error_ComponentDiffers", null);
            }
            i = createInstaller(p, floader);
            if (!verifyInstaller(i)) {
                continue;
            }
            addLicenseToAccept(i, floader);
            registerComponent(i, p);
            if (validateBeforeInstall) {
                current = i.getComponentInfo().getName();
                i.validateAll();
            } else {
                if (!force) {
                    i.validateRequirements();
                }
            }
            realInstallers.put(p, i);
        }
    }
}
Also used : ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 74 with ComponentInfo

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

the class InstallCommand method createInstaller.

Installer createInstaller(ComponentParam p, MetadataLoader ldr) throws IOException {
    ComponentInfo partialInfo;
    partialInfo = ldr.getComponentInfo();
    parameterInfos.putIfAbsent(p, partialInfo);
    feedback.verboseOutput("INSTALL_PrepareToInstall", p.getDisplayName(), partialInfo.getId(), partialInfo.getVersionString(), partialInfo.getName());
    ldr.loadPaths();
    Archive a = null;
    if (p.isComplete()) {
        a = ldr.getArchive();
        a.verifyIntegrity(input);
    }
    Installer inst = new Installer(feedback, input.getFileOperations(), partialInfo, input.getLocalRegistry(), input.getRegistry(), a);
    inst.setPermissions(ldr.loadPermissions());
    inst.setSymlinks(ldr.loadSymlinks());
    configureInstaller(inst);
    return inst;
}
Also used : Archive(org.graalvm.component.installer.Archive) ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 75 with ComponentInfo

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

the class UninstallCommand method prepareUninstall.

void prepareUninstall() {
    String compId;
    while ((compId = input.nextParameter()) != null) {
        if (toUninstall.containsKey(compId)) {
            continue;
        }
        ComponentInfo info = input.getLocalRegistry().loadSingleComponent(compId.toLowerCase(), true);
        if (info == null) {
            throw feedback.failure("UNINSTALL_UnknownComponentId", null, compId);
        }
        if (info.getId().equals(BundleConstants.GRAAL_COMPONENT_ID)) {
            throw feedback.failure("UNINSTALL_CoreComponent", null, compId);
        }
        if (info.isNativeComponent()) {
            throw feedback.failure("UNINSTALL_NativeComponent", null, info.getId(), info.getName());
        }
        if (info.getDistributionType() != DistributionType.OPTIONAL) {
            throw feedback.failure("UNINSTALL_BundledComponent", null, info.getId(), info.getName());
        }
        toUninstall.put(compId, info);
    }
    if (input.hasOption(Commands.OPTION_NO_DEPENDENCIES)) {
        return;
    }
    for (ComponentInfo u : toUninstall.values()) {
        Set<ComponentInfo> br = registry.findDependentComponents(u, true);
        if (!br.isEmpty()) {
            brokenDependencies.put(u, br);
        }
    }
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Aggregations

ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)149 Test (org.junit.Test)94 Path (java.nio.file.Path)36 Version (org.graalvm.component.installer.Version)28 HashSet (java.util.HashSet)20 ArrayList (java.util.ArrayList)19 ComponentParam (org.graalvm.component.installer.ComponentParam)19 IOException (java.io.IOException)13 URL (java.net.URL)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)10 InputStream (java.io.InputStream)9 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 List (java.util.List)8 Properties (java.util.Properties)8 Map (java.util.Map)7 Set (java.util.Set)7 Collections (java.util.Collections)6 FailedOperationException (org.graalvm.component.installer.FailedOperationException)6 SystemUtils (org.graalvm.component.installer.SystemUtils)6