use of org.graalvm.component.installer.persist.MetadataLoader in project graal by oracle.
the class UpgradeProcess method prepareInstall.
/**
* Prepares the installation of the core Component. Returns {@code false} if the upgrade is not
* necessary or not found.
*
* @param info
* @return true, if the graalvm should be updated.
* @throws IOException
*/
boolean prepareInstall(ComponentInfo info) throws IOException {
Version min = input.getLocalRegistry().getGraalVersion();
if (info == null) {
feedback.message("UPGRADE_NoUpdateFound", min.displayString());
return false;
}
int cmp = min.compareTo(info.getVersion());
if ((cmp > 0) || ((editionUpgrade == null) && (cmp == 0))) {
feedback.message("UPGRADE_NoUpdateLatestVersion", min.displayString());
migrated.clear();
return false;
}
Path reported = createInstallName(info);
// there's a slight chance this will be different from the final name ...
feedback.output("UPGRADE_PreparingInstall", info.getVersion().displayString(), reported);
failIfDirectotyExistsNotEmpty(reported);
ComponentParam coreParam = createGraalComponentParam(info);
// reuse License logic from the installer command:
InstallCommand cmd = new InstallCommand();
cmd.init(input, feedback);
// ask the InstallCommand to process/accept the licenses, if there are any.
MetadataLoader ldr = coreParam.createMetaLoader();
cmd.addLicenseToAccept(ldr);
cmd.acceptLicenses();
acceptedLicenseIDs = cmd.getProcessedLicenses();
// force download
ComponentParam param = input.existingFiles().createParam("core", info);
metaLoader = param.createFileLoader();
ComponentInfo completeInfo = metaLoader.completeMetadata();
newInstallPath = createInstallName(completeInfo);
newGraalHomePath = newInstallPath;
failIfDirectotyExistsNotEmpty(newInstallPath);
if (!reported.equals(newInstallPath)) {
feedback.error("UPGRADE_WarningEditionDifferent", null, info.getVersion().displayString(), newInstallPath);
}
existingComponents.addAll(input.getLocalRegistry().getComponentIDs());
existingComponents.remove(BundleConstants.GRAAL_COMPONENT_ID);
return true;
}
use of org.graalvm.component.installer.persist.MetadataLoader in project graal by oracle.
the class DownloadURLIterableTest method testURLParameter.
@Test
public void testURLParameter() throws Exception {
initURLComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip");
this.textParams.add("test://graalvm.io/download/truffleruby.zip");
DownloadURLIterable iterable = new DownloadURLIterable(this, this);
Iterator<ComponentParam> it = iterable.iterator();
assertTrue(it.hasNext());
ComponentParam p = it.next();
assertEquals("test://graalvm.io/download/truffleruby.zip", p.getSpecification());
MetadataLoader ldr = p.createMetaLoader();
assertFalse(p.isComplete());
ComponentInfo ci = ldr.getComponentInfo();
assertTrue(p.isComplete());
assertEquals("ruby", ci.getId());
assertEquals("0.33-dev", ci.getVersionString());
JarArchive jf = (JarArchive) ldr.getArchive();
Archive.FileEntry je = jf.getJarEntry("META-INF/MANIFEST.MF");
assertNotNull(je);
jf.close();
}
use of org.graalvm.component.installer.persist.MetadataLoader in project graal by oracle.
the class CatalogIterableTest method testCreateFileLoader.
@Test
public void testCreateFileLoader() throws Exception {
initRemoteComponent("persist/data/truffleruby3.jar", "test://graalvm.io/download/truffleruby.zip", "testComponent", "test");
MetadataLoader ldr = param.createFileLoader();
ldr.setNoVerifySymlinks(false);
ldr.loadPaths();
ldr.loadPermissions();
ldr.loadSymlinks();
ComponentInfo meta = ldr.getComponentInfo();
assertEquals("ruby", meta.getId());
assertNull(meta.getInfoPath());
assertFalse(meta.getPaths().isEmpty());
assertEquals("TruffleRuby 0.33-dev", meta.getName());
assertEquals("0.33-dev", meta.getVersionString());
assertTrue(Handler.isVisited(url));
}
use of org.graalvm.component.installer.persist.MetadataLoader 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());
}
}
}
}
use of org.graalvm.component.installer.persist.MetadataLoader in project graal by oracle.
the class LicensePresenter method displaySingleLicense.
void displaySingleLicense() {
String licId = licensesToAccept.keySet().iterator().next();
MetadataLoader ldr = licensesToAccept.get(licId).get(0);
String type = ldr.getLicenseType();
String compList = formatComponentList(licId);
feedback.output("INSTALL_AcceptLicense", compList, type);
feedback.outputPart("INSTALL_AcceptSingleLicense");
String input = feedback.acceptLine(true);
if (isYes(input)) {
acceptLicense(licId);
return;
} else if (isRead(input)) {
displayLicenseId = licId;
state = State.LICENSE;
} else {
throw new UserAbortException();
}
}
Aggregations