[Esbox-commits] r2134 - branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Thu Sep 10 00:46:29 EEST 2009
Author: eswartz
Date: 2009-09-10 00:46:16 +0300 (Thu, 10 Sep 2009)
New Revision: 2134
Modified:
branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
Log:
Try to avoid conflicts...
Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-09-09 21:34:59 UTC (rev 2133)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-09-09 21:46:16 UTC (rev 2134)
@@ -1,278 +1,278 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (c) 2009 Nokia 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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.api.vm.vmware;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-/**
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMInfo implements Comparable<MaemoSDKVMInfo> {
-//XXX REMOVE ME public static final String DOWNLOAD_PAGE = "http://localhost:8080/nokia/";
- public static final String DOWNLOAD_PAGE = "http://tablets-dev.nokia.com/maemo-dev-env-downloads.php";
-
- // status for the file
- public enum Status {
- DOWNLOADING, // file is being downloaded
- PAUSED, // download is waiting
- COMPLETE, // download is complete
- CANCELLED, // download was canceled
- ERROR
- // an error occurred
- }
-
- // main information
- private MaemoSDKVMDescription descriptor;
- private long size;
- private long downloaded;
- private Status status;
-
- // urls for download and storage
- private URL installLocaltion;
- private String fileName;
-
- private int numParts;
-
- /**
- * Constructor.
- */
- public MaemoSDKVMInfo() {
- this(null);
- }
-
- /**
- * Constructor.
- *
- * @param url
- */
- public MaemoSDKVMInfo(URL localURL) {
- this.installLocaltion = localURL;
- size = -1;
- downloaded = 0;
- descriptor = null;
- status = Status.DOWNLOADING;
- numParts = DefaultVMZipExtractor.SINGLE_FILE_PART;
- }
-
- /**
- * Get the description of this file.
- *
- * @return the description of this file.
- */
- public MaemoSDKVMDescription getDescriptor() {
- return descriptor;
- }
-
- /**
- * Set the description of this file.
- *
- * @param descriptor
- * the new description.
- */
- public void setDescriptor(MaemoSDKVMDescription descriptor) {
- this.descriptor = descriptor;
- }
-
- /**
- * Get this download's URL.
- *
- * @return
- */
- public URL getInstallLocation() {
- return installLocaltion;
- }
-
- /**
- * Get this download's URL.
- *
- * @return
- */
- public void setInstallLocation(URL localURL) {
- this.installLocaltion = localURL;
- }
-
- /**
- * The name of the file
- * @return
- */
- public String getFileName(){
- return this.fileName;
- }
-
- /**
- * @return returns the local downloaded file name, it can be null
- */
- public File resolveLocalFile() {
- return internalResolveLocalFile(getFileName());
- }
-
- private File internalResolveLocalFile(String fileName) {
- String path = getInstallLocation().getPath();
- return new File(path, fileName);
- }
-
- /**
- * @param fileName the fileName to set
- */
- public void setFileName(String fileName){
- this.fileName = fileName;
- }
-
- /**
- * Get this download's size.
- *
- * @return
- */
- public long getSize() {
- return size;
- }
-
- /**
- *
- * @param size
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * Get the number of bytes already downloaded.
- *
- * @return
- */
- public long getDownloadedSize() {
- return downloaded;
- }
-
- /**
- * Set the number of downloaded bytes.
- *
- * @param downloaded
- */
- public void setDownloadedSize(long downloaded) {
- this.downloaded = downloaded;
- }
-
- /**
- * Get progress of this download file
- *
- * @return
- */
- public float getProgress() {
- return ((float) downloaded / size) * 100;
- }
-
- /**
- * Return the status of this download file
- *
- * @return
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * Set download state to PAUSED.
- */
- public void pause() {
- status = Status.PAUSED;
- }
-
- /**
- * Resume the download.
- */
- public void resume() {
- status = Status.DOWNLOADING;
- }
-
- /**
- * Set download state to CANCELLED.
- */
- public void cancel() {
- status = Status.CANCELLED;
- }
-
- /**
- * Set download state to ERROR.
- */
- public void error() {
- status = Status.ERROR;
- }
-
- /**
- * Set download state to ERROR.
- */
- public void complete() {
- status = Status.COMPLETE;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null)
- return false;
- if (obj.getClass() != this.getClass())
- return false;
- MaemoSDKVMInfo downloadFile = (MaemoSDKVMInfo) obj;
- return descriptor.equals(downloadFile.getDescriptor());
-
- }
-
- /**
- * Check if the file has more than one part.
- *
- * @return true, if the file has more than one part; false, otherwise.
- */
- public boolean isMultipart() {
- return this.numParts > DefaultVMZipExtractor.SINGLE_FILE_PART;
- }
-
- /**
- * Set if the file has more than one part.
- *
- * @param hasMoreParts
- */
- public void setNumberOfParts(int number) {
- this.numParts = number;
- }
-
- /**
- * @return
- */
- public int getNumParts(){
- return numParts;
- }
- /**
- * Download the file.
- *
- * @return the runnable process
- */
- public IRunnableWithProgress downloadFile() {
- return new DownloadExecution(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(MaemoSDKVMInfo o) {
- if (o == null)
- return 1;
- return getDescriptor().compareTo(o.getDescriptor());
- }
-
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (c) 2009 Nokia 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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.api.vm.vmware;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+/**
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMInfo implements Comparable<MaemoSDKVMInfo> {
+//XXX REMOVE ME public static final String DOWNLOAD_PAGE = "http://localhost:8080/nokia/";
+ public static final String DOWNLOAD_PAGE = "http://tablets-dev.nokia.com/maemo-dev-env-downloads.php";
+
+ // status for the file
+ public enum Status {
+ DOWNLOADING, // file is being downloaded
+ PAUSED, // download is waiting
+ COMPLETE, // download is complete
+ CANCELLED, // download was canceled
+ ERROR
+ // an error occurred
+ }
+
+ // main information
+ private MaemoSDKVMDescription descriptor;
+ private long size;
+ private long downloaded;
+ private Status status;
+
+ // urls for download and storage
+ private URL installLocaltion;
+ private String fileName;
+
+ private int numParts;
+
+ /**
+ * Constructor.
+ */
+ public MaemoSDKVMInfo() {
+ this(null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param url
+ */
+ public MaemoSDKVMInfo(URL localURL) {
+ this.installLocaltion = localURL;
+ size = -1;
+ downloaded = 0;
+ descriptor = null;
+ status = Status.DOWNLOADING;
+ numParts = DefaultVMZipExtractor.SINGLE_FILE_PART;
+ }
+
+ /**
+ * Get the description of this file.
+ *
+ * @return the description of this file.
+ */
+ public MaemoSDKVMDescription getDescriptor() {
+ return descriptor;
+ }
+
+ /**
+ * Set the description of this file.
+ *
+ * @param descriptor
+ * the new description.
+ */
+ public void setDescriptor(MaemoSDKVMDescription descriptor) {
+ this.descriptor = descriptor;
+ }
+
+ /**
+ * Get this download's URL.
+ *
+ * @return
+ */
+ public URL getInstallLocation() {
+ return installLocaltion;
+ }
+
+ /**
+ * Get this download's URL.
+ *
+ * @return
+ */
+ public void setInstallLocation(URL localURL) {
+ this.installLocaltion = localURL;
+ }
+
+ /**
+ * The name of the file
+ * @return
+ */
+ public String getFileName(){
+ return this.fileName;
+ }
+
+ /**
+ * @return returns the local downloaded file name, it can be null
+ */
+ public File resolveLocalFile() {
+ return internalResolveLocalFile(getFileName());
+ }
+
+ private File internalResolveLocalFile(String fileName) {
+ String path = getInstallLocation().getPath();
+ return new File(path, fileName);
+ }
+
+ /**
+ * @param fileName the fileName to set
+ */
+ public void setFileName(String fileName){
+ this.fileName = fileName;
+ }
+
+ /**
+ * Get this download's size.
+ *
+ * @return
+ */
+ public long getSize() {
+ return size;
+ }
+
+ /**
+ *
+ * @param size
+ */
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ /**
+ * Get the number of bytes already downloaded.
+ *
+ * @return
+ */
+ public long getDownloadedSize() {
+ return downloaded;
+ }
+
+ /**
+ * Set the number of downloaded bytes.
+ *
+ * @param downloaded
+ */
+ public void setDownloadedSize(long downloaded) {
+ this.downloaded = downloaded;
+ }
+
+ /**
+ * Get progress of this download file
+ *
+ * @return
+ */
+ public float getProgress() {
+ return ((float) downloaded / size) * 100;
+ }
+
+ /**
+ * Return the status of this download file
+ *
+ * @return
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * Set download state to PAUSED.
+ */
+ public void pause() {
+ status = Status.PAUSED;
+ }
+
+ /**
+ * Resume the download.
+ */
+ public void resume() {
+ status = Status.DOWNLOADING;
+ }
+
+ /**
+ * Set download state to CANCELLED.
+ */
+ public void cancel() {
+ status = Status.CANCELLED;
+ }
+
+ /**
+ * Set download state to ERROR.
+ */
+ public void error() {
+ status = Status.ERROR;
+ }
+
+ /**
+ * Set download state to ERROR.
+ */
+ public void complete() {
+ status = Status.COMPLETE;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (obj.getClass() != this.getClass())
+ return false;
+ MaemoSDKVMInfo downloadFile = (MaemoSDKVMInfo) obj;
+ return descriptor.equals(downloadFile.getDescriptor());
+
+ }
+
+ /**
+ * Check if the file has more than one part.
+ *
+ * @return true, if the file has more than one part; false, otherwise.
+ */
+ public boolean isMultipart() {
+ return this.numParts > DefaultVMZipExtractor.SINGLE_FILE_PART;
+ }
+
+ /**
+ * Set if the file has more than one part.
+ *
+ * @param hasMoreParts
+ */
+ public void setNumberOfParts(int number) {
+ this.numParts = number;
+ }
+
+ /**
+ * @return
+ */
+ public int getNumParts(){
+ return numParts;
+ }
+ /**
+ * Download the file.
+ *
+ * @return the runnable process
+ */
+ public IRunnableWithProgress downloadFile() {
+ return new DownloadExecution(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(MaemoSDKVMInfo o) {
+ if (o == null)
+ return 1;
+ return getDescriptor().compareTo(o.getDescriptor());
+ }
+
+
+}
Property changes on: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-09-09 21:34:59 UTC (rev 2133)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-09-09 21:46:16 UTC (rev 2134)
@@ -1,519 +1,519 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (c) 2009 Nokia 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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.api.vm.vmware;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo.Status;
-import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1SDKWizard;
-import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1TargetWizard;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.esbox.internal.vm.vmware.ui.wizards.MaemoSDKVMInstallData;
-import org.maemo.esbox.vm.core.IVirtualMachine;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.Policy;
-import org.maemo.mica.common.core.machine.IBuildMachine;
-import org.maemo.mica.common.core.machine.IMachine;
-import org.maemo.mica.common.core.machine.MachineRegistry;
-import org.maemo.mica.common.core.sdk.ISDKTarget;
-import org.maemo.mica.common.core.sdk.SDKManager;
-import org.maemo.mica.common.core.ui.IProgressReporter;
-import org.maemo.mica.common.ui.dialogs.DialogUtils;
-import org.maemo.mica.common.ui.dialogs.StyledTextProgressDialog;
-import org.maemo.mica.internal.api.common.core.GeneralUtils;
-import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
-import org.maemo.mica.internal.api.linux.packages.core.aptinstall.AptInstallerHelper;
-
-/**
- * This class wraps the main methods used during installation of Maemo SDK
- * virtual image.
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMInstaller {
-
- private MaemoSDKVMInstallData installData;
-
- /**
- * Constructor.
- *
- * @param installData
- * the installation data
- * @param reporter
- * the progress reporter
- */
- public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData) {
- this.installData = installData;
- }
-
- /**
- * Install component into virtual image based on installer data information
- * @param timeout the timeout
- * @param shell the shell
- * @param monitor the monitor
- * @return the result status as result for the installation process.
- */
- public IStatus installVirtualImage(int timeout, Shell shell, IProgressMonitor monitor) {
- IStatus status = Activator.createStatus(IStatus.OK, "Maemo SDK Virtual Image was properly installed.");
-
- if (!installData.canUsePreviousInstallation())
- status = this.downloadVM(shell, monitor);
-
- if (canProceed(status))
- status = this.uncompressVM(shell, monitor);
-
- if (canProceed(status))
- status = promptPreferencesDialog(shell, monitor);
-
- if (canProceed(status) && installData.canInstallSbox())
- status = this.installScratchbox(shell,monitor);
-
- if (canProceed(status) && installData.canInstallTargets())
- status = this.installScratchboxTargets(shell,monitor);
-
- if (canProceed(status) && ((installData.canInstallCppEnv() || installData.canInstallPythonEnv())))
- status = this.installPackages(shell, monitor);
-
- return status;
- }
-
- /**
- * Check if can go ahead on installation based on given status.
- * @param status the status.
- * @return true if can go ahead on installation process; false, otherwise.
- */
- private boolean canProceed(IStatus status) {
- return ! (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR));
- }
-
- /**
- * Download Maemo SDK virtual image. If the virtual image consists of more
- * than one file, the other will be also downloaded.
- *
- * @return the result of download process as IStatus
- */
- public IStatus downloadVM(final Shell shell, IProgressMonitor monitor) {
- monitor.subTask("Downloading image...");
- //reporter.reportStep("Downloading Maemo SDK virtual image...");
-
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- MaemoSDKVMInfo fileDownload = installData.getFileToDownload();
- DownloadExecution downloadWrapper = (DownloadExecution) fileDownload.downloadFile();
- try {
- DownloadProgressMonitor progressMonitor = new DownloadProgressMonitor(shell, downloadWrapper);
- progressMonitor.run(true, true, downloadWrapper);
- } catch (Exception exception) {
- Activator.getErrorLogger().logAndShowError("Error during Maemo SDK virtual image downloading", exception);
- }
- }
-
- });
- IStatus result = Policy.getCancelStatus(Activator.getDefault());
- Status downloadStatus = installData.getFileToDownload().getStatus();
- if (downloadStatus.equals(Status.CANCELLED))
- result = Activator.createErrorStatus(
- "Maemo SDK virtual image download was canceled.", null);
- else if (downloadStatus.equals(Status.ERROR))
- result = Activator.createErrorStatus(
- "An error occured during Maemo SDK virtual image download.", null);
- else if (downloadStatus.equals(Status.COMPLETE))
- result = Activator.createStatus(IStatus.OK,
- "Maemo SDK virtual image was properly downloaded.");
- return result;
-
- }
-
- /**
- * Uncompress the Maemo SDK virtual image.
- *
- * @return the result of process as IStatus.
- */
- public IStatus uncompressVM(final Shell shell, IProgressMonitor monitor) {
- final StyledTextProgressDialog dialog = new StyledTextProgressDialog(shell, "Uncompressing Image");
- dialog.setBlockOnOpen(false);
-
- dialog.open();
-
- final IStatus[] statuses = { Policy.getCancelStatus(Activator.getDefault()) };
- final IProgressReporter reporter = dialog.getProgressReporter();
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- statuses[0] = doUncompressVM(dialog.getShell(), reporter, monitor);
- }
- });
-
- reporter.log(statuses[0]);
-
- if (statuses[0].isOK() || statuses[0].getSeverity() == IStatus.INFO) {
- dialog.close();
- }
-
- return statuses[0];
- } catch (Exception e) {
- Throwable t;
- if (e instanceof InvocationTargetException)
- t = ((InvocationTargetException) e).getCause();
- else
- t = e;
- IStatus status = Activator.createErrorStatus("Failed to extract image", t);
- Activator.getErrorLogger().log(status);
- return status;
- }
- }
-
- /**
- * Uncompress the Maemo SDK virtual image.
- *
- * @return the result of process as IStatus.
- */
- private IStatus doUncompressVM(final Shell shell, IProgressReporter reporter, IProgressMonitor monitor) {
- monitor.subTask("Uncompressing image...");
- reporter.logInfo("Uncompressing Maemo SDK virtual image...");
-
- String fileName = null;
- MaemoSDKVMInfo fileToDownload = installData.getFileToDownload();
-
- if(installData.getPathOfExistentVM() == null){
- File resolvedLocalFile = fileToDownload.resolveLocalFile();
- if (resolvedLocalFile == null ) {
- return Activator.createStatus(IStatus.ERROR,"Cannot retrieve information about zipped Maemo SDK virtual image.");
- }
- fileName = resolvedLocalFile.getAbsolutePath();
- }else{
- fileName = installData.getPathOfExistentVM();
- }
-
- if (fileName == null ) {
- return Activator.createStatus(IStatus.ERROR,"Cannot retrieve information about zipped Maemo SDK virtual image.");
- }
-
- final String destinationPath = installData.getInstallationPath();
-
- IStatus status = Activator.createStatus(IStatus.OK, "File " + fileName
- + " was properly uncompressed into " + destinationPath) ;
-
-
- int numParts = fileToDownload.getNumParts();
- long requiredSpace = DefaultVMZipExtractor.getEstimatedDecompressedSize(fileName, numParts);
- long freeSpace = DefaultVMZipExtractor.getFreeSpaceSize(fileName);
-
- if(installData.getUncompressToolPath() == null){
- if (!DefaultVMZipExtractor.haveEnoughFreeSpace(fileName,destinationPath) ) {
- return Activator.createStatus(IStatus.ERROR,"There is not enough free space to uncompress the Maemo SDK virtual image files.");
- }
- status = DefaultVMZipExtractor.extract(fileName, shell, destinationPath, reporter);
- }else{
- Tool7zip tool = new Tool7zip(installData.getUncompressToolPath());
-
- if (freeSpace <= requiredSpace ) {
- reporter.log(Activator.createStatus(IStatus.WARNING, "Low disk space warning, perform a disk cleanup."));
- if(!DialogUtils
- .showQuestionDialog(
- DialogUtils.getShell(),
- "Low Disk Space Warning",
- MessageFormat.format(
- "The disk might not have enough free space to uncompress the" +
- " Maemo SDK virtual image files.\n" +
- "(Estimated size: {0}, Free space: {1}) \n" +
- " Do you want to proceed anyway?",
- GeneralUtils.getFormattedString(requiredSpace),
- GeneralUtils.getFormattedString(freeSpace))) ) {
- return Activator.createStatus(IStatus.ERROR,"There is not enough free space to uncompress the Maemo SDK virtual image files.");
- }
- }
- status = tool.extractAndGetStatus(fileName, destinationPath, reporter, monitor);
- }
- return status;
- }
-
- /**
- * Utility method to install Scratchbox into Maemo SDK virtual image.
- * @param shell the shell
- * @param monitor the progress monitor
- * @return the result status of process
- */
- private IStatus installScratchbox(final Shell shell, IProgressMonitor monitor) {
- monitor.subTask("Installing Scratchbox 1...");
- //reporter.queryToContinue("Installing Scratchbox 1 on Maemo SDK virtual image. This operation will take several minutes.");
-
- final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox was properly installed on Maemo SDK virtual image.") } ;
-
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- statuses[0] = NewScratchbox1SDKWizard.startWizard();
- }
-
- });
-
- return statuses[0];
- }
-
- /**
- * Utility method to install Scratchbox targets into Maemo SDK virtual image.
- * @param shell the shell
- * @param monitor the progress monitor
- * @return the result status of process
- */
- private IStatus installScratchboxTargets(final Shell shell, IProgressMonitor monitor) {
- monitor.subTask("Installing Scratchbox 1 targets...");
- //reporter.logInfo("Installing Scratchbox 1 Targets on Maemo SDK virtual image. This operation will take several minutes.");
-
- final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox targets were properly installed on Maemo SDK virtual image.") } ;
-
- final NewScratchbox1TargetWizard wizard = new NewScratchbox1TargetWizard();
- wizard.setSuppressNokiaBinariesWizard(true);
-
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- statuses[0] = NewScratchbox1TargetWizard.startWizard(wizard);
- }
-
- });
-
- // need to break out of syncexec to launch a new wizard on OS X
- if (statuses[0].getSeverity() == IStatus.OK
- || statuses[0].getSeverity() == IStatus.INFO) {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- // now install Nokia binaries synchronously
- wizard.promptInstallNokiaBinaries(true);
- }
- });
- }
-
- return statuses[0];
- }
-
- /**
- * Show a preference dialog that points to virtual image preference page. It is necessary
- * to configure the new virtual image so the installation process can proceeed.
- * @param shell
- * @return
- */
- private IStatus promptPreferencesDialog(final Shell shell, IProgressMonitor monitor) {
- monitor.subTask("Configuring Maemo SDK virtual image...");
- //reporter.logInfo("Configuring Maemo SDK virtual image...");
-
- final IStatus statuses[] = new IStatus[] {Policy.getCancelStatus(Activator.getDefault())};
-
- String vmLocation = configureInitialVMSettings();
-
- if (!vmLocation.trim().equals("")) {
-
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- SDKManagerInternal.getInstance().lock();
-
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
- null, /* do not tie to a shell to avoid #4438 */
- MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
- new String[] {
- MaemoSDKPreferenceIds.ESBOX_PREFERENCE_CATEGORY_ID,
- MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
- },
- null);
- int result = dialog.open();
-
- // user clicked on Cancel
- if (result == Window.CANCEL) {
- statuses[0] = Activator.createErrorStatus("Installation was cancelled.", null);
- return;
- }
-
- // check for valid build machine
- if (MachineRegistry.getInstance().getCurrentBuildMachines().length == 0)
- statuses[0] = Activator.createErrorStatus("Virtual image was not properly configured.", null);
- else
- statuses[0] = Activator.createStatus(IStatus.OK, "Virtual image configured.");
-
- } finally {
- SDKManagerInternal.getInstance().unlock();
- }
- }
- });
- }
-
- return statuses[0];
- }
-
- /**
- * Configure initial VM settings, such as vmx file path.
- */
- public String configureInitialVMSettings() {
- IBuildMachine vmwareMachine = getVMWareMachine();
-
- IVirtualMachineConfiguration machineConfig = ((IVirtualMachine)vmwareMachine).getConfiguration();
-
- MachineRegistry.getInstance().setCurrentBuildMachine(vmwareMachine);
-
- String vmxFileLocation = getLocationVMXFile();
- if (vmxFileLocation != null) {
- vmxFileLocation = installData.getInstallationPath() + File.separator + vmxFileLocation;
- } else {
- vmxFileLocation = "";
- }
-
- ((IVMwareConfiguration)machineConfig).setVmxPath(vmxFileLocation);
-
- return vmxFileLocation;
- }
-
- /**
- * Get current VMWare build machine.
- * @return VMWare build machine.
- */
- private IBuildMachine getVMWareMachine() {
- List<IBuildMachine> availableMachines = new ArrayList<IBuildMachine>(
- Arrays.asList(MachineRegistry.getInstance().getAvailableBuildMachines()));
-
- IBuildMachine vmwareMachine = null;
-
- for (IBuildMachine buildMachine : availableMachines) {
- String machineName = buildMachine.getName();
- if(machineName.contains("VMware")) {
- vmwareMachine = buildMachine;
- break;
- }
- }
-
- return vmwareMachine;
- }
-
- /**
- * Get the location of vmx file.
- * @return
- */
- public String getLocationVMXFile() {
- String result = null;
- File installationPath = new File(installData.getInstallationPath());
- if (installationPath != null && installationPath.exists() && installationPath.isDirectory()) {
- String filesNames[] = installationPath.list();
- for (String fileName : filesNames) {
- String ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length());
- if (ext.equals("vmx")) {
- result = fileName;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Install programming environment packages (python and c++) into Maemo SDK virtual image.
- * @param timeout
- * @param shell
- * @param monitor
- * @return
- */
- private IStatus installPackages(Shell shell, IProgressMonitor monitor) {
- monitor.subTask("Installing programming environment...");
- //reporter.logInfo("Installing Python/C++ programming environment on Maemo SDK virtual image. This operation may take several minutes.");
-
- IStatus status = Policy.getCancelStatus(Activator.getDefault());
-
- ISDKTarget[] sdkTargets = getBuildMachineTargets();
-
- String[] packages = checkPackagesToInstall();
-
- status = AptInstallerHelper.installPackages(sdkTargets, packages, true, shell,
- "Install C++ and Python Programming Environment",
- "Install the C++ and Python development metapackages now?",
- null /*reporter*/, null /*monitor*/);
-
- return status;
- }
-
- /**
- * Get targets of current build machine.
- * @return
- */
- private ISDKTarget[] getBuildMachineTargets() {
- IMachine currentMachine = getBuildMachine();
-
- if (currentMachine == null)
- return new ISDKTarget[0];
-
- List<ISDKTarget> machineTargets = new ArrayList<ISDKTarget>();
-
- ISDKTarget[] sdkTargets = SDKManager.getInstance().getAllSDKTargets();
- for (ISDKTarget target : sdkTargets) {
- IMachine targetMachine = target.getMachine();
- if (targetMachine.getName().equals(currentMachine.getName()))
- machineTargets.add(target);
- }
-
- return machineTargets.toArray(new ISDKTarget[machineTargets.size()]);
- }
-
- /**
- * Get current build machine.
- * @return current build machine or <b>null</b> if any build machine is properly configured.
- */
- private IMachine getBuildMachine() {
- IBuildMachine buildMachines[] =
- MachineRegistry.getInstance().getBuildMachines();
- IBuildMachine machine = null;
- for (IBuildMachine buildMachine : buildMachines) {
- if (buildMachine.isAlive()) {
- machine = buildMachine;
- break;
- }
- }
- return machine;
- }
-
- /**
- * Get packages to be installed into Maemo SDK virtual image based on the given <i>MaemoSDKVMInstallData</i>.
- * @return an array of String with packages to be installed into Maemo SDK virtual image.
- */
- private String[] checkPackagesToInstall() {
- List<String> packagesToInstall = new ArrayList<String>();
-
- if (installData.canInstallCppEnv() || installData.canInstallPythonEnv()) {
- packagesToInstall.add("maemo-debug-scripts");
- packagesToInstall.add("maemo-c-debug-tools");
- if (installData.canInstallCppEnv())
- packagesToInstall.add("maemo-cplusplus-env");
- if (installData.canInstallPythonEnv())
- packagesToInstall.add("maemo-python-env");
- }
-
- return packagesToInstall.toArray(new String[packagesToInstall.size()]);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (c) 2009 Nokia 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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.api.vm.vmware;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo.Status;
+import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1SDKWizard;
+import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1TargetWizard;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.esbox.internal.vm.vmware.ui.wizards.MaemoSDKVMInstallData;
+import org.maemo.esbox.vm.core.IVirtualMachine;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.machine.IBuildMachine;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.core.sdk.SDKManager;
+import org.maemo.mica.common.core.ui.IProgressReporter;
+import org.maemo.mica.common.ui.dialogs.DialogUtils;
+import org.maemo.mica.common.ui.dialogs.StyledTextProgressDialog;
+import org.maemo.mica.internal.api.common.core.GeneralUtils;
+import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
+import org.maemo.mica.internal.api.linux.packages.core.aptinstall.AptInstallerHelper;
+
+/**
+ * This class wraps the main methods used during installation of Maemo SDK
+ * virtual image.
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMInstaller {
+
+ private MaemoSDKVMInstallData installData;
+
+ /**
+ * Constructor.
+ *
+ * @param installData
+ * the installation data
+ * @param reporter
+ * the progress reporter
+ */
+ public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData) {
+ this.installData = installData;
+ }
+
+ /**
+ * Install component into virtual image based on installer data information
+ * @param timeout the timeout
+ * @param shell the shell
+ * @param monitor the monitor
+ * @return the result status as result for the installation process.
+ */
+ public IStatus installVirtualImage(int timeout, Shell shell, IProgressMonitor monitor) {
+ IStatus status = Activator.createStatus(IStatus.OK, "Maemo SDK Virtual Image was properly installed.");
+
+ if (!installData.canUsePreviousInstallation())
+ status = this.downloadVM(shell, monitor);
+
+ if (canProceed(status))
+ status = this.uncompressVM(shell, monitor);
+
+ if (canProceed(status))
+ status = promptPreferencesDialog(shell, monitor);
+
+ if (canProceed(status) && installData.canInstallSbox())
+ status = this.installScratchbox(shell,monitor);
+
+ if (canProceed(status) && installData.canInstallTargets())
+ status = this.installScratchboxTargets(shell,monitor);
+
+ if (canProceed(status) && ((installData.canInstallCppEnv() || installData.canInstallPythonEnv())))
+ status = this.installPackages(shell, monitor);
+
+ return status;
+ }
+
+ /**
+ * Check if can go ahead on installation based on given status.
+ * @param status the status.
+ * @return true if can go ahead on installation process; false, otherwise.
+ */
+ private boolean canProceed(IStatus status) {
+ return ! (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR));
+ }
+
+ /**
+ * Download Maemo SDK virtual image. If the virtual image consists of more
+ * than one file, the other will be also downloaded.
+ *
+ * @return the result of download process as IStatus
+ */
+ public IStatus downloadVM(final Shell shell, IProgressMonitor monitor) {
+ monitor.subTask("Downloading image...");
+ //reporter.reportStep("Downloading Maemo SDK virtual image...");
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ MaemoSDKVMInfo fileDownload = installData.getFileToDownload();
+ DownloadExecution downloadWrapper = (DownloadExecution) fileDownload.downloadFile();
+ try {
+ DownloadProgressMonitor progressMonitor = new DownloadProgressMonitor(shell, downloadWrapper);
+ progressMonitor.run(true, true, downloadWrapper);
+ } catch (Exception exception) {
+ Activator.getErrorLogger().logAndShowError("Error during Maemo SDK virtual image downloading", exception);
+ }
+ }
+
+ });
+ IStatus result = Policy.getCancelStatus(Activator.getDefault());
+ Status downloadStatus = installData.getFileToDownload().getStatus();
+ if (downloadStatus.equals(Status.CANCELLED))
+ result = Activator.createErrorStatus(
+ "Maemo SDK virtual image download was canceled.", null);
+ else if (downloadStatus.equals(Status.ERROR))
+ result = Activator.createErrorStatus(
+ "An error occured during Maemo SDK virtual image download.", null);
+ else if (downloadStatus.equals(Status.COMPLETE))
+ result = Activator.createStatus(IStatus.OK,
+ "Maemo SDK virtual image was properly downloaded.");
+ return result;
+
+ }
+
+ /**
+ * Uncompress the Maemo SDK virtual image.
+ *
+ * @return the result of process as IStatus.
+ */
+ public IStatus uncompressVM(final Shell shell, IProgressMonitor monitor) {
+ final StyledTextProgressDialog dialog = new StyledTextProgressDialog(shell, "Uncompressing Image");
+ dialog.setBlockOnOpen(false);
+
+ dialog.open();
+
+ final IStatus[] statuses = { Policy.getCancelStatus(Activator.getDefault()) };
+ final IProgressReporter reporter = dialog.getProgressReporter();
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ statuses[0] = doUncompressVM(dialog.getShell(), reporter, monitor);
+ }
+ });
+
+ reporter.log(statuses[0]);
+
+ if (statuses[0].isOK() || statuses[0].getSeverity() == IStatus.INFO) {
+ dialog.close();
+ }
+
+ return statuses[0];
+ } catch (Exception e) {
+ Throwable t;
+ if (e instanceof InvocationTargetException)
+ t = ((InvocationTargetException) e).getCause();
+ else
+ t = e;
+ IStatus status = Activator.createErrorStatus("Failed to extract image", t);
+ Activator.getErrorLogger().log(status);
+ return status;
+ }
+ }
+
+ /**
+ * Uncompress the Maemo SDK virtual image.
+ *
+ * @return the result of process as IStatus.
+ */
+ private IStatus doUncompressVM(final Shell shell, IProgressReporter reporter, IProgressMonitor monitor) {
+ monitor.subTask("Uncompressing image...");
+ reporter.logInfo("Uncompressing Maemo SDK virtual image...");
+
+ String fileName = null;
+ MaemoSDKVMInfo fileToDownload = installData.getFileToDownload();
+
+ if(installData.getPathOfExistentVM() == null){
+ File resolvedLocalFile = fileToDownload.resolveLocalFile();
+ if (resolvedLocalFile == null ) {
+ return Activator.createStatus(IStatus.ERROR,"Cannot retrieve information about zipped Maemo SDK virtual image.");
+ }
+ fileName = resolvedLocalFile.getAbsolutePath();
+ }else{
+ fileName = installData.getPathOfExistentVM();
+ }
+
+ if (fileName == null ) {
+ return Activator.createStatus(IStatus.ERROR,"Cannot retrieve information about zipped Maemo SDK virtual image.");
+ }
+
+ final String destinationPath = installData.getInstallationPath();
+
+ IStatus status = Activator.createStatus(IStatus.OK, "File " + fileName
+ + " was properly uncompressed into " + destinationPath) ;
+
+
+ int numParts = fileToDownload.getNumParts();
+ long requiredSpace = DefaultVMZipExtractor.getEstimatedDecompressedSize(fileName, numParts);
+ long freeSpace = DefaultVMZipExtractor.getFreeSpaceSize(fileName);
+
+ if(installData.getUncompressToolPath() == null){
+ if (!DefaultVMZipExtractor.haveEnoughFreeSpace(fileName,destinationPath) ) {
+ return Activator.createStatus(IStatus.ERROR,"There is not enough free space to uncompress the Maemo SDK virtual image files.");
+ }
+ status = DefaultVMZipExtractor.extract(fileName, shell, destinationPath, reporter);
+ }else{
+ Tool7zip tool = new Tool7zip(installData.getUncompressToolPath());
+
+ if (freeSpace <= requiredSpace ) {
+ reporter.log(Activator.createStatus(IStatus.WARNING, "Low disk space warning, perform a disk cleanup."));
+ if(!DialogUtils
+ .showQuestionDialog(
+ DialogUtils.getShell(),
+ "Low Disk Space Warning",
+ MessageFormat.format(
+ "The disk might not have enough free space to uncompress the" +
+ " Maemo SDK virtual image files.\n" +
+ "(Estimated size: {0}, Free space: {1}) \n" +
+ " Do you want to proceed anyway?",
+ GeneralUtils.getFormattedString(requiredSpace),
+ GeneralUtils.getFormattedString(freeSpace))) ) {
+ return Activator.createStatus(IStatus.ERROR,"There is not enough free space to uncompress the Maemo SDK virtual image files.");
+ }
+ }
+ status = tool.extractAndGetStatus(fileName, destinationPath, reporter, monitor);
+ }
+ return status;
+ }
+
+ /**
+ * Utility method to install Scratchbox into Maemo SDK virtual image.
+ * @param shell the shell
+ * @param monitor the progress monitor
+ * @return the result status of process
+ */
+ private IStatus installScratchbox(final Shell shell, IProgressMonitor monitor) {
+ monitor.subTask("Installing Scratchbox 1...");
+ //reporter.queryToContinue("Installing Scratchbox 1 on Maemo SDK virtual image. This operation will take several minutes.");
+
+ final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox was properly installed on Maemo SDK virtual image.") } ;
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ statuses[0] = NewScratchbox1SDKWizard.startWizard();
+ }
+
+ });
+
+ return statuses[0];
+ }
+
+ /**
+ * Utility method to install Scratchbox targets into Maemo SDK virtual image.
+ * @param shell the shell
+ * @param monitor the progress monitor
+ * @return the result status of process
+ */
+ private IStatus installScratchboxTargets(final Shell shell, IProgressMonitor monitor) {
+ monitor.subTask("Installing Scratchbox 1 targets...");
+ //reporter.logInfo("Installing Scratchbox 1 Targets on Maemo SDK virtual image. This operation will take several minutes.");
+
+ final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox targets were properly installed on Maemo SDK virtual image.") } ;
+
+ final NewScratchbox1TargetWizard wizard = new NewScratchbox1TargetWizard();
+ wizard.setSuppressNokiaBinariesWizard(true);
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ statuses[0] = NewScratchbox1TargetWizard.startWizard(wizard);
+ }
+
+ });
+
+ // need to break out of syncexec to launch a new wizard on OS X
+ if (statuses[0].getSeverity() == IStatus.OK
+ || statuses[0].getSeverity() == IStatus.INFO) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ // now install Nokia binaries synchronously
+ wizard.promptInstallNokiaBinaries(true);
+ }
+ });
+ }
+
+ return statuses[0];
+ }
+
+ /**
+ * Show a preference dialog that points to virtual image preference page. It is necessary
+ * to configure the new virtual image so the installation process can proceeed.
+ * @param shell
+ * @return
+ */
+ private IStatus promptPreferencesDialog(final Shell shell, IProgressMonitor monitor) {
+ monitor.subTask("Configuring Maemo SDK virtual image...");
+ //reporter.logInfo("Configuring Maemo SDK virtual image...");
+
+ final IStatus statuses[] = new IStatus[] {Policy.getCancelStatus(Activator.getDefault())};
+
+ String vmLocation = configureInitialVMSettings();
+
+ if (!vmLocation.trim().equals("")) {
+
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ SDKManagerInternal.getInstance().lock();
+
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ null, /* do not tie to a shell to avoid #4438 */
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
+ new String[] {
+ MaemoSDKPreferenceIds.ESBOX_PREFERENCE_CATEGORY_ID,
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
+ },
+ null);
+ int result = dialog.open();
+
+ // user clicked on Cancel
+ if (result == Window.CANCEL) {
+ statuses[0] = Activator.createErrorStatus("Installation was cancelled.", null);
+ return;
+ }
+
+ // check for valid build machine
+ if (MachineRegistry.getInstance().getCurrentBuildMachines().length == 0)
+ statuses[0] = Activator.createErrorStatus("Virtual image was not properly configured.", null);
+ else
+ statuses[0] = Activator.createStatus(IStatus.OK, "Virtual image configured.");
+
+ } finally {
+ SDKManagerInternal.getInstance().unlock();
+ }
+ }
+ });
+ }
+
+ return statuses[0];
+ }
+
+ /**
+ * Configure initial VM settings, such as vmx file path.
+ */
+ public String configureInitialVMSettings() {
+ IBuildMachine vmwareMachine = getVMWareMachine();
+
+ IVirtualMachineConfiguration machineConfig = ((IVirtualMachine)vmwareMachine).getConfiguration();
+
+ MachineRegistry.getInstance().setCurrentBuildMachine(vmwareMachine);
+
+ String vmxFileLocation = getLocationVMXFile();
+ if (vmxFileLocation != null) {
+ vmxFileLocation = installData.getInstallationPath() + File.separator + vmxFileLocation;
+ } else {
+ vmxFileLocation = "";
+ }
+
+ ((IVMwareConfiguration)machineConfig).setVmxPath(vmxFileLocation);
+
+ return vmxFileLocation;
+ }
+
+ /**
+ * Get current VMWare build machine.
+ * @return VMWare build machine.
+ */
+ private IBuildMachine getVMWareMachine() {
+ List<IBuildMachine> availableMachines = new ArrayList<IBuildMachine>(
+ Arrays.asList(MachineRegistry.getInstance().getAvailableBuildMachines()));
+
+ IBuildMachine vmwareMachine = null;
+
+ for (IBuildMachine buildMachine : availableMachines) {
+ String machineName = buildMachine.getName();
+ if(machineName.contains("VMware")) {
+ vmwareMachine = buildMachine;
+ break;
+ }
+ }
+
+ return vmwareMachine;
+ }
+
+ /**
+ * Get the location of vmx file.
+ * @return
+ */
+ public String getLocationVMXFile() {
+ String result = null;
+ File installationPath = new File(installData.getInstallationPath());
+ if (installationPath != null && installationPath.exists() && installationPath.isDirectory()) {
+ String filesNames[] = installationPath.list();
+ for (String fileName : filesNames) {
+ String ext = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length());
+ if (ext.equals("vmx")) {
+ result = fileName;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Install programming environment packages (python and c++) into Maemo SDK virtual image.
+ * @param timeout
+ * @param shell
+ * @param monitor
+ * @return
+ */
+ private IStatus installPackages(Shell shell, IProgressMonitor monitor) {
+ monitor.subTask("Installing programming environment...");
+ //reporter.logInfo("Installing Python/C++ programming environment on Maemo SDK virtual image. This operation may take several minutes.");
+
+ IStatus status = Policy.getCancelStatus(Activator.getDefault());
+
+ ISDKTarget[] sdkTargets = getBuildMachineTargets();
+
+ String[] packages = checkPackagesToInstall();
+
+ status = AptInstallerHelper.installPackages(sdkTargets, packages, true, shell,
+ "Install C++ and Python Programming Environment",
+ "Install the C++ and Python development metapackages now?",
+ null /*reporter*/, null /*monitor*/);
+
+ return status;
+ }
+
+ /**
+ * Get targets of current build machine.
+ * @return
+ */
+ private ISDKTarget[] getBuildMachineTargets() {
+ IMachine currentMachine = getBuildMachine();
+
+ if (currentMachine == null)
+ return new ISDKTarget[0];
+
+ List<ISDKTarget> machineTargets = new ArrayList<ISDKTarget>();
+
+ ISDKTarget[] sdkTargets = SDKManager.getInstance().getAllSDKTargets();
+ for (ISDKTarget target : sdkTargets) {
+ IMachine targetMachine = target.getMachine();
+ if (targetMachine.getName().equals(currentMachine.getName()))
+ machineTargets.add(target);
+ }
+
+ return machineTargets.toArray(new ISDKTarget[machineTargets.size()]);
+ }
+
+ /**
+ * Get current build machine.
+ * @return current build machine or <b>null</b> if any build machine is properly configured.
+ */
+ private IMachine getBuildMachine() {
+ IBuildMachine buildMachines[] =
+ MachineRegistry.getInstance().getBuildMachines();
+ IBuildMachine machine = null;
+ for (IBuildMachine buildMachine : buildMachines) {
+ if (buildMachine.isAlive()) {
+ machine = buildMachine;
+ break;
+ }
+ }
+ return machine;
+ }
+
+ /**
+ * Get packages to be installed into Maemo SDK virtual image based on the given <i>MaemoSDKVMInstallData</i>.
+ * @return an array of String with packages to be installed into Maemo SDK virtual image.
+ */
+ private String[] checkPackagesToInstall() {
+ List<String> packagesToInstall = new ArrayList<String>();
+
+ if (installData.canInstallCppEnv() || installData.canInstallPythonEnv()) {
+ packagesToInstall.add("maemo-debug-scripts");
+ packagesToInstall.add("maemo-c-debug-tools");
+ if (installData.canInstallCppEnv())
+ packagesToInstall.add("maemo-cplusplus-env");
+ if (installData.canInstallPythonEnv())
+ packagesToInstall.add("maemo-python-env");
+ }
+
+ return packagesToInstall.toArray(new String[packagesToInstall.size()]);
+ }
+
+}
Property changes on: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Esbox-commits
mailing list