Search in sources :

Example 1 with ComponentPackageLoader

use of org.graalvm.component.installer.persist.ComponentPackageLoader in project graal by oracle.

the class RemotePropertiesStorage method createVersionedComponent.

private ComponentInfo createVersionedComponent(String versoPrefix, Properties filtered, String id, String tag) throws IOException {
    URL downloadURL;
    String s = filtered.getProperty(versoPrefix + id.toLowerCase());
    if (s == null) {
        return null;
    }
    // try {
    downloadURL = new URL(baseURL, s);
    // NOI18N
    String prefix = versoPrefix + id.toLowerCase() + "-";
    String hashS = filtered.getProperty(prefix + PROPERTY_HASH);
    byte[] hash = hashS == null ? null : toHashBytes(id, hashS);
    ComponentPackageLoader ldr = new ComponentPackageLoader(tag, new PrefixedPropertyReader(prefix, filtered), feedback);
    ComponentInfo info = ldr.createComponentInfo();
    info.setRemoteURL(downloadURL);
    info.setShaDigest(hash);
    info.setOrigin(baseURL.toString());
    return configureComponentInfo(info);
}
Also used : ComponentInfo(org.graalvm.component.installer.model.ComponentInfo) URL(java.net.URL) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader)

Example 2 with ComponentPackageLoader

use of org.graalvm.component.installer.persist.ComponentPackageLoader in project graal by oracle.

the class ComponentRegistryTest method setUp.

@Before
public void setUp() throws Exception {
    registry = new ComponentRegistry(this, mockStorage);
    try (JarFile jf = new JarFile(dataFile("truffleruby2.jar").toFile())) {
        ComponentPackageLoader ldr = new JarMetaLoader(jf, this);
        rubyInfo = ldr.createComponentInfo();
        ldr.loadPaths();
        ldr.loadSymlinks();
    }
    fakeInfo = new ComponentInfo("org.graalvm.fake", "Fake component", "0.32");
    fakeInfo.addPaths(Arrays.asList("jre/bin/ruby", "jre/languages/fake/nothing"));
    mockStorage.installed.add(fakeInfo);
}
Also used : JarFile(java.util.jar.JarFile) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader) JarMetaLoader(org.graalvm.component.installer.jar.JarMetaLoader) Before(org.junit.Before)

Example 3 with ComponentPackageLoader

use of org.graalvm.component.installer.persist.ComponentPackageLoader in project graal by oracle.

the class VerifierTest method testGraalCapabilitiesMismatch.

@Test
public void testGraalCapabilitiesMismatch() throws Exception {
    try (JarFile jf = new JarFile(dataFile("truffleruby2.jar").toFile())) {
        ComponentPackageLoader ldr = new JarMetaLoader(jf, this);
        rubyInfo = ldr.createComponentInfo();
        ldr.loadPaths();
        ldr.loadSymlinks();
    }
    mockStorage.graalInfo.put(CAP_OS_NAME, "LiNuy");
    Verifier vfy = new Verifier(this, registry, registry);
    exception.expect(DependencyException.Mismatch.class);
    exception.expectMessage("VERIFY_Dependency_Failed");
    vfy.validateRequirements(rubyInfo);
}
Also used : JarFile(java.util.jar.JarFile) DependencyException(org.graalvm.component.installer.DependencyException) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader) JarMetaLoader(org.graalvm.component.installer.jar.JarMetaLoader) Test(org.junit.Test)

Example 4 with ComponentPackageLoader

use of org.graalvm.component.installer.persist.ComponentPackageLoader in project graal by oracle.

the class CommandTestBase method initURLComponent.

protected void initURLComponent(String relativeJar, String spec) throws IOException {
    clu = getClass().getResource(relativeJar);
    url = new URL(spec);
    Handler.bind(url.toString(), clu);
    File f = dataFile(relativeJar).toFile();
    JarFile jf = new JarFile(f, false);
    ComponentPackageLoader cpl = new JarMetaLoader(jf, this);
    info = cpl.getComponentInfo();
    // unknown in catalog metadata
    info.setLicensePath(null);
    info.setRemoteURL(url);
    param = rparam = new DownloadURLParam(url, spec, spec, this, false);
}
Also used : JarFile(java.util.jar.JarFile) DownloadURLParam(org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader) JarMetaLoader(org.graalvm.component.installer.jar.JarMetaLoader)

Example 5 with ComponentPackageLoader

use of org.graalvm.component.installer.persist.ComponentPackageLoader in project graal by oracle.

the class CommandTestBase method initRemoteComponent.

protected void initRemoteComponent(String relativeJar, String u, String disp, String spec) throws IOException {
    clu = getClass().getResource(relativeJar);
    url = new URL(u);
    Handler.bind(url.toString(), clu);
    File f = dataFile(relativeJar).toFile();
    JarFile jf = new JarFile(f, false);
    ComponentPackageLoader cpl = new JarMetaLoader(jf, this);
    info = cpl.getComponentInfo();
    // unknown in catalog metadata
    info.setLicensePath(null);
    info.setRemoteURL(url);
    param = rparam = new CatalogItemParam(this, info, disp, spec, this, false);
}
Also used : CatalogItemParam(org.graalvm.component.installer.remote.CatalogIterable.CatalogItemParam) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL) ComponentPackageLoader(org.graalvm.component.installer.persist.ComponentPackageLoader) JarMetaLoader(org.graalvm.component.installer.jar.JarMetaLoader)

Aggregations

ComponentPackageLoader (org.graalvm.component.installer.persist.ComponentPackageLoader)7 JarFile (java.util.jar.JarFile)6 JarMetaLoader (org.graalvm.component.installer.jar.JarMetaLoader)6 File (java.io.File)3 URL (java.net.URL)3 ComponentInfo (org.graalvm.component.installer.model.ComponentInfo)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Attributes (java.util.jar.Attributes)1 Manifest (java.util.jar.Manifest)1 DependencyException (org.graalvm.component.installer.DependencyException)1 DownloadURLParam (org.graalvm.component.installer.DownloadURLIterable.DownloadURLParam)1 CatalogItemParam (org.graalvm.component.installer.remote.CatalogIterable.CatalogItemParam)1 Before (org.junit.Before)1