Search in sources :

Example 11 with RPMProject

use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.

the class DownloadPrepareSourcesTest method importSrpm.

/**
 * Import the SRPM into the project (make .spec accessible)
 *
 * @param testProject The test project
 * @param layout layout The layout of the RPM project (RPMBuild or FLAT)
 * @return The RPM project
 * @throws CoreException
 * @throws IOException
 */
private RPMProject importSrpm(IProject testProject, RPMProjectLayout layout) throws CoreException, IOException {
    // Instantiate an RPMProject
    RPMProject rpmProject = new RPMProject(testProject, layout);
    // Find the test SRPM and install it
    URL url = FileLocator.find(FrameworkUtil.getBundle(RPMProjectTest.class), new Path(// $NON-NLS-1$ //$NON-NLS-2$
    "resources" + file_sep + "srpms" + file_sep + "hello-2.8-1.fc19.src.rpm"), null);
    File foo = new File(FileLocator.toFileURL(url).getPath());
    // import the SRPM into the RPMProject
    rpmProject.importSourceRPM(foo);
    return rpmProject;
}
Also used : Path(org.eclipse.core.runtime.Path) RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL)

Example 12 with RPMProject

use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.

the class DownloadPrepareSourcesTest method layoutRPMBuildDownloadSourcesTest.

/**
 * Testing downloading sources using RPMBuild layout
 *
 * @throws CoreException
 * @throws IOException
 * @throws InterruptedException
 */
@Test
public void layoutRPMBuildDownloadSourcesTest() throws CoreException, IOException, InterruptedException {
    RPMProject rpmProject = importSrpm(testProject, RPMProjectLayout.RPMBUILD);
    assertNotNull(rpmProject);
    downloadFile(rpmProject);
    checkDownloadedFile(rpmProject, RPMProjectLayout.RPMBUILD);
}
Also used : RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) Test(org.junit.Test)

Example 13 with RPMProject

use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.

the class RPMProjectTest method testBuildAllRPMHelloWorld.

@Test
@Ignore
public void testBuildAllRPMHelloWorld() throws Exception {
    // Create a project for the test
    IProject testProject = root.getProject("testBuildAllRPMHelloWorld1");
    RPMProject rpmProject = importSrpm(testProject);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    rpmProject.buildAll(bos);
    IFile foo2 = rpmProject.getConfiguration().getSrpmsFolder().getFile(new Path("helloworld-2-2.src.rpm"));
    assertTrue(foo2.exists());
    String arch = Utils.runCommandToString("rpm", "--eval", "%{_arch}").trim();
    IFile foo3 = rpmProject.getConfiguration().getRpmsFolder().getFolder(new Path(arch)).getFile(new Path("helloworld-2-2." + arch + ".rpm"));
    assertTrue(foo3.exists());
    testProject.delete(true, true, null);
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IProject(org.eclipse.core.resources.IProject) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with RPMProject

use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.

the class RPMProjectTest method testGetSourcesFolder.

@Test
@Ignore
public void testGetSourcesFolder() throws Exception {
    // Create a project for the test
    IProject testProject = root.getProject("testBuildSourceRPMHelloWorld1");
    testProject.create(monitor);
    testProject.open(monitor);
    // Instantiate an RPMProject
    RPMProject rpmProject = new RPMProject(testProject, RPMProjectLayout.RPMBUILD);
    IProjectConfiguration config = rpmProject.getConfiguration();
    String folder = config.getSourcesFolder().getLocation().toOSString();
    int sourceFolder = folder.indexOf("SOURCES");
    assertTrue(sourceFolder != -1);
    testProject.delete(true, true, null);
}
Also used : RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) IProjectConfiguration(org.eclipse.linuxtools.rpm.core.IProjectConfiguration) IProject(org.eclipse.core.resources.IProject) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with RPMProject

use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.

the class RPMProjectTest method testImportHelloWorld.

@Test
public void testImportHelloWorld() throws Exception {
    // Create a project for the test
    IProject testProject = root.getProject("testHelloWorld");
    RPMProject rpmProject = importSrpm(testProject);
    // Make sure the original SRPM got copied into the workspace
    IFile srpm = rpmProject.getConfiguration().getSrpmsFolder().getFile(new Path("helloworld-2-2.src.rpm"));
    assertTrue(srpm.exists());
    // Make sure everything got installed properly
    IFile spec = rpmProject.getConfiguration().getSpecsFolder().getFile(new Path("helloworld.spec"));
    assertTrue(spec.exists());
    IFile sourceBall = rpmProject.getConfiguration().getSourcesFolder().getFile(new Path("helloworld-2.tar.bz2"));
    assertTrue(sourceBall.exists());
    // Make sure we got the spec file
    IResource specFile = rpmProject.getSpecFile();
    assertNotNull(specFile);
    // Make sure the RPM nature was added
    assertTrue(testProject.hasNature(IRPMConstants.RPM_NATURE_ID));
    // Clean up
    testProject.delete(true, true, monitor);
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) RPMProject(org.eclipse.linuxtools.rpm.core.RPMProject) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) Test(org.junit.Test)

Aggregations

RPMProject (org.eclipse.linuxtools.rpm.core.RPMProject)16 Test (org.junit.Test)11 IFile (org.eclipse.core.resources.IFile)9 Path (org.eclipse.core.runtime.Path)9 IProject (org.eclipse.core.resources.IProject)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Ignore (org.junit.Ignore)5 URL (java.net.URL)4 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IStatus (org.eclipse.core.runtime.IStatus)3 CoreException (org.eclipse.core.runtime.CoreException)2 Job (org.eclipse.core.runtime.jobs.Job)2 DownloadJob (org.eclipse.linuxtools.rpm.core.utils.DownloadJob)2 Specfile (org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile)2 SpecfileParser (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileParser)2 Shell (org.eclipse.swt.widgets.Shell)2 IOException (java.io.IOException)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1