use of org.graalvm.component.installer.FailedOperationException in project graal by oracle.
the class CatalogInstallTest method testInstallWithBrokenDeps.
@Test
public void testInstallWithBrokenDeps() throws Exception {
setupVersion("19.3-dev");
setupCatalog(null);
paramIterable = new CatalogIterable(this, this);
textParams.add("additional");
InstallCommand cmd = new InstallCommand();
cmd.init(this, withBundle(InstallCommand.class));
cmd.executionInit();
exception.expect(FailedOperationException.class);
exception.expectMessage("INSTALL_UnresolvedDependencies");
try {
cmd.executeStep(cmd::prepareInstallation, false);
} catch (FailedOperationException ex) {
Set<String> u = cmd.getUnresolvedDependencies();
assertFalse(u.isEmpty());
assertEquals("org.graalvm.unknown", u.iterator().next());
throw ex;
}
}
use of org.graalvm.component.installer.FailedOperationException in project graal by oracle.
the class UpgradeProcess method migrateLicenses.
/*
* public void identifyMigratedCompoents(ComponentInfo target) { if
* (!satisfiedAddedComponents(target)) { throw
* feedback.failure("UPGRADE_NoVersionSatisfiesComponents", null); } this.targetInfo = target;
* this.addComponents.addAll(findInstallables(target)); }
*/
public void migrateLicenses() {
if (!SystemUtils.isLicenseTrackingEnabled()) {
return;
}
feedback.output("UPGRADE_MigratingLicenses", input.getLocalRegistry().getGraalVersion().displayString(), targetInfo.getVersion().displayString());
for (Map.Entry<String, Collection<String>> e : input.getLocalRegistry().getAcceptedLicenses().entrySet()) {
String licId = e.getKey();
for (String compId : e.getValue()) {
try {
String t = input.getLocalRegistry().licenseText(licId);
ComponentInfo info = input.getLocalRegistry().findComponent(compId);
Date d = input.getLocalRegistry().isLicenseAccepted(info, licId);
newGraalRegistry.acceptLicense(info, licId, t, d);
} catch (FailedOperationException ex) {
feedback.error("UPGRADE_CannotMigrateLicense", ex, compId, licId);
}
}
}
// dirty way how to migrate GDS settings:
Path gdsSettings = SystemUtils.resolveRelative(input.getGraalHomePath(), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
if (Files.isDirectory(gdsSettings)) {
Path targetGdsSettings = SystemUtils.resolveRelative(newInstallPath.resolve(SystemUtils.getGraalVMJDKRoot(newGraalRegistry)), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
try {
SystemUtils.copySubtree(gdsSettings, targetGdsSettings);
} catch (IOException ex) {
feedback.error("UPGRADE_CannotMigrateGDS", ex, ex.getLocalizedMessage());
}
}
}
use of org.graalvm.component.installer.FailedOperationException in project graal by oracle.
the class UpgradeProcess method failIfDirectotyExistsNotEmpty.
void failIfDirectotyExistsNotEmpty(Path target) throws IOException {
if (!Files.exists(target)) {
return;
}
if (!Files.isDirectory(target)) {
throw feedback.failure("UPGRADE_TargetExistsNotDirectory", null, target);
}
Path ghome = target.resolve(SystemUtils.getGraalVMJDKRoot(input.getLocalRegistry()));
Path relFile = ghome.resolve("release");
if (Files.isReadable(relFile)) {
Version targetVersion = null;
try {
ComponentRegistry reg = createRegistryFor(ghome);
targetVersion = reg.getGraalVersion();
} catch (FailedOperationException ex) {
// ignore
}
if (targetVersion != null) {
throw feedback.failure("UPGRADE_TargetExistsContainsGraalVM", null, target, targetVersion.displayString());
}
}
if (Files.list(target).findFirst().isPresent()) {
throw feedback.failure("UPGRADE_TargetExistsNotEmpty", null, target);
}
}
use of org.graalvm.component.installer.FailedOperationException 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;
}
use of org.graalvm.component.installer.FailedOperationException in project graal by oracle.
the class ComponentPackageLoader method supplyComponentTag.
/**
* Computes some component hash/tag. Computes a digest from each read/present value in the
* manifest.
*/
private void supplyComponentTag() {
String ct = info.getTag();
if (ct != null && !ct.isEmpty()) {
return;
}
try (StringWriter wr = new StringWriter()) {
// NOI18N
props.store(wr, "");
// NOI18N
info.setTag(SystemUtils.digestString(wr.toString().replaceAll("#.*\r?\n\r?", ""), false));
} catch (IOException ex) {
throw new FailedOperationException(ex.getLocalizedMessage(), ex);
}
}
Aggregations