Search in sources :

Example 1 with MetadataLoader

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;
}
Also used : Path(java.nio.file.Path) Version(org.graalvm.component.installer.Version) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 2 with MetadataLoader

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();
}
Also used : JarArchive(org.graalvm.component.installer.jar.JarArchive) JarArchive(org.graalvm.component.installer.jar.JarArchive) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 3 with MetadataLoader

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));
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 4 with MetadataLoader

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());
            }
        }
    }
}
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 5 with MetadataLoader

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();
    }
}
Also used : MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) UserAbortException(org.graalvm.component.installer.UserAbortException)

Aggregations

MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)15 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)9 ComponentParam (org.graalvm.component.installer.ComponentParam)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)2 IOException (java.io.IOException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 List (java.util.List)1 Archive (org.graalvm.component.installer.Archive)1 CommandInput (org.graalvm.component.installer.CommandInput)1 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)1 DependencyException (org.graalvm.component.installer.DependencyException)1 InstallerStopException (org.graalvm.component.installer.InstallerStopException)1 UserAbortException (org.graalvm.component.installer.UserAbortException)1 Version (org.graalvm.component.installer.Version)1 JarArchive (org.graalvm.component.installer.jar.JarArchive)1 CatalogContents (org.graalvm.component.installer.model.CatalogContents)1