Search in sources :

Example 81 with ComponentInfo

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

the class UpgradeProcess method migrateLicenses.

/*
     * public void identifyMigratedCompoents(ComponentInfo target) { if
     * (!satisfiedAddedComponents(target)) { throw
     * feedback.failure("UPGRADE_NoVersionSatisfiesComponents", null); } this.targetInfo = target;
     * this.addComponents.addAll(findInstallables(target)); }
     */
public void migrateLicenses() {
    if (!SystemUtils.isLicenseTrackingEnabled()) {
        return;
    }
    feedback.output("UPGRADE_MigratingLicenses", input.getLocalRegistry().getGraalVersion().displayString(), targetInfo.getVersion().displayString());
    for (Map.Entry<String, Collection<String>> e : input.getLocalRegistry().getAcceptedLicenses().entrySet()) {
        String licId = e.getKey();
        for (String compId : e.getValue()) {
            try {
                String t = input.getLocalRegistry().licenseText(licId);
                ComponentInfo info = input.getLocalRegistry().findComponent(compId);
                Date d = input.getLocalRegistry().isLicenseAccepted(info, licId);
                newGraalRegistry.acceptLicense(info, licId, t, d);
            } catch (FailedOperationException ex) {
                feedback.error("UPGRADE_CannotMigrateLicense", ex, compId, licId);
            }
        }
    }
    // dirty way how to migrate GDS settings:
    Path gdsSettings = SystemUtils.resolveRelative(input.getGraalHomePath(), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
    if (Files.isDirectory(gdsSettings)) {
        Path targetGdsSettings = SystemUtils.resolveRelative(newInstallPath.resolve(SystemUtils.getGraalVMJDKRoot(newGraalRegistry)), CommonConstants.PATH_COMPONENT_STORAGE + "/gds");
        try {
            SystemUtils.copySubtree(gdsSettings, targetGdsSettings);
        } catch (IOException ex) {
            feedback.error("UPGRADE_CannotMigrateGDS", ex, ex.getLocalizedMessage());
        }
    }
}
Also used : Path(java.nio.file.Path) FailedOperationException(org.graalvm.component.installer.FailedOperationException) ComponentCollection(org.graalvm.component.installer.ComponentCollection) Collection(java.util.Collection) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 82 with ComponentInfo

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

the class UpgradeProcess method createGraalVMInstaller.

/**
 * Completes the component info, loads symlinks, permissions. Same as
 * {@link InstallCommand#createInstaller}.
 */
GraalVMInstaller createGraalVMInstaller(ComponentInfo info) throws IOException {
    ComponentParam p = createGraalComponentParam(info);
    MetadataLoader ldr = p.createFileLoader();
    ldr.loadPaths();
    if (p.isComplete()) {
        Archive a;
        a = ldr.getArchive();
        a.verifyIntegrity(input);
    }
    ComponentInfo completeInfo = ldr.getComponentInfo();
    targetInfo = completeInfo;
    metaLoader = ldr;
    GraalVMInstaller gvmInstaller = new GraalVMInstaller(feedback, input.getFileOperations(), input.getLocalRegistry(), completeInfo, catalog, metaLoader.getArchive());
    // do not create symlinks if disabled, or target directory is given.
    boolean disableSymlink = input.hasOption(Commands.OPTION_NO_SYMLINK) || input.hasOption(Commands.OPTION_TARGET_DIRECTORY);
    gvmInstaller.setDisableSymlinks(disableSymlink);
    // will make registrations for bundled components, too.
    gvmInstaller.setAllowFilesInComponentDir(true);
    gvmInstaller.setCurrentInstallPath(input.getGraalHomePath());
    gvmInstaller.setInstallPath(newInstallPath);
    gvmInstaller.setPermissions(ldr.loadPermissions());
    gvmInstaller.setSymlinks(ldr.loadSymlinks());
    newGraalHomePath = gvmInstaller.getInstalledPath();
    return gvmInstaller;
}
Also used : Archive(org.graalvm.component.installer.Archive) ComponentParam(org.graalvm.component.installer.ComponentParam) MetadataLoader(org.graalvm.component.installer.persist.MetadataLoader) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 83 with ComponentInfo

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

the class UpgradeProcess method resetExistingComponents.

final void resetExistingComponents() {
    existingComponents.clear();
    existingComponents.addAll(input.getLocalRegistry().getComponentIDs().stream().filter((id) -> {
        ComponentInfo info = input.getLocalRegistry().findComponent(id);
        // only auto-include the 'leaf' components
        return info != null && input.getLocalRegistry().findDependentComponents(info, false).isEmpty();
    }).collect(Collectors.toList()));
    existingComponents.remove(BundleConstants.GRAAL_COMPONENT_ID);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 84 with ComponentInfo

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

the class UpgradeProcess method satisfiedAddedComponents.

/**
 * Checks if the candidate GraalVM satisfies all dependencies of added components. Added
 * components are those specified on the commandline;
 *
 * @param candidate candidate GraalVM component
 * @return broken components
 */
Collection<ComponentInfo> satisfiedAddedComponents(ComponentInfo candidate) throws IOException {
    List<ComponentInfo> broken = new ArrayList<>();
    Version gv = candidate.getVersion();
    Version.Match satisfies = gv.match(Version.Match.Type.COMPATIBLE);
    for (ComponentParam param : addComponents) {
        ComponentInfo in = param.createMetaLoader().getComponentInfo();
        String vs = in.getRequiredGraalValues().get(BundleConstants.GRAAL_VERSION);
        Version cv = Version.fromString(vs);
        if (!satisfies.test(cv)) {
            broken.add(in);
            if (minVersion.compareTo(cv) < 0) {
                minVersion = cv;
            }
        }
    }
    return broken;
}
Also used : Version(org.graalvm.component.installer.Version) ArrayList(java.util.ArrayList) ComponentParam(org.graalvm.component.installer.ComponentParam) ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

Example 85 with ComponentInfo

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

the class ComponentPackageLoader method createBaseComponentInfo.

protected ComponentInfo createBaseComponentInfo() {
    parse(() -> id = parseHeader(BundleConstants.BUNDLE_ID).parseSymbolicName(), () -> name = parseHeader(BundleConstants.BUNDLE_NAME).getContents(id), () -> version = parseHeader(BundleConstants.BUNDLE_VERSION).version(), () -> {
        info = new ComponentInfo(id, name, version, findComponentTag());
        info.addRequiredValues(parseHeader(BundleConstants.BUNDLE_REQUIRED).parseRequiredCapabilities());
        info.addProvidedValues(parseHeader(BundleConstants.BUNDLE_PROVIDED, "").parseProvidedCapabilities());
        info.setDependencies(parseHeader(BundleConstants.BUNDLE_DEPENDENCY, "").parseDependencies());
        info.setStability(// to "".
        parseHeader(BundleConstants.BUNDLE_STABILITY2, value(BundleConstants.BUNDLE_STABILITY)).parseStability());
    });
    supplyComponentTag();
    return info;
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo)

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