Date   

[PATCH] Validate project name and location for Bitbake command project

Ioana Grigoropol <ioanax.grigoropol@...>
 

- if the project location is empty default value will be used (e.g. /home/user/)
- project name must not contain whitespaces and/or invalid characters
- if we choose to clone a new repo but the destination directory already contains a .git directory, do not allow moving forward
- if we choose to validate an existing repository, make sure that the directory exists, and contains a .git directory as well as a oe-init-build-env script

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
.../src/org/yocto/bc/bitbake/ShellSession.java | 94 +++--------
.../org/yocto/bc/remote/utils/RemoteHelper.java | 69 ++++----
.../remote/utils/YoctoHostShellProcessAdapter.java | 15 +-
.../yocto/bc/ui/wizards/install/OptionsPage.java | 178 ++++++++++----------
.../BBConfigurationInitializeOperation.java | 6 +-
.../newproject/CreateBBCProjectOperation.java | 24 ++-
6 files changed, 173 insertions(+), 213 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index 961472f..f143bed 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -48,23 +48,23 @@ public class ShellSession {
public static final String LT = System.getProperty("line.separator");
public static final String exportCmd = "export BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
public static final String exportColumnsCmd = "export COLUMNS=1000";
-
+
public static String getFilePath(String file) throws IOException {
File f = new File(file);
-
+
if (!f.exists() || f.isDirectory()) {
throw new IOException("Path passed is not a file: " + file);
}
-
+
StringBuffer sb = new StringBuffer();
-
+
String elems[] = file.split("//");
-
+
for (int i = 0; i < elems.length - 1; ++i) {
sb.append(elems[i]);
sb.append("//");
}
-
+
return sb.toString();
}
private Process process;
@@ -90,7 +90,7 @@ public class ShellSession {
// shellPath = "/bin/sh";
// }
// shellPath = "/bin/bash";
-
+
initializeShell(new NullProgressMonitor());
}

@@ -104,13 +104,14 @@ public class ShellSession {
}
}

- synchronized
+ synchronized
public String execute(String command) throws IOException {
return execute(command, false);
}

- synchronized
+ synchronized
public String execute(String command, boolean hasErrors) throws IOException {
+
try {
IHost connection = RemoteHelper.getRemoteConnectionByName(projectInfo.getConnection().getName());
hasErrors = RemoteHelper.runCommandRemote(connection, new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""));
@@ -119,57 +120,15 @@ public class ShellSession {
e.printStackTrace();
}
return null;
-// sendToProcessAndTerminate(command);
-//
-// if (process.getErrorStream().available() > 0) {
-// byte[] msg = new byte[process.getErrorStream().available()];
-//
-// process.getErrorStream().read(msg, 0, msg.length);
-// out.write(new String(msg));
-// out.write(LT);
-// errorMessage = "Error while executing: " + command + LT + new String(msg);
-// }
-//
-// BufferedReader br = new BufferedReader(new InputStreamReader(process
-// .getInputStream()));
-//
-// StringBuffer sb = new StringBuffer();
-// String line = null;
-
-// while (((line = br.readLine()) != null) && !line.endsWith(TERMINATOR) && !interrupt) {
-// sb.append(line);
-// sb.append(LT);
-// out.write(line);
-// out.write(LT);
-// }
-//
-// if (interrupt) {
-// process.destroy();
-// initializeShell(null);
-// interrupt = false;
-// }
-// else if (line != null && retCode != null) {
-// try {
-// retCode[0]=Integer.parseInt(line.substring(0,line.lastIndexOf(TERMINATOR)));
-// }catch (NumberFormatException e) {
-// throw new IOException("Can NOT get return code" + command + LT + line);
-// }
-// }
-//
-// if (errorMessage != null) {
-// throw new IOException(errorMessage);
-// }
-//
-// return sb.toString();
}

-synchronized
+synchronized
public void execute(String command, ICommandResponseHandler handler) throws IOException {
System.out.println(command);
execute(command, TERMINATOR, handler);
}
-
- synchronized
+
+ synchronized
public void execute(String command, String terminator, ICommandResponseHandler handler) throws IOException {
interrupt = false;
InputStream errIs = process.getErrorStream();
@@ -177,40 +136,40 @@ synchronized
clearErrorStream(errIs);
}
sendToProcessAndTerminate(command);
-
+
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String std = null;

- do {
+ do {
if (errIs.available() > 0) {
byte[] msg = new byte[errIs.available()];

errIs.read(msg, 0, msg.length);
// out.write(new String(msg));
handler.response(new String(msg), true);
- }
-
+ }
+
std = br.readLine();
-
+
if (std != null && !std.endsWith(terminator)) {
// out.write(std);
handler.response(std, false);
- }
-
+ }
+
} while (std != null && !std.endsWith(terminator) && !interrupt);
-
+
if (interrupt) {
process.destroy();
initializeShell(null);
interrupt = false;
}
}
-
+
private void clearErrorStream(InputStream is) {
-
+
try {
byte b[] = new byte[is.available()];
- is.read(b);
+ is.read(b);
System.out.println("clearing: " + new String(b));
} catch (IOException e) {
e.printStackTrace();
@@ -221,7 +180,7 @@ synchronized
/**
* Send command string to shell process and add special terminator string so
* reader knows when output is complete.
- *
+ *
* @param command
* @throws IOException
*/
@@ -241,6 +200,5 @@ synchronized
public void interrupt() {
interrupt = true;
}
-
-}

+}
\ No newline at end of file
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
index 929ad63..f375de1 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
@@ -47,13 +47,13 @@ import org.yocto.bc.ui.wizards.install.Messages;
public class RemoteHelper {
public static final int TOTALWORKLOAD = 100;
private static Map<IHost, RemoteMachine> machines;
-
+
public static RemoteMachine getRemoteMachine(IHost connection){
if (!getMachines().containsKey(connection))
getMachines().put(connection, new RemoteMachine(connection));
return getMachines().get(connection);
}
-
+
private static Map<IHost, RemoteMachine> getMachines() {
if (machines == null)
machines = new HashMap<IHost, RemoteMachine>();
@@ -71,7 +71,7 @@ public class RemoteHelper {
public static YoctoHostShellProcessAdapter getHostShellProcessAdapter(IHost connection) {
return getRemoteMachine(connection).getHostShellProcessAdapter();
}
-
+
public static ProcessStreamBuffer getProcessBuffer(IHost connection) {
return getRemoteMachine(connection).getProcessBuffer();
}
@@ -87,20 +87,20 @@ public class RemoteHelper {
for (int i = 0; i < connections.length; i++)
if (connections[i].getAliasName().equals(remoteConnection))
return connections[i];
- return null;
+ return null;
}
-
+
public static IHost getRemoteConnectionForURI(URI uri, IProgressMonitor monitor) {
if (uri == null)
return null;
-
+
String host = uri.getHost();
- if (host == null)
+ if (host == null)
return null;
-
+
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
IHost[] connections = sr.getHosts();
-
+
IHost unconnected = null;
for (IHost conn : connections) {
if (host.equalsIgnoreCase(conn.getHostName())) {
@@ -110,26 +110,26 @@ public class RemoteHelper {
unconnected = conn;
}
}
-
+
return unconnected;
}
-
+
public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) {
IRemoteFileSubSystem candidate = null;
IRemoteFileSubSystem otherServiceCandidate = null;
IRemoteFileSubSystem[] subSystems = RemoteFileUtility.getFileSubSystems(host);
-
+
for (IRemoteFileSubSystem subSystem : subSystems) {
if (subSystem instanceof FileServiceSubSystem) {
if (subSystem.isConnected())
return subSystem;
-
+
if (otherServiceCandidate == null)
otherServiceCandidate = subSystem;
-
+
} else if (candidate == null || (subSystem.isConnected() && !candidate.isConnected()))
candidate = subSystem;
-
+
}
if (candidate != null && candidate.isConnected())
return candidate;
@@ -137,7 +137,7 @@ public class RemoteHelper {
return otherServiceCandidate;
return null;
}
-
+
public static String getRemoteHostName(String remoteConnection){
final IHost host = getRemoteConnectionByName(remoteConnection);
if(host == null)
@@ -149,9 +149,9 @@ public class RemoteHelper {
public static IFileService getConnectedRemoteFileService(IHost connection, IProgressMonitor monitor) throws Exception {
return getRemoteMachine(connection).getRemoteFileService(monitor);
}
-
+
public static IHostFile[] getRemoteDirContent(IHost connection, String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor){
-
+
try {
IFileService fileServ = getConnectedRemoteFileService(connection, monitor);
return fileServ.list(remoteParent, fileFilter, fileType, monitor);
@@ -182,11 +182,11 @@ public class RemoteHelper {

return ((IFileServiceSubSystem) subsystem).getFileService();
}
-
+
public static ISubSystem getFileSubsystem(IHost connection) {
return getRemoteMachine(connection).getFileSubsystem();
}
-
+
public static IService getConnectedShellService(IHost connection, IProgressMonitor monitor) throws Exception {
return getRemoteMachine(connection).getShellService(monitor);
}
@@ -201,21 +201,21 @@ public class RemoteHelper {
}
return null;
}
-
+
public static void getRemoteFile(IHost connection, String localExePath, String remoteExePath,
IProgressMonitor monitor) throws Exception {
-
+
assert(connection!=null);
monitor.beginTask(Messages.InfoDownload, 100);
-
+
IFileService fileService;
try {
- fileService = (IFileService) getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+ fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
File file = new File(localExePath);
file.deleteOnExit();
monitor.worked(5);
Path remotePath = new Path(remoteExePath);
- fileService.download(remotePath.removeLastSegments(1).toString(),
+ fileService.download(remotePath.removeLastSegments(1).toString(),
remotePath.lastSegment(),file,true, null,
new SubProgressMonitor(monitor, 85));
} finally {
@@ -223,13 +223,13 @@ public class RemoteHelper {
}
return;
}
-
+
public static IHostFile getRemoteHostFile(IHost connection, String remoteFilePath, IProgressMonitor monitor){
assert(connection != null);
monitor.beginTask(Messages.InfoDownload, 100);
-
+
try {
- IFileService fileService = (IFileService) getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
+ IFileService fileService = getConnectedRemoteFileService(connection, new SubProgressMonitor(monitor, 10));
Path remotePath = new Path(remoteFilePath);
IHostFile remoteFile = fileService.getFile(remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(), new SubProgressMonitor(monitor, 5));
return remoteFile;
@@ -239,20 +239,20 @@ public class RemoteHelper {
}
return null;
}
-
+
public static boolean runCommandRemote(final IHost connection, final YoctoCommand cmd) throws Exception {
final String remoteCommand = cmd.getCommand() + " " + cmd.getArguments();
final boolean hasErrors = false;
-
+
if (!cmd.getInitialDirectory().isEmpty()) {
writeToShell(connection, "cd " + cmd.getInitialDirectory());
}
if (!hasErrors)
writeToShell(connection, remoteCommand);
-
+
return hasErrors;
}
-
+
public static boolean writeToShell(final IHost connection, final String remoteCommand){
new Thread(new Runnable() {
@Override
@@ -282,7 +282,7 @@ public class RemoteHelper {
}
writeToShell(connection, remoteCommand);
}
-
+
} catch (Exception e1) {
e1.printStackTrace();
}
@@ -291,7 +291,7 @@ public class RemoteHelper {
/**
* Throws a core exception with an error status object built from the given
* message, lower level exception, and error code.
- *
+ *
* @param message
* the status message
* @param exception
@@ -329,6 +329,7 @@ public class RemoteHelper {
String parentPath = path.substring(0, nameStart);
String name = path.substring(nameStart + 1);
IHostFile hostFile = fs.getFile(parentPath, name, monitor);
+
return hostFile.exists();
} catch (Exception e) {
e.printStackTrace();
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
index baedc3b..9ab43cf 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
@@ -33,7 +33,7 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
private String endChar = null;

private Semaphore sem;
-
+
public YoctoHostShellProcessAdapter(IHostShell hostShell, ProcessStreamBuffer processStreamBuffer, CommandResponseHandler commandResponseHandler) throws IOException {
super(hostShell);
this.processStreamBuffer = processStreamBuffer;
@@ -67,11 +67,11 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
private interface ICalculatePercentage {
public float calWorkloadDone(String info) throws IllegalArgumentException;
}
-
+
private class GitCalculatePercentage implements ICalculatePercentage {
final Pattern pattern = Pattern.compile("^Receiving objects:\\s*(\\d+)%.*");
public float calWorkloadDone(String info) throws IllegalArgumentException {
- Matcher m = pattern.matcher(info.trim());
+ Matcher m = pattern.matcher(info.trim());
if(m.matches()) {
return new Float(m.group(1)) / 100;
}else {
@@ -79,7 +79,7 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
}
}
}
-
+
private IProgressMonitor getMonitor() {
if (command == null) {
return null;
@@ -88,16 +88,13 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
}

private void updateMonitor(final int work){
-
Display.getDefault().asyncExec(new Runnable() {
-
@Override
public void run() {
if (getMonitor() != null) {
getMonitor().worked(work);
}
}
-
});
}

@@ -155,10 +152,9 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
continue;
}
setCommandPrompt(value);
-
if (commandPrompt != null && endChar != null && command != null && processStreamBuffer != null &&
value.startsWith(commandPrompt) && value.endsWith(endChar) &&
- !value.endsWith(command) && processStreamBuffer.getLastOutputLineContaining(command) != null) {
+ !value.endsWith(command) && processStreamBuffer.getLastOutputLineContaining(command) != null /*&& waitForOutput*/) {
sem.release();
isFinished = true;
}
@@ -210,4 +206,3 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
}

}
-
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/OptionsPage.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/OptionsPage.java
index 7c1a655..37c12f8 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/OptionsPage.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/OptionsPage.java
@@ -1,7 +1,6 @@
package org.yocto.bc.ui.wizards.install;

import java.io.File;
-import java.io.FilenameFilter;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
@@ -13,6 +12,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ptp.rdt.ui.wizards.RemoteProjectContentsLocationArea;
@@ -22,9 +22,9 @@ import org.eclipse.ptp.remote.core.IRemoteFileManager;
import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.ptp.remote.core.exception.RemoteConnectionException;
import org.eclipse.ptp.remote.rse.core.RSEConnection;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.files.IHostFile;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -32,31 +32,32 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
+import org.yocto.bc.remote.utils.RemoteHelper;
import org.yocto.bc.ui.wizards.FiniteStateWizardPage;

/**
* Select which flavor of OE is to be installed.
- *
+ *
* @author kgilmer
- *
+ *
* Setting up the parameters for creating the new Yocto Bitbake project
- *
+ *
* @modified jzhang
*/
public class OptionsPage extends FiniteStateWizardPage {

public static final String URI_SEPARATOR = "/";
public static final String LOCALHOST = "LOCALHOST";
-
+
private Composite top;
-
+
private ValidationListener validationListener;
private Text txtProjectName;
private Button btnGit;
private Button btnValidate;
-
+
private RemoteProjectContentsLocationArea locationArea;
-
+
protected OptionsPage(Map<String, Object> model) {
super("Options", model);
setMessage("Enter these parameters to create new Yocto Project BitBake commander project");
@@ -69,7 +70,7 @@ public class OptionsPage extends FiniteStateWizardPage {
top.setLayoutData(new GridData(GridData.FILL_BOTH));

GridData gdFillH = new GridData(GridData.FILL_HORIZONTAL);
-
+
Composite projectNameComp = new Composite(top, SWT.NONE);
GridData gdProjName = new GridData(GridData.FILL_HORIZONTAL);
projectNameComp.setLayoutData(gdProjName);
@@ -81,11 +82,11 @@ public class OptionsPage extends FiniteStateWizardPage {
txtProjectName.setLayoutData(gdFillH);
txtProjectName.setFocus();
validationListener = new ValidationListener();
-
+
txtProjectName.addModifyListener(validationListener);

IErrorMessageReporter errorReporter = new IErrorMessageReporter() {
-
+
@Override
public void reportError(String errorMessage, boolean infoOnly) {
setMessage(errorMessage);
@@ -93,47 +94,32 @@ public class OptionsPage extends FiniteStateWizardPage {
updateModel();
}
};
-
+
locationArea = new RemoteProjectContentsLocationArea(errorReporter, top, null);
-
+
Group locationValidationGroup = new Group(top, SWT.NONE);
locationValidationGroup.setText("Git repository");
GridData gd = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL);
locationValidationGroup.setLayoutData(gd);
GridLayout gl = new GridLayout(1, false);
locationValidationGroup.setLayout(gl);
-
- SelectionListener lst = new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (validateProjectName() && validateProjectLocation())
- setPageComplete(true);
-
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
-
-
+
btnGit = new Button(locationValidationGroup, SWT.RADIO);
btnGit.setText("Clone from Yocto Project &Git Repository into new location");
btnGit.setEnabled(true);
btnGit.setSelection(true);
- btnGit.addSelectionListener(lst);
-
-
+ btnGit.addSelectionListener(validationListener);
+
+
btnValidate = new Button(locationValidationGroup, SWT.RADIO);
btnValidate.setText("&Validate existing Git project location");
btnValidate.setEnabled(true);
btnValidate.setSelection(false);
- btnValidate.addSelectionListener(lst);
-
+ btnValidate.addSelectionListener(validationListener);
+
setControl(top);
}
-
+
private boolean validateProjectName() {
IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();

@@ -143,7 +129,7 @@ public class OptionsPage extends FiniteStateWizardPage {
setErrorMessage("Project name cannot be empty!");
return false;
}
-
+
if (!validate.isOK() || !isValidProjectName(txtProjectName.getText())) {
setErrorMessage("Invalid project name: " + txtProjectName.getText());
return false;
@@ -156,67 +142,78 @@ public class OptionsPage extends FiniteStateWizardPage {
}
return true;
}
-
+
public String getProjectName(){
return txtProjectName.getText().trim();
}
-
+
protected boolean validateProjectLocation() {
-
+
String projectLoc = locationArea.getProjectLocation().trim();
-
- File checkProject_dir = new File(projectLoc);
- if (!checkProject_dir.isDirectory()) {
- setErrorMessage("The project location directory " + projectLoc + " is not valid");
+
+ IRemoteConnection remoteConnection = locationArea.getRemoteConnection();
+ if (remoteConnection == null)
return false;
- }
+
+ if (projectLoc.isEmpty())
+ return true;
+
+ IHost connection = RemoteHelper.getRemoteConnectionByName(remoteConnection.getName());
+
projectLoc = convertToRealPath(projectLoc);
String separator = projectLoc.endsWith(URI_SEPARATOR) ? "" : URI_SEPARATOR;
String projectPath = projectLoc + separator + getProjectName();
- File gitDir = new File(projectPath);
+ IHostFile repoDest = RemoteHelper.getRemoteHostFile(connection, projectPath, new NullProgressMonitor());
+
if(btnValidate.getSelection()) {
- if(!gitDir.isDirectory() || !gitDir.exists()) {
+ if (repoDest == null || !repoDest.exists()) {
setErrorMessage("Directory " + projectPath + " does not exist, please select git clone.");
return false;
}
- File[] filesMatched = gitDir.listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File file, String pattern) {
- return file.getName().equals(".git");
- }
- });
-
- if (filesMatched.length != 1) {
+ IHostFile gitDescr = RemoteHelper.getRemoteHostFile(connection, projectPath + "/.git", new NullProgressMonitor());
+ if (gitDescr == null || !gitDescr.exists()) {
setErrorMessage("Directory " + projectPath + " does not contain a git repository, please select git clone.");
return false;
}
-
- if(!new File(projectLoc + separator + InstallWizard.VALIDATION_FILE).exists()) {
+
+ IHostFile validationFile = RemoteHelper.getRemoteHostFile(connection, projectPath + URI_SEPARATOR + InstallWizard.VALIDATION_FILE, new NullProgressMonitor());
+ if (validationFile == null || !validationFile.exists()) {
setErrorMessage("Directory " + projectPath + " seems invalid, please use other directory or project name.");
return false;
}
+ } else { //git clone
+ if (repoDest.exists() && repoDest.isDirectory()) {
+ IHostFile gitDescr = RemoteHelper.getRemoteHostFile(connection, projectPath + "/.git", new NullProgressMonitor());
+ if (gitDescr != null && gitDescr.exists()) {
+ setErrorMessage("Directory " + projectPath + " contains a repository, please select validate repository.");
+ return false;
+ }
+ }
}
-
+
try {
- IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
- IProject proj = wsroot.getProject(txtProjectName.getText());
- if (proj.exists()) {
- setErrorMessage("A project with the name " + txtProjectName.getText() + " already exists");
- return false;
- }
- URI location = new URI("file:" + URI_SEPARATOR + URI_SEPARATOR + convertToRealPath(projectLoc) + URI_SEPARATOR + txtProjectName.getText());
-
- IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocationURI(proj, location);
- if (!status.isOK()) {
- setErrorMessage(status.getMessage());
- return false;
+ String projName = txtProjectName.getText();
+ if (!projName.trim().isEmpty() && validateProjectName()) {
+ IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject proj = wsroot.getProject();
+ if (proj != null && proj.exists()) {
+ setErrorMessage("A project with the name " + projName + " already exists");
+ return false;
+ }
+ URI location = new URI("file:" + URI_SEPARATOR + URI_SEPARATOR + convertToRealPath(projectLoc) + URI_SEPARATOR + txtProjectName.getText());
+
+ IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocationURI(proj, location);
+ if (!status.isOK()) {
+ setErrorMessage(status.getMessage());
+ return false;
+ }
}
} catch (Exception e) {
+ e.printStackTrace();
setErrorMessage("Run into error while trying to validate entries!");
return false;
}
-
+
setErrorMessage(null);
return true;
}
@@ -238,7 +235,7 @@ public class OptionsPage extends FiniteStateWizardPage {
return convertedpath;
}

-
+
@Override
public void pageCleanup() {

@@ -249,7 +246,7 @@ public class OptionsPage extends FiniteStateWizardPage {
}

@Override
-
+
protected void updateModel() {
try {
URI uri = getProjectLocationURI();
@@ -266,12 +263,12 @@ public class OptionsPage extends FiniteStateWizardPage {

public URI getProjectLocationURI() throws URISyntaxException {
URI uri = locationArea.getProjectLocationURI();
-
+
if (uri != null) {
String location = locationArea.getProjectLocation();
if (!uri.getPath().isEmpty()) {
String separator = uri.getPath().endsWith(URI_SEPARATOR) ? "" : URI_SEPARATOR;
-
+
return new URI( uri.getScheme(),
uri.getHost(),
uri.getPath() + separator + txtProjectName.getText(),
@@ -284,7 +281,7 @@ public class OptionsPage extends FiniteStateWizardPage {
} else {
String location = locationArea.getProjectLocation();
String separator = location.endsWith(URI_SEPARATOR) ? "" : URI_SEPARATOR;
-
+
IRemoteConnection conn = locationArea.getConnection();
if (conn instanceof RSEConnection) {
RSEConnection rseConn = (RSEConnection)conn;
@@ -294,7 +291,7 @@ public class OptionsPage extends FiniteStateWizardPage {
}
}
}
-
+
private String getDefaultPathDisplayString(IRemoteConnection connection, IRemoteServices remoteServices) {
String projectName = getProjectName();
if (projectName.isEmpty())
@@ -306,7 +303,7 @@ public class OptionsPage extends FiniteStateWizardPage {
} catch (RemoteConnectionException e) {
e.printStackTrace();
}
-
+
IRemoteFileManager fileMgr = remoteServices.getFileManager(connection);
URI defaultURI = fileMgr.toURI(connection.getWorkingDirectory());

@@ -322,19 +319,30 @@ public class OptionsPage extends FiniteStateWizardPage {
}
return ""; //$NON-NLS-1$
}
-
+
private boolean isValidProjectName(String projectName) {
- if (projectName.indexOf('$') > -1) {
+ if (projectName.contains("\\s+"))
+ return false;
+
+ if (projectName.indexOf('$') != -1)
return false;
- }

+ char[] chars = projectName.toCharArray();
+ if (!Character.isJavaIdentifierStart(chars[0]))
+ return false;
+ for (int i = 1; i < chars.length; i++)
+ if (!Character.isJavaIdentifierPart(chars[i]))
+ return false;
return true;
- }
+ }
@Override
protected boolean validatePage() {
if (!validateProjectName())
return false;
-
+
+ if (!validateProjectLocation())
+ return false;
+
setErrorMessage(null);
setMessage("All the entries are valid, press \"Finish\" to start the process, "+
"this will take a while. Please don't interrupt till there's output in the Yocto Console window...");
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
index a2af6e4..7a68ed5 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -15,7 +15,6 @@ import java.lang.reflect.InvocationTargetException;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
-
import org.yocto.bc.bitbake.BBSession;
import org.yocto.bc.bitbake.ProjectInfoHelper;
import org.yocto.bc.remote.utils.RemoteHelper;
@@ -37,13 +36,16 @@ public class BBConfigurationInitializeOperation implements IRunnableWithProgress
this.writer = writer;
}

+ @Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
BBSession session;
try {
+ monitor.beginTask("Initialize bitbake session ...", RemoteHelper.TOTALWORKLOAD);
ProjectInfoHelper.store(RemoteHelper.getRemoteConnectionByName(pinfo.getConnection().getName()), pinfo.getURI(), pinfo, monitor);
session = Activator.getBBSession(pinfo, writer, monitor);
session.initialize();
-
+ monitor.worked(90);
+ monitor.done();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index fcc939c..1a19479 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -42,40 +42,40 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
public static void addNatureToProject(IProject proj, String nature_id, IProgressMonitor monitor) throws CoreException {
IProjectDescription desc = proj.getDescription();
Vector<String> natureIds = new Vector<String>();
-
+
natureIds.add(nature_id);
natureIds.addAll(Arrays.asList(desc.getNatureIds()));
- desc.setNatureIds((String[]) natureIds.toArray(new String[natureIds.size()]));
-
+ desc.setNatureIds(natureIds.toArray(new String[natureIds.size()]));
+
proj.setDescription(desc, monitor);
}
-
+
private ProjectInfo projInfo;

public CreateBBCProjectOperation(ProjectInfo projInfo) {
this.projInfo = projInfo;
}
-
+
protected void addNatures(IProject proj, IProgressMonitor monitor) throws CoreException {
addNatureToProject(proj, BitbakeCommanderNature.NATURE_ID, monitor);
}

private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInformation) throws CoreException {
IProjectDescription desc = workspace.newProjectDescription(projInformation.getProjectName());
-
+
desc.setLocationURI(projInformation.getURI());
-
+
return desc;
}

@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
IProjectDescription desc = createProjectDescription(ResourcesPlugin.getWorkspace(), projInfo);
-
+
IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();

IProject proj = wsroot.getProject(projInfo.getProjectName());
-
+
try {
proj.create(desc, monitor);
ProjectInfoHelper.store(RemoteHelper.getRemoteConnectionByName(projInfo.getConnection().getName()), proj.getLocationURI(), projInfo, monitor);
@@ -85,13 +85,9 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
} catch (Exception e) {
e.printStackTrace();
}
-
-
-
-
addNatures(proj, monitor);
}
-
+
public ProjectInfo getProjectInfo() {
return projInfo;
}
--
1.7.9.5


Re: Howto use yocto meta-toolchain?

Laurentiu Palcu <laurentiu.palcu@...>
 

On 12/04/2012 01:22 PM, Marco wrote:
Il 03/12/2012 18:46, Zhang, Jessica ha scritto:
Hi Marco,

Can you filed a bug about this in bugzilla? Also, you don't need to sudo to run the install script, if you choose the default location which is /opt/poky/1.3, it'll prompt you for the password, or you can specify a directory under your $HOME dir. In your bug, can you provide some detail how you build the toolchain, e.g. the local.conf file changes, etc.?
Jessica,
thank you for answering.

Bugzilla classification is different from its documentation.
Where do you suggest to place my bug?
https://wiki.yoctoproject.org/wiki/Bugzilla_Configuration_and_Bug_Tracking
You can place it for ADT.



Actually if I don't sudo to run the install script it doesn't work:

$ tmp/deploy/sdk/poky-eglibc-x86_64-arm-toolchain-1.3.sh
Enter target directory for SDK (default: /opt/poky/1.3):
You are about to install the SDK to "/opt/poky/1.3". Proceed[Y/n]?
Error: Unable to create target directory. Do you have permissions?
The latest changes which are now in master, should fix that. You will be
asked to insert the password. However, there still is a patch pending in
order for this to work properly (I just saw the problem today and sent a
patch on oe-core mailing list).

However, going back to your initial problem. Is that a tarball you
downloaded or one you built yourself? If you're filling a bug, provide
as much details as possible in order to replicate your issue.

Thanks,
Laurentiu


Re: chris larson's cool "bitbake-env" utility

Robert P. J. Day
 

On Mon, 3 Dec 2012, Tim Bird wrote:

On 11/30/2012 05:53 AM, Robert P. J. Day wrote:
On Thu, 29 Nov 2012, Tim Bird wrote:

I put a link to your page on my bitbake cheat sheet page at:
http://elinux.org/Bitbake_Cheat_Sheet
as someone who has never bothered to play with any of the UIs and is
thus asking from a position of total ignorance, i have a couple
questions about the "User interfaces" section of that cheat sheet.

using stock oe-core, i followed your cheat sheet and tried this:

$ bitbake

and got:

ERROR: Timeout while attempting to communicate with bitbake server

so i need to start the server? should that be mentioned there?
Hmmm. With bitbake from poky-1.2-denzil I get:
"Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."

I think that "bitbake <nothing>" is not really a valid invocation.
never mind, just my incoherence ... when i was reading up on
"bitbake -u hob", i also read that "-u" had a default value of knotty,
so i assumed, oh, then i should be able to run just "bitbake" (even
though i had no idea what that would represent). just silliness on my
part.

rday

--

========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================


Re: Howto use yocto meta-toolchain?

Marco <koansoftware@...>
 

Il 03/12/2012 18:46, Zhang, Jessica ha scritto:
Hi Marco,

Can you filed a bug about this in bugzilla? Also, you don't need to sudo to run the install script, if you choose the default location which is /opt/poky/1.3, it'll prompt you for the password, or you can specify a directory under your $HOME dir. In your bug, can you provide some detail how you build the toolchain, e.g. the local.conf file changes, etc.?
Jessica,
thank you for answering.

Bugzilla classification is different from its documentation.
Where do you suggest to place my bug?
https://wiki.yoctoproject.org/wiki/Bugzilla_Configuration_and_Bug_Tracking


Actually if I don't sudo to run the install script it doesn't work:

$ tmp/deploy/sdk/poky-eglibc-x86_64-arm-toolchain-1.3.sh
Enter target directory for SDK (default: /opt/poky/1.3):
You are about to install the SDK to "/opt/poky/1.3". Proceed[Y/n]?
Error: Unable to create target directory. Do you have permissions?

--
Marco


[PATCH 2/2] Show progress bar for building new Recipe in Bitbake commander perspective

Ioana Grigoropol <ioanax.grigoropol@...>
 

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
.../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 119 +++++++++++++-------
1 file changed, 78 insertions(+), 41 deletions(-)

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
index e27619e..e9dc1f3 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.yocto.bc.ui.wizards;

+import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -27,6 +28,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
@@ -74,6 +76,8 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
private IHost connection;

private String tempFolderPath;
+ private String srcFileNameExt;
+ private String srcFileName;

public static final String TEMP_FOLDER_NAME = "temp";
public static final String TAR_BZ2_EXT = ".tar.bz2";
@@ -98,6 +102,12 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
private static final String md5Pattern = "^[0-9a-f]{32}$";
protected static final String sha256Pattern = "^[0-9a-f]{64}$";

+ private HashMap<String, String> mirrorTable;
+ private URI extractDir;
+ private YoctoCommand licenseChecksumCmd;
+ protected YoctoCommand md5YCmd;
+ protected YoctoCommand sha256YCmd;
+
public NewBitBakeFileRecipeWizardPage(ISelection selection, IHost connection) {
super("wizardPage");
setTitle("BitBake Recipe");
@@ -300,16 +310,17 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
IProgressMonitor monitor = new NullProgressMonitor();
URI srcURI = new URI(txtSrcURI.getText().trim());
String scheme = srcURI.getScheme();
- String srcFileName = getSrcFileName(true);
+ this.srcFileNameExt = getSrcFileName(true);
+ this.srcFileName = getSrcFileName(false);
if ((scheme.equals(HTTP) || scheme.equals(FTP))
- && (srcFileName.endsWith(TAR_GZ_EXT) || srcFileName.endsWith(TAR_BZ2_EXT))) {
+ && (srcFileNameExt.endsWith(TAR_GZ_EXT) || srcFileNameExt.endsWith(TAR_BZ2_EXT))) {
try {
handleRemotePopulate(srcURI, monitor);
} catch (Exception e) {
e.printStackTrace();
}
} else {
- String packageName = getSrcFileName(false).replace("-", "_");
+ String packageName = srcFileName.replace("-", "_");
fileText.setText(packageName + BB_RECIPE_EXT);

handleLocalPopulate(srcURI, monitor);
@@ -320,52 +331,78 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}

private void handleLocalPopulate(URI srcURI, IProgressMonitor monitor) {
- populateLicenseFileChecksum(srcURI, monitor);
+ populateLicenseFileChecksum(srcURI);
populateInheritance(srcURI, monitor);
}

- private void handleRemotePopulate(URI srcURI, IProgressMonitor monitor) throws Exception {
+ private void handleRemotePopulate(final URI srcURI, IProgressMonitor monitor) throws Exception {
RemoteHelper.clearProcessBuffer(connection);
-
populateRecipeName(srcURI);
- List<YoctoCommand> commands = new ArrayList<YoctoCommand>();

- String metaDirLocPath = metaDirLoc.getPath();
- commands.add(new YoctoCommand("rm -rf " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
- commands.add(new YoctoCommand( "mkdir " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
- updateTempFolderPath();
+ this.getContainer().run(true, true, new IRunnableWithProgress() {

+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask("Populating recipe fields ... ", 100);
+ List<YoctoCommand> commands = new ArrayList<YoctoCommand>();

- try {
- commands.add(new YoctoCommand("wget " + srcURI.toURL(), tempFolderPath, ""));
+ try {
+ String metaDirLocPath = metaDirLoc.getPath();

- updateTempFolderPath();
- RemoteHelper.runBatchRemote(connection, commands, true);
+ monitor.subTask("Cleaning environment");
+ commands.add(new YoctoCommand("rm -rf " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
+ commands.add(new YoctoCommand( "mkdir " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
+ updateTempFolderPath();
+ monitor.worked(10);

- commands.clear();
+ monitor.subTask("Downloading package sources");
+ commands.add(new YoctoCommand("wget " + srcURI.toURL(), tempFolderPath, ""));

- String md5Cmd = "md5sum " + getSrcFileName(true);
- YoctoCommand md5YCmd = new YoctoCommand(md5Cmd, tempFolderPath, "");
- RemoteHelper.runCommandRemote(connection, md5YCmd);
+ updateTempFolderPath();
+ RemoteHelper.runBatchRemote(connection, commands, true);

- String sha256Cmd = "sha256sum " + getSrcFileName(true);
- YoctoCommand sha256YCmd = new YoctoCommand(sha256Cmd, tempFolderPath, "");
- RemoteHelper.runCommandRemote(connection, sha256YCmd);
+ commands.clear();
+ monitor.worked(50);

- URI extractDir = extractPackage(srcURI, monitor);
- YoctoCommand licenseChecksumCmd = populateLicenseFileChecksum(extractDir, monitor);
- updateSrcUri(createMirrorLookupTable(monitor), srcURI);
- populateInheritance(extractDir, monitor);
+ monitor.subTask("Compute package checksums");
+ String md5Cmd = "md5sum " + srcFileNameExt;
+ md5YCmd = new YoctoCommand(md5Cmd, tempFolderPath, "");
+ RemoteHelper.runCommandRemote(connection, md5YCmd);

- String md5Val = retrieveSum(md5YCmd);
- md5sumText.setText(Pattern.matches(md5Pattern, md5Val) ? md5Val : "");
- String sha256Val = retrieveSum(sha256YCmd);
- sha256sumText.setText(Pattern.matches(sha256Pattern, sha256Val) ? sha256Val : "");
- String checkSumVal = retrieveSum(licenseChecksumCmd);
- checksumText.setText(RemoteHelper.createNewURI(extractDir, COPYING_FILE).toString() + ";md5=" + (Pattern.matches(md5Pattern, checkSumVal) ? checkSumVal : ""));
- } catch (Exception e) {
- e.printStackTrace();
- }
+ monitor.worked(60);
+
+ String sha256Cmd = "sha256sum " + srcFileNameExt;
+ sha256YCmd = new YoctoCommand(sha256Cmd, tempFolderPath, "");
+ RemoteHelper.runCommandRemote(connection, sha256YCmd);
+
+ monitor.worked(70);
+
+ monitor.subTask("Extracting package");
+ extractDir = extractPackage(srcURI);
+ monitor.worked(80);
+
+ licenseChecksumCmd = populateLicenseFileChecksum(extractDir);
+
+ monitor.subTask("Creating mirror lookup table");
+ mirrorTable = createMirrorLookupTable();
+
+ monitor.worked(90);
+ monitor.done();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ updateSrcUri(mirrorTable, srcURI);
+ populateInheritance(extractDir, monitor);
+
+ String md5Val = retrieveSum(md5YCmd);
+ md5sumText.setText(Pattern.matches(md5Pattern, md5Val) ? md5Val : "");
+ String sha256Val = retrieveSum(sha256YCmd);
+ sha256sumText.setText(Pattern.matches(sha256Pattern, sha256Val) ? sha256Val : "");
+ String checkSumVal = retrieveSum(licenseChecksumCmd);
+ checksumText.setText(RemoteHelper.createNewURI(extractDir, COPYING_FILE).toString() + ";md5=" + (Pattern.matches(md5Pattern, checkSumVal) ? checkSumVal : ""));
}

private String retrieveSum(YoctoCommand cmd) {
@@ -378,9 +415,9 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
return "";
}

- private URI extractPackage(URI srcURI, IProgressMonitor monitor) {
+ private URI extractPackage(URI srcURI) {
try {
- String path = getSrcFileName(true);
+ String path = srcFileNameExt;
String tarCmd = "tar ";
if (path.endsWith(TAR_BZ2_EXT)) {
tarCmd += "-zxvf ";
@@ -390,7 +427,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {

RemoteHelper.runCommandRemote(connection, new YoctoCommand(tarCmd + path, tempFolderPath, ""));

- return RemoteHelper.createNewURI(metaDirLoc, TEMP_FOLDER_NAME + "/" + getSrcFileName(false));
+ return RemoteHelper.createNewURI(metaDirLoc, TEMP_FOLDER_NAME + "/" + srcFileName);

} catch (Exception e) {
e.printStackTrace();
@@ -424,7 +461,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}
}

- private YoctoCommand populateLicenseFileChecksum(URI extractDir, IProgressMonitor monitor) {
+ private YoctoCommand populateLicenseFileChecksum(URI extractDir) {
if (extractDir == null)
throw new RuntimeException("Something went wrong during source extraction!");

@@ -459,7 +496,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
return "";
}

- private HashMap<String, String> createMirrorLookupTable(IProgressMonitor monitor) throws Exception {
+ private HashMap<String, String> createMirrorLookupTable() throws Exception {
HashMap<String, String> mirrorMap = new HashMap<String, String>();

YoctoCommand cmd = new YoctoCommand("cat " + MIRRORS_FILE, getMetaFolderPath() + CLASSES_FOLDER, "");
@@ -486,7 +523,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
if (!fileName.isEmpty())
return;

- String recipeFile = getSrcFileName(false).replace("-", "_");
+ String recipeFile = srcFileName.replace("-", "_");
recipeFile += BB_RECIPE_EXT;
if (recipeFile != null)
fileText.setText(recipeFile);
--
1.7.9.5


[PATCH 1/2] Show progress bar for New Bitbake Commander project

Ioana Grigoropol <ioanax.grigoropol@...>
 

- run new Bitbake project creation in a new thread, being cancelable and update the monitor from the event handler in a asynchronous way by invoking Display.asyncExec
- use a blocking way to wait(mutex) for the event handler to finish reading command outputs - not only the event handler must be blocked, the one invoking the remote commands must block waiting for output, otherwise the new Project Wizard will not wait for the commands to finish running
- When searching for the desired output through the existing lines, we should not search for the prompt + previous command exactly, because the terminal shell used will use a wrapping value for the lines received and insert a whitespace character at each multiple of wrapping value
- usually, the wrapping value is controlled by $COLUMNS shell variable - a quick fix setting this variable to a bigger value does not prove useful
- instead, wait for the line containing the prompt & the previous command having all existing whitespaces removed
- the possibility that this line will be issued more than once is small.
- use YoctoHostShellAdapter to run long task showing progress in a Wizard page & parse task output using specialized Calculators

Signed-off-by: Ioana Grigoropol <ioanax.grigoropol@intel.com>
---
.../src/org/yocto/bc/bitbake/ShellSession.java | 24 +--
.../yocto/bc/remote/utils/ProcessStreamBuffer.java | 3 +-
.../org/yocto/bc/remote/utils/RemoteHelper.java | 92 +++-----
.../org/yocto/bc/remote/utils/RemoteMachine.java | 4 +-
.../remote/utils/YoctoHostShellProcessAdapter.java | 137 ++++++------
.../bc/remote/utils/YoctoRunnableWithProgress.java | 106 ++++++++++
.../bc/ui/wizards/NewBitBakeFileRecipeWizard.java | 2 +-
.../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 222 +++++++++-----------
.../yocto/bc/ui/wizards/install/InstallWizard.java | 113 +++-------
.../newproject/CreateBBCProjectOperation.java | 7 +-
10 files changed, 340 insertions(+), 370 deletions(-)
create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoRunnableWithProgress.java

diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
index edff746..961472f 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java
@@ -47,6 +47,7 @@ public class ShellSession {
public static final String TERMINATOR = "#234o987dsfkcqiuwey18837032843259d";
public static final String LT = System.getProperty("line.separator");
public static final String exportCmd = "export BB_ENV_EXTRAWHITE=\"DISABLE_SANITY_CHECKS $BB_ENV_EXTRAWHITE\"";
+ public static final String exportColumnsCmd = "export COLUMNS=1000";

public static String getFilePath(String file) throws IOException {
File f = new File(file);
@@ -96,8 +97,8 @@ public class ShellSession {
private void initializeShell(IProgressMonitor monitor) throws IOException {
try {
IHost connection = RemoteHelper.getRemoteConnectionByName(projectInfo.getConnection().getName());
- RemoteHelper.runCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""), monitor);
- RemoteHelper.runCommandRemote(connection, new YoctoCommand(exportCmd, root.getAbsolutePath(), ""), monitor);
+ RemoteHelper.runCommandRemote(connection, new YoctoCommand("source " + initCmd, root.getAbsolutePath(), ""));
+ RemoteHelper.runCommandRemote(connection, new YoctoCommand(exportCmd, root.getAbsolutePath(), ""));
} catch (Exception e) {
e.printStackTrace();
}
@@ -112,7 +113,7 @@ public class ShellSession {
public String execute(String command, boolean hasErrors) throws IOException {
try {
IHost connection = RemoteHelper.getRemoteConnectionByName(projectInfo.getConnection().getName());
- hasErrors = RemoteHelper.runCommandRemote(connection, new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""), new NullProgressMonitor());
+ hasErrors = RemoteHelper.runCommandRemote(connection, new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""));
return RemoteHelper.getProcessBuffer(connection).getMergedOutputLines();
} catch (Exception e) {
e.printStackTrace();
@@ -241,20 +242,5 @@ synchronized
interrupt = true;
}

- private class NullWriter extends Writer {
-
- @Override
- public void close() throws IOException {
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- }
-
- }
-
}
+
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ProcessStreamBuffer.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ProcessStreamBuffer.java
index 6756fe3..438a5b4 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ProcessStreamBuffer.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ProcessStreamBuffer.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;

public class ProcessStreamBuffer {
+ private static final String WHITESPACES = "\\s+";
List<String> errorLines;
List<String> outputLines;

@@ -47,7 +48,7 @@ public class ProcessStreamBuffer {
return null;
for (int i = outputLines.size() - 1; i >= 0; i--){
String line = outputLines.get(i);
- if (line.contains(str))
+ if (line.replaceAll(WHITESPACES, "").contains(str.replaceAll(WHITESPACES, "")))
return line;
}
return null;
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
index 432969c..929ad63 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java
@@ -138,36 +138,6 @@ public class RemoteHelper {
return null;
}

-// private static int displayDialogBox(String name, String[] choices) {
-// Display display = Display.getDefault();;
-// final Shell shell = new Shell(display);
-// shell.setText(name);
-//
-// shell.setLayout(new GridLayout(2, false));
-//
-// new Label(shell, SWT.NONE).setText("Connections for host:");
-// final Combo comboChoices = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
-// for (int i = 0, n = choices.length; i < n; i++)
-// comboChoices.add(choices[i]);
-// comboChoices.select(0);
-//
-// Button btnOK = new Button(shell, SWT.PUSH);
-// btnOK.setText("OK");
-//
-// DialogSelectionListener dsl = new DialogSelectionListener(shell, comboChoices);
-//
-// btnOK.addSelectionListener(dsl);
-//
-// shell.pack();
-// shell.open();
-// while (!shell.isDisposed()) {
-// if (!display.readAndDispatch()) {
-// display.sleep();
-// }
-// }
-// return dsl.getReturnValue();
-// }
-
public static String getRemoteHostName(String remoteConnection){
final IHost host = getRemoteConnectionByName(remoteConnection);
if(host == null)
@@ -270,49 +240,49 @@ public class RemoteHelper {
return null;
}

- public static boolean runCommandRemote(IHost connection, YoctoCommand cmd, IProgressMonitor monitor) throws Exception {
- String remoteCommand = cmd.getCommand() + " " + cmd.getArguments();
- boolean hasErrors = false;
- try {
- if (!cmd.getInitialDirectory().isEmpty()) {
- hasErrors = writeToShell(connection, "cd " + cmd.getInitialDirectory(), monitor);
- }
- if (!hasErrors)
- return writeToShell(connection, remoteCommand, monitor);
- } catch (Exception e) {
- e.printStackTrace();
+ public static boolean runCommandRemote(final IHost connection, final YoctoCommand cmd) throws Exception {
+ final String remoteCommand = cmd.getCommand() + " " + cmd.getArguments();
+ final boolean hasErrors = false;
+
+ if (!cmd.getInitialDirectory().isEmpty()) {
+ writeToShell(connection, "cd " + cmd.getInitialDirectory());
}
+ if (!hasErrors)
+ writeToShell(connection, remoteCommand);
+
return hasErrors;
}

- public static boolean writeToShell(IHost connection, String remoteCommand, IProgressMonitor monitor){
- YoctoHostShellProcessAdapter hostShellProcessAdapter = getHostShellProcessAdapter(connection);
- hostShellProcessAdapter.setMonitor(monitor);
- hostShellProcessAdapter.setLastCommand(remoteCommand);
- getHostShell(connection).writeToShell(remoteCommand);
-
-// try {
-// while (!hostShellProcessAdapter.isFinished() && hostShellProcessAdapter.isAlive()) {
-// Thread.sleep(2);
-// }
-//// System.out.println(">>>>>>>>>>>>>>>>>>>>finished command " + remoteCommand);
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-//
- return hostShellProcessAdapter.hasErrors();
+ public static boolean writeToShell(final IHost connection, final String remoteCommand){
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ YoctoHostShellProcessAdapter adapter = getHostShellProcessAdapter(connection);
+ adapter.setLastCommand(remoteCommand);
+ getHostShell(connection).writeToShell(remoteCommand);
+ while (!adapter.isFinished())
+ Thread.sleep(2);
+// return hostShellProcessAdapter.hasErrors();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }).run();
+ return true;
}
-
- public static void runBatchRemote(IHost connection, List<YoctoCommand> cmds, IProgressMonitor monitor, boolean waitForOutput) throws CoreException {
+
+ public static void runBatchRemote(IHost connection, List<YoctoCommand> cmds, boolean waitForOutput) throws CoreException {
try {
String remoteCommand = "";
for (YoctoCommand cmd : cmds) {
remoteCommand = cmd.getCommand() + " " + cmd.getArguments();
if (!cmd.getInitialDirectory().isEmpty()) {
- writeToShell(connection, "cd " + cmd.getInitialDirectory(), monitor);
+ writeToShell(connection, "cd " + cmd.getInitialDirectory());
}
- writeToShell(connection, remoteCommand, monitor);
+ writeToShell(connection, remoteCommand);
}
+
} catch (Exception e1) {
e1.printStackTrace();
}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java
index a953ef7..6eb2945 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java
@@ -8,6 +8,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.ptp.remote.core.IRemoteConnection;
+import org.eclipse.ptp.remote.core.IRemoteServices;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
@@ -72,7 +74,7 @@ public class RemoteMachine {
public YoctoHostShellProcessAdapter getHostShellProcessAdapter() {
try {
if (hostShellProcessAdapter == null)
- hostShellProcessAdapter = new YoctoHostShellProcessAdapter(getHostShell(), getProcessBuffer(), getCmdHandler());
+ hostShellProcessAdapter = new YoctoRunnableWithProgress(getHostShell(), getProcessBuffer(), getCmdHandler());
return hostShellProcessAdapter;
} catch (IOException e) {
e.printStackTrace();
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
index 79a62e0..baedc3b 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java
@@ -1,19 +1,22 @@
package org.yocto.bc.remote.utils;

import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.Semaphore;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.rse.services.shells.AbstractHostShellOutputReader;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
import org.eclipse.rse.services.shells.IHostShellOutputReader;
+import org.eclipse.swt.widgets.Display;

-public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
+public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter {
private String commandPrompt = null;
private static final String ROOT = "root";
private static final String PROMPT_USER_CH = "$";
@@ -23,42 +26,42 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
private boolean isFinished;
private ICalculatePercentage calculator;
private int reportedWorkload;
- private IProgressMonitor monitor;
private boolean isAlive;

- private String lastCommand;
- private boolean waitForOutput;
+ private String command;
+ private Map<String, IProgressMonitor> commandMonitors;
private String endChar = null;

private Semaphore sem;

- public String getLastCommand() {
- return lastCommand;
- }
-
- public synchronized void setLastCommand(String lastCommand) {
-// if (waitForOutput) {
- try {
- // there are still some processes that might take a long time and if we do not wait for them,
- // then the semaphore will not be released, because an interrupted exception will occur
- Thread.sleep(2000);
- System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>semaphore aquire");
- sem.acquire();
- this.lastCommand = lastCommand.trim();
- System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>last command set " + lastCommand);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-// }
+ public YoctoHostShellProcessAdapter(IHostShell hostShell, ProcessStreamBuffer processStreamBuffer, CommandResponseHandler commandResponseHandler) throws IOException {
+ super(hostShell);
+ this.processStreamBuffer = processStreamBuffer;
+ this.commandResponseHandler = commandResponseHandler;
+ this.calculator = new GitCalculatePercentage();
+ this.sem = new Semaphore(1);
+ this.command = "";
+ this.commandMonitors = new HashMap<>();
}

-
- public IProgressMonitor getMonitor() {
- return monitor;
+ public String getLastCommand() {
+ return command;
}

- public void setMonitor(IProgressMonitor monitor) {
- this.monitor = monitor;
+ public synchronized void setLastCommand(String lastCommand) {
+ try {
+ // there are still some processes that might take a long time and if we do not wait for them,
+ // then the semaphore will not be released, because an interrupted exception will occur
+ Thread.sleep(2000);
+ isFinished = false;
+ sem.acquire();
+ this.command = lastCommand.trim();
+ System.out.println("last command " + lastCommand + getOwnMonitor());
+ this.commandMonitors.put(command, getOwnMonitor());
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}

private interface ICalculatePercentage {
@@ -68,7 +71,7 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
private class GitCalculatePercentage implements ICalculatePercentage {
final Pattern pattern = Pattern.compile("^Receiving objects:\\s*(\\d+)%.*");
public float calWorkloadDone(String info) throws IllegalArgumentException {
- Matcher m = pattern.matcher(info.trim());
+ Matcher m = pattern.matcher(info.trim());
if(m.matches()) {
return new Float(m.group(1)) / 100;
}else {
@@ -77,38 +80,37 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
}
}

- public YoctoHostShellProcessAdapter(IHostShell hostShell, ProcessStreamBuffer processStreamBuffer, CommandResponseHandler commandResponseHandler) throws IOException {
- super(hostShell);
- this.processStreamBuffer = processStreamBuffer;
- this.commandResponseHandler = commandResponseHandler;
- this.calculator = new GitCalculatePercentage();
- this.sem = new Semaphore(1);
- this.lastCommand = "";
-
+ private IProgressMonitor getMonitor() {
+ if (command == null) {
+ return null;
+ }
+ return commandMonitors.get(command);
}

private void updateMonitor(final int work){
-// Display.getDefault().syncExec(new Runnable() {
-//
-// @Override
-// public void run() {
-// monitor.worked(work);
-// }
-// });
- }

+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (getMonitor() != null) {
+ getMonitor().worked(work);
+ }
+ }
+
+ });
+ }
+
private void doneMonitor(){
-// Display.getCurrent().syncExec(new Runnable() {
-//
-// @Override
-// public void run() {
-// monitor.done();
-// }
-// });
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ getMonitor().done();
+ }
+ });
}
-
+
private void reportProgress(String info) {
-
if(calculator == null) {
updateMonitor(1);
} else {
@@ -130,7 +132,7 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
doneMonitor();
}
}
-
+
@Override
public void shellOutputChanged(IHostShellChangeEvent event) {
IHostShellOutputReader reader = event.getReader();
@@ -153,10 +155,12 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
continue;
}
setCommandPrompt(value);
- if (value.startsWith(commandPrompt) && value.endsWith(endChar) &&
- !value.endsWith(lastCommand) && processStreamBuffer.getLastOutputLineContaining(lastCommand) != null /*&& waitForOutput*/) {
- System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Sem release");
+
+ if (commandPrompt != null && endChar != null && command != null && processStreamBuffer != null &&
+ value.startsWith(commandPrompt) && value.endsWith(endChar) &&
+ !value.endsWith(command) && processStreamBuffer.getLastOutputLineContaining(command) != null) {
sem.release();
+ isFinished = true;
}

reportProgress(value);
@@ -166,9 +170,6 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
}
}

- AbstractHostShellOutputReader absReader = (AbstractHostShellOutputReader)reader;
- isAlive = absReader.isAlive();
- isFinished = absReader.isFinished();
}
private void setCommandPrompt(String value) {
if (commandPrompt == null) {
@@ -199,16 +200,14 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{
this.isAlive = isAlive;
}

- public boolean isWaitForOutput() {
- return waitForOutput;
- }
-
- public void setWaitForOutput(boolean waitForOutput) {
- this.waitForOutput = waitForOutput;
- }
-
public void clearProcessBuffer() {
this.processStreamBuffer.outputLines.clear();
this.processStreamBuffer.errorLines.clear();
}
+
+ public IProgressMonitor getOwnMonitor() {
+ return new NullProgressMonitor();
+ }
+
}
+
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoRunnableWithProgress.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoRunnableWithProgress.java
new file mode 100644
index 0000000..3483a8c
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoRunnableWithProgress.java
@@ -0,0 +1,106 @@
+package org.yocto.bc.remote.utils;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ptp.remote.core.IRemoteConnection;
+import org.eclipse.ptp.remote.core.IRemoteServices;
+import org.eclipse.ptp.remote.core.exception.RemoteConnectionException;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.services.shells.IHostShell;
+
+public class YoctoRunnableWithProgress extends YoctoHostShellProcessAdapter
+ implements IRunnableWithProgress {
+
+ private String taskName;
+ private IRemoteConnection remoteConnection;
+ private IRemoteServices remoteServices;
+ private String cmd;
+ private String args;
+ private IProgressMonitor monitor;
+
+ public YoctoRunnableWithProgress(IHostShell hostShell,
+ ProcessStreamBuffer processStreamBuffer,
+ CommandResponseHandler commandResponseHandler) throws IOException {
+ super(hostShell, processStreamBuffer, commandResponseHandler);
+ }
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ try {
+ this.monitor = monitor;
+ this.monitor.beginTask(taskName, RemoteHelper.TOTALWORKLOAD);
+
+ if (!remoteConnection.isOpen()) {
+ try {
+ remoteConnection.open(monitor);
+ } catch (RemoteConnectionException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ if (!remoteServices.isInitialized()) {
+ remoteServices.initialize();
+ }
+
+ try {
+ IHost connection = RemoteHelper.getRemoteConnectionByName(remoteConnection.getName());
+ RemoteHelper.runCommandRemote(connection, new YoctoCommand(cmd, "", args));
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ monitor.done();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public IProgressMonitor getOwnMonitor() {
+ return monitor;
+ }
+
+ public IRemoteConnection getRemoteConnection() {
+ return remoteConnection;
+ }
+
+ public void setRemoteConnection(IRemoteConnection remoteConnection) {
+ this.remoteConnection = remoteConnection;
+ }
+
+ public String getTaskName() {
+ return taskName;
+ }
+
+ public void setTaskName(String taskName) {
+ this.taskName = taskName;
+ }
+
+ public IRemoteServices getRemoteServices() {
+ return remoteServices;
+ }
+
+ public void setRemoteServices(IRemoteServices remoteServices) {
+ this.remoteServices = remoteServices;
+ }
+
+ public String getCmd() {
+ return cmd;
+ }
+
+ public void setCmd(String cmd) {
+ this.cmd = cmd;
+ }
+
+ public String getArgs() {
+ return args;
+ }
+
+ public void setArgs(String args) {
+ this.args = args;
+ }
+}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java
index 73b21f5..57cad18 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java
@@ -205,7 +205,7 @@ public class NewBitBakeFileRecipeWizard extends Wizard implements INewWizard {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(element, monitor);
- RemoteHelper.runCommandRemote(connection, new YoctoCommand("rm -rf temp", element.getMetaDir() + "/temp", ""), monitor);
+ RemoteHelper.runCommandRemote(connection, new YoctoCommand("rm -rf temp", element.getMetaDir() + "/temp", ""));
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
index f1d90c9..e27619e 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java
@@ -24,7 +24,6 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -54,7 +53,7 @@ import org.yocto.bc.remote.utils.YoctoCommand;
public class NewBitBakeFileRecipeWizardPage extends WizardPage {
private Text containerText;
private Text fileText;
-
+
private Text descriptionText;
private Text licenseText;
private Text checksumText;
@@ -65,17 +64,17 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
private Text md5sumText;
private Text sha256sumText;
private Button btnPopulate;
-
+
private BitbakeRecipeUIElement element;
-
+
private ISelection selection;
private URI metaDirLoc;
private ArrayList<String> inheritance;

private IHost connection;
-
+
private String tempFolderPath;
-
+
public static final String TEMP_FOLDER_NAME = "temp";
public static final String TAR_BZ2_EXT = ".tar.bz2";
public static final String TAR_GZ_EXT = ".tar.gz";
@@ -98,7 +97,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
private static final String AUTOTOOLS = "autotools";
private static final String md5Pattern = "^[0-9a-f]{32}$";
protected static final String sha256Pattern = "^[0-9a-f]{64}$";
-
+
public NewBitBakeFileRecipeWizardPage(ISelection selection, IHost connection) {
super("wizardPage");
setTitle("BitBake Recipe");
@@ -107,9 +106,10 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
this.connection = connection;
this.element = new BitbakeRecipeUIElement();
this.inheritance = new ArrayList<String>();
-
+
}

+ @Override
public void createControl(Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
@@ -129,6 +129,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
gd = new GridData(GridData.FILL_HORIZONTAL);
containerText.setLayoutData(gd);
containerText.addModifyListener(new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
dialogChanged();
}
@@ -142,12 +143,12 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
handleBrowse(container, containerText);
}
});
-
+
label = new Label(container, SWT.NULL);
gd = new GridData();
gd.horizontalSpan = 3;
label.setLayoutData(gd);
-
+
label = new Label(container, SWT.NULL);
label.setText("SRC_&URI:");

@@ -155,12 +156,13 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
gd = new GridData(GridData.FILL_HORIZONTAL);
txtSrcURI.setLayoutData(gd);
txtSrcURI.addModifyListener(new ModifyListener() {
+ @Override
public void modifyText(ModifyEvent e) {
if (txtSrcURI.getText().trim().isEmpty()) {
if (btnPopulate != null)
btnPopulate.setEnabled(false);
} else if (btnPopulate != null){
- btnPopulate.setEnabled(true);
+ btnPopulate.setEnabled(true);
}
dialogChanged();
}
@@ -182,7 +184,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
createField(container, "License File &Checksum:", (checksumText = new Text(container, SWT.BORDER | SWT.SINGLE)));
createField(container, "&Package Description:", (descriptionText = new Text(container, SWT.BORDER | SWT.SINGLE)));
createField(container, "&License:", (licenseText = new Text(container, SWT.BORDER | SWT.SINGLE)));
-
+
createField(container, "&Homepage:", (homepageText = new Text(container, SWT.BORDER | SWT.SINGLE)));
createField(container, "Package &Author:", (authorText = new Text(container, SWT.BORDER | SWT.SINGLE)));
createField(container, "&Section:", (sectionText = new Text(container, SWT.BORDER | SWT.SINGLE)));
@@ -190,7 +192,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
// ProxySettingsComposite proxySettings = new ProxySettingsComposite(container, SWT.NONE);
// proxySettings.setEnabled(true);
// proxySettings.setVisible(true);
-
+
initialize();
dialogChanged();
setControl(container);
@@ -200,12 +202,13 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
Label label = new Label(container, SWT.NONE);
label.setText(title);
label.moveAbove(control);
-
+
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
control.setLayoutData(gd);
control.addModifyListener(new ModifyListener() {

+ @Override
public void modifyText(ModifyEvent e) {
dialogChanged();
}
@@ -222,7 +225,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
updateStatus("Directory must be specified");
return;
}
-
+
if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
updateStatus("File container must exist");
return;
@@ -231,10 +234,10 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
updateStatus("Project must be writable");
return;
}
-
+
IProject project = container.getProject();
metaDirLoc = RemoteHelper.createNewURI(project.getLocationURI(), "meta");
-
+
if (fileName.length() == 0) {
updateStatus("File name must be specified");
return;
@@ -252,7 +255,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
updateStatus("Recipe must have a description");
return;
}
-
+
if (licenseText.getText().length() == 0) {
updateStatus("Recipe must have a license");
return;
@@ -261,7 +264,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
if (txtSrcURI.getText().length() == 0) {
updateStatus("SRC_URI can't be empty");
}
-
+
updateStatus(null);
}

@@ -281,7 +284,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
element.setMetaDir(metaDirLoc);
return element;
}
-
+
private void handleBrowse(final Composite parent, final Text text) {
ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, "Select project directory");
if (dialog.open() == Window.OK) {
@@ -291,14 +294,14 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}
}
}
-
+
private void handlePopulate() {
try {
IProgressMonitor monitor = new NullProgressMonitor();
URI srcURI = new URI(txtSrcURI.getText().trim());
String scheme = srcURI.getScheme();
String srcFileName = getSrcFileName(true);
- if ((scheme.equals(HTTP) || scheme.equals(FTP))
+ if ((scheme.equals(HTTP) || scheme.equals(FTP))
&& (srcFileName.endsWith(TAR_GZ_EXT) || srcFileName.endsWith(TAR_BZ2_EXT))) {
try {
handleRemotePopulate(srcURI, monitor);
@@ -315,7 +318,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
e.printStackTrace();
}
}
-
+
private void handleLocalPopulate(URI srcURI, IProgressMonitor monitor) {
populateLicenseFileChecksum(srcURI, monitor);
populateInheritance(srcURI, monitor);
@@ -326,43 +329,43 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {

populateRecipeName(srcURI);
List<YoctoCommand> commands = new ArrayList<YoctoCommand>();
-
+
String metaDirLocPath = metaDirLoc.getPath();
commands.add(new YoctoCommand("rm -rf " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
commands.add(new YoctoCommand( "mkdir " + TEMP_FOLDER_NAME, metaDirLocPath, ""));
updateTempFolderPath();
- commands.add(new YoctoCommand("wget " + srcURI.toURL(), tempFolderPath, ""));
-
- updateTempFolderPath();
-
+
+
try {
- RemoteHelper.runBatchRemote(connection, commands, monitor, true);
- } catch (CoreException e) {
+ commands.add(new YoctoCommand("wget " + srcURI.toURL(), tempFolderPath, ""));
+
+ updateTempFolderPath();
+ RemoteHelper.runBatchRemote(connection, commands, true);
+
+ commands.clear();
+
+ String md5Cmd = "md5sum " + getSrcFileName(true);
+ YoctoCommand md5YCmd = new YoctoCommand(md5Cmd, tempFolderPath, "");
+ RemoteHelper.runCommandRemote(connection, md5YCmd);
+
+ String sha256Cmd = "sha256sum " + getSrcFileName(true);
+ YoctoCommand sha256YCmd = new YoctoCommand(sha256Cmd, tempFolderPath, "");
+ RemoteHelper.runCommandRemote(connection, sha256YCmd);
+
+ URI extractDir = extractPackage(srcURI, monitor);
+ YoctoCommand licenseChecksumCmd = populateLicenseFileChecksum(extractDir, monitor);
+ updateSrcUri(createMirrorLookupTable(monitor), srcURI);
+ populateInheritance(extractDir, monitor);
+
+ String md5Val = retrieveSum(md5YCmd);
+ md5sumText.setText(Pattern.matches(md5Pattern, md5Val) ? md5Val : "");
+ String sha256Val = retrieveSum(sha256YCmd);
+ sha256sumText.setText(Pattern.matches(sha256Pattern, sha256Val) ? sha256Val : "");
+ String checkSumVal = retrieveSum(licenseChecksumCmd);
+ checksumText.setText(RemoteHelper.createNewURI(extractDir, COPYING_FILE).toString() + ";md5=" + (Pattern.matches(md5Pattern, checkSumVal) ? checkSumVal : ""));
+ } catch (Exception e) {
e.printStackTrace();
}
-
- commands.clear();
-
-
- String md5Cmd = "md5sum " + getSrcFileName(true);
- YoctoCommand md5YCmd = new YoctoCommand(md5Cmd, tempFolderPath, "");
- RemoteHelper.runCommandRemote(connection, md5YCmd, monitor);
-
- String sha256Cmd = "sha256sum " + getSrcFileName(true);
- YoctoCommand sha256YCmd = new YoctoCommand(sha256Cmd, tempFolderPath, "");
- RemoteHelper.runCommandRemote(connection, sha256YCmd, monitor);
-
- URI extractDir = extractPackage(srcURI, monitor);
- YoctoCommand licenseChecksumCmd = populateLicenseFileChecksum(extractDir, monitor);
- updateSrcUri(createMirrorLookupTable(monitor), srcURI);
- populateInheritance(extractDir, monitor);
-
- String md5Val = retrieveSum(md5YCmd);
- md5sumText.setText(Pattern.matches(md5Pattern, md5Val) ? md5Val : "");
- String sha256Val = retrieveSum(sha256YCmd);
- sha256sumText.setText(Pattern.matches(sha256Pattern, sha256Val) ? sha256Val : "");
- String checkSumVal = retrieveSum(licenseChecksumCmd);
- checksumText.setText(RemoteHelper.createNewURI(extractDir, COPYING_FILE).toString() + ";md5=" + (Pattern.matches(md5Pattern, checkSumVal) ? checkSumVal : ""));
}

private String retrieveSum(YoctoCommand cmd) {
@@ -384,31 +387,31 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
} else if(path.endsWith(TAR_GZ_EXT)){
tarCmd += "-xvf ";
}
-
- RemoteHelper.runCommandRemote(connection, new YoctoCommand(tarCmd + path, tempFolderPath, ""), monitor);
-
+
+ RemoteHelper.runCommandRemote(connection, new YoctoCommand(tarCmd + path, tempFolderPath, ""));
+
return RemoteHelper.createNewURI(metaDirLoc, TEMP_FOLDER_NAME + "/" + getSrcFileName(false));
-
+
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
-
+
private void updateTempFolderPath(){
this.tempFolderPath = getMetaFolderPath() + TEMP_FOLDER_NAME + "/";
}
-
+
private String getMetaFolderPath(){
String sep = metaDirLoc.getPath().endsWith("/")? "" : "/";
return metaDirLoc.getPath() + sep;
}
-
+
private void populateInheritance(URI extractDir, IProgressMonitor monitor) {
IHostFile[] hostFiles = RemoteHelper.getRemoteDirContent(connection, metaDirLoc.getPath(), "", IFileService.FILE_TYPE_FILES, monitor);
if (hostFiles == null)
return;
-
+
for (IHostFile file: hostFiles) {
String fileName = file.getName();
if (fileName.equalsIgnoreCase(CMAKE_LIST)){
@@ -420,21 +423,21 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}
}
}
-
+
private YoctoCommand populateLicenseFileChecksum(URI extractDir, IProgressMonitor monitor) {
if (extractDir == null)
throw new RuntimeException("Something went wrong during source extraction!");
-
+
try {
YoctoCommand catCmd = new YoctoCommand("md5sum " + COPYING_FILE, extractDir.getPath(), "");
- RemoteHelper.runCommandRemote(connection, catCmd, monitor);
+ RemoteHelper.runCommandRemote(connection, catCmd);
return catCmd;
} catch (Exception e) {
throw new RuntimeException("Unable to process file for MD5 calculation", e);
}
-
+
}
-
+
private String getSrcFileName(boolean withExt){
URI srcURI;
try {
@@ -455,48 +458,13 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}
return "";
}
-
-
-
-// private void populateSrcUriChecksum(URI srcUri, IProgressMonitor monitor) {
-// try {
-// String rmCmd = "rm -rf " + TEMP_FOLDER_NAME;
-// RemoteHelper.handleRunCommandRemote(connection, metaDirLoc.getPath(), rmCmd, "", monitor, cmdHandler);
-
-// String mkdirCmd = "mkdir " + TEMP_FOLDER_NAME;
-// updateTempFolderPath();
-// RemoteHelper.handleRunCommandRemote(connection, metaDirLoc.getPath(), mkdirCmd, "", monitor, cmdHandler);
-
-
-// String wgetCmd = "wget " + srcUri.toURL();
-// RemoteHelper.handleRunCommandRemote(connection, tempFolderPath, rmCmd + APPEND_CH + mkdirCmd + APPEND_CH + wgetCmd, "", monitor, cmdHandler);
-//
-// String md5Cmd = "md5sum " + getSrcFileName(true);
-// ProcessStreamBuffer md5SumBuffer = RemoteHelper.handleRunCommandRemote(connection, tempFolderPath, md5Cmd, "", monitor, cmdHandler);
-// String line = md5SumBuffer.getLastOutputLineContaining(getSrcFileName(true));
-// if (line != null) {
-// String[] md5SumTokens = line.split(WHITESPACES);
-// md5sumText.setText(md5SumTokens[0]);
-// }
-//
-// String sha256Cmd = "sha256sum " + getSrcFileName(true);
-// ProcessStreamBuffer sha256SumBuffer = RemoteHelper.handleRunCommandRemote(connection, tempFolderPath, sha256Cmd, "", monitor, cmdHandler);
-// line = sha256SumBuffer.getLastOutputLineContaining(getSrcFileName(true));
-// if (line != null) {
-// String[] sha256SumTokens = line.split(WHITESPACES);
-// sha256sumText.setText(sha256SumTokens[0]);
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-
+
private HashMap<String, String> createMirrorLookupTable(IProgressMonitor monitor) throws Exception {
HashMap<String, String> mirrorMap = new HashMap<String, String>();
-
+
YoctoCommand cmd = new YoctoCommand("cat " + MIRRORS_FILE, getMetaFolderPath() + CLASSES_FOLDER, "");
- RemoteHelper.runCommandRemote(connection, cmd, monitor);
-
+ RemoteHelper.runCommandRemote(connection, cmd);
+
if (!cmd.getProcessBuffer().hasErrors()){
String delims = "[\\t]+";
List<String> outputLines = cmd.getProcessBuffer().getOutputLines();
@@ -512,42 +480,42 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage {
}
return mirrorMap;
}
-
+
private void populateRecipeName(URI srcUri) {
String fileName = fileText.getText();
- if (!fileName.isEmpty())
+ if (!fileName.isEmpty())
return;
-
+
String recipeFile = getSrcFileName(false).replace("-", "_");
recipeFile += BB_RECIPE_EXT;
if (recipeFile != null)
fileText.setText(recipeFile);
}
-
+
private void updateSrcUri(HashMap<String, String> mirrorsMap, URI srcUri) {
Set<String> mirrors = mirrorsMap.keySet();
Iterator<String> iter = mirrors.iterator();
String mirror_key = null;
String srcURL = srcUri.toString();
-
- while (iter.hasNext()) {
- String value = (String)iter.next();
- if (srcURL.startsWith(value)) {
- mirror_key = value;
- break;
- }
- }
-
- if (mirror_key != null) {
- String replace_string = (String)mirrorsMap.get(mirror_key);
- if (replace_string != null)
- srcURL = replace_string + srcURL.substring(mirror_key.length());
- }
- int idx = srcURL.lastIndexOf("-");
- String new_src_uri = srcURL.substring(0, idx)+"-${PV}" + TAR_GZ_EXT;
- txtSrcURI.setText(new_src_uri);
+
+ while (iter.hasNext()) {
+ String value = iter.next();
+ if (srcURL.startsWith(value)) {
+ mirror_key = value;
+ break;
+ }
+ }
+
+ if (mirror_key != null) {
+ String replace_string = mirrorsMap.get(mirror_key);
+ if (replace_string != null)
+ srcURL = replace_string + srcURL.substring(mirror_key.length());
+ }
+ int idx = srcURL.lastIndexOf("-");
+ String new_src_uri = srcURL.substring(0, idx)+"-${PV}" + TAR_GZ_EXT;
+ txtSrcURI.setText(new_src_uri);
}
-
+
private void initialize() {
if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) selection;
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
index d780cbf..77f4d2c 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java
@@ -5,16 +5,13 @@ import java.net.URI;
import java.util.Hashtable;
import java.util.Map;

-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ptp.remote.core.IRemoteConnection;
import org.eclipse.ptp.remote.core.IRemoteServices;
-import org.eclipse.ptp.remote.core.exception.RemoteConnectionException;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
@@ -22,7 +19,7 @@ import org.eclipse.ui.console.MessageConsole;
import org.yocto.bc.remote.utils.CommandResponseHandler;
import org.yocto.bc.remote.utils.ConsoleWriter;
import org.yocto.bc.remote.utils.RemoteHelper;
-import org.yocto.bc.remote.utils.YoctoCommand;
+import org.yocto.bc.remote.utils.YoctoRunnableWithProgress;
import org.yocto.bc.ui.Activator;
import org.yocto.bc.ui.model.ProjectInfo;
import org.yocto.bc.ui.wizards.FiniteStateWizard;
@@ -106,24 +103,35 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard
page.setPageComplete(true);
Map<String, Object> options = model;

-
try {
URI uri = new URI("");
if (options.containsKey(INSTALL_DIRECTORY)) {
uri = (URI) options.get(INSTALL_DIRECTORY);
}
+ IRemoteConnection remoteConnection = ((IRemoteConnection)model.get(InstallWizard.SELECTED_CONNECTION));
+ IRemoteServices remoteServices = ((IRemoteServices)model.get(InstallWizard.SELECTED_REMOTE_SERVICE));
+ IHost connection = RemoteHelper.getRemoteConnectionByName(remoteConnection.getName());
+ CommandResponseHandler cmdHandler = RemoteHelper.getCommandHandler(connection);

if (((Boolean)options.get(GIT_CLONE)).booleanValue()) {
- String[] cmd = {"/usr/bin/git clone --progress", "git://git.yoctoproject.org/poky.git", uri.getPath()};
-// String[] cmd = {"md5sum /home/builder/socks-gw"};
- LongtimeRunningTask runningTask = new LongtimeRunningTask("Checking out Yocto git repository", cmd,
- ((IRemoteConnection)model.get(InstallWizard.SELECTED_CONNECTION)),
- ((IRemoteServices)model.get(InstallWizard.SELECTED_REMOTE_SERVICE)));
- ModalContext.setAllowReadAndDispatch(false);
- this.getContainer().run(false, false, runningTask);
+ String cmd = "/usr/bin/git clone --progress";
+ String args = "git://git.yoctoproject.org/poky.git " + uri.getPath();
+ String taskName = "Checking out Yocto git repository";
+ YoctoRunnableWithProgress adapter = (YoctoRunnableWithProgress)RemoteHelper.getHostShellProcessAdapter(connection);
+ adapter.setRemoteConnection(remoteConnection);
+ adapter.setRemoteServices(remoteServices);
+ adapter.setTaskName(taskName);
+ adapter.setCmd(cmd);
+ adapter.setArgs(args);
+ IWizardContainer container = this.getContainer();
+ try {
+ container.run(true, true, adapter);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
-
- CommandResponseHandler cmdHandler = RemoteHelper.getCommandHandler(RemoteHelper.getRemoteConnectionByName(((IRemoteConnection)model.get(InstallWizard.SELECTED_CONNECTION)).getName()));
if (!cmdHandler.hasError()) {
String initPath = "";
if (uri.getPath() != null) {
@@ -136,28 +144,25 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard
pinfo.setInitScriptPath(initPath);
pinfo.setLocation(uri);
pinfo.setName(prjName);
- IRemoteConnection remConn = (IRemoteConnection) model.get(InstallWizard.SELECTED_CONNECTION);
- IHost connection = RemoteHelper.getRemoteConnectionByName(remConn.getName());
pinfo.setConnection(connection);
- pinfo.setRemoteServices((IRemoteServices) model.get(InstallWizard.SELECTED_REMOTE_SERVICE));
+ pinfo.setRemoteServices(remoteServices);

ConsoleWriter cw = new ConsoleWriter();
- this.getContainer().run(false, false, new BBConfigurationInitializeOperation(pinfo, cw));
+ this.getContainer().run(true, true, new BBConfigurationInitializeOperation(pinfo, cw));
console = RemoteHelper.getConsole(connection);
console.newMessageStream().println(cw.getContents());

model.put(InstallWizard.KEY_PINFO, pinfo);
Activator.putProjInfo(pinfo.getURI(), pinfo);

- this.getContainer().run(false, false, new CreateBBCProjectOperation(pinfo));
+ this.getContainer().run(true, true, new CreateBBCProjectOperation(pinfo));
return true;
-
}
+ return true;
} catch (Exception e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
IStatus.ERROR, e.getMessage(), e));
- this.getContainer().getCurrentPage().setDescription(
- "Failed to create project: " + e.getMessage());
+ this.getContainer().getCurrentPage().setDescription("Failed to create project: " + e.getMessage());
}
return false;
}
@@ -165,66 +170,4 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard
public void init(IWorkbench workbench, IStructuredSelection selection) {
}

- private class LongtimeRunningTask implements IRunnableWithProgress {
- static public final int TOTALWORKLOAD = 100;
-
- private String []cmdArray;
- private String taskName;
- private IRemoteConnection connection;
- private IRemoteServices remoteServices;
-
- public LongtimeRunningTask(String taskName,
- String []cmdArray,
- IRemoteConnection connection, IRemoteServices remoteServices) {
- this.taskName = taskName;
- this.cmdArray = cmdArray;
- this.connection = connection;
- this.remoteServices = remoteServices;
- }
-
- synchronized public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
-// boolean cancel = false;
- try {
- monitor.beginTask(taskName, TOTALWORKLOAD);
-
- if (!connection.isOpen()) {
- try {
- connection.open(monitor);
- } catch (RemoteConnectionException e1) {
- e1.printStackTrace();
- }
- }
-
- if (!remoteServices.isInitialized()) {
- remoteServices.initialize();
- }
-
- String args = "";
- for (int i = 1; i < cmdArray.length; i++)
- args += cmdArray[i] + " ";
- try {
-// while (!cancel) {
-// if(monitor.isCanceled()) {
-// cancel=true;
-// throw new InterruptedException("User Cancelled");
-// }
- RemoteHelper.runCommandRemote(RemoteHelper.getRemoteConnectionByName(connection.getName()), new YoctoCommand(cmdArray[0], "", args), monitor);
-// if (hasErrors)
-// break;
-
-// Thread.sleep(5000);
-// }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- monitor.done();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
-
}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
index e5ebd1b..fcc939c 100644
--- a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -63,12 +63,7 @@ public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInformation) throws CoreException {
IProjectDescription desc = workspace.newProjectDescription(projInformation.getProjectName());

-// try {
-// desc.setLocationURI(new URI(OEFS_SCHEME + projInfo2.getRootPath()));
- desc.setLocationURI(projInformation.getURI());
-// } catch (URISyntaxException e) {
-// throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to load filesystem.", e));
-// }
+ desc.setLocationURI(projInformation.getURI());

return desc;
}
--
1.7.9.5


[PATCH 8/8] plugins/sdk.ide: Open project properties instead of standalone yocto settings dialog

mail@...
 

From: Timo Mueller <timo.mueller@bmw-carit.de>

As the yocto settings can now be set via the project's property pages,
the "Change Yocto Project Settings" will now open the property page
instead of showing the a standalone dialog.
---
.../yocto/sdk/ide/actions/ReconfigYoctoAction.java | 29 ++----
.../yocto/sdk/ide/actions/SDKLocationDialog.java | 89 --------------------
2 files changed, 10 insertions(+), 108 deletions(-)
delete mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/SDKLocationDialog.java

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
index d7021be..e255fd1 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
@@ -14,16 +14,13 @@ import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
-import org.eclipse.swt.widgets.Shell;
-import org.yocto.sdk.ide.YoctoSDKMessages;
-import org.yocto.sdk.ide.YoctoSDKUtils;
-import org.yocto.sdk.ide.YoctoUIElement;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.yocto.sdk.ide.YoctoSDKPlugin;


@SuppressWarnings("restriction")
public class ReconfigYoctoAction extends InvokeAction {
- private static final String DIALOG_TITLE = "Menu.SDK.Dialog.Title";
-

public void run(IAction action) {
IContainer container = getSelectedContainer();
@@ -32,19 +29,13 @@ public class ReconfigYoctoAction extends InvokeAction {

IProject project = container.getProject();

- //Try to get the per project configuration first
- YoctoUIElement elem = YoctoSDKUtils.getElemFromProjectEnv(project);
- if (elem.getStrToolChainRoot().isEmpty()|| elem.getStrTarget().isEmpty()){
- // No project environment has been set yet, use the Preference values
- elem = YoctoSDKUtils.getElemFromStore();
- }
-
- SDKLocationDialog optionDialog = new SDKLocationDialog(new Shell(), YoctoSDKMessages.getString(DIALOG_TITLE), elem);
- optionDialog.open();
- elem = optionDialog.getElem();
- if (elem.getStrToolChainRoot() != null) {
- YoctoSDKUtils.saveElemToProjectEnv(project, elem);
- }
+ PreferenceDialog dialog =
+ PreferencesUtil.createPropertyDialogOn(YoctoSDKPlugin.getActiveWorkbenchShell(),
+ project,
+ "org.yocto.sdk.ide.page",
+ null,
+ null);
+ dialog.open();
}

public void dispose() {
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/SDKLocationDialog.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/SDKLocationDialog.java
deleted file mode 100644
index 439d720..0000000
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/SDKLocationDialog.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Intel - initial API and implementation
- *******************************************************************************/
-package org.yocto.sdk.ide.actions;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.yocto.sdk.ide.YoctoGeneralException;
-import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom;
-import org.yocto.sdk.ide.YoctoUIElement;
-import org.yocto.sdk.ide.YoctoUISetting;
-
-public class SDKLocationDialog extends Dialog {
- private String title;
- private YoctoUISetting yoctoUISetting;
- private YoctoUIElement elem;
-
- public SDKLocationDialog(Shell parentShell, String dialogTitle, YoctoUIElement elem) {
- super(parentShell);
- this.setElem(elem);
- this.yoctoUISetting = new YoctoUISetting(elem);
- this.title = dialogTitle;
- setShellStyle(getShellStyle() | SWT.RESIZE);
-
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- final Composite result = (Composite) super.createDialogArea(parent);
-
- try {
- yoctoUISetting.createComposite(result);
- yoctoUISetting.validateInput(SDKCheckRequestFrom.Menu, false);
- } catch (YoctoGeneralException e) {
- // TODO Auto-generated catch block
- System.out.println("Have you ever set the project specific Yocto Settings?");
- System.out.println(e.getMessage());
- }
-
- return result;
- }
-
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(title);
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- //this should not be called in fact, because widget change should be called firstly!
- try {
- yoctoUISetting.validateInput(SDKCheckRequestFrom.Menu, true);
- this.setElem(yoctoUISetting.getCurrentInput());
- super.buttonPressed(buttonId);
- } catch (YoctoGeneralException e) {
- // TODO Auto-generated catch block
- System.out.println(e.getMessage());
- }
- }
- else if (buttonId == IDialogConstants.CANCEL_ID)
- {
- super.buttonPressed(buttonId);
- }
- }
-
- public void setElem(YoctoUIElement elem) {
- this.elem = elem;
- }
-
- public YoctoUIElement getElem() {
- return elem;
- }
-
-}
--
1.7.7.6


[PATCH 7/8] plugins/sdk.ide: Show yocto ui setting widget in project property page

mail@...
 

From: Timo Mueller <timo.mueller@bmw-carit.de>

The yocto property page in a project's properties dialog will now show
the yocto settings that are also used in the global yocto preferences
dialog. On save the defined values will be stored to the project's
environment.
---
.../preferences/YoctoSDKProjectPropertyPage.java | 88 +++++++++++++++++++-
1 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
index 265c8dc..92d476a 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright (c) 2012 BMW Car IT GmbH.
+ * Copyright (c) 2010 Intel.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,23 +8,104 @@
*
* Contributors:
* BMW Car IT GmbH - initial implementation
+ * Intel - initial API implementation (copied from YoctoSDKPreferencePage)
*******************************************************************************/
package org.yocto.sdk.ide.preferences;

+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PropertyPage;
+import org.yocto.sdk.ide.YoctoGeneralException;
+import org.yocto.sdk.ide.YoctoSDKUtils;
+import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom;
+import org.yocto.sdk.ide.YoctoUIElement;
+import org.yocto.sdk.ide.YoctoUISetting;

public class YoctoSDKProjectPropertyPage extends PropertyPage implements
IWorkbenchPropertyPage {

- public YoctoSDKProjectPropertyPage() {
- }
+ private YoctoUISetting yoctoUISetting;
+ private IProject project = null;

@Override
protected Control createContents(Composite parent) {
- return null;
+ YoctoUIElement uiElement = loadUIElement();
+ this.yoctoUISetting = new YoctoUISetting(uiElement);
+
+ initializeDialogUnits(parent);
+ final Composite result = new Composite(parent, SWT.NONE);
+
+ try {
+ yoctoUISetting.createComposite(result);
+ yoctoUISetting
+ .validateInput(SDKCheckRequestFrom.Preferences, false);
+ Dialog.applyDialogFont(result);
+ return result;
+ } catch (YoctoGeneralException e) {
+ System.out.println("Have you ever set Yocto Project Reference before?");
+ System.out.println(e.getMessage());
+ return result;
+ }
+ }
+
+ private IProject getProject() {
+ if (project != null) {
+ return project;
+ }
+
+ IAdaptable adaptable = getElement();
+ if (adaptable == null) {
+ throw new IllegalStateException("Project can only be retrieved after properties page has been set up.");
+ }
+
+ project = (IProject) adaptable.getAdapter(IProject.class);
+ return project;
+ }
+
+ private YoctoUIElement loadUIElement() {
+ YoctoUIElement uiElement = YoctoSDKUtils.getElemFromProjectEnv(getProject());
+
+ if (uiElement.getStrToolChainRoot().isEmpty()
+ || uiElement.getStrTarget().isEmpty()) {
+ // No project environment has been set yet, use the Preference
+ // values
+ uiElement = YoctoSDKUtils.getElemFromStore();
+ }
+
+ return uiElement;
+ }
+
+ /*
+ * @see PreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromStore();
+ yoctoUISetting.setCurrentInput(defaultElement);
+ super.performDefaults();
}

+ /*
+ * @see IPreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ try {
+ yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, true);
+
+ YoctoUIElement elem = yoctoUISetting.getCurrentInput();
+ YoctoSDKUtils.saveElemToProjectEnv(getProject(), elem);
+
+ return super.performOk();
+ } catch (YoctoGeneralException e) {
+ // TODO Auto-generated catch block
+ System.out.println(e.getMessage());
+ return false;
+ }
+ }
}
--
1.7.7.6


[PATCH 6/8] plugins/sdk.ide: Move modification of yocto project settings to utils class

mail@...
 

From: Timo Mueller <timo.mueller@bmw-carit.de>

Saving yocto project settings is currently only used by the "Change
Yocto Project Settings" command. To allow other UI elements
(e.g. project property pages) to modify the yocto settings of a
project the functionality has been extraced to a separate method and
moved to the utils class.
---
.../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 42 ++++++++++++++++++++
.../yocto/sdk/ide/actions/ReconfigYoctoAction.java | 41 ++-----------------
2 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
index 16035fd..7ea4262 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
@@ -22,10 +22,12 @@ import java.util.HashMap;
import java.util.Iterator;

import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.envvar.IContributedEnvironment;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.core.resources.IProject;
@@ -75,6 +77,7 @@ public class YoctoSDKUtils {
private static final String DEFAULT_SYSROOT_PREFIX = "--sysroot=";
private static final String LIBTOOL_SYSROOT_PREFIX = "--with-libtool-sysroot=";
private static final String SYSROOTS_DIR = "sysroots";
+ private static final String CONSOLE_MESSAGE = "Menu.SDK.Console.Configure.Message";

public static SDKCheckResults checkYoctoSDK(YoctoUIElement elem) {

@@ -418,6 +421,45 @@ public class YoctoSDKUtils {
elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
return elem;
}
+
+ /* Save YoctoUIElement to project settings */
+ public static void saveElemToProjectEnv(IProject project, YoctoUIElement elem)
+ {
+ ConsoleOutputStream consoleOutStream = null;
+
+ try {
+ YoctoSDKProjectNature.setEnvironmentVariables(project, elem);
+ YoctoSDKProjectNature.configureAutotoolsOptions(project);
+ IConsole console = CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole");
+ console.start(project);
+ consoleOutStream = console.getOutputStream();
+ String messages = YoctoSDKMessages.getString(CONSOLE_MESSAGE);
+ consoleOutStream.write(messages.getBytes());
+ }
+ catch (CoreException e)
+ {
+ System.out.println(e.getMessage());
+ }
+ catch (IOException e)
+ {
+ System.out.println(e.getMessage());
+ }
+ catch (YoctoGeneralException e)
+ {
+ System.out.println(e.getMessage());
+ }
+ finally {
+ if (consoleOutStream != null) {
+ try {
+ consoleOutStream.flush();
+ consoleOutStream.close();
+ }
+ catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }

/* Load IDE wide POKY Preference settings into Preference Store */
public static void saveElemToStore(YoctoUIElement elem)
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
index f68b552..d7021be 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/ReconfigYoctoAction.java
@@ -10,29 +10,19 @@
*******************************************************************************/
package org.yocto.sdk.ide.actions;

-import java.io.IOException;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
-import org.eclipse.cdt.internal.autotools.ui.actions.InvokeAction;
import org.eclipse.swt.widgets.Shell;
-
-import org.yocto.sdk.ide.YoctoGeneralException;
-import org.yocto.sdk.ide.YoctoSDKUtils;
import org.yocto.sdk.ide.YoctoSDKMessages;
-import org.yocto.sdk.ide.YoctoSDKProjectNature;
+import org.yocto.sdk.ide.YoctoSDKUtils;
import org.yocto.sdk.ide.YoctoUIElement;


@SuppressWarnings("restriction")
public class ReconfigYoctoAction extends InvokeAction {
private static final String DIALOG_TITLE = "Menu.SDK.Dialog.Title";
- private static final String CONSOLE_MESSAGE = "Menu.SDK.Console.Configure.Message";


public void run(IAction action) {
@@ -52,31 +42,8 @@ public class ReconfigYoctoAction extends InvokeAction {
SDKLocationDialog optionDialog = new SDKLocationDialog(new Shell(), YoctoSDKMessages.getString(DIALOG_TITLE), elem);
optionDialog.open();
elem = optionDialog.getElem();
- if (elem.getStrToolChainRoot() != null) {
- try {
- YoctoSDKProjectNature.setEnvironmentVariables(project, elem);
- YoctoSDKProjectNature.configureAutotoolsOptions(project);
- IConsole console = CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole");
- console.start(project);
- ConsoleOutputStream consoleOutStream;
- consoleOutStream = console.getOutputStream();
- String messages = YoctoSDKMessages.getString(CONSOLE_MESSAGE);
- consoleOutStream.write(messages.getBytes());
- consoleOutStream.flush();
- consoleOutStream.close();
- }
- catch (CoreException e)
- {
- System.out.println(e.getMessage());
- }
- catch (IOException e)
- {
- System.out.println(e.getMessage());
- }
- catch (YoctoGeneralException e)
- {
- System.out.println(e.getMessage());
- }
+ if (elem.getStrToolChainRoot() != null) {
+ YoctoSDKUtils.saveElemToProjectEnv(project, elem);
}
}

--
1.7.7.6


[PATCH 5/8] plugins/sdk.ide: Added empty yocto preference page to project properties

mail@...
 

From: Timo Mueller <timo.mueller@bmw-carit.de>

Adds an empty preference page to projects with the YoctoSDKNature. This
preference page is shown in the standard project properties dialog and
will later allow modifying the yocto settings of the project.
---
.../OSGI-INF/l10n/bundle.properties | 1 +
plugins/org.yocto.sdk.ide/plugin.xml | 14 +++++++++
.../preferences/YoctoSDKProjectPropertyPage.java | 29 ++++++++++++++++++++
3 files changed, 44 insertions(+), 0 deletions(-)
create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java

diff --git a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
index d0bf9b7..a7172be 100644
--- a/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties
@@ -5,5 +5,6 @@ command.name = ReconfigureYoctoProject
command.label.0 = Change Yocto Project Settings
command.mnemonic = C
projectType.name.0 = Yocto Project ADT Project
+projectProperties.label.0 = Yocto Project Settings
Bundle-Vendor = yoctoproject.org
Bundle-Name = Yocto Plugin IDE
diff --git a/plugins/org.yocto.sdk.ide/plugin.xml b/plugins/org.yocto.sdk.ide/plugin.xml
index c540b9b..6548ae2 100644
--- a/plugins/org.yocto.sdk.ide/plugin.xml
+++ b/plugins/org.yocto.sdk.ide/plugin.xml
@@ -180,5 +180,19 @@
id="org.yocto.sdk.ide.YoctoConsole">
</CBuildConsole>
</extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ adaptable="true"
+ class="org.yocto.sdk.ide.preferences.YoctoSDKProjectPropertyPage"
+ id="org.yocto.sdk.ide.page"
+ name="%projectProperties.label.0"
+ objectClass="org.eclipse.core.resources.IProject">
+ <filter
+ name="projectNature"
+ value="org.yocto.sdk.ide.YoctoSDKNature">
+ </filter>
+ </page>
+ </extension>

</plugin>
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
new file mode 100644
index 0000000..265c8dc
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BMW Car IT GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BMW Car IT GmbH - initial implementation
+ *******************************************************************************/
+package org.yocto.sdk.ide.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class YoctoSDKProjectPropertyPage extends PropertyPage implements
+ IWorkbenchPropertyPage {
+
+ public YoctoSDKProjectPropertyPage() {
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ return null;
+ }
+
+}
--
1.7.7.6


[PATCH 4/8] plugins/sdk.ide: Remove fControl array that is no longer needed

mail@...
 

From: Atanas Gegov <atanas.gegov@bmw-carit.de>

The setCurrentInput method replaces the functionality that was
provided by the fControl array.
---
.../src/org/yocto/sdk/ide/YoctoUISetting.java | 14 --------------
1 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
index 53af8f0..0fbfde0 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
@@ -43,7 +43,6 @@ import org.yocto.sdk.ide.preferences.PreferenceConstants;
public class YoctoUISetting {

private static final String ENV_SCRIPT_FILE_PREFIX = "environment-setup-";
- private ArrayList<Control> fControls;

private SelectionListener fSelectionListener;
private ModifyListener fModifyListener;
@@ -66,7 +65,6 @@ public class YoctoUISetting {

public YoctoUISetting(YoctoUIElement elem)
{
- fControls = new ArrayList<Control>();
yoctoUIElement = elem;
elem.setStrTargetsArray(getTargetArray(elem));

@@ -88,11 +86,8 @@ public class YoctoUISetting {

private Control addControls(Control fControl, final String sKey, String sValue)
{
-
fControl.setData(new String[]{sKey,sValue});
- fControls.add(fControl);
return fControl;
-
}

private Control addRadioButton(Composite parent, String label, String key, boolean bSelected) {
@@ -375,15 +370,6 @@ public class YoctoUISetting {
return pass;
}

-
- public void setfControls(ArrayList<Control> fControls) {
- this.fControls = fControls;
- }
-
- public ArrayList<Control> getfControls() {
- return fControls;
- }
-
private void updateQemuControlState()
{
boolean bQemuMode = btnQemu.getSelection();
--
1.7.7.6


[PATCH 3/8] plugins/sdk.ide: Use new setCurrentInput method to set defaults

mail@...
 

From: Atanas Gegov <atanas.gegov@bmw-carit.de>

Removes the error prone method of using the fControls array and uses
the new YoctoUIElement interface.

Improved method of setting default preferences (globally)
---
.../ide/preferences/YoctoSDKPreferencePage.java | 51 +------------------
1 files changed, 3 insertions(+), 48 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
index b75bdc1..d1c1a72 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java
@@ -89,58 +89,13 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench
return false;
}
}
-
+
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
- IPreferenceStore store= getPreferenceStore();
- ArrayList<Control> arrControls = this.yoctoUISetting.getfControls();
-
- for (int i = 0; i < arrControls.size(); i++)
- {
- Control control = arrControls.get(i);
- String[] controlData = (String[])control.getData();
- String sKey = controlData[0];
- if (control instanceof Button)
- {
- sKey = sKey.substring(0, sKey.lastIndexOf("_"));
- }
- String sValue = store.getDefaultString(sKey);
- if (control instanceof Button)
- {
- if (sValue.equalsIgnoreCase("true"))
- {
- if (controlData[0].endsWith("_1")) //the 1st radio button of the group
- ((Button)control).setSelection(true);
- else
- ((Button)control).setSelection(false);//the 2nd radio button of the group
- }
- else
- {
- if (controlData[0].endsWith("_1")) //the 1st radio button of the group
- ((Button)control).setSelection(false);
- else
- ((Button)control).setSelection(true);//the 2nd radio button of the group
- }
- }
- else if (control instanceof Text)
- {
- ((Text)control).setText(sValue);
- }
- else if (control instanceof Combo)
- {
- if (!sValue.isEmpty())
- ((Combo)control).select(Integer.valueOf(sValue).intValue());
- }
- }
-
- try {
- yoctoUISetting.validateInput(SDKCheckRequestFrom.Preferences, false);
- } catch (YoctoGeneralException e) {
- System.out.println("Have you ever set Yocto Project Reference before?");
- System.out.println(e.getMessage());
- }
+ YoctoUIElement defaultElement = YoctoSDKUtils.getDefaultElemFromStore();
+ yoctoUISetting.setCurrentInput(defaultElement);
super.performDefaults();
}

--
1.7.7.6


[PATCH 2/8] plugins/sdk.ide: Create a default YoctoUIElement from the preference store

mail@...
 

From: Atanas Gegov <atanas.gegov@bmw-carit.de>

Adds a method to create a YoctoUIElement that contains the content of
the yocto settings stored in the plugin's default preference store.
---
.../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 25 ++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
index 749fac7..16035fd 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java
@@ -465,6 +465,31 @@ public class YoctoSDKUtils {
return elem;
}

+ /* Load default IDE wide POKY Preference settings into YoctoUIElement */
+ public static YoctoUIElement getDefaultElemFromStore()
+ {
+ IPreferenceStore store = YoctoSDKPlugin.getDefault().getPreferenceStore();
+ YoctoUIElement elem = new YoctoUIElement();
+ if (store.getDefaultString(PreferenceConstants.SDK_MODE).equals(IPreferenceStore.TRUE))
+ elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
+ else
+ elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
+
+ elem.setStrToolChainRoot(store.getDefaultString(PreferenceConstants.TOOLCHAIN_ROOT));
+ elem.setStrTarget(store.getDefaultString(PreferenceConstants.TOOLCHAIN_TRIPLET));
+ elem.setIntTargetIndex(store.getDefaultInt(PreferenceConstants.TARGET_ARCH_INDEX));
+ elem.setStrQemuKernelLoc(store.getDefaultString(PreferenceConstants.QEMU_KERNEL));
+ elem.setStrQemuOption(store.getDefaultString(PreferenceConstants.QEMU_OPTION));
+ elem.setStrSysrootLoc(store.getDefaultString(PreferenceConstants.SYSROOT));
+
+ if (store.getDefaultString(PreferenceConstants.TARGET_MODE).equals(IPreferenceStore.TRUE))
+ elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
+ else
+ elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
+
+ return elem;
+ }
+
public static String qemuTargetTranslate(String strTargetArch)
{
String qemu_target = "";
--
1.7.7.6


[PATCH 1/8] plugins/sdk.ide: Allow using a YoctoUIElement to set the input of a yocto settings widget

mail@...
 

From: Atanas Gegov <atanas.gegov@bmw-carit.de>

Currently a YoctoUIElement is used to create a YoctoUISetting
widget. It is also possible to retrieve a YoctoUIElement containing
the current input of the widget. This patch adds the capability to
also set the input of the widget using a YoctoUIElement. Instead of
using the fControl array clients can now use this method to set the
input of the widget.
---
.../src/org/yocto/sdk/ide/YoctoUISetting.java | 40 ++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
index b4625f6..53af8f0 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java
@@ -307,6 +307,46 @@ public class YoctoUISetting {
return elem;
}

+ public void setCurrentInput(YoctoUIElement elem){
+ btnSDKRoot.setSelection(false);
+ btnPokyRoot.setSelection(false);
+ if(elem.getEnumPokyMode().equals(YoctoUIElement.PokyMode.POKY_SDK_MODE)){
+ btnSDKRoot.setSelection(true);
+ }
+ else if(elem.getEnumPokyMode().equals(YoctoUIElement.PokyMode.POKY_TREE_MODE)){
+ btnPokyRoot.setSelection(true);
+ }
+
+ btnQemu.setSelection(false);
+ btnDevice.setSelection(false);
+ if(elem.getEnumDeviceMode().equals(YoctoUIElement.DeviceMode.QEMU_MODE)){
+ btnQemu.setSelection(true);
+ }
+ else if(elem.getEnumDeviceMode().equals(YoctoUIElement.DeviceMode.DEVICE_MODE)){
+ btnDevice.setSelection(true);
+ }
+
+ textRootLoc.setText(elem.getStrToolChainRoot());
+ targetArchCombo.select(elem.getIntTargetIndex());
+ if(elem.getStrTargetsArray() == null){
+ targetArchCombo.setItems(new String[]{});
+ }
+ else {
+ targetArchCombo.setItems(elem.getStrTargetsArray());
+ }
+ targetArchCombo.setText(elem.getStrTarget());
+ textKernelLoc.setText(elem.getStrQemuKernelLoc());
+ textQemuOption.setText(elem.getStrQemuOption());
+ textSysrootLoc.setText(elem.getStrSysrootLoc());
+
+ try {
+ validateInput(SDKCheckRequestFrom.Preferences, false);
+ } catch (YoctoGeneralException e) {
+ System.out.println("Have you ever set Yocto Project Reference before?");
+ System.out.println(e.getMessage());
+ }
+ }
+
public boolean validateInput(SDKCheckRequestFrom from, boolean bPrompt) throws YoctoGeneralException {
YoctoUIElement elem = getCurrentInput();
boolean pass = true;
--
1.7.7.6


[PATCH 0/8][eclipse-poky] Enable setting yocto settings in the project properties dialog

mail@...
 

From: Timo Mueller <timo.mueller@bmw-carit.de>

Hi,

changing the yocto settings of a project is currently achieved through
a separate dialog. This dialog can be opened via the eclipse menu bar
(project -> change yocto project settings). Typically all project
related settings in eclipse are located in the project properties
dialog.

This patch series adds yocto settings to the project properties
dialog. It also removes the separate dialog. Instead the yocto section
in the project properties is opened if "change yocto project settings"
is selected from the menu bar.

Best regards,
Atanas and Timo

Atanas Gegov (4):
plugins/sdk.ide: Allow using a YoctoUIElement to set the input of a
yocto settings widget
plugins/sdk.ide: Create a default YoctoUIElement from the preference
store
plugins/sdk.ide: Use new setCurrentInput method to set defaults
plugins/sdk.ide: Remove fControl array that is no longer needed

Timo Mueller (4):
plugins/sdk.ide: Added empty yocto preference page to project
properties
plugins/sdk.ide: Move modification of yocto project settings to utils
class
plugins/sdk.ide: Show yocto ui setting widget in project property
page
plugins/sdk.ide: Open project properties instead of standalone yocto
settings dialog

.../OSGI-INF/l10n/bundle.properties | 1 +
plugins/org.yocto.sdk.ide/plugin.xml | 14 +++
.../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 67 ++++++++++++
.../src/org/yocto/sdk/ide/YoctoUISetting.java | 54 +++++++---
.../yocto/sdk/ide/actions/ReconfigYoctoAction.java | 64 ++---------
.../yocto/sdk/ide/actions/SDKLocationDialog.java | 89 ----------------
.../ide/preferences/YoctoSDKPreferencePage.java | 51 +---------
.../preferences/YoctoSDKProjectPropertyPage.java | 111 ++++++++++++++++++++
8 files changed, 247 insertions(+), 204 deletions(-)
delete mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/actions/SDKLocationDialog.java
create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java

--
1.7.7.6


ghostscript running error on powerpc

Jia Hongtao-B38951 <B38951@...>
 

Hi Kai,

 

I got some running errors using ghostscript built by yocto on powerpc.

Note that this log is for ghostscript 9.04 and the current version on yocto

is 9.05 which has the same issue as 9.04.

 

Here is the log:

 

root@p1022ds:/usr/tmp/lm90plots# ps2pdf temps.ps temps.pdf

 

*** Warning: GenericResourceDir doesn't point to a valid resource directory.

               the -sGenericResourceDir=... option can be used to set this.

 

Error: /invalidaccess in /findfont

Operand stack:

   Helvetica

Execution stack:

   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861   1   3   %oparray_pop   --nostringval--   1845   1   3   %oparray_pop   1739   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1820   1   4   %oparray_pop

Dictionary stack:

   --dict:1154/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--   --dict:182/256(L)--

Current allocation mode is local

Last OS error: 2

Current file position is 16962

GPL Ghostscript 9.04: Unrecoverable error, exit code 1

 

 

I did some investigations on google but got nothing helpful.

So I wonder if you could help me to find out the reason?

I hope I'm not interrupting and looking forward to your message.

 

Thanks.

 

 

---

Best Regards,

Hongtao

 


Difference of toolchain recipes

Luo Zhenhua-B19537 <B19537@...>
 

It is a bit confused for the different recipes of toolchian, can somebody help to explain what's the difference for those recipes? E.g. gcc-cross, gcc-cross-canadian, gcc-cross-initial, gcc-cross-intermediate, gcc-crosssdk, gcc-crosssdk-initial, gcc-crosssdk-intermediate, gcc-runtime, etc.

Is there any document for those description?


Best Regards,

Zhenhua


Re: chris larson's cool "bitbake-env" utility

Tim Bird <tim.bird@...>
 

On 11/30/2012 05:53 AM, Robert P. J. Day wrote:
On Thu, 29 Nov 2012, Tim Bird wrote:

I put a link to your page on my bitbake cheat sheet page at:
http://elinux.org/Bitbake_Cheat_Sheet
as someone who has never bothered to play with any of the UIs and is
thus asking from a position of total ignorance, i have a couple
questions about the "User interfaces" section of that cheat sheet.

using stock oe-core, i followed your cheat sheet and tried this:

$ bitbake

and got:

ERROR: Timeout while attempting to communicate with bitbake server

so i need to start the server? should that be mentioned there?
Hmmm. With bitbake from poky-1.2-denzil I get:
"Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."

I think that "bitbake <nothing>" is not really a valid invocation.
I've changed the page accordingly.

i then tried:

$ bitbake -u knotty2
FATAL: Invalid user interface 'knotty2' specified.
Valid interfaces: depexp, goggle, ncurses, hob, knotty [default].
$
It looks like knotty2 was an experimental interface, with features
now folded into knotty in poky-1.3-danny.

I removed it from the page.

just pointing out that if i follow that cheat sheet to the letter, i
run into problems.
Thanks very much for trying things out and reporting the problems.

I've altered the page to hopefully address the issues.

Maybe I should mention that I'm using the bitbake from the yocto project?
I didn't think they were diverged very far.
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Workgroup of the Linux Foundation
Senior Staff Engineer, Sony Network Entertainment
=============================


[meta-baryon][PATCH 1/1] proftpd: conditionally remove /usr/libexec

Kevin Strasser <kevin.strasser@...>
 

As of poky commit id 1d18224b24a515a07170ce36dbd725cb203d3300
libexecdir has been changed to ${libdir}/${BPN} which is typically
/usr/lib. This change introduces a check to see if /usr/libexec is
being used before attempting to remove it.

Fixes [YOCTO #3504]

Signed-off-by: Kevin Strasser <kevin.strasser@linux.intel.com>
---
recipes-extended/proftpd/proftpd_1.3.4b.bb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/recipes-extended/proftpd/proftpd_1.3.4b.bb b/recipes-extended/proftpd/proftpd_1.3.4b.bb
index 8ebafbf..2b2b4e2 100644
--- a/recipes-extended/proftpd/proftpd_1.3.4b.bb
+++ b/recipes-extended/proftpd/proftpd_1.3.4b.bb
@@ -34,7 +34,10 @@ FTPGROUP = "ftp"

do_install () {
oe_runmake DESTDIR=${D} install
- rmdir ${D}${libexecdir} ${D}${libdir}/proftpd ${D}${datadir}/locale
+ rmdir ${D}${libdir}/proftpd ${D}${datadir}/locale
+ if [ -d ${D}/usr/libexec ] ; then
+ rmdir ${D}/usr/libexec
+ fi
sed -i '/ *User[ \t]*/s/ftp/${FTPUSER}/' ${D}${sysconfdir}/proftpd.conf
sed -i '/ *Group[ \t]*/s/ftp/${FTPGROUP}/' ${D}${sysconfdir}/proftpd.conf
install -d ${D}${sysconfdir}/init.d
--
1.7.9.5


[meta-baryon][PATCH 0/1] proftpd fix

Kevin Strasser <kevin.strasser@...>
 

This change fixes a breakage introduced when the value of libexecdir was
changed to "${libdir}/${BPN}".

The proftpd recipe in meta-networking will likely need a similar patch.

The following changes since commit ad1dfa139195f39a72b8e0fb47de5c3339397b8b:

proftpd: add initscript and tidy up recipe (2012-10-28 01:47:32 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib strassek/baryon-proftpd
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=strassek/poky-contrib

Kevin Strasser (1):
proftpd: conditionally remove /usr/libexec

recipes-extended/proftpd/proftpd_1.3.4b.bb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

--
1.7.9.5