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);
}
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;
}
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;
}
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);
}
}
}
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());
}
}
Aggregations