[Esbox-commits] r1561 - in branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard: . nokiabin
fabricioepa at garage.maemo.org
fabricioepa at garage.maemo.org
Fri May 8 17:15:42 EEST 2009
Author: fabricioepa
Date: 2009-05-08 17:15:42 +0300 (Fri, 08 May 2009)
New Revision: 1561
Modified:
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerData.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerEngine.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/NokiaBinariesInstallWizard.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/SDKTargetSelectionPage.java
Log:
Fixed BUG #4054
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -169,7 +169,7 @@
installed.add(t);
}
//call wizard with targets pre selected
- NokiaBinariesInstallWizard.startWizard(installed.toArray(new ISDKTarget[2]));
+ NokiaBinariesInstallWizard.startWizard(installed.toArray(new ISDKTarget[installed.size()]));
}
});
}
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerData.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerData.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerData.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -7,6 +7,7 @@
*
* Contributors:
* Ed Swartz (Nokia) - initial API and implementation
+ * Fabrício S Epaminondas (UFCG)
*******************************************************************************/
package org.maemo.esbox.internal.scratchbox.sb1.ui.wizard;
@@ -36,6 +37,9 @@
private String qemu;
private IScratchbox1SDK sdk;
private boolean forceRemove;
+ private boolean installRequiredDevkits = false;
+ private boolean installRequiredCompilers = false;
+ private boolean useCache;
/**
*
@@ -208,6 +212,48 @@
}
/**
+ * @return the installRequiredDevkits
+ */
+ public boolean isInstallRequiredDevkits() {
+ return installRequiredDevkits;
+ }
+
+ /**
+ * @param installRequiredDevkits the installRequiredDevkits to set
+ */
+ public void setInstallRequiredDevkits(boolean installRequiredDevkits) {
+ this.installRequiredDevkits = installRequiredDevkits;
+ }
+
+ /**
+ * @return the installRequiredCompilers
+ */
+ public boolean isInstallRequiredCompilers() {
+ return installRequiredCompilers;
+ }
+
+ /**
+ * @param installRequiredCompilers the installRequiredCompilers to set
+ */
+ public void setInstallRequiredCompilers(boolean installRequiredCompilers) {
+ this.installRequiredCompilers = installRequiredCompilers;
+ }
+
+ /**
+ * @return the useCache
+ */
+ public boolean isUseCache() {
+ return useCache;
+ }
+
+ /**
+ * @param useCache the useCache to set
+ */
+ public void setUseCache(boolean useCache) {
+ this.useCache = useCache;
+ }
+
+ /**
* Get the name of the X86 target, given the default basename
*/
public String getX86TargetName() {
@@ -251,6 +297,9 @@
cmdLine.add("-y");
}
+ if(isUseCache()){
+ cmdLine.add("-c");
+ }
return cmdLine;
}
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerEngine.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerEngine.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerEngine.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -11,9 +11,13 @@
package org.maemo.esbox.internal.scratchbox.sb1.ui.wizard;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -23,6 +27,7 @@
import org.eclipse.swt.widgets.Shell;
import org.maemo.esbox.internal.scratchbox.sb1.Activator;
import org.maemo.esbox.internal.scratchbox.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
import org.maemo.mica.common.core.IProgressReporter;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
@@ -32,6 +37,10 @@
import org.maemo.mica.common.core.process.ProcessLauncherCreator;
import org.maemo.mica.common.core.process.ProcessLauncherUtils;
import org.maemo.mica.common.core.sdk.SDKFactory;
+import org.maemo.mica.linux.packages.core.IPackageManager;
+import org.maemo.mica.linux.packages.core.ISystemPackage;
+import org.maemo.mica.linux.packages.core.PackageManagerProvider;
+import org.maemo.mica.linux.packages.ui.MachinePackageInstaller;
/**
* This engine runs the SDK installer script in non-interactive mode,
@@ -103,6 +112,11 @@
IStatus status;
monitor.beginTask("", IProgressMonitor.UNKNOWN);
+ checkRequiredDevkitsAndCompilers(multiStatus, new SubProgressMonitor(monitor, 1));
+
+ if (!multiStatus.isOK())
+ return multiStatus;
+
reporter.logInfo("Installing " + installerData.getName());
IPath installScript = fetchInstallScript(multiStatus, monitor, installerData.getInstallerURL());
@@ -176,6 +190,171 @@
return multiStatus;
}
+ /**
+ * Check if required devkits and compilers are installed. If not, it tries to install.
+ * @param multiStatus
+ * @param monitor
+ */
+ private void checkRequiredDevkitsAndCompilers(MultiStatus multiStatus, IProgressMonitor monitor) {
+ IStatus status;
+ if(!installerData.isInstallRequiredCompilers() || !installerData.isInstallRequiredDevkits())
+ return;
+
+ monitor.beginTask("", 3);
+ monitor.subTask("Looking for required scratchbox compilers and devkits...");
+ reporter.logInfo("Looking for required scratchbox compilers and devkits");
+
+ IScratchbox1SDK sdk = installerData.getScratchbox1SDK();
+
+ List<String> missingDevkits = new ArrayList<String>(Arrays.asList(installerData.getRequiredDevkits()));
+ List<String> missingCompilers = new ArrayList<String>(Arrays.asList(installerData.getRequiredCompilers()));
+ try {
+ missingDevkits.removeAll(sdk.getDevkits());
+ missingCompilers.removeAll(sdk.getCompilers());
+ } catch (MicaException e) {
+ status = Activator.createErrorStatus(
+ "The Scratchbox 1 installation at " + sdk
+ + " has problems; please fix or reinstall it:\n"
+ + e.getMessage(), e);
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+
+
+ monitor.worked(1);
+
+ IPackageManager manager = PackageManagerProvider.getInstance().getPackageManagerFor(
+ machine);
+
+ if (manager == null){
+ status = Activator.createStatus(IStatus.ERROR,
+ "Could not found package manager.");
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+
+ ISystemPackage[] sboxPackages = null;
+ try {
+ sboxPackages = manager.searchSystemPackages(
+ Pattern.compile("scratchbox-(core|libs|devkit-.*|toolchain-.*)"),
+ new SubProgressMonitor(monitor, 1));
+
+ if (sboxPackages.length == 0) {
+ reporter.logInfo("No Scratchbox 1 packages detected.");
+ status = Activator.createStatus(IStatus.ERROR, "No Scratchbox 1 packages detected.");
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+ } catch (MicaException e) {
+ status = Activator.createErrorStatus("Failed to scan Scratchbox compilers and devkits", e);
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+
+
+ try {
+ if(installerData.isInstallRequiredDevkits()){
+ reporter.logInfo("Checking required devkits for " + installerData.getName());
+ List<ISystemPackage> toInstall = new ArrayList<ISystemPackage>();
+ List<String> uninstallable = new ArrayList<String>();
+ for(String devkit : missingDevkits){
+ boolean unknown = true;//unknown package?
+ String name = inferPkgNameFromDevkit(devkit);
+ for(ISystemPackage pkg : sboxPackages){
+ if(pkg.getName().matches(name)){
+ unknown = false;
+ toInstall.add(pkg);
+ }
+ }
+ if(unknown)
+ uninstallable.add(devkit);
+ }
+
+
+ if (uninstallable.size() > 0) {
+ status = Activator.createStatus(IStatus.ERROR,
+ "Could not find required packages for devkits: " + uninstallable
+ + " you should add the repository to sources list before use this installer, or manually install them.");
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+
+ MachinePackageInstaller.installPackages(toInstall, shell, reporter, monitor);
+ }
+
+ monitor.worked(2);
+
+ if(installerData.isInstallRequiredCompilers()){
+ reporter.logInfo("Checking required compilers for " + installerData.getName());
+ List<ISystemPackage> toInstall = new ArrayList<ISystemPackage>();
+ List<String> uninstallable = new ArrayList<String>();
+ for(String compiler : missingCompilers){
+ boolean unknown = true;//unknown package?
+ String name = inferPkgNameFromCompiler(compiler);
+ for(ISystemPackage pkg : sboxPackages){
+ if(pkg.getName().matches(name)){
+ unknown = false;
+ toInstall.add(pkg);
+ }
+ }
+ if(unknown)
+ uninstallable.add(compiler);
+ }
+
+
+ if (uninstallable.size() > 0) {
+ status = Activator.createStatus(IStatus.ERROR,
+ "Could not find required packages for compilers: " + uninstallable
+ + " you should add the repository to sources list before use this installer, or manually install them.");
+ reporter.log(status);
+ multiStatus.add(status);
+ return;
+ }
+
+ MachinePackageInstaller.installPackages(toInstall, shell, reporter, monitor);
+ }
+ monitor.worked(3);
+
+ } catch (CoreException e) {
+ multiStatus.add(e.getStatus());
+ }
+ }
+
+ /**
+ * It can infer the packages names from devkit name
+ * @param devkit
+ * @return
+ */
+ private String inferPkgNameFromDevkit(String devkit) {
+ String prefix = "scratchbox-devkit-";
+ //XXX HACK: to infer package names from devkit name
+ if(devkit.matches("debian-*")){
+ return prefix + "debian";
+ }
+
+ if(devkit.matches("maemo3-tools")){
+ return prefix + "maemo3";
+ }
+
+ return prefix + devkit;
+ }
+
+ /**
+ * It can infer the packages names from compiler name
+ * @param devkit
+ * @return
+ */
+ private String inferPkgNameFromCompiler(String compiler) {
+ //XXX HACK: to infer package names from compiler name
+ String prefix = "scratchbox-toolchain-";
+ return prefix + compiler;
+ }
+
@Override
protected String doRewriteInstallScript(String text) {
text = super.doRewriteInstallScript(text);
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -498,6 +498,9 @@
private boolean validateScratchbox(IProgressMonitor monitor, IScratchbox1SDK sdk) {
monitor.beginTask("Validating Scratchbox installation", IProgressMonitor.UNKNOWN);
+ targetInstallerData.setInstallRequiredCompilers(false);
+ targetInstallerData.setInstallRequiredDevkits(false);
+
StringBuilder errors = new StringBuilder();
try {
List<String> devkits = sdk.getDevkits();
@@ -511,7 +514,8 @@
}
}
if (!matched) {
- errors.append("no devkit '" + reqdDevkit + "'; ");
+ errors.append(" devkit '" + reqdDevkit + "'; ");
+ targetInstallerData.setInstallRequiredDevkits(true);
}
}
@@ -524,13 +528,14 @@
}
}
if (!matched) {
- errors.append("no compiler '" + reqdToolchain + "'; ");
+ errors.append(" compiler '" + reqdToolchain + "'; ");
+ targetInstallerData.setInstallRequiredCompilers(true);
}
}
if (errors.length() != 0) {
- setErrorMessage("This Scratchbox 1 installation is not suitable: " + errors + "please upgrade it or install a new one.");
- return false;
+ setMessage("This Scratchbox 1 installation is not suitable, it will require to install support to: " + errors + " ", WARNING);
+ return true;
}
// check existing targets
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/NokiaBinariesInstallWizard.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/NokiaBinariesInstallWizard.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/NokiaBinariesInstallWizard.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -14,6 +14,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -27,6 +28,7 @@
import org.maemo.mica.common.core.machine.IBuildMachine;
import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.core.sdk.SDKFactory;
import org.maemo.mica.internal.api.maemosdk.ui.wizards.BadInstallationPage;
/**
@@ -194,8 +196,9 @@
// action has been disposed
return;
}
-
+
NokiaBinariesInstallWizard wizard = new NokiaBinariesInstallWizard();
+ establishTargetsPlatform(defaultTargets);
wizard.setDefaultTargets(defaultTargets);
wizard.init(activeWorkbenchWindow.getWorkbench(),
StructuredSelection.EMPTY);
@@ -207,4 +210,13 @@
SIZING_WIZARD_HEIGHT);
dialog.open();
}
+
+ private static void establishTargetsPlatform(ISDKTarget[] defaultTargets) {
+ if(defaultTargets !=null){
+ for(ISDKTarget t: defaultTargets){
+ if(t !=null)
+ SDKFactory.getInstance().establishPlatform(t, new NullProgressMonitor());
+ }
+ }
+ }
}
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/SDKTargetSelectionPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/SDKTargetSelectionPage.java 2009-05-08 13:11:15 UTC (rev 1560)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/nokiabin/SDKTargetSelectionPage.java 2009-05-08 14:15:42 UTC (rev 1561)
@@ -105,17 +105,13 @@
GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
setControl(container);
-
Label comboLb = new Label(container, SWT.NONE);
comboLb.setText("Select Platform:");
GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(comboLb);
-
fmaemoSDKCombo = new Combo(container, SWT.READ_ONLY | SWT.DROP_DOWN);
fmaemoSDKCombo.setItems(SDK_NAMES);
-
-
fmaemoSDKCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
updateUI();
@@ -156,10 +152,7 @@
}
});
-
targetTree.setInput(new Object());
-
-
}
More information about the Esbox-commits
mailing list