import org.tizen.nativeplatform.types.CmdTargetTypes;
import org.tizen.nativeplatform.types.LaunchTypes;
import org.tizen.nativeplatform.util.PackageUtil;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
import org.tizen.nativeplatform.util.PlatformProjectUtil;
public class LaunchConfigurationProcessor implements ILaunchConfigurationProcessor {
if (!installPackages(configurationIsSet, new SubProgressMonitor(monitor, 1))) {
descMsg = "Installation seems to be failed. Check package installation log.";
}
- if (!setLaunchConfigurationForEFL(new SubProgressMonitor(monitor, 1), descMsg,
- isEflApp)) {
+ if (!setLaunchConfiguration(new SubProgressMonitor(monitor, 1), descMsg, isEflApp)) {
return false;
}
} finally {
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, new SubProgressMonitor(
monitor, 1));
+ setSmackRule();
} else {
pkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
}
}
+ private void setSmackRule() {
+ String[] programPaths = PlatformLaunchUtil.getProgramPath(project);
+ if (programPaths == null || programPaths.length <= 0) {
+ return;
+ }
+ IPkgCommander commander = target.getDeviceCommander();
+ StringBuffer pathlist = new StringBuffer();
+ for (String path : programPaths) {
+ pathlist.append(path);
+ pathlist.append(" ");
+ }
+ String list = pathlist.toString().trim();
+ Map<String, String[]> smackInfo = PlatformLaunchUtil.getSmackInfo(commander, list);
+ if (smackInfo == null) {
+ return;
+ }
+ for (String filepath : smackInfo.keySet()) {
+ String[] labels = smackInfo.get(filepath);
+ String a_label = labels[0];
+ if (a_label != null && !a_label.isEmpty()) {
+ commander.executeBinary(getSmackRuleCommand(a_label));
+ }
+ commander.setSmackExecute(filepath, "\"\"");
+ }
+ }
+
+ private String getSmackRuleCommand(String value) {
+ value = value.replaceAll("\"", "");
+ String cmd = String.format("echo \"sdbd::home %s rwx\" | smackload", value);
+ return cmd;
+ }
+
@SuppressWarnings("unchecked")
private boolean installPackages(boolean configurationIsSet, IProgressMonitor monitor)
throws CoreException {
}
}
- private boolean setLaunchConfigurationForEFL(IProgressMonitor monitor, final String descMsg,
+ private boolean setLaunchConfiguration(IProgressMonitor monitor, final String descMsg,
final boolean isEflApp) throws CoreException {
monitor.beginTask("", 1);
final ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy();
protected IConfiguration getBuildConfiguration() {
return PlatformConfigurationManager.getDefaultConfiguration(project);
}
-
- protected boolean questionIfNoPackagesToInstall(List<IPackage> devicePackages, List<IPackage> rootstrapPackages) {
+
+ protected boolean questionIfNoPackagesToInstall(List<IPackage> devicePackages,
+ List<IPackage> rootstrapPackages) {
final StringBuffer msg = new StringBuffer();
if (devicePackages.isEmpty()) {
msg.append("There is no package to install to device.");
msg.append("\n");
- }
+ }
if (mode.equals(ILaunchManager.DEBUG_MODE) && rootstrapPackages.isEmpty()) {
msg.append("There is no package to install to rootstrap.");
msg.append("\n");
ICommandStatus makeDir(String path);
ICommandStatus removeFile(String path);
+
+ ICommandStatus setSmackExecute(String path, String e_label);
ICommandStatus changeSmack(String path, String a_label, String e_label);
@Override
public void cancelExecution() {
}
+
+ @Override
+ public ICommandStatus setSmackExecute(String path, String e_label) {
+ return null;
+ }
}
return new CommandStatus(IStatus.ERROR, "", syncResult.getMessage(), null);
}
value.add(pathOnDevice.toOSString());
- printResultLog(String.format("[RDS] Copied file: %s \n " +
- "-> %s", srcPath, dstPath));
+ printResultLog(String.format("[RDS] Copied file: %s \n " + "-> %s", srcPath, dstPath));
return new CommandStatus(IStatus.OK, value, null);
}
} catch (IOException e) {
return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e);
}
- SyncResult syncResult = syncService.push(filePath, device.getFileEntry(TMP_DIR));// Fixxed
+ SyncResult syncResult = syncService.push(filePath, device.getFileEntry(TMP_DIR));// Fixxed
if (!syncResult.isOk()) {
return new CommandStatus(IStatus.ERROR, "", syncResult.getMessage(), null);
}
String msgLog = status.getException().toString();
String log = String.format("[Exception]%s:%s", cmdLog, msgLog);
printResultLog(log);
- }
+ }
+ return status;
+ }
+
+ @Override
+ public ICommandStatus setSmackExecute(String path, String e_label) {
+ // 1. change smack information
+ StringBuffer sbCommand = new StringBuffer("chsmack");
+ // Something is wrong if access information is empty
+ // In case of this, smack may be not supported.
+ if (!e_label.isEmpty()) {
+ sbCommand.append(String.format(" -e %s", e_label));
+ }
+ sbCommand.append(String.format(" %s", path));
+ // 2. check the changing
+ sbCommand.append(String.format(";chsmack %s", path));
+ String command = sbCommand.toString();
+ ICommandStatus status = execute(command, null, false, false);
+ if (status.isOk()) {
+ List<String> value = status.getValues();
+ String e_result = "";
+ if (value.size() > 0) {
+ String line = value.get(0);
+ for (String info : line.split(" ")) {
+ if (info.startsWith("execute")) {
+ String[] e = info.split("=");
+ if (e.length == 2) {
+ e_result = e[1];
+ }
+ }
+ }
+ }
+ if (e_label.equals("\"\"") && e_result.isEmpty()) {
+ printResultLog(String.format("[RDS] Change smack: %s %s", path, e_label));
+ } else if (e_label.equals(e_result)) {
+ printResultLog(String.format("[RDS] Change smack: %s %s", path, e_label));
+ } else {
+ return null;
+ }
+ }
return status;
}
return execute(command, rec, monitor, true);
}
- protected ICommandStatus execute(String command, PackageManagerOutputReceiver rec,
- int timeout, IProgressMonitor monitor) {
+ protected ICommandStatus execute(String command, PackageManagerOutputReceiver rec, int timeout,
+ IProgressMonitor monitor) {
return execute(command, rec, timeout, monitor, true);
}
return status;
}
- protected ICommandStatus execute(String command, PackageManagerOutputReceiver rec,
- int timeout, IProgressMonitor monitor, boolean printlog) {
+ protected ICommandStatus execute(String command, PackageManagerOutputReceiver rec, int timeout,
+ IProgressMonitor monitor, boolean printlog) {
if (printlog) {
printCommandLog(command);
}
public ICommandStatus executeBinary(String binary) {
return null;
}
+
+ @Override
+ public ICommandStatus setSmackExecute(String path, String e_label) {
+ return null;
+ }
}
public ICommandStatus executeBinary(String binary) {
return null;
}
+
+ @Override
+ public ICommandStatus setSmackExecute(String path, String e_label) {
+ return null;
+ }
}
import org.tizen.nativeplatform.pkg.model.IPackage;
import org.tizen.nativeplatform.types.CmdTargetTypes;
import org.tizen.nativeplatform.util.CommandLauncherUtil;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
public class RpmRapidDeployer {
private IProject project;
}
Map<String, String[]> smackInfo = null;
if (isDeviceCommander()) {
- smackInfo = getSmackInfo(copyFileList);
+ smackInfo = PlatformLaunchUtil.getSmackInfo(commander, copyFileList);
if (smackInfo == null) {
return false;
}
return true;
}
- private Map<String, String[]> getSmackInfo(String fileList) {
- Map<String, String[]> smackInfo = new HashMap<String, String[]>();
- String[] args;
- if (fileList.length() > CommandLauncherUtil.LIMIT_COMMAND_LENGTH) {
- args = CommandLauncherUtil.splitCommandArgs(fileList);
- } else {
- args = new String[1];
- args[0] = fileList;
- }
- for (String arg : args) {
- if (arg.isEmpty()) {
- continue;
- }
- ICommandStatus status = commander.getSmack(arg);
- if (status == null || !status.isOk()) {
- logger.error(String.format("Failed to get smack info [%s]", fileList));
- return null;
- }
- List<String> result = status.getValues();
- if (result == null) {
- logger.error(String.format("Failed to get smack info [%s]", fileList));
- return null;
- }
- for (String line : result) {
- String targetFile = "";
- String labels[] = { "", "" };
- for (String info : line.split(" ")) {
- if (info.startsWith("access=")) {
- String[] a_label = info.split("=");
- if (a_label.length == 2) {
- labels[0] = a_label[1].trim();
- }
- } else if (info.startsWith("execute")) {
- String[] e_label = info.split("=");
- if (e_label.length == 2) {
- labels[1] = e_label[1].trim();
- }
- } else {
- targetFile = info;
- }
- }
- if (targetFile.isEmpty()) {
- logger.error(String.format("Failed to get smack info [%s]", fileList));
- return null;
- } else {
- smackInfo.put(targetFile, labels);
- }
- }
- }
- return smackInfo;
- }
-
// compare source data and target data. divide all files into four list parts.
private String groupFiles(Map<String, String> sourceChecksums,
Map<String, String> targetChecksums, List<String> copyList, List<String> addList,
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.tizen.nativecommon.launch.TizenLaunchMessages;
import org.tizen.nativeplatform.IPlatformXMLStore;
import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.types.CmdTargetTypes;
return null;
}
}
+
+ public static String[] getProgramPath(IProject project, String appId) {
+ IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
+ if (store.loadXml()) {
+ List<String> files = store.getExecutableFiles(appId);
+ if (files != null && files.size() > 0) {
+ return files.toArray(new String[0]);
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
public static String[] getAppId(IProject project) {
IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
return null;
}
}
+
+ public static Map<String, String[]> getSmackInfo(IPkgCommander commander, String fileList) {
+ Map<String, String[]> smackInfo = new HashMap<String, String[]>();
+ String[] args;
+ if (fileList.length() > CommandLauncherUtil.LIMIT_COMMAND_LENGTH) {
+ args = CommandLauncherUtil.splitCommandArgs(fileList);
+ } else {
+ args = new String[1];
+ args[0] = fileList;
+ }
+ for (String arg : args) {
+ if (arg.isEmpty()) {
+ continue;
+ }
+ ICommandStatus status = commander.getSmack(arg);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to get smack info [%s]", fileList));
+ return null;
+ }
+ List<String> result = status.getValues();
+ if (result == null) {
+ logger.error(String.format("Failed to get smack info [%s]", fileList));
+ return null;
+ }
+ for (String line : result) {
+ String targetFile = "";
+ String labels[] = { "", "" };
+ for (String info : line.split(" ")) {
+ if (info.startsWith("access=")) {
+ String[] a_label = info.split("=");
+ if (a_label.length == 2) {
+ labels[0] = a_label[1].trim();
+ }
+ } else if (info.startsWith("execute")) {
+ String[] e_label = info.split("=");
+ if (e_label.length == 2) {
+ labels[1] = e_label[1].trim();
+ }
+ } else {
+ targetFile = info;
+ }
+ }
+ if (targetFile.isEmpty()) {
+ logger.error(String.format("Failed to get smack info [%s]", fileList));
+ return null;
+ } else {
+ smackInfo.put(targetFile, labels);
+ }
+ }
+ }
+ return smackInfo;
+ }
}