use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.
the class SpecfileEditorPrepareSourcesActionDelegate method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Shell shell = HandlerUtil.getActiveShellChecked(event);
final SpecfileParser specparser = new SpecfileParser();
final IResource resource = RPMHandlerUtils.getResource(event);
final RPMProject rpj = RPMHandlerUtils.getRPMProject(resource);
final IFile workFile = (IFile) rpj.getSpecFile();
final Specfile specfile = specparser.parse(workFile);
if (!downloadFile(shell, rpj, specfile)) {
return null;
}
Job job = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"Preparing sources") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask(NLS.bind(Messages.PrepareSources_prepareSources, rpj.getSpecFile().getName()), IProgressMonitor.UNKNOWN);
// $NON-NLS-1$
int offset = rpj.getSpecFile().getName().lastIndexOf(".");
MessageConsoleStream out = getConsole(rpj.getSpecFile().getName().substring(0, offset)).newMessageStream();
IStatus is = null;
try {
is = rpj.buildPrep(out);
} catch (CoreException e) {
SpecfileLog.logError(Messages.PrepareSources_coreException, e);
RPMUtils.showErrorDialog(shell, Messages.PrepareSources_error, Messages.PrepareSources_coreException);
return is;
} finally {
monitor.done();
}
return is;
}
};
// suppress UI. That's done in encapsulated
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.
the class DownloadPrepareSourcesTest method layoutFLATDownloadSourcesTest.
/**
* Test downloading sources using FLAT layout
*
* @throws CoreException
* @throws IOException
* @throws InterruptedException
*/
@Test
public void layoutFLATDownloadSourcesTest() throws CoreException, IOException, InterruptedException {
RPMProject rpmProject = importSrpm(testProject, RPMProjectLayout.FLAT);
assertNotNull(rpmProject);
downloadFile(rpmProject);
checkDownloadedFile(rpmProject, RPMProjectLayout.FLAT);
}
use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.
the class DownloadPrepareSourcesTest method layoutRPMBuildPrepareSourcesTest.
/**
* Test preparing sources using RPMBuild layout
*
* @throws CoreException
* @throws IOException
* @throws InterruptedException
*/
@Test
public void layoutRPMBuildPrepareSourcesTest() throws CoreException, IOException, InterruptedException {
RPMProject rpmProject = importSrpm(testProject, RPMProjectLayout.RPMBUILD);
assertNotNull(rpmProject);
downloadFile(rpmProject);
checkDownloadedFile(rpmProject, RPMProjectLayout.RPMBUILD);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
IStatus is = rpmProject.buildPrep(bos);
assertTrue(is.isOK());
checkPreparedSources(rpmProject, RPMProjectLayout.RPMBUILD);
}
use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.
the class RPMProjectTest method importSrpm.
private RPMProject importSrpm(IProject testProject) throws CoreException, IOException {
testProject.create(monitor);
testProject.open(monitor);
// Instantiate an RPMProject
RPMProject rpmProject = new RPMProject(testProject, RPMProjectLayout.RPMBUILD);
// 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 + "helloworld-2-2.src.rpm"), null);
File foo = new File(FileLocator.toFileURL(url).getPath());
rpmProject.importSourceRPM(foo);
return rpmProject;
}
use of org.eclipse.linuxtools.rpm.core.RPMProject in project linuxtools by eclipse.
the class RPMProjectTest method testImportHelloWorldFlat.
@Test
public void testImportHelloWorldFlat() throws Exception {
// Create a project for the test
IProject testProject = root.getProject("testHelloWorld");
testProject.create(monitor);
testProject.open(monitor);
// Instantiate an RPMProject
RPMProject rpmProject = new RPMProject(testProject, RPMProjectLayout.FLAT);
// 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 + "helloworld-2-2.src.rpm"), null);
File foo = new File(FileLocator.toFileURL(url).getPath());
rpmProject.importSourceRPM(foo);
// 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);
}
Aggregations