Search in sources :

Example 86 with ComponentInfo

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

the class JarMetaLoader method loadPaths.

@Override
public void loadPaths() {
    ComponentInfo cinfo = getComponentInfo();
    Set<String> emptyDirectories = new HashSet<>();
    List<String> files = new ArrayList<>();
    for (JarEntry en : Collections.list(jarFile.entries())) {
        String eName = en.getName();
        if (eName.startsWith(META_INF_PATH)) {
            continue;
        }
        int li = eName.lastIndexOf("/", en.isDirectory() ? eName.length() - 2 : eName.length() - 1);
        if (li > 0) {
            emptyDirectories.remove(eName.substring(0, li + 1));
        }
        if (en.isDirectory()) {
            // directory names always come first
            emptyDirectories.add(eName);
        } else {
            files.add(eName);
        }
    }
    addFiles(new ArrayList<>(emptyDirectories));
    // sort empty directories first
    Collections.sort(files);
    cinfo.addPaths(files);
    addFiles(files);
}
Also used : ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) JarEntry(java.util.jar.JarEntry) HashSet(java.util.HashSet)

Example 87 with ComponentInfo

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

the class ListInstalledCommand method process.

boolean process() {
    makeRegularExpression();
    List<String> ids = findComponentIds();
    List<MetadataException> exceptions = new ArrayList<>();
    if (ids.isEmpty()) {
        if (!simpleFormat) {
            feedback.message("LIST_NoComponentsFound");
        }
        return false;
    }
    Version.Match versionFilter = getVersionFilter();
    for (String id : ids) {
        try {
            List<ComponentInfo> infos = new ArrayList<>(catalog.loadComponents(id, versionFilter, listFiles));
            if (infos != null) {
                for (ComponentInfo ci : filterDisplayedVersions(id, infos)) {
                    addComponent(null, ci);
                }
            }
        } catch (MetadataException ex) {
            exceptions.add(ex);
        }
    }
    if (components.isEmpty()) {
        if (!simpleFormat) {
            feedback.message("LIST_NoComponentsFound");
        }
        return false;
    }
    if (!simpleFormat && !exceptions.isEmpty()) {
        feedback.error("LIST_ErrorInComponentMetadata", null);
        for (Exception e : exceptions) {
            feedback.error("LIST_ErrorInComponentMetadataItem", e, e.getLocalizedMessage());
        }
    }
    return true;
}
Also used : Version(org.graalvm.component.installer.Version) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) MetadataException(org.graalvm.component.installer.MetadataException) IOException(java.io.IOException) MetadataException(org.graalvm.component.installer.MetadataException)

Example 88 with ComponentInfo

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

the class PostInstCommand method execute.

@Override
public int execute() throws IOException {
    String compId;
    PostInstProcess pp = new PostInstProcess(input, feedback);
    while ((compId = input.nextParameter()) != null) {
        ComponentInfo info = input.getLocalRegistry().loadSingleComponent(compId.toLowerCase(), true);
        if (info != null) {
            pp.addComponentInfo(info);
        }
    }
    pp.run();
    return 0;
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 89 with ComponentInfo

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

the class QueryCommandBase method printComponents.

protected void printComponents() {
    printHeader();
    Iterator<ComponentParam> itpar = componentParams.iterator();
    for (ComponentInfo info : components) {
        printDetails(itpar.next(), info);
        printFileList(info);
        printSeparator(info);
    }
}
Also used : ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 90 with ComponentInfo

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

the class UninstallCommand method includeAndOrderComponents.

void includeAndOrderComponents() {
    Set<ComponentInfo> allBroken = new LinkedHashSet<>();
    if (!(input.hasOption(Commands.OPTION_NO_DEPENDENCIES) || breakDependent)) {
        for (Collection<ComponentInfo> ii : brokenDependencies.values()) {
            allBroken.addAll(ii);
        }
        for (ComponentInfo ci : allBroken) {
            Set<ComponentInfo> br = registry.findDependentComponents(ci, true);
            if (!br.isEmpty()) {
                allBroken.addAll(br);
                brokenDependencies.put(ci, br);
            }
        }
        if (removeDependent) {
            Set<ComponentInfo> newBroken = new HashSet<>();
            for (ComponentInfo i : allBroken) {
                ComponentInfo full = registry.loadSingleComponent(i.getId(), true);
                newBroken.add(full);
                toUninstall.put(i.getId(), full);
            }
            allBroken = newBroken;
        }
    }
    List<ComponentInfo> leaves = new ArrayList<>(toUninstall.values());
    leaves.removeAll(allBroken);
    List<ComponentInfo> ordered = new ArrayList<>(toUninstall.size());
    ordered.addAll(leaves);
    int top = leaves.size();
    for (ComponentInfo ci : allBroken) {
        Set<ComponentInfo> check = new HashSet<>();
        CatalogContents.findDependencies(ci, true, Boolean.TRUE, check, (a, b, c, d) -> registry.findComponentMatch(a, b, true));
        int i;
        for (i = ordered.size(); i > top; i--) {
            ComponentInfo c = ordered.get(i - 1);
            if (check.contains(c)) {
                break;
            }
        }
        ordered.add(i, ci);
    }
    Collections.reverse(ordered);
    this.uninstallSequence = ordered;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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