package org.tizen.nativeplatform.rootstrap;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.model.Rootstrap;
import org.tizen.nativecommon.build.model.SBIModel;
import org.tizen.nativecommon.build.model.Target;
-import org.tizen.nativeplatform.password.SudoPasswdManager;
import org.tizen.nativeplatform.preferences.PreferencesManager;
+import org.tizen.nativeplatform.util.CommandLauncher;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
if ( rootstrap != null ) {
rootstraps.remove( rootstrap );
removeSBIPluginXML( rootstrap );
- removeBaseFileSystem( rootstrap.getId() );
+ try {
+ removeBaseFileSystem( rootstrap.getId() , rootstrap.getArch());
+ } catch (InterruptedException e) {
+ // do nothing
+ }
RootstrapManager.notifyChangedRootstrap();
return true;
}
public static boolean exportRootstrap(
- PlatformRootstrap rootstrap,
- String exportFilePath) {
+ PlatformRootstrap rootstrap, String exportFilePath,
+ IProgressMonitor monitor) throws InterruptedException {
// make temp directory
String tempDirPath = makeTempDirectory();
// zip file-system
String basePath = rootstrap.getPath().removeLastSegments(1).toOSString();
String rootstrapID = rootstrap.getId();
- if( !commandWithSudo( String.format("cd %s;sudo -S tar cvzf %s/rootstrap.tar.gz %s",
- basePath, tempDirPath, rootstrapID), "Platform Internal" ) ) {
+ if( !CommandLauncher.executeSudo( String.format("sudo -S tar cvzf %s/rootstrap.tar.gz %s",
+ tempDirPath, rootstrapID), basePath, "Platform Internal", monitor ) ) {
return false;
}
String pluginFileName = rootstrap.getId() + ".xml";
String pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath())
.append(pluginFileName).toOSString();
- if ( !commandWithSudo( String.format("cp %s %s/", pluginPath, tempDirPath ), null) ) {
+ if ( !CommandLauncher.executeSudo( String.format("cp %s %s/", pluginPath, tempDirPath )) ) {
return false;
}
// zip them together
- if ( !commandWithSudo( String.format("cd %s;tar cvf %s rootstrap.tar.gz %s",
- tempDirPath, exportFilePath, pluginFileName), "Platform Internal" ) ) {
+ if ( !CommandLauncher.executeSudo( String.format("tar cvf %s rootstrap.tar.gz %s",
+ exportFilePath, pluginFileName), tempDirPath, "Platform Internal", monitor ) ) {
return false;
}
}
finally {
// remove temporary directory
- commandWithSudo( String.format("sudo -S rm -rf %s",tempDirPath), null );
+ CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s",tempDirPath) );
}
}
- public static PlatformRootstrap importRootstrap( String importFilePath) throws Exception {
+ public static PlatformRootstrap importRootstrap( String importFilePath,
+ IProgressMonitor monitor) throws InterruptedException {
+
PlatformRootstrap result = null;
String pluginPath = null;
String rootstrapPath = null;
try {
// extract "tar" archive
- if( !commandWithSudo( String.format("cd %s;tar xvf %s",
- tempDirPath, importFilePath), "Platform Internal" ) ) {
- throw new Exception("Extracting rootsrap failed!");
+ if( !CommandLauncher.executeSudo( String.format("tar xvf %s",
+ importFilePath), tempDirPath, "Platform Internal", monitor ) ) {
+ throw new InterruptedException("Extracting rootsrap failed!");
}
// find rootstrap id
} );
if ( xmlFiles.length == 0 ) {
- throw new Exception("There is no SBI plugin file(*.xml)");
+ throw new InterruptedException("There is no SBI plugin file(*.xml)");
}
String pluginFilePath = xmlFiles[0].getPath().toString();
String pluginFileName = new File(pluginFilePath).getName();
// check already exist?
if( RootstrapManager.getRootstrap(pluginId) != null ) {
- throw new Exception("There already exists the rootrap with same id!");
+ throw new InterruptedException("There already exists the rootrap with same id!");
}
// copy xml
pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath())
.append(pluginFileName).toOSString();
- commandWithSudo( String.format("cp %s %s", pluginFilePath, pluginPath), null);
+ CommandLauncher.executeSudo( String.format("cp %s %s", pluginFilePath, pluginPath), null);
// extracting file system
String basePath = SmartBuildInterface.getInstance().getBaseRootstrapPath()+"/platform";
if ( !(baseDirDir.exists()) ) {
baseDirDir.mkdir();
}
- if ( !commandWithSudo( String.format("cd %s;sudo -S tar xvf %s/rootstrap.tar.gz",
- basePath, tempDirPath), "Platform Internal" ) ) {
- throw new Exception("Extracting rootsrap failed!");
+ if ( !CommandLauncher.executeSudo( String.format("sudo -S tar xvf %s/rootstrap.tar.gz",
+ tempDirPath), basePath, "Platform Internal", monitor ) ) {
+ throw new InterruptedException("Extracting rootsrap failed!");
}
SBIModel.reinitialize();
result = createRootstrapFromSBIPlugin( pluginId );
if ( result == null ) {
- throw new Exception("Loading SBI plugin failed!");
+ throw new InterruptedException("Loading SBI plugin failed!");
}
return result;
}
catch (Exception e) {
if ( pluginPath != null ) {
- commandWithSudo( String.format("rm -rf %s", pluginPath), null );
- SBIModel.reinitialize();
+ CommandLauncher.executeSudo( String.format("rm -rf %s", pluginPath), null );
+ try {
+ SBIModel.reinitialize();
+ } catch (SBIException e1) {
+ throw new InterruptedException(e1.getMessage());
+ }
}
if ( rootstrapPath != null ) {
- commandWithSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null );
+ CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null );
}
- throw e;
+ throw new InterruptedException(e.getMessage());
}
finally {
// remove temporary directory
- commandWithSudo( String.format("sudo -S rm -rf %s",tempDirPath), null );
+ CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s",tempDirPath), null );
}
}
public static PlatformRootstrap generate(String name, String arch,
- ArrayList<String> reposURLs, boolean immediateGen) {
+ ArrayList<String> reposURLs, boolean immediateGen,
+ IProgressMonitor monitor) throws InterruptedException {
boolean initialized = false;
String id = name;
if ( immediateGen ) {
- if ( generateBaseFileSystem(id, arch, reposURLs) ) {
+ if ( generateBaseFileSystem(id, arch, reposURLs, monitor) ) {
initialized = true;
}
else {
- removeBaseFileSystem(id);
return null;
}
}
}
else {
if ( immediateGen ) {
- removeBaseFileSystem(id);
+ removeBaseFileSystem(id, arch);
}
return null;
}
private static boolean generateBaseFileSystem(String id, String arch,
- ArrayList<String> reposURLs) {
+ ArrayList<String> reposURLs, IProgressMonitor monitor) throws InterruptedException {
- // remove temp directory if exist
- if ( !commandWithSudo(String.format("sudo -S rm -rf %s", id), null) ) {
- // this is for checking sudo password error
- return false;
- }
-
- // use rogen
- String rogen = InstallPathConfig.getSDKPath()+"/tools/rogen/bin/rogen.rb";
- String baseArch = getBaseArchitecture(arch);
- String urlData = "";
- for( String url: reposURLs ) {
- urlData += (urlData.isEmpty() ? url : "," + url );
- }
-
- String command;
- if ( PreferencesManager.isProxyUsed() ) {
- String protocol = PreferencesManager.getProxyProtocol();
- String host = PreferencesManager.getProxyHost();
- int port = PreferencesManager.getProxyPort();
- String envSetup = String.format("%s_proxy=%s://%s:%d", protocol, protocol, host, port);
- command = String.format( "%s %s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
- envSetup, rogen, id, baseArch, urlData );
- }
- else {
- command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
- rogen, id, baseArch, urlData );
+ String tempDirPath = null;
+ try {
+ // make temp directory
+ tempDirPath = makeTempDirectory();
+
+ // use rogen
+ String rogen = InstallPathConfig.getSDKPath()+"/tools/rogen/bin/rogen.rb";
+ String baseArch = getBaseArchitecture(arch);
+ String urlData = "";
+ for( String url: reposURLs ) {
+ urlData += (urlData.isEmpty() ? url : "," + url );
+ }
+
+ String command;
+ if ( PreferencesManager.isProxyUsed() ) {
+ String protocol = PreferencesManager.getProxyProtocol();
+ String host = PreferencesManager.getProxyHost();
+ int port = PreferencesManager.getProxyPort();
+ String envSetup = String.format("%s_proxy=%s://%s:%d", protocol, protocol, host, port);
+ command = String.format( "%s %s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+ envSetup, rogen, id, baseArch, urlData );
+ }
+ else {
+ command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+ rogen, id, baseArch, urlData );
+ }
+
+ if ( !CommandLauncher.executeSudo( command, tempDirPath, "Platform Internal", monitor) ) {
+ return false;
+ }
+
+ // copy
+ String rootstrapBasePath = new File(getRootstrapPath(id)).getParent();
+ CommandLauncher.executeSudo(String.format("sudo -S mkdir -p %s", rootstrapBasePath), tempDirPath);
+ CommandLauncher.executeSudo(String.format("sudo -S mv %/%s %s/", tempDirPath, id, rootstrapBasePath), tempDirPath);
}
-
- if ( !commandWithSudo( command, "Platform Internal") ) {
- return false;
+ finally {
+ if ( new File(tempDirPath).exists() ) {
+ // check sub-directory
+ String checkDir = String.format("%s/%s/local/scratch.%s.0/proc", tempDirPath, id, arch );
+ if ( new File(checkDir).exists() ) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+ checkDir = String.format("%s/%s/local/scratch.%s.0/dev/pts", tempDirPath, id, arch );
+ if ( new File(checkDir).exists() ) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+
+ // remove
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", tempDirPath));
+ }
}
-
- // copy
- String rootstrapBasePath = new File(getRootstrapPath(id)).getParent();
- commandWithSudo(String.format("sudo -S mkdir -p %s", rootstrapBasePath), null);
- commandWithSudo(String.format("sudo -S mv %s %s/", id, rootstrapBasePath), null);
-
+
return true;
}
- private static void removeBaseFileSystem( String id ) {
+ private static void removeBaseFileSystem( String id, String arch ) throws InterruptedException {
String path = getRootstrapPath( id );
- commandWithSudo( String.format("sudo -S rm -rf %s", path), null );
+ // check sub-directory
+ String checkDir = String.format("%s/local/scratch.%s.0/proc", path, arch );
+ if ( new File(checkDir).exists() ) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+ checkDir = String.format("%s/local/scratch.%s.0/dev/pts", path, arch );
+ if ( new File(checkDir).exists() ) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+
+ CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", path), null );
}
}
- private static boolean commandWithSudo( String command, String consoleName ) {
- String passwd = SudoPasswdManager.getSudoPassword();
- try {
- // create expect script file
- File expectScript = new File("/tmp/run_sudo.exp");
- expectScript.createNewFile();
- BufferedWriter bw = new BufferedWriter(new FileWriter(expectScript));
- bw.write("#!/usr/bin/expect --");bw.newLine();
- bw.write(String.format("spawn sh -c \"%s;echo \\$? > /tmp/exit-status\"",command));bw.newLine();
- bw.write("while (1) {");bw.newLine();
- bw.write(" expect {");bw.newLine();
- bw.write(" \"password for\" {");bw.newLine();
- bw.write(String.format("send \"%s\\r\"", passwd));bw.newLine();
- bw.write(" }");bw.newLine();
- bw.write(" eof {");bw.newLine();
- bw.write(" return");bw.newLine();
- bw.write(" }");bw.newLine();
- bw.write(" }");bw.newLine();
- bw.write("}");bw.newLine();
- bw.close();
- expectScript.setExecutable(true);
-
- File shellScript = new File("/tmp/run_sudo.sh");
- shellScript.createNewFile();
- bw = new BufferedWriter(new FileWriter(shellScript));
- bw.write("#!/bin/sh -ee");bw.newLine();
- bw.write("/tmp/run_sudo.exp");bw.newLine();
- bw.write("EXIT_CODE=`cat /tmp/exit-status`");bw.newLine();
- bw.write("if [ \"$EXIT_CODE\" != \"0\" ]; then");bw.newLine();
- bw.write(" echo \"EXIT CODE=${EXIT_CODE}\" >&2");bw.newLine();
- bw.write(" exit 1");bw.newLine();
- bw.write("fi");bw.newLine();
- bw.close();
- shellScript.setExecutable(true);
-
- // execute script
- String scriptCommand = shellScript.getPath();
- if (consoleName != null && !consoleName.isEmpty() ) {
- SmartBuildInterface.getInstance().commandConsole(scriptCommand, "/tmp", consoleName);
- }
- else {
- SmartBuildInterface.getInstance().command(scriptCommand, "/tmp");
- }
- }
- catch (IOException e) {
- e.printStackTrace();
- return false;
- } catch (SBIException e) {
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
-
-
public static boolean generateSBIPluginXML( String id, String name, String arch, ArrayList<String> reposURLs) {
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.util.HostUtil;
+import org.tizen.nativeplatform.password.SudoPasswdManager;
+
+public class CommandLauncher {
+ public static boolean executeSudo(String command ) throws InterruptedException {
+ return executeSudo( command, null, null, null );
+ }
+
+
+ public static boolean executeSudo(String command, String workingDir ) throws InterruptedException {
+ return executeSudo( command, workingDir, null, null );
+ }
+
+
+ public static boolean executeSudo(String command, String workingDir,
+ String consoleViewName, IProgressMonitor monitor ) throws InterruptedException {
+
+ // generate script
+ String scriptCmd = genSudoExecuteScript(command);
+ if ( scriptCmd == null ) {
+ throw new InterruptedException("Generating execution script failed!");
+ }
+
+ // start process
+ Process proc = createProcess( scriptCmd, workingDir );
+
+ // create monitor process
+ ProcessMonitorThread monitorThread = null;
+ if ( monitor != null ) {
+ monitorThread = new ProcessMonitorThread(proc, monitor);
+ monitorThread.start();
+ }
+
+ // handle console
+ if( consoleViewName != null ) {
+ ConsoleManager cm = new ConsoleManager( consoleViewName, true );
+ cm.clear();
+ BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ try {
+ while((line=input.readLine())!=null){
+ cm.println(line);
+ }
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ proc.waitFor();
+ if ( monitor != null ) {
+ monitorThread.join();
+ if ( monitor.isCanceled() ) {
+ throw new InterruptedException("Command execution is canceled!");
+ }
+ }
+
+ // abnormal termination
+ if (proc.exitValue() != 0) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+
+ public static Process createProcess(String command, String workingDir ) throws InterruptedException {
+ // start process
+ String[] fullCommand = HostUtil.getCommand(command);
+ ProcessBuilder pb = new ProcessBuilder();
+ pb.redirectErrorStream(true);
+ pb.command(fullCommand);
+ if(workingDir != null) {
+ pb.directory(new File(workingDir));
+ }
+ Process proc;
+ try {
+ proc = pb.start();
+ } catch (IOException e) {
+ throw new InterruptedException("Creating process failed!");
+ }
+
+ return proc;
+ }
+
+
+ // return generate script and return script path
+ private static String genSudoExecuteScript(String command) {
+ String passwd = SudoPasswdManager.getSudoPassword();
+ File shellScript = null;
+
+ try {
+ // create expect script file
+ File expectScript = new File("/tmp/run_sudo.exp");
+ expectScript.createNewFile();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(expectScript));
+ bw.write("#!/usr/bin/expect --");bw.newLine();
+ bw.write(String.format("spawn sh -c \"%s;echo \\$? > /tmp/exit-status\"",command));bw.newLine();
+ bw.write("while (1) {");bw.newLine();
+ bw.write(" expect {");bw.newLine();
+ bw.write(" \"password for\" {");bw.newLine();
+ bw.write(String.format("send \"%s\\r\"", passwd));bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write(" eof {");bw.newLine();
+ bw.write(" return");bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write("}");bw.newLine();
+ bw.close();
+ expectScript.setExecutable(true);
+
+ shellScript = new File("/tmp/run_sudo.sh");
+ shellScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(shellScript));
+ bw.write("#!/bin/sh -ee");bw.newLine();
+ bw.write("/tmp/run_sudo.exp");bw.newLine();
+ bw.write("EXIT_CODE=`cat /tmp/exit-status`");bw.newLine();
+ bw.write("if [ \"$EXIT_CODE\" != \"0\" ]; then");bw.newLine();
+ bw.write(" echo \"EXIT CODE=${EXIT_CODE}\" >&2");bw.newLine();
+ bw.write(" exit 1");bw.newLine();
+ bw.write("fi");bw.newLine();
+ bw.close();
+ shellScript.setExecutable(true);
+ }
+ catch (IOException e ) {
+ return null;
+ }
+
+ // execute script
+ return shellScript.getPath();
+ }
+
+
+ // return generate script and return script path
+ private static String genSudoKillProcessScript(Process process) {
+ String passwd = SudoPasswdManager.getSudoPassword();
+ File shellScript = null;
+
+ try {
+ // get process id
+ Field f = process.getClass().getDeclaredField("pid");
+ f.setAccessible(true);
+ String pid = f.get(process).toString();
+
+ // create killtree script file
+ File killScript = new File("/tmp/killtree.sh");
+ killScript.createNewFile();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(killScript));
+ bw.write("#!/bin/sh");bw.newLine();
+ bw.write("killtree() {");bw.newLine();
+ bw.write(" local _pid=$1");bw.newLine();
+ bw.write(" sudo kill -STOP ${_pid}");bw.newLine();
+ bw.write(" for _child in $(ps -o pid --no-headers --ppid ${_pid}); do");bw.newLine();
+ bw.write(" killtree ${_child}");bw.newLine();
+ bw.write(" done");bw.newLine();
+ bw.write(" sudo kill -KILL ${_pid}");bw.newLine();
+ bw.write("}");bw.newLine();
+ bw.write("killtree $1");bw.newLine();
+ bw.close();
+ killScript.setExecutable(true);
+
+ // create expect script file
+ File expectScript = new File("/tmp/run_sudo2.exp");
+ expectScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(expectScript));
+ bw.write("#!/usr/bin/expect --");bw.newLine();
+ bw.write(String.format("spawn sh -c \"/tmp/killtree.sh %s\"",pid ));bw.newLine();
+ bw.write("while (1) {");bw.newLine();
+ bw.write(" expect {");bw.newLine();
+ bw.write(" \"password for\" {");bw.newLine();
+ bw.write(String.format("send \"%s\\r\"", passwd));bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write(" eof {");bw.newLine();
+ bw.write(" return");bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write(" }");bw.newLine();
+ bw.write("}");bw.newLine();
+ bw.close();
+ expectScript.setExecutable(true);
+
+ shellScript = new File("/tmp/run_sudo2.sh");
+ shellScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(shellScript));
+ bw.write("#!/bin/sh -ee");bw.newLine();
+ bw.write("/tmp/run_sudo2.exp");bw.newLine();
+ bw.close();
+ shellScript.setExecutable(true);
+
+ return shellScript.getPath();
+ }
+ catch (Exception e ) {
+ return null;
+ }
+ }
+
+
+ static class ProcessMonitorThread extends Thread {
+ private Process process;
+ private IProgressMonitor monitor;
+ public ProcessMonitorThread(Process process, IProgressMonitor monitor) {
+ this.process = process;
+ this.monitor = monitor;
+ }
+
+
+ public void run() {
+ boolean sendSignal = false;
+ while( true ) {
+ try {
+ Thread.sleep(1000); // wait 1 sec
+ if ( !sendSignal && monitor.isCanceled() ) {
+ String killCmd = genSudoKillProcessScript( process );
+ Process killProcess = createProcess( killCmd, null );
+ killProcess.waitFor();
+ sendSignal = true;
+ }
+ process.exitValue();
+ break;
+ }
+ catch(Exception e) {
+ continue;
+ }
+ }
+ }
+ }
+}
// generate rootstrap here
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
- dialog.run(true, false, new IRunnableWithProgress() {
+ dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Generating"), -1);
generatedRootstrap = null;
- generatedRootstrap = RootstrapManager.generate(rootstrapName, arch, repositoryURLs, immediateGen);
+ generatedRootstrap = RootstrapManager.generate(rootstrapName, arch, repositoryURLs, immediateGen, monitor);
if ( generatedRootstrap == null ) {
throw new InterruptedException();
}
}
});
} catch (Exception e1) {
- e1.printStackTrace();
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed") );
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
+ e1.getMessage()));
return;
}
// generate rootstrap here
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
- dialog.run(true, false, new IRunnableWithProgress() {
+ dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(resources.getString("Action.Msg.Progress.Importing"), -1);
generatedRootstrap = null;
try {
- generatedRootstrap = RootstrapManager.importRootstrap( selectedFilePath );
+ generatedRootstrap = RootstrapManager.importRootstrap( selectedFilePath, monitor );
} catch (Exception e) {
throw new InterruptedException(e.getMessage());
}
}
});
} catch (Exception e1) {
- DialogUtil.openErrorDialog(
- String.format("%s\n * %s", resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
- e1.getMessage() ) );
+ DialogUtil.openErrorDialog( String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
+ e1.getMessage() ) );
return;
}
{
Table table = tableViewer.getTable();
TableItem[] item = table.getSelection();
- PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
+ final PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
// default rootstrap cannot be removed!
PlatformRootstrap defaultRootstrap = RootstrapManager.getDefaultRootstrap( selected.getArch() );
IWorkspace works = ResourcesPlugin.getWorkspace();
IProject[] projs = works.getRoot().getProjects();
- for (final IProject proj : projs) {
+ for (IProject proj : projs) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(proj);
+ if ( info == null ) continue;
+ IConfiguration config = info.getDefaultConfiguration();
+ if ( config == null ) continue;
+ IManagedProject managedProject = config.getManagedProject();
+ String projectArtifactType = managedProject.getProjectType() != null ?
+ managedProject.getProjectType().getBuildArtefactType().getId() : null;
+ if ( managedProject == null ||
+ projectArtifactType != PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE) continue;
+
setActiveRootstrap( proj, defaultRootstrap );
}
// generate rootstrap here
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
- dialog.run(true, false, new IRunnableWithProgress() {
+ dialog.run(true, true, new IRunnableWithProgress() {
@Override
- public void run(IProgressMonitor monitor) {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+
monitor.beginTask(resources.getString("Action.Msg.Progress.Exporting"), -1);
- boolean result = RootstrapManager.exportRootstrap( selectedRootstrap, selectedFilePath );
+ boolean result = RootstrapManager.exportRootstrap( selectedRootstrap, selectedFilePath, monitor );
if ( result ) {
DialogUtil.openMessageDialog(shell,resources.getString("Action.Msg.Info.ExportOK"));
}
}
});
} catch (Exception e1) {
- e1.printStackTrace();
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed") );
+ DialogUtil.openErrorDialog( String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.ExportFailed"),
+ e1.getMessage() ) );
return;
}
}