Search in sources :

Example 91 with ComponentInfo

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

the class UninstallCommand method checkBrokenDependencies.

void checkBrokenDependencies() {
    if (brokenDependencies.isEmpty()) {
        return;
    }
    Set<ComponentInfo> uninstalled = new HashSet<>(toUninstall.values());
    // get all broken components, excluding the ones scheduled for uninstall
    Stream<ComponentInfo> stm = brokenDependencies.values().stream().flatMap((col) -> col.stream()).filter((c) -> !uninstalled.contains(c));
    // if all broken are uninstalled -> OK
    if (!stm.findFirst().isPresent()) {
        return;
    }
    List<ComponentInfo> sorted = new ArrayList<>(brokenDependencies.keySet());
    P printer;
    boolean warning = removeDependent || breakDependent;
    if (warning) {
        printer = feedback::output;
        feedback.output(removeDependent ? "UNINSTALL_BrokenDependenciesRemove" : "UNINSTALL_BrokenDependenciesWarn");
    } else {
        printer = (a, b) -> feedback.error(a, null, b);
        feedback.error("UNINSTALL_BrokenDependencies", null);
    }
    Comparator<ComponentInfo> c = (a, b) -> a.getId().compareToIgnoreCase(b.getId());
    Collections.sort(sorted, c);
    for (ComponentInfo i : sorted) {
        List<ComponentInfo> deps = new ArrayList<>(brokenDependencies.get(i));
        deps.removeAll(uninstalled);
        if (deps.isEmpty()) {
            continue;
        }
        Collections.sort(sorted, c);
        if (!warning) {
            printer.print("UNINSTALL_BreakDepSource", i.getName(), i.getId());
        }
        for (ComponentInfo d : deps) {
            printer.print("UNINSTALL_BreakDepTarget", d.getName(), d.getId());
        }
    }
    if (warning) {
        return;
    }
    throw feedback.failure("UNINSTALL_BreakDependenciesTerminate", null);
}
Also used : ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) InstallerStopException(org.graalvm.component.installer.InstallerStopException) Commands(org.graalvm.component.installer.Commands) HashMap(java.util.HashMap) Feedback(org.graalvm.component.installer.Feedback) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) BundleConstants(org.graalvm.component.installer.BundleConstants) Map(java.util.Map) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) CommandInput(org.graalvm.component.installer.CommandInput) WARN_REBUILD_IMAGES(org.graalvm.component.installer.CommonConstants.WARN_REBUILD_IMAGES) CommonConstants(org.graalvm.component.installer.CommonConstants) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) CatalogContents(org.graalvm.component.installer.model.CatalogContents) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) File(java.io.File) SystemUtils(org.graalvm.component.installer.SystemUtils) List(java.util.List) DistributionType(org.graalvm.component.installer.model.DistributionType) Stream(java.util.stream.Stream) InstallerCommand(org.graalvm.component.installer.InstallerCommand) Comparator(java.util.Comparator) Collections(java.util.Collections) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 92 with ComponentInfo

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

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

the class UpgradeCommand method execute.

@Override
public int execute() throws IOException {
    input.getLocalRegistry().verifyAdministratorAccess();
    if (input.optValue(Commands.OPTION_HELP) != null) {
        feedback.output(allowDistUpgrades ? "UPGRADE_Help" : "UPDATE_Help");
        return 0;
    }
    try (UpgradeProcess h = this.helper) {
        ComponentInfo info = configureProcess();
        boolean workDone;
        if (allowDistUpgrades) {
            workDone = h.installGraalCore(info);
        } else {
            workDone = false;
        }
        h.installAddedComponents();
        if (h.addedComponents().isEmpty()) {
            return workDone ? 0 : 1;
        }
    }
    return 0;
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 94 with ComponentInfo

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

the class PostInstProcess method run.

void run() {
    for (ComponentInfo ci : infos) {
        printPostinst(ci);
        rebuildPolyglot |= ci.isPolyglotRebuild();
    }
    if (rebuildPolyglot && WARN_REBUILD_IMAGES) {
        Path p = SystemUtils.fromCommonString(CommonConstants.PATH_JRE_BIN);
        Path toolPath = RebuildImageCommand.findNativeImagePath(input, feedback);
        feedback.output("INSTALL_RebuildPolyglotNeeded", File.separator, input.getGraalHomePath().resolve(p).normalize());
        if (toolPath == null) {
            feedback.output("INSTALL_RebuildPolyglotNeeded2", CommonConstants.NATIVE_IMAGE_ID);
        }
    }
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 95 with ComponentInfo

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

the class PreRemoveProcess method run.

/**
 * Process all the components, prints message.
 *
 * @throws IOException if deletion fails
 */
public void run() throws IOException {
    for (ComponentInfo ci : infos) {
        processComponent(ci);
    }
    if (rebuildPolyglot && WARN_REBUILD_IMAGES) {
        Path p = SystemUtils.fromCommonString(CommonConstants.PATH_JRE_BIN);
        feedback.output("INSTALL_RebuildPolyglotNeeded", File.separator, installPath.resolve(p).normalize());
    }
}
Also used : Path(java.nio.file.Path) 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