Search in sources :

Example 6 with ComponentRegistry

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

the class UpgradeTest method testUpgradeToCompatibleVersionCommandline.

/**
 * Tests "gu upgrade 1.0.1" on 1.0.1 installation. 1.0.1 core should be installed with ruby
 * 1.0.1.1
 */
@Test
public void testUpgradeToCompatibleVersionCommandline() throws Exception {
    initVersion("1.0.0.0");
    textParams.add("1.0.1");
    ComponentInfo ci = new ComponentInfo("org.graalvm.ruby", "Installed Ruby", "1.0.0.0");
    storage.installed.add(ci);
    UpgradeCommand cmd = new UpgradeCommand();
    cmd.init(this, this);
    assertEquals(0, cmd.execute());
    ComponentRegistry newReg = cmd.getProcess().getNewGraalRegistry();
    ComponentInfo ruby = newReg.findComponent("ruby");
    assertEquals("1.0.1.1", ruby.getVersion().toString());
}
Also used : ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Test(org.junit.Test)

Example 7 with ComponentRegistry

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

the class ComponentInstaller method completeEnvironment.

protected Environment completeEnvironment() {
    if (env.getGraalHomePath() != null) {
        return env;
    }
    findGraalHome();
    env.setGraalHome(graalHomePath);
    // Use our own GraalVM's trust store contents; also bypasses embedded trust store
    // when running AOT.
    Path trustStorePath = SystemUtils.resolveRelative(SystemUtils.getRuntimeBaseDir(env.getGraalHomePath()), // NOI18N
    "lib/security/cacerts");
    // NOI18N
    System.setProperty("javax.net.ssl.trustStore", trustStorePath.normalize().toString());
    DirectoryStorage storage = new DirectoryStorage(env, storagePath, graalHomePath);
    storage.setConfig(env);
    storage.setJavaVersion("" + SystemUtils.getJavaMajorVersion(env));
    env.setLocalRegistry(new ComponentRegistry(env, storage));
    FileOperations fops = FileOperations.createPlatformInstance(env, env.getGraalHomePath());
    env.setFileOperations(fops);
    // also sets up input and feedback.
    forSoftwareChannels(true, (ch) -> {
        ch.init(input, feedback);
    });
    return env;
}
Also used : Path(java.nio.file.Path) DirectoryStorage(org.graalvm.component.installer.persist.DirectoryStorage) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry)

Example 8 with ComponentRegistry

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

the class RemoteStorageTest method loadCatalog.

private void loadCatalog(String s) throws IOException {
    catalogProps.clear();
    localRegistry = new ComponentRegistry(this, storage);
    try (InputStream is = getClass().getResourceAsStream(s)) {
        catalogProps.load(is);
    }
}
Also used : ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) InputStream(java.io.InputStream)

Example 9 with ComponentRegistry

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

the class UpgradeProcess method createRegistryFor.

private ComponentRegistry createRegistryFor(Path home) {
    DirectoryStorage dst = new DirectoryStorage(feedback.withBundle(ComponentInstaller.class), home.resolve(SystemUtils.fromCommonRelative(CommonConstants.PATH_COMPONENT_STORAGE)), home);
    dst.setJavaVersion(input.getLocalRegistry().getJavaVersion());
    return new ComponentRegistry(feedback, dst);
}
Also used : DirectoryStorage(org.graalvm.component.installer.persist.DirectoryStorage) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) ComponentInstaller(org.graalvm.component.installer.ComponentInstaller)

Example 10 with ComponentRegistry

use of org.graalvm.component.installer.model.ComponentRegistry 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);
    }
}
Also used : Path(java.nio.file.Path) FailedOperationException(org.graalvm.component.installer.FailedOperationException) Version(org.graalvm.component.installer.Version) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry)

Aggregations

ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)16 Test (org.junit.Test)8 CatalogContents (org.graalvm.component.installer.model.CatalogContents)5 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)5 Path (java.nio.file.Path)4 List (java.util.List)4 CommandInput (org.graalvm.component.installer.CommandInput)4 ComponentCatalog (org.graalvm.component.installer.ComponentCatalog)4 URL (java.net.URL)3 RemoteCatalogDownloader (org.graalvm.component.installer.remote.RemoteCatalogDownloader)3 SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)2 Version (org.graalvm.component.installer.Version)2 DirectoryStorage (org.graalvm.component.installer.persist.DirectoryStorage)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 ComponentInstaller (org.graalvm.component.installer.ComponentInstaller)1 ComponentParam (org.graalvm.component.installer.ComponentParam)1 FailedOperationException (org.graalvm.component.installer.FailedOperationException)1 Feedback (org.graalvm.component.installer.Feedback)1