Search in sources :

Example 76 with ComponentInfo

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

the class UninstallCommand method execute.

@Override
public int execute() throws IOException {
    registry.verifyAdministratorAccess();
    if (input.optValue(Commands.OPTION_HELP) != null) {
        feedback.output("UNINSTALL_Help");
        return 0;
    }
    if (!input.hasParameter()) {
        feedback.output("UNINSTALL_ParametersMissing");
        return 1;
    }
    prepareUninstall();
    checkBrokenDependencies();
    includeAndOrderComponents();
    try {
        for (ComponentInfo info : uninstallSequence) {
            try {
                uninstallSingleComponent(info);
            } catch (InstallerStopException | IOException ex) {
                if (ignoreFailures) {
                    feedback.error("UNINSTALL_IgnoreFailed", ex, info.getId(), ex.getLocalizedMessage());
                } else {
                    feedback.error("UNINSTALL_ErrorDuringProcessing", ex, info.getId());
                    throw ex;
                }
            }
        }
    } finally {
        if (rebuildPolyglot && WARN_REBUILD_IMAGES) {
            Path p = SystemUtils.fromCommonString(CommonConstants.PATH_JRE_BIN);
            feedback.output("INSTALL_RebuildPolyglotNeeded", File.separator, input.getGraalHomePath().resolve(p).normalize());
        }
    }
    return 0;
}
Also used : Path(java.nio.file.Path) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) InstallerStopException(org.graalvm.component.installer.InstallerStopException)

Example 77 with ComponentInfo

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

the class DirectoryCatalogProvider method maybeCreateComponent.

private ComponentInfo maybeCreateComponent(Path localFile) throws IOException {
    byte[] fileStart = null;
    String serial;
    if (Files.isRegularFile(localFile)) {
        try (ReadableByteChannel ch = FileChannel.open(localFile, StandardOpenOption.READ)) {
            ByteBuffer bb = ByteBuffer.allocate(8);
            ch.read(bb);
            fileStart = bb.array();
        }
        serial = SystemUtils.fingerPrint(SystemUtils.computeFileDigest(localFile, null));
    } else {
        fileStart = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
        serial = SystemUtils.digestString(localFile.toString(), false);
    }
    MetadataLoader ldr = null;
    try {
        for (ComponentArchiveReader provider : ServiceLoader.load(ComponentArchiveReader.class)) {
            ldr = provider.createLoader(localFile, fileStart, serial, feedback, verifyJars);
            if (ldr != null) {
                ComponentInfo info = ldr.getComponentInfo();
                info.setRemoteURL(localFile.toUri().toURL());
                info.setOrigin(feedback.l10n("DIR_LocalFile"));
                return info;
            }
        }
    } finally {
        // ignore, may be not a component...
        if (ldr != null) {
            ldr.close();
        }
    }
    return null;
}
Also used : ReadableByteChannel(java.nio.channels.ReadableByteChannel) ComponentArchiveReader(org.graalvm.component.installer.ComponentArchiveReader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) ByteBuffer(java.nio.ByteBuffer)

Example 78 with ComponentInfo

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

the class DirectoryStorage method loadMetadataFrom.

ComponentInfo loadMetadataFrom(InputStream fileStream) throws IOException {
    loaded = new Properties();
    loaded.load(fileStream);
    String serial = loaded.getProperty(BundleConstants.BUNDLE_SERIAL);
    if (serial == null) {
        serial = computeTag(loaded);
    }
    String id = getRequiredProperty(BundleConstants.BUNDLE_ID);
    String name = getRequiredProperty(BundleConstants.BUNDLE_NAME);
    String version = getRequiredProperty(BundleConstants.BUNDLE_VERSION);
    return propertiesToMeta(loaded, new ComponentInfo(id, name, version, serial), feedback);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) Properties(java.util.Properties)

Example 79 with ComponentInfo

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

the class DirectoryStorage method doLoadComponentMetadata.

private ComponentInfo doLoadComponentMetadata(Path cmpFile, boolean nc) throws IOException {
    try (InputStream fileStream = Files.newInputStream(cmpFile)) {
        ComponentInfo info = loadMetadataFrom(fileStream);
        info.setInfoPath(cmpFile.toString());
        info.setNativeComponent(nc);
        return info;
    }
}
Also used : InputStream(java.io.InputStream) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 80 with ComponentInfo

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

the class UpgradeProcess method findInstallables.

Set<ComponentInfo> findInstallables(ComponentInfo graal) {
    Version gv = graal.getVersion();
    Version.Match satisfies = gv.match(Version.Match.Type.COMPATIBLE);
    Set<ComponentInfo> ret = new HashSet<>();
    for (String id : existingComponents) {
        if (explicitIds.contains(id)) {
            continue;
        }
        Collection<ComponentInfo> cis = catalog.loadComponents(id, satisfies, false);
        if (cis == null || cis.isEmpty()) {
            continue;
        }
        List<ComponentInfo> versions = new ArrayList<>(cis);
        ret.add(versions.get(versions.size() - 1));
    }
    return ret;
}
Also used : Version(org.graalvm.component.installer.Version) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet)

Aggregations

ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)149 Test (org.junit.Test)94 Path (java.nio.file.Path)36 Version (org.graalvm.component.installer.Version)28 HashSet (java.util.HashSet)20 ArrayList (java.util.ArrayList)19 ComponentParam (org.graalvm.component.installer.ComponentParam)19 IOException (java.io.IOException)13 URL (java.net.URL)11 MetadataLoader (org.graalvm.component.installer.persist.MetadataLoader)10 InputStream (java.io.InputStream)9 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 List (java.util.List)8 Properties (java.util.Properties)8 Map (java.util.Map)7 Set (java.util.Set)7 Collections (java.util.Collections)6 FailedOperationException (org.graalvm.component.installer.FailedOperationException)6 SystemUtils (org.graalvm.component.installer.SystemUtils)6