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);
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations