Search in sources :

Example 11 with ComponentParam

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

Example 12 with ComponentParam

use of org.graalvm.component.installer.ComponentParam 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;
}
Also used : Version(org.graalvm.component.installer.Version) ArrayList(java.util.ArrayList) ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 13 with ComponentParam

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

the class QueryCommandBase method printComponents.

protected void printComponents() {
    printHeader();
    Iterator<ComponentParam> itpar = componentParams.iterator();
    for (ComponentInfo info : components) {
        printDetails(itpar.next(), info);
        printFileList(info);
        printSeparator(info);
    }
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 14 with ComponentParam

use of org.graalvm.component.installer.ComponentParam 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 15 with ComponentParam

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

the class InstallCommand method execute.

@Override
public int execute() throws IOException {
    executionInit();
    if (input.optValue(Commands.OPTION_HELP) != null) {
        feedback.output("INSTALL_Help");
        return 0;
    }
    if (!input.hasParameter()) {
        feedback.output("INSTALL_ParametersMissing");
        return 1;
    }
    if (input.optValue(Commands.OPTION_LOCAL_DEPENDENCIES) != null && input.optValue(Commands.OPTION_FILES) == null) {
        feedback.error("INSTALL_WarnLocalDependencies", null);
    }
    try {
        executeStep(this::prepareInstallation, false);
        if (validateBeforeInstall) {
            return 0;
        }
        executeStep(this::acceptLicenses, false);
        executeStep(this::completeInstallers, false);
        executeStep(this::acceptLicenses, false);
        executeStep(this::doInstallation, false);
        // execute the post-install steps for all processed installers
        executeStep(this::printMessages, true);
    /*
             * if (rebuildPolyglot && WARN_REBUILD_IMAGES) { Path p =
             * SystemUtils.fromCommonString(CommonConstants.PATH_JRE_BIN);
             * feedback.output("INSTALL_RebuildPolyglotNeeded", File.separator,
             * input.getGraalHomePath().resolve(p).normalize()); }
             */
    } finally {
        for (Map.Entry<ComponentParam, Installer> e : realInstallers.entrySet()) {
            ComponentParam p = e.getKey();
            Installer i = e.getValue();
            p.close();
            if (i != null) {
                i.close();
            }
        }
    }
    return 0;
}
Also used : ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ComponentParam(org.graalvm.component.installer.ComponentParam) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ComponentParam (org.graalvm.component.installer.ComponentParam)24 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)19 Test (org.junit.Test)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)6 CatalogIterable (org.graalvm.component.installer.remote.CatalogIterable)5 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)4 Version (org.graalvm.component.installer.Version)4 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Archive (org.graalvm.component.installer.Archive)2 CommandInput (org.graalvm.component.installer.CommandInput)2 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Path (java.nio.file.Path)1