Multiple fixes against eclipse plugin for working on Windows agains Build Appliance
cover Multiple fixes against eclipse plugin for working on Windows agains Build Appliance
- Add fixes for Recipe wizard & Bitbake Project Wizard
- Wait for command output in a synchronous way using semaphores
- Fix remote deletion of files
- Initialize Bitbake session & parse environment variables
Ioana Grigoropol (8):
Add console fixes & run commands in a synchronous way Initialize bitbake session & environment parse variables Fix Bitbake commander project wizard
Validate Recipe autopopulated fields
Fix remote deletion of files
Fix md5sum & sha256sum pattern checks
Fix bitbake session by disabling sanity checks
Do not rely on AbstractHostShellOutputReader for waiting for command
outputs
.../src/org/yocto/bc/bitbake/BBRecipe.java | 10 +- .../src/org/yocto/bc/bitbake/BBSession.java | 17 ++- .../src/org/yocto/bc/bitbake/ShellSession.java | 58 ++++----- .../org/yocto/bc/remote/utils/ConsoleHelper.java | 18 +-- .../bc/remote/utils/ConsoleHelperRunnable.java | 31 +++++ .../org/yocto/bc/remote/utils/ConsoleRunnable.java | 37 ++++++ .../org/yocto/bc/remote/utils/RemoteHelper.java | 41 ++++-- .../org/yocto/bc/remote/utils/RemoteMachine.java | 6 +- .../remote/utils/YoctoHostShellProcessAdapter.java | 132 +++++++++++++++++--- .../bc/ui/wizards/NewBitBakeFileRecipeWizard.java | 2 +- .../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 40 +++--- .../yocto/bc/ui/wizards/install/InstallWizard.java | 85 ++++--------- 12 files changed, 297 insertions(+), 180 deletions(-) create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleHelperRunnable.java create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleRunnable.java
Signature · 1 line
1.7.9.5
PATCH 1/8 Add console fixes & run commands in a synchronous way
- when creating a new Yocto Project, the window does not wait for the process to complete, and closes beforehand
- the long time running task will be created without forking and monitor will be updated when receiving events from the YoctoHostShellProcessAdapter
- use AbstractHostShellReader.isFinished to wait for command outputs
--- .../src/org/yocto/bc/bitbake/ShellSession.java | 13 +- .../org/yocto/bc/remote/utils/ConsoleHelper.java | 18 +-- .../bc/remote/utils/ConsoleHelperRunnable.java | 31 +++++ .../org/yocto/bc/remote/utils/ConsoleRunnable.java | 37 ++++++ .../org/yocto/bc/remote/utils/RemoteHelper.java | 34 +++-- .../org/yocto/bc/remote/utils/RemoteMachine.java | 6 +- .../remote/utils/YoctoHostShellProcessAdapter.java | 140 +++++++++++++------- .../bc/ui/wizards/NewBitBakeFileRecipeWizard.java | 2 +- .../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 10 +- .../yocto/bc/ui/wizards/install/InstallWizard.java | 86 +++--------- 10 files changed, 217 insertions(+), 160 deletions(-) create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleHelperRunnable.java create mode 100644 plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleRunnable.java
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +6 -7
@@ -18,7 +18,6 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.Writer; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.rse.services.files.IHostFile;
@@ -119,12 +118,12 @@ public class ShellSession { synchronized public String execute(String command, int[] retCode) throws IOException { //FIXME : parse output - try { - RemoteHelper.runCommandRemote(RemoteHelper.getRemoteConnectionByName(projectInfo.getConnection().getName()), new YoctoCommand(command, root.getAbsolutePath(), ""), new NullProgressMonitor(), true); - } catch (Exception e) { - e.printStackTrace(); - } - +// try { +// RemoteHelper.runCommandRemote(RemoteHelper.getRemoteConnectionByName(projectInfo.getConnection().getName()), new YoctoCommand(command, root.getAbsolutePath(), ""), new NullProgressMonitor()); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// // String errorMessage = null; // interrupt = false; // out.write(command);
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleHelper.java +2 -16
@@ -1,14 +1,9 @@ package org.yocto.bc.remote.utils; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsole; -import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.console.IConsoleManager; -import org.eclipse.ui.console.IConsoleView; import org.eclipse.ui.console.MessageConsole; public class ConsoleHelper {
@@ -28,15 +23,6 @@ public class ConsoleHelper { } public static void showConsole(MessageConsole console){ - IWorkbench wb = PlatformUI.getWorkbench(); - IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); - IWorkbenchPage page = win.getActivePage(); - String id = IConsoleConstants.ID_CONSOLE_VIEW; - try { - IConsoleView view = (IConsoleView) page.showView(id); - view.display(console); - } catch (Exception e) { - e.printStackTrace(); - } + Display.getDefault().syncExec(new ConsoleRunnable(console)); } }
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleHelperRunnable.java new file +31 -0
@@ -0,0 +1,31 @@ +package org.yocto.bc.remote.utils; + +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.IConsoleConstants; +import org.eclipse.ui.console.IConsoleView; +import org.eclipse.ui.console.MessageConsole; + +public class ConsoleHelperRunnable implements Runnable { + MessageConsole console; + + ConsoleHelperRunnable(MessageConsole console){ + this.console = console; + } + @Override + public void run() { + IWorkbench wb = PlatformUI.getWorkbench(); + IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); + IWorkbenchPage page = win.getActivePage(); + String id = IConsoleConstants.ID_CONSOLE_VIEW; + try { + IConsoleView view = (IConsoleView) page.showView(id); + view.display(console); + } catch (Exception e) { + e.printStackTrace(); + } + } + +}
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/ConsoleRunnable.java new file +37 -0
@@ -0,0 +1,37 @@ +package org.yocto.bc.remote.utils; + +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.IConsoleConstants; +import org.eclipse.ui.console.IConsoleView; +import org.eclipse.ui.console.MessageConsole; + +public class ConsoleRunnable implements Runnable{ + MessageConsole console; + ConsoleRunnable (MessageConsole console){ + this.console = console; + } + @Override + public void run() { + IWorkbench wb = PlatformUI.getWorkbench(); + if (wb == null) + return; + IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); + if (win == null) + return; + IWorkbenchPage page = win.getActivePage(); + if (page == null) + return; + String id = IConsoleConstants.ID_CONSOLE_VIEW; + try { + IConsoleView view = (IConsoleView) page.showView(id); + if (view == null) + return; + view.display(console); + } catch (Exception e) { + e.printStackTrace(); + } + } +}
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java +22 -12
@@ -34,7 +34,6 @@ import org.eclipse.rse.services.IService; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.services.files.IHostFile; -import org.eclipse.rse.services.shells.HostShellProcessAdapter; import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
@@ -46,6 +45,7 @@ import org.yocto.bc.ui.Activator; 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){
@@ -68,7 +68,7 @@ public class RemoteHelper { return getRemoteMachine(connection).getCmdHandler(); } - public static HostShellProcessAdapter getHostShellProcessAdapter(IHost connection) { + public static YoctoHostShellProcessAdapter getHostShellProcessAdapter(IHost connection) { return getRemoteMachine(connection).getHostShellProcessAdapter(); }
@@ -270,24 +270,34 @@ public class RemoteHelper { return null; } - public static void runCommandRemote(IHost connection, YoctoCommand cmd, IProgressMonitor monitor, boolean waitForOutput) throws Exception { + 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()) { - writeToShell(connection, "cd " + cmd.getInitialDirectory(), waitForOutput); + hasErrors = writeToShell(connection, "cd " + cmd.getInitialDirectory(), monitor); } - writeToShell(connection, remoteCommand, waitForOutput); + if (!hasErrors) + return writeToShell(connection, remoteCommand, monitor); } catch (Exception e) { e.printStackTrace(); } + return hasErrors; } - public static void writeToShell(IHost connection, String remoteCommand, boolean waitForOutput){ - YoctoHostShellProcessAdapter hostShellProcessAdapter = ((YoctoHostShellProcessAdapter)getHostShellProcessAdapter(connection)); - hostShellProcessAdapter.setWaitForOutput(waitForOutput); - hostShellProcessAdapter.setLastCommand(remoteCommand); + public static boolean writeToShell(IHost connection, String remoteCommand, IProgressMonitor monitor){ + YoctoHostShellProcessAdapter hostShellProcessAdapter = getHostShellProcessAdapter(connection); + hostShellProcessAdapter.setMonitor(monitor); getHostShell(connection).writeToShell(remoteCommand); + + try { + while (!hostShellProcessAdapter.isFinished() && hostShellProcessAdapter.isAlive()) { + Thread.sleep(2); + } + } catch (Exception e) { + e.printStackTrace(); + } + return hostShellProcessAdapter.hasErrors(); } public static void runBatchRemote(IHost connection, List<YoctoCommand> cmds, IProgressMonitor monitor, boolean waitForOutput) throws CoreException {
@@ -298,9 +308,9 @@ public class RemoteHelper { for (YoctoCommand cmd : cmds) { remoteCommand = cmd.getCommand() + " " + cmd.getArguments(); if (!cmd.getInitialDirectory().isEmpty()) { - writeToShell(connection, "cd " + cmd.getInitialDirectory(), waitForOutput); + writeToShell(connection, "cd " + cmd.getInitialDirectory(), monitor); } - writeToShell(connection, remoteCommand, waitForOutput); + writeToShell(connection, remoteCommand, monitor); } } catch (Exception e1) { e1.printStackTrace();
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteMachine.java +2 -4
@@ -12,7 +12,6 @@ import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.IFileService; -import org.eclipse.rse.services.shells.HostShellProcessAdapter; import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.services.shells.IShellService; import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
@@ -27,7 +26,7 @@ public class RemoteMachine { private MessageConsole console; private CommandResponseHandler cmdHandler; private IHostShell hostShell; - private HostShellProcessAdapter hostShellProcessAdapter; + private YoctoHostShellProcessAdapter hostShellProcessAdapter; private IShellService shellService; private ProcessStreamBuffer processBuffer; private IHost connection;
@@ -61,7 +60,6 @@ public class RemoteMachine { try { if (hostShell == null) { hostShell = getShellService(new NullProgressMonitor()).launchShell("", new String[]{}, new NullProgressMonitor()); - getHostShellProcessAdapter(); } } catch (SystemMessageException e) { e.printStackTrace();
@@ -71,7 +69,7 @@ public class RemoteMachine { return hostShell; } - public HostShellProcessAdapter getHostShellProcessAdapter() { + public YoctoHostShellProcessAdapter getHostShellProcessAdapter() { try { if (hostShellProcessAdapter == null) hostShellProcessAdapter = new YoctoHostShellProcessAdapter(getHostShell(), getProcessBuffer(), getCmdHandler());
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java +89 -51
195 lines not on this page · raw message
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizard.java +1 -1
@@ -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, true); + RemoteHelper.runCommandRemote(connection, new YoctoCommand("rm -rf temp", element.getMetaDir() + "/temp", ""), monitor); } catch (Exception e) { throw new InvocationTargetException(e); } finally {
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java +5 -5
@@ -352,11 +352,11 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { String md5Cmd = "md5sum " + getSrcFileName(true); YoctoCommand md5YCmd = new YoctoCommand(md5Cmd, tempFolderPath, ""); - RemoteHelper.runCommandRemote(connection, md5YCmd, monitor, true); + RemoteHelper.runCommandRemote(connection, md5YCmd, monitor); String sha256Cmd = "sha256sum " + getSrcFileName(true); YoctoCommand sha256YCmd = new YoctoCommand(sha256Cmd, tempFolderPath, ""); - RemoteHelper.runCommandRemote(connection, sha256YCmd, monitor, true); + RemoteHelper.runCommandRemote(connection, sha256YCmd, monitor); URI extractDir = extractPackage(srcURI, monitor); YoctoCommand licenseChecksumCmd = populateLicenseFileChecksum(extractDir, monitor);
@@ -388,7 +388,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { tarCmd += "-xvf "; } - RemoteHelper.runCommandRemote(connection, new YoctoCommand(tarCmd + path, tempFolderPath, ""), monitor, true); + RemoteHelper.runCommandRemote(connection, new YoctoCommand(tarCmd + path, tempFolderPath, ""), monitor); return RemoteHelper.createNewURI(metaDirLoc, TEMP_FOLDER_NAME + "/" + getSrcFileName(false));
@@ -427,7 +427,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { try { YoctoCommand catCmd = new YoctoCommand("md5sum " + COPYING_FILE, extractDir.getPath(), ""); - RemoteHelper.runCommandRemote(connection, catCmd, monitor, true); + RemoteHelper.runCommandRemote(connection, catCmd, monitor); return catCmd; } catch (Exception e) { throw new RuntimeException("Unable to process file for MD5 calculation", e);
@@ -495,7 +495,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { HashMap<String, String> mirrorMap = new HashMap<String, String>(); YoctoCommand cmd = new YoctoCommand("cat " + MIRRORS_FILE, getMetaFolderPath() + CLASSES_FOLDER, ""); - RemoteHelper.runCommandRemote(connection, cmd, monitor, true); + RemoteHelper.runCommandRemote(connection, cmd, monitor); if (!cmd.getProcessBuffer().hasErrors()){ String delims = "[\\t]+";
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +22 -64
144 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/8 Initialize bitbake session & environment parse variables
In reply to Ioana Grigoropol- source oe-init-env for the connection shell
- parse environment variables
--- .../src/org/yocto/bc/bitbake/BBSession.java | 13 +++-- .../src/org/yocto/bc/bitbake/ShellSession.java | 53 ++++++++------------ 2 files changed, 26 insertions(+), 40 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +6 -7
@@ -329,18 +329,17 @@ public class BBSession implements IBBSessionListener, IModelElement, Map { } } - protected int checkExecuteError(String result, int code) { + protected void checkExecuteError(String result, boolean hasErrors) { URI recipeURI = getDefaultDepends(); String text = "Parsing " + ((recipeURI != null) ? ("recipe " + recipeURI) : "base configurations"); - if (code != 0) { + if (hasErrors) { text = text + " ERROR!\n" + result; }else { text = text + " SUCCESS.\n"; } if(!silent) { - displayInConsole(text, code, false); + displayInConsole(text, -1, false); } - return code; } protected void displayInConsole(final String result, final int code, boolean clear) {
@@ -377,9 +376,9 @@ public class BBSession implements IBBSessionListener, IModelElement, Map { } try { if(!initialized) { //recheck - int [] codes = {-1}; - String result = shell.execute(parsingCmd, codes); - if(checkExecuteError(result, codes[0]) == 0) { + boolean hasErrors = false; + String result = shell.execute(parsingCmd, hasErrors); + if(!hasErrors) { properties = parseBBEnvironment(result); } else { properties = parseBBEnvironment("");
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +20 -33
84 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/8 Fix Bitbake commander project wizard
In reply to Ioana Grigoropol- do not run git task in a loop
- wait for the command to finish - use ModalContext.allowReadAndDispatch(false) - (needs some fixes for upstream RSE API - TBA)
--- .../yocto/bc/ui/wizards/install/InstallWizard.java | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/install/InstallWizard.java +14 -13
@@ -9,6 +9,7 @@ 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.WizardPage; import org.eclipse.ptp.remote.core.IRemoteConnection;
@@ -114,12 +115,12 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard 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); -// while (!runningTask.isFinished) -// Thread.sleep(2); } CommandResponseHandler cmdHandler = RemoteHelper.getCommandHandler(RemoteHelper.getRemoteConnectionByName(((IRemoteConnection)model.get(InstallWizard.SELECTED_CONNECTION)).getName()));
@@ -183,7 +184,7 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard synchronized public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - boolean cancel = false; +// boolean cancel = false; try { monitor.beginTask(taskName, TOTALWORKLOAD);
@@ -203,17 +204,17 @@ public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard for (int i = 1; i < cmdArray.length; i++) args += cmdArray[i] + " "; try { - while (!cancel) { - if(monitor.isCanceled()) { - cancel=true; - throw new InterruptedException("User Cancelled"); - } - boolean hasErrors = RemoteHelper.runCommandRemote(RemoteHelper.getRemoteConnectionByName(connection.getName()), new YoctoCommand(cmdArray[0], "", args), monitor); - if (hasErrors) - break; +// 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); - } +// Thread.sleep(5000); +// } } catch (Exception e) { e.printStackTrace(); } finally {
Signature · 1 line
1.7.9.5
PATCH 4/8 Validate Recipe autopopulated fields
In reply to Ioana Grigoropol- validate that generated md5sums and sha256 sums are valid before populating the fields
- clear all previous commands output (like after source & bitbake -e) in order to limit output parsing
--- .../org/yocto/bc/remote/utils/RemoteHelper.java | 3 -- .../remote/utils/YoctoHostShellProcessAdapter.java | 8 ++++-- .../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 29 ++++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java +0 -3
@@ -301,8 +301,6 @@ public class RemoteHelper { } public static void runBatchRemote(IHost connection, List<YoctoCommand> cmds, IProgressMonitor monitor, boolean waitForOutput) throws CoreException { - connection.getHostName(); - connection.getDefaultUserId(); try { String remoteCommand = ""; for (YoctoCommand cmd : cmds) {
@@ -364,5 +362,4 @@ public class RemoteHelper { } return false; } - }
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java +5 -3
@@ -11,7 +11,6 @@ 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{ private ProcessStreamBuffer processStreamBuffer;
@@ -75,7 +74,6 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{ private void reportProgress(String info) { - if(calculator == null) { updateMonitor(1); } else {
@@ -125,7 +123,6 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{ this.commandResponseHandler.response(value, false); } } - AbstractHostShellOutputReader absReader = (AbstractHostShellOutputReader)reader; isAlive = absReader.isAlive(); isFinished = absReader.isFinished();
@@ -145,4 +142,9 @@ public class YoctoHostShellProcessAdapter extends HostShellProcessAdapter{ public void setAlive(boolean isAlive) { this.isAlive = isAlive; } + + public void clearProcessBuffer() { + this.processStreamBuffer.outputLines.clear(); + this.processStreamBuffer.errorLines.clear(); + } }
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java +14 -15
@@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.regex.Pattern; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject;
@@ -95,6 +96,8 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { private static final String CONFIGURE_IN = "configure.in"; private static final String CONFIGURE_AC = "configure.ac"; private static final String AUTOTOOLS = "autotools"; + private static final String md5Pattern = "^[0-9a-e]{32}$"; + protected static final String sha256Pattern = "^[0-9a-e]{64}$"; public NewBitBakeFileRecipeWizardPage(ISelection selection, IHost connection) { super("wizardPage");
@@ -302,14 +305,6 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { } catch (Exception e) { e.printStackTrace(); } -// populateRecipeName(srcURI); -// populateSrcUriChecksum(srcURI, monitor); -// -// URI extractDir = extractPackage(srcURI, monitor); -// populateLicenseFileChecksum(extractDir, monitor); -// updateSrcUri(createMirrorLookupTable(monitor), srcURI); -// populateInheritance(extractDir, monitor); - } else { String packageName = getSrcFileName(false).replace("-", "_"); fileText.setText(packageName + BB_RECIPE_EXT);
@@ -318,10 +313,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { } } catch (URISyntaxException e) { e.printStackTrace(); - } /*catch (MalformedURLException e) { - e.printStackTrace(); - }*/ - + } } private void handleLocalPopulate(URI srcURI, IProgressMonitor monitor) {
@@ -330,6 +322,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { } private void handleRemotePopulate(URI srcURI, IProgressMonitor monitor) throws Exception { + RemoteHelper.clearProcessBuffer(connection); populateRecipeName(srcURI); List<YoctoCommand> commands = new ArrayList<YoctoCommand>();
@@ -363,9 +356,12 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { updateSrcUri(createMirrorLookupTable(monitor), srcURI); populateInheritance(extractDir, monitor); - md5sumText.setText(retrieveSum(md5YCmd)); - sha256sumText.setText(retrieveSum(sha256YCmd)); - checksumText.setText(RemoteHelper.createNewURI(extractDir, COPYING_FILE).toString() + ";md5=" + retrieveSum(licenseChecksumCmd)); + 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) {
@@ -409,6 +405,9 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { 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)){
Signature · 1 line
1.7.9.5
PATCH 5/8 Fix remote deletion of files
In reply to Ioana Grigoropol- when deleting a file from a remote directory use the URI and not the location of the file which is null
--- .../src/org/yocto/bc/bitbake/BBSession.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBSession.java +3 -3
@@ -80,7 +80,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map { this.pinfo = new ProjectInfo(); pinfo.setLocation(projectRoot); pinfo.setInitScriptPath(ProjectInfoHelper.getInitScriptPath(projectRoot)); - this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e"; + this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e"; } public BBSession(ShellSession ssession, URI projectRoot, boolean silent) throws IOException {
@@ -376,7 +376,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map { } try { if(!initialized) { //recheck - boolean hasErrors = false; + boolean hasErrors = false; String result = shell.execute(parsingCmd, hasErrors); if(!hasErrors) { properties = parseBBEnvironment(result);
@@ -725,7 +725,7 @@ public class BBSession implements IBBSessionListener, IModelElement, Map { try { if (initialized && (removed != null || changed != null)) { for(int i=0;removed != null && i<removed.length;i++) { - if (this.depends.contains(removed[i].getLocation().toString())) { + if (this.depends.contains(removed[i].getLocationURI())) { initialized = false; return; }
Signature · 1 line
1.7.9.5
PATCH 6/8 Fix md5sum & sha256sum pattern checks
In reply to Ioana Grigoropol--- .../ui/wizards/NewBitBakeFileRecipeWizardPage.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/NewBitBakeFileRecipeWizardPage.java +3 -2
@@ -96,8 +96,8 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { private static final String CONFIGURE_IN = "configure.in"; private static final String CONFIGURE_AC = "configure.ac"; private static final String AUTOTOOLS = "autotools"; - private static final String md5Pattern = "^[0-9a-e]{32}$"; - protected static final String sha256Pattern = "^[0-9a-e]{64}$"; + 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");
@@ -323,6 +323,7 @@ public class NewBitBakeFileRecipeWizardPage extends WizardPage { private void handleRemotePopulate(URI srcURI, IProgressMonitor monitor) throws Exception { RemoteHelper.clearProcessBuffer(connection); + populateRecipeName(srcURI); List<YoctoCommand> commands = new ArrayList<YoctoCommand>();
Signature · 1 line
1.7.9.5
PATCH 7/8 Fix bitbake session by disabling sanity checks
In reply to Ioana Grigoropol- when creating a shell session for Bitbake, we cannot run "bitbake -e -b recipe.bb" just by setting DISABLE_SANITY_CHECKS=1; we must first append DISABLE_SANITY_CHECKS to BB_ENV_EXTRAWHITE
--- .../src/org/yocto/bc/bitbake/BBRecipe.java | 10 +++++----- .../src/org/yocto/bc/bitbake/ShellSession.java | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/BBRecipe.java +5 -5
@@ -20,24 +20,24 @@ import java.net.URI; */ public class BBRecipe extends BBSession { private final BBSession session; - private final URI filePath; + private final URI fileURI; public BBRecipe(BBSession session, URI filePath) throws IOException { super(session.shell, session.pinfo.getURI()); this.session = session; - this.filePath = filePath; - this.parsingCmd = "DISABLE_SANITY_CHECKS=1 bitbake -e -b " + filePath; + this.fileURI = filePath; + this.parsingCmd = "DISABLE_SANITY_CHECKS=\"1\" bitbake -e -b " + filePath.getPath(); } @Override public void initialize() throws Exception { if (this.size() == 0) { - System.out.println("Failed to parse " + filePath); + System.out.println("Failed to parse " + fileURI); //throw new IOException("Failed to parse " + filePath); } } protected URI getDefaultDepends() { - return this.filePath; + return this.fileURI; } }
plugins/org.yocto.bc.ui/src/org/yocto/bc/bitbake/ShellSession.java +9 -7
@@ -46,6 +46,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 String getFilePath(String file) throws IOException { File f = new File(file);
@@ -69,7 +70,7 @@ public class ShellSession { private OutputStream pos = null; //private File initFile = null; - private String shellPath = null; +// private String shellPath = null; private final String initCmd; private final IHostFile root; // private final Writer out;
@@ -84,10 +85,10 @@ public class ShellSession { // } else { // this.out = out; // } - if (shellType == SHELL_TYPE_SH) { - shellPath = "/bin/sh"; - } - shellPath = "/bin/bash"; +// if (shellType == SHELL_TYPE_SH) { +// shellPath = "/bin/sh"; +// } +// shellPath = "/bin/bash"; initializeShell(new NullProgressMonitor()); }
@@ -95,7 +96,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("source " + initCmd, root.getAbsolutePath(), ""), monitor); + RemoteHelper.runCommandRemote(connection, new YoctoCommand(exportCmd, root.getAbsolutePath(), ""), monitor); } catch (Exception e) { e.printStackTrace(); }
@@ -110,7 +112,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(), ""), new NullProgressMonitor()); + hasErrors = RemoteHelper.runCommandRemote(connection, new YoctoCommand(command, root.getAbsolutePath() + "/build/", ""), new NullProgressMonitor()); return RemoteHelper.getProcessBuffer(connection).getMergedOutputLines(); } catch (Exception e) { e.printStackTrace();
Signature · 1 line
1.7.9.5
PATCH 8/8 Do not rely on AbstractHostShellOutputReader for waiting for command outputs
In reply to Ioana Grigoropol- AbstractHostShellReader is designed such that it will block in a read from the pipeline when the command is finished its execution, therefore we should not wait for this variable to be set because it will eventually block. Instead we will acquire a semaphore each time we run a command and wait for the first prompt line that comes after it, in order to parse the output.
--- .../org/yocto/bc/remote/utils/RemoteHelper.java | 22 +++++-- .../remote/utils/YoctoHostShellProcessAdapter.java | 68 +++++++++++++++++++- 2 files changed, 81 insertions(+), 9 deletions(-)
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/RemoteHelper.java +15 -7
@@ -288,15 +288,18 @@ public class RemoteHelper { 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); - } - } catch (Exception e) { - e.printStackTrace(); - } +// try { +// while (!hostShellProcessAdapter.isFinished() && hostShellProcessAdapter.isAlive()) { +// Thread.sleep(2); +// } +//// System.out.println(">>>>>>>>>>>>>>>>>>>>finished command " + remoteCommand); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return hostShellProcessAdapter.hasErrors(); }
@@ -362,4 +365,9 @@ public class RemoteHelper { } return false; } + + public static void clearProcessBuffer(IHost connection) { + getHostShellProcessAdapter(connection).clearProcessBuffer(); + } + }
plugins/org.yocto.bc.ui/src/org/yocto/bc/remote/utils/YoctoHostShellProcessAdapter.java +66 -2
121 lines not on this page · raw message
Signature · 1 line
1.7.9.5