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