Search in sources :

Example 1 with InstallerStopException

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

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

the class UninstallCommand method execute.

@Override
public int execute() throws IOException {
    registry.verifyAdministratorAccess();
    if (input.optValue(Commands.OPTION_HELP) != null) {
        feedback.output("UNINSTALL_Help");
        return 0;
    }
    if (!input.hasParameter()) {
        feedback.output("UNINSTALL_ParametersMissing");
        return 1;
    }
    prepareUninstall();
    checkBrokenDependencies();
    includeAndOrderComponents();
    try {
        for (ComponentInfo info : uninstallSequence) {
            try {
                uninstallSingleComponent(info);
            } catch (InstallerStopException | IOException ex) {
                if (ignoreFailures) {
                    feedback.error("UNINSTALL_IgnoreFailed", ex, info.getId(), ex.getLocalizedMessage());
                } else {
                    feedback.error("UNINSTALL_ErrorDuringProcessing", ex, info.getId());
                    throw ex;
                }
            }
        }
    } finally {
        if (rebuildPolyglot && WARN_REBUILD_IMAGES) {
            Path p = SystemUtils.fromCommonString(CommonConstants.PATH_JRE_BIN);
            feedback.output("INSTALL_RebuildPolyglotNeeded", File.separator, input.getGraalHomePath().resolve(p).normalize());
        }
    }
    return 0;
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException)

Example 3 with InstallerStopException

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

the class MergeStorage method listComponentIDs.

@Override
public Set<String> listComponentIDs() throws IOException {
    Set<String> ids = new HashSet<>();
    List<Exception> savedEx = new ArrayList<>();
    List<SoftwareChannel> errChannels = new ArrayList<>();
    boolean oneSucceeded = false;
    Exception toThrow = null;
    for (SoftwareChannel del : new ArrayList<>(channels)) {
        try {
            ids.addAll(del.getStorage().listComponentIDs());
            oneSucceeded = true;
        } catch (IncompatibleException ex) {
            savedEx.add(ex);
            errChannels.add(del);
            channels.remove(del);
        } catch (IOException | FailedOperationException ex) {
            if (!isIgnoreCatalogErrors()) {
                throw ex;
            }
            if (!idsLoaded) {
                reportError(ex, del);
            }
            toThrow = ex;
            channels.remove(del);
        }
    }
    if (!oneSucceeded || ids.isEmpty()) {
        for (int i = 0; i < savedEx.size(); i++) {
            reportError(toThrow = savedEx.get(i), errChannels.get(i));
        }
        if (toThrow instanceof IOException) {
            throw (IOException) toThrow;
        } else if (toThrow != null) {
            throw (InstallerStopException) toThrow;
        }
    }
    idsLoaded = true;
    return ids;
}
Also used : SoftwareChannel(org.graalvm.component.installer.SoftwareChannel) ArrayList(java.util.ArrayList) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException) IOException(java.io.IOException) IncompatibleException(org.graalvm.component.installer.IncompatibleException) FailedOperationException(org.graalvm.component.installer.FailedOperationException) FailedOperationException(org.graalvm.component.installer.FailedOperationException) IncompatibleException(org.graalvm.component.installer.IncompatibleException) HashSet(java.util.HashSet)

Example 4 with InstallerStopException

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

the class InstallCommand method executeStep.

void executeStep(Step s, boolean close) throws IOException {
    boolean ok = false;
    try {
        s.execute();
        ok = true;
    } catch (ZipException ex) {
        feedback.error("INSTALL_InvalidComponentArchive", ex, current);
        throw ex;
    } catch (UserAbortException ex) {
        throw ex;
    } catch (InstallerStopException | IOException ex) {
        if (ignoreFailures) {
            if (current == null) {
                feedback.error("INSTALL_IgnoreFailedInstallation", ex, ex.getLocalizedMessage());
            } else {
                feedback.error("INSTALL_IgnoreFailedInstallation2", ex, current, ex.getLocalizedMessage());
            }
        } else {
            if (current != null) {
                feedback.error("INSTALL_ErrorDuringProcessing", ex, current, ex.getLocalizedMessage());
            }
            throw ex;
        }
    } finally {
        if (!ok) {
            for (Installer inst : executedInstallers) {
                inst.revertInstall();
            }
        }
        if (close || !ok) {
            for (Installer inst : installers) {
                try {
                    inst.close();
                } catch (IOException ex) {
                // expected
                }
            }
        }
    }
}
Also used : ComponentInstaller(org.graalvm.component.installer.ComponentInstaller) ZipException(java.util.zip.ZipException) UserAbortException(org.graalvm.component.installer.UserAbortException) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException)

Aggregations

InstallerStopException (org.graalvm.component.installer.InstallerStopException)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 ZipException (java.util.zip.ZipException)1 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)1 DependencyException (org.graalvm.component.installer.DependencyException)1 FailedOperationException (org.graalvm.component.installer.FailedOperationException)1 IncompatibleException (org.graalvm.component.installer.IncompatibleException)1 SoftwareChannel (org.graalvm.component.installer.SoftwareChannel)1 UserAbortException (org.graalvm.component.installer.UserAbortException)1 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)1 Verifier (org.graalvm.component.installer.model.Verifier)1 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)1