Search in sources :

Example 6 with MetadataLoader

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

the class LicensePresenter method acceptLicense.

protected void acceptLicense(String licenseId) {
    String licText;
    try {
        licText = loadLicenseText(licenseId);
    } catch (IOException ex) {
        throw feedback.failure("INSTALL_ErrorHandlingLicenses", ex, ex.getLocalizedMessage());
    }
    for (MetadataLoader ldr : licensesToAccept.get(licenseId)) {
        Boolean result = null;
        try {
            // first ask the metadata loader delegate.
            result = ldr.recordLicenseAccepted(ldr.getComponentInfo(), licenseId, licText, null);
        } catch (IOException ex) {
            feedback.error("WARN_LicenseNotRecorded", ex, licenseId, ex.getLocalizedMessage());
        }
        if (result == null) {
            localRegistry.acceptLicense(ldr.getComponentInfo(), licenseId, licText);
        }
    }
    licensesToAccept.remove(licenseId);
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) IOException(java.io.IOException)

Example 7 with MetadataLoader

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

the class LicensePresenter method formatComponentList.

String formatComponentList(String licId) {
    List<MetadataLoader> loaders = licensesToAccept.get(licId);
    String list = null;
    for (MetadataLoader l : loaders) {
        ComponentInfo ci = l.getComponentInfo();
        if (list == null) {
            list = feedback.l10n("INSTALL_LicenseComponentStart", ci.getName());
        } else {
            list = feedback.l10n("INSTALL_LicenseComponentCont", list, ci.getName());
        }
    }
    return list;
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 8 with MetadataLoader

use of org.graalvm.component.installer.persist.MetadataLoader 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 9 with MetadataLoader

use of org.graalvm.component.installer.persist.MetadataLoader 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 10 with MetadataLoader

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

the class UpgradeProcess method createGraalVMInstaller.

/**
 * Completes the component info, loads symlinks, permissions. Same as
 * {@link InstallCommand#createInstaller}.
 */
GraalVMInstaller createGraalVMInstaller(ComponentInfo info) throws IOException {
    ComponentParam p = createGraalComponentParam(info);
    MetadataLoader ldr = p.createFileLoader();
    ldr.loadPaths();
    if (p.isComplete()) {
        Archive a;
        a = ldr.getArchive();
        a.verifyIntegrity(input);
    }
    ComponentInfo completeInfo = ldr.getComponentInfo();
    targetInfo = completeInfo;
    metaLoader = ldr;
    GraalVMInstaller gvmInstaller = new GraalVMInstaller(feedback, input.getFileOperations(), input.getLocalRegistry(), completeInfo, catalog, metaLoader.getArchive());
    // do not create symlinks if disabled, or target directory is given.
    boolean disableSymlink = input.hasOption(Commands.OPTION_NO_SYMLINK) || input.hasOption(Commands.OPTION_TARGET_DIRECTORY);
    gvmInstaller.setDisableSymlinks(disableSymlink);
    // will make registrations for bundled components, too.
    gvmInstaller.setAllowFilesInComponentDir(true);
    gvmInstaller.setCurrentInstallPath(input.getGraalHomePath());
    gvmInstaller.setInstallPath(newInstallPath);
    gvmInstaller.setPermissions(ldr.loadPermissions());
    gvmInstaller.setSymlinks(ldr.loadSymlinks());
    newGraalHomePath = gvmInstaller.getInstalledPath();
    return gvmInstaller;
}
Also used : Archive(org.graalvm.component.installer.Archive) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Aggregations

MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)15 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)9 ComponentParam (org.graalvm.component.installer.ComponentParam)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)2 IOException (java.io.IOException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 List (java.util.List)1 Archive (org.graalvm.component.installer.Archive)1 CommandInput (org.graalvm.component.installer.CommandInput)1 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)1 DependencyException (org.graalvm.component.installer.DependencyException)1 InstallerStopException (org.graalvm.component.installer.InstallerStopException)1 UserAbortException (org.graalvm.component.installer.UserAbortException)1 Version (org.graalvm.component.installer.Version)1 JarArchive (org.graalvm.component.installer.jar.JarArchive)1 CatalogContents (org.graalvm.component.installer.model.CatalogContents)1