DEBUG: Set smack rule when debugging a project. Removed repository 33/20333/1
authordonghyuk.yang <donghyuk.yang@samsung.com>
Fri, 2 May 2014 08:26:28 +0000 (17:26 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Fri, 2 May 2014 08:26:28 +0000 (17:26 +0900)
initializing process whenever launching a project.

- Smack rule was set by sdbd before but it will be set by IDE now. So,
pkg launcher set smack rule after installing packages.
- Do not need to initialized repositories whenever launching a project

Change-Id: Ice8915c20542e5fc3af494c18acd2d9894c6bd7c
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
16 files changed:
org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/DeviceChangeListener.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchConfigurationProcessor.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRemoteHost.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildsystemTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RpmRapidDeployer.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java

index 36e0d5d..6042ebd 100644 (file)
@@ -37,7 +37,9 @@ import org.tizen.nativeplatform.build.PlatformConfigurationManager;
 import org.tizen.nativeplatform.build.PlatformProjectDependentBuilder;
 import org.tizen.nativeplatform.build.PlatformProjectDependentPackager;
 import org.tizen.nativeplatform.command.launcher.CommandUtil;
+import org.tizen.nativeplatform.command.launcher.DeviceChangeListener;
 import org.tizen.nativeplatform.preferences.PreferencesManager;
+import org.tizen.sdblib.SmartDevelopmentBridge;
 
 /**
  * The activator class controls the plug-in life cycle
@@ -74,6 +76,7 @@ public class Activator extends AbstractUIPlugin {
         PlatformResourceChangeListener listener = new PlatformResourceChangeListener();
         ResourcesPlugin.getWorkspace().addResourceChangeListener(
                 listener, IResourceChangeEvent.PRE_DELETE);
+        SmartDevelopmentBridge.addDeviceChangeListener(new DeviceChangeListener(), true);
     }
 
     /*
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/DeviceChangeListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/DeviceChangeListener.java
new file mode 100644 (file)
index 0000000..d26ac8b
--- /dev/null
@@ -0,0 +1,48 @@
+package org.tizen.nativeplatform.command.launcher;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmCommanderCommon;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.IDeviceChangeListener;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.util.DeviceUtil;
+
+public class DeviceChangeListener implements IDeviceChangeListener {
+    
+    protected final Logger logger = LoggerFactory.getLogger(DeviceChangeListener.class);
+
+    @Override
+    public void onConnected(IDevice device) {
+        if (!DeviceUtil.isOnline(device)) {
+            return;
+        }
+        PkgCommandTarget target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(), device);
+        try {
+            device.becomeSuperUser(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.error("Faile to root on device", e);
+        }
+        
+        target.getDeviceCommander().actionBeforeUsingZypper();
+    }
+
+    @Override
+    public void onDisconnected(IDevice device) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void onChanged(IDevice device, int changeMask) {
+        // TODO Auto-generated method stub
+
+    }
+
+}
index 769cba8..23e3698 100644 (file)
@@ -40,6 +40,7 @@ import org.tizen.nativeplatform.types.CmdTargetTypes;
 import org.tizen.nativeplatform.types.LaunchTypes;
 import org.tizen.nativeplatform.util.IPackageUtil;
 import org.tizen.nativeplatform.util.PkgUtilFactory;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
 import org.tizen.nativeplatform.util.PlatformUserInteraction;
 import org.tizen.nativeplatform.util.SSHUtil;
@@ -96,7 +97,7 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
                     descMsg = "Installation seems to be failed. Check package installation log.";
                 }
                 UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.PRE_LAUNCH);
-                if (!setLaunchConfigurationForEFL(new SubProgressMonitor(monitor, 1), descMsg, isEflApp)) {
+                if (!setLaunchConfiguration(new SubProgressMonitor(monitor, 1), descMsg, isEflApp)) {
                     return false;
                 }
             } finally {
@@ -120,6 +121,7 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
             if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                 pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, new SubProgressMonitor(
                         monitor, 1));
+                setSmackRule();
             } else {
                 pkgLauncher.launchPkgs(shell, new SubProgressMonitor(monitor, 1));
             }
@@ -132,7 +134,38 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
         }
 
         return true;
+    }
+    
+    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")
@@ -169,7 +202,7 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
         }
     }
 
-    private boolean setLaunchConfigurationForEFL(IProgressMonitor monitor, final String descMsg,
+    private boolean setLaunchConfiguration(IProgressMonitor monitor, final String descMsg,
             final boolean isEflApp) throws CoreException {
         
         monitor.beginTask("", 1);
index 0c4e28c..720d7dd 100644 (file)
@@ -45,6 +45,8 @@ public interface IPkgCommander {
     }
 
     PackageManagerOutputReceiver getOutputReceiver();
+    
+    void actionBeforeUsingZypper();
 
     void setHttpProxy(String proxy);
     
@@ -134,6 +136,8 @@ public interface IPkgCommander {
 
     ICommandStatus getSmack(String paths);
 
+    ICommandStatus setSmackExecute(String path, String e_label);
+
     CmdTargetTypes getCommandType();
 
     boolean isRunningApp(String appId);
index 8e1ff16..7d52857 100644 (file)
@@ -331,4 +331,13 @@ public class DebCommanderHost implements IPkgCommander {
                // TODO Auto-generated method stub
                return null;
        }
+
+    @Override
+    public void actionBeforeUsingZypper() {
+    }
+
+    @Override
+    public ICommandStatus setSmackExecute(String path, String e_label) {
+        return null;
+    }
 }
index 0c61524..92aceda 100644 (file)
@@ -111,7 +111,9 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
 
     abstract protected void changeUpdateMode();
 
-    abstract protected void actionBeforeUsingZypper();
+    public void actionBeforeUsingZypper() {
+        return;
+    }
 
     public RpmCommanderCommon() {
         setConsole(true, null);
@@ -195,9 +197,11 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     }
 
     public String[] getArch(String pkg) {
+        /*
         if (!checkPkgInstalled(pkg)) {
             return new String[0];
         }
+        */
         String command = makeCommand(getResetRpmDb(), RpmTool.pkgArchCommand(pkg));
         PackageManagerOutputReceiver hrec = getNewOuputReceiver();
         ICommandStatus status = execute(command, hrec, null);
@@ -224,9 +228,11 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     }
 
     public String[] getName(String pkg) {
+        /*
         if (!checkPkgInstalled(pkg)) {
             return new String[0];
         }
+        */
         String command = makeCommand(getResetRpmDb(), RpmTool.pkgNameCommand(pkg));
         PackageManagerOutputReceiver hrec = getNewOuputReceiver();
         ICommandStatus status = execute(command, hrec, null);
@@ -277,9 +283,11 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
                 }
             }
         } else if (tool.equals(TOOL.RPM)) {
+            /*
             if (!checkPkgInstalled(pkg)) {
                 return new String[0];
             }
+            */
             String command = makeCommand(getResetRpmDb(), RpmTool.pkgFullVerCommand(pkg));
             PackageManagerOutputReceiver hrec = getNewOuputReceiver();
             ICommandStatus status = execute(command, hrec, null);
@@ -332,7 +340,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
 
         List<String> value = status.getValues();
         if (value != null && value.size() > 0) {
-            changeUpdateMode();
+            // changeUpdateMode();
             UserLogger.start(PlatformUserInteraction.INSTALL_PKG);
             if (type == TOOL.RPM) {
                 String command = makeCommand(getResetRpmDb(),
@@ -378,7 +386,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
             monitor.beginTask("", 1);
         }
 
-        changeUpdateMode();
+        // changeUpdateMode();
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.installRemoteCommand(pkgs));
         ICommandStatus status = execute(command, monitor);
@@ -400,7 +408,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
             monitor.beginTask("", 1);
         }
 
-        changeUpdateMode();
+        // changeUpdateMode();
         String command = makeCommand(getResetRpmDb(), RpmTool.uninstallCommand(pkgs));
         ICommandStatus status = execute(command, monitor);
 
@@ -782,7 +790,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     }
 
     public ICommandStatus addRepo(String name, String url) {
-        changeUpdateMode();
+        // changeUpdateMode();
         // addRepoXmlOut(name, url);
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.addRemoteRepoCommand(name, url));
@@ -813,7 +821,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     }
 
     public ICommandStatus addLocalRepo(String name, String path) {
-        changeUpdateMode();
+        // changeUpdateMode();
         // addLocalRepoXmlOut(name, path);
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.addLocalRepoCommand(name, path));
@@ -844,7 +852,7 @@ public abstract class RpmCommanderCommon implements IPkgCommander {
     }
 
     public ICommandStatus removeRepo(String name) {
-        changeUpdateMode();
+        // changeUpdateMode();
         // removeRepoXmlOut(name);
         String command = makeCommand(getProxyCommand(), getResetRpmDb(),
                 ZypperTool.removeRepoCommand(name));
index a48f671..eef963a 100644 (file)
@@ -72,13 +72,11 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
     public RpmCommanderDevice(IDevice device, boolean useConsoleLog) {
         super(useConsoleLog, CONSOLE_NAME);
         this.device = device;
-        actionBeforeUsingZypper();
     }
 
     public RpmCommanderDevice(IDevice device) {
         super(CONSOLE_NAME);
         this.device = device;
-        actionBeforeUsingZypper();
     }
 
     public ICommandStatus copyFile(String srcPath, String dstPath) {
@@ -187,7 +185,7 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
 
         List<String> value = status.getValues();
         if (value != null && value.size() > 0) {
-            changeUpdateMode();
+            // changeUpdateMode();
             UserLogger.start(PlatformUserInteraction.INSTALL_PKG);
             if (type == TOOL.RPM) {
                 String command = makeCommand(getResetRpmDb(),
@@ -285,6 +283,45 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         }
         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;
+    }    
 
     @Override
     public ICommandStatus changeSmack(String path, String a_label, String e_label) {
@@ -362,7 +399,7 @@ public class RpmCommanderDevice extends RpmCommanderCommon {
         }
     }
 
-    protected void actionBeforeUsingZypper() {
+    public void actionBeforeUsingZypper() {
         if (device.isEmulator()) {
             if (existsFile(ZYPPER_CONF_FILE)) {
                 String command = CMD_ACTION_FOR_USING_ZYPPER;
index a0af6bc..2edc4ee 100644 (file)
@@ -207,11 +207,6 @@ public class RpmCommanderHost extends RpmCommanderCommon {
     }
 
     @Override
-    protected void actionBeforeUsingZypper() {
-        return;
-    }
-
-    @Override
     public ICommandStatus copyFile(String srcPath, String dstPath) {
         return null;
     }
@@ -255,4 +250,9 @@ public class RpmCommanderHost extends RpmCommanderCommon {
     public ICommandStatus executeBinary(String binary) {
         return null;
     }
+
+    @Override
+    public ICommandStatus setSmackExecute(String path, String e_label) {
+        return null;
+    }
 }
index 3f739ce..db098fe 100644 (file)
@@ -316,11 +316,6 @@ public class RpmCommanderRemoteHost extends RpmCommanderCommon {
     }
 
     @Override
-    protected void actionBeforeUsingZypper() {
-        return;
-    }
-
-    @Override
     public ICommandStatus copyFile(String srcPath, String dstPath) {
         return null;
     }
@@ -364,4 +359,9 @@ public class RpmCommanderRemoteHost extends RpmCommanderCommon {
     public ICommandStatus executeBinary(String binary) {
         return null;
     }
+
+    @Override
+    public ICommandStatus setSmackExecute(String path, String e_label) {
+        return null;
+    }
 }
index f8fab1b..f27a94c 100644 (file)
@@ -66,7 +66,7 @@ public class RpmCommanderRootstrap extends RpmCommanderCommon {
         actionBeforeUsingZypper();
     }
 
-    protected void actionBeforeUsingZypper() {
+    public void actionBeforeUsingZypper() {
         /*
          * (with --nodeps --force) Error: Subprocess failed. Error: RPM failed:
          * error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH:
@@ -260,4 +260,9 @@ public class RpmCommanderRootstrap extends RpmCommanderCommon {
     public ICommandStatus executeBinary(String binary) {
         return null;
     }
+
+    @Override
+    public ICommandStatus setSmackExecute(String path, String e_label) {
+        return null;
+    }
 }
index e6da59b..213b920 100644 (file)
@@ -254,10 +254,12 @@ public class RpmPackageLauncher implements IPkgLauncher {
                     PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, target.getRootstrap()
                             .getId()));
         } else {
+            /*
             UserLogger.start(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_ROOTSTRAP_REPO);
             PkgMgrInitializer initializer = new PkgMgrInitializer(target, CmdTargetTypes.ROOTSTRAP);
             initializer.faskInitRootstrapData();            
             UserLogger.end(UserInteraction.CATE_PLATFORM_LAUNCH, PlatformUserInteraction.INIT_ROOTSTRAP_REPO);
+            */
         }
         IPkgCommander commander = target.getCommander(CmdTargetTypes.ROOTSTRAP);
         boolean installResult = false;
index 9421a0f..2af0087 100644 (file)
@@ -174,6 +174,7 @@ public class BuildsystemTab extends CommonTab {
                     if (status != null && !status.isOk()) {
                         throw new InterruptedException();
                     }
+                    updatePackageInfo(null);
                     monitor.done();
                 }
             });
index 314b991..f64c504 100644 (file)
@@ -649,7 +649,6 @@ abstract public class CommonTab {
             @Override
             public void mouseDown(MouseEvent e) {
                 handleRefreshRepositoryButton();
-                updatePackageInfo(null);
                 pkgViewer.refresh();
             }
 
@@ -671,7 +670,6 @@ abstract public class CommonTab {
             @Override
             public void mouseDown(MouseEvent e) {
                 handleUpgradeButton();
-                updatePackageInfo(null);
                 pkgViewer.refresh();
             }
 
@@ -693,7 +691,6 @@ abstract public class CommonTab {
             @Override
             public void mouseDown(MouseEvent e) {
                 handleInstallPackageButton();
-                updatePackageInfo(null);
                 pkgViewer.refresh();
             }
 
@@ -732,7 +729,6 @@ abstract public class CommonTab {
                 }
 
                 handleInstallLocalPackageButton(selectedFiles);
-                updatePackageInfo(selectedFiles);
                 pkgViewer.refresh();
             }
 
@@ -754,7 +750,6 @@ abstract public class CommonTab {
             @Override
             public void mouseDown(MouseEvent e) {
                 handleRemovePackageButton();
-                updatePackageInfo(null);
                 pkgViewer.refresh();
             }
 
@@ -952,6 +947,7 @@ abstract public class CommonTab {
                     if (status == null || !status.isOk()) {
                         throw new InterruptedException();
                     }
+                    updatePackageInfo(null);
                     monitor.done();
                 }
             });
@@ -992,6 +988,7 @@ abstract public class CommonTab {
                     if (status == null || !status.isOk()) {
                         throw new InterruptedException();
                     }
+                    updatePackageInfo(null);
                     monitor.done();
                 }
             });
@@ -1023,6 +1020,7 @@ abstract public class CommonTab {
                     if (status == null || !status.isOk()) {
                         throw new InterruptedException();
                     }
+                    updatePackageInfo(selectedFiles);
                     monitor.done();
                 }
             });
@@ -1035,7 +1033,7 @@ abstract public class CommonTab {
         }
     }
 
-    protected void handleRemovePackageButton() {
+    protected void handleRemovePackageButton() { 
         final List<PkgStatus> selectedList = getSelectedPkgList(true);
         if (selectedList.isEmpty()) {
             DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package")
@@ -1064,6 +1062,7 @@ abstract public class CommonTab {
                     if (status == null || !status.isOk()) {
                         throw new InterruptedException();
                     }
+                    updatePackageInfo(null);
                     monitor.done();
                 }
             });
index f307975..da7eadc 100644 (file)
@@ -8,13 +8,8 @@ import java.util.Map.Entry;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
-import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
-import org.eclipse.ptp.remotetools.exception.CancelException;
-import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
-import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.util.FileUtil;
@@ -25,11 +20,10 @@ import org.tizen.nativeplatform.command.launcher.RemoteCommandUtil;
 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.pkg.model.IPackage;
-import org.tizen.nativeplatform.pkg.model.Package;
 import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.RootstrapUtil;
 
 public class RemoteRpmRapidDeployer {
@@ -77,9 +71,9 @@ public class RemoteRpmRapidDeployer {
         StringBuffer sbCheckFiles = new StringBuffer();
         for (String file : sourceChecksums.keySet()) {
             // key = <package filename>_<checksum>/<filepath>
-            sbCheckFiles.append("\"");
+            sbCheckFiles.append("\'");
             sbCheckFiles.append(new Path(file).removeFirstSegments(1).toString());
-            sbCheckFiles.append("\" ");
+            sbCheckFiles.append("\' ");
         }
         String needCheckFiles = sbCheckFiles.toString().trim();
         Map<String, String> targetChecksums = getTargetChecksumMap(needCheckFiles);
@@ -106,7 +100,7 @@ public class RemoteRpmRapidDeployer {
         }
         Map<String, String[]> smackInfo = null;
         if (isDeviceCommander()) {
-            smackInfo = getSmackInfo(copyFileList);
+            smackInfo = PlatformLaunchUtil.getSmackInfo(commander, copyFileList);
             if (smackInfo == null) {
                 return false;
             }
@@ -234,58 +228,6 @@ public class RemoteRpmRapidDeployer {
         return true;
     }
 
-    private Map<String, String[]> getSmackInfo(String fileList) {
-        Map<String, String[]> smackInfo = new HashMap<String, String[]>();
-        String[] args;
-        if (fileList.length() > CommandUtil.LIMIT_COMMAND_LENGTH) {
-            args = CommandUtil.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,
index e11dca4..449ad45 100644 (file)
@@ -11,14 +11,13 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativeplatform.command.launcher.CommandUtil;
 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.model.IPackage;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
-import org.tizen.nativeplatform.util.RootstrapUtil;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 
 public class RpmRapidDeployer {
     private IProject project;
@@ -85,7 +84,7 @@ public class RpmRapidDeployer {
         }
         Map<String, String[]> smackInfo = null;
         if (isDeviceCommander()) {
-            smackInfo = getSmackInfo(copyFileList);
+            smackInfo = PlatformLaunchUtil.getSmackInfo(commander, copyFileList);
             if (smackInfo == null) {
                 return false;
             }
@@ -186,58 +185,6 @@ public class RpmRapidDeployer {
         return true;
     }
 
-    private Map<String, String[]> getSmackInfo(String fileList) {
-        Map<String, String[]> smackInfo = new HashMap<String, String[]>();
-        String[] args;
-        if (fileList.length() > CommandUtil.LIMIT_COMMAND_LENGTH) {
-            args = CommandUtil.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,
index 24aeac2..b6b64b1 100644 (file)
@@ -34,20 +34,17 @@ import java.io.File;
 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.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
-import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
-import org.eclipse.ptp.remotetools.exception.CancelException;
-import org.eclipse.ptp.remotetools.exception.RemoteConnectionException;
-import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
@@ -67,7 +64,9 @@ import org.tizen.nativecommon.launch.LaunchUtils;
 import org.tizen.nativecommon.launch.TizenLaunchCommand;
 import org.tizen.nativecommon.launch.TizenLaunchMessages;
 import org.tizen.nativeplatform.IPlatformXMLStore;
+import org.tizen.nativeplatform.command.launcher.CommandUtil;
 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.remote.connection.RemoteConnectionManager;
@@ -391,4 +390,56 @@ public class PlatformLaunchUtil {
             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() > CommandUtil.LIMIT_COMMAND_LENGTH) {
+            args = CommandUtil.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;
+    }
 }