From: hyunsik.noh Date: Wed, 29 Jan 2014 04:55:57 +0000 (+0900) Subject: CLI: Fix InstallCLICommand for windows X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93bf0738a73fdb11f6d985395ffd44db5c6d4995;p=sdk%2Ftools%2Fcli.git CLI: Fix InstallCLICommand for windows Change-Id: I49230981c16dc044b49e2c9026ecf55cf8241e51 Signed-off-by: hyunsik.noh --- diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties index 472df90..1591863 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties @@ -43,7 +43,7 @@ INST_INSTALLED = Installed the package: Id({0}) INST_FAIL_PACKAGE = Failed to install Tizen application. INST_FAIL_TRANSFER_PACKAGE = [Fail] Fail install. There is the problem to transfer package. -INST_FAIL_INVALID_PACKAGE = [Fail Fail install. There is the problem about package. +INST_FAIL_INVALID_PACKAGE = [Fail] Fail install. There is the problem about package. UNINST_UNREMOVABLE_PACKAGE = The package is unremovable. UNINST_UNEXIST_PACKAGE = The package is not exist. diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/InstallCLICommand.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/InstallCLICommand.java index 9eaf27f..a40e09a 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/InstallCLICommand.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/InstallCLICommand.java @@ -35,6 +35,7 @@ import org.tizen.common.launch.LaunchMessages; import org.tizen.common.util.FileUtil; import org.tizen.common.util.HostUtil; import org.tizen.common.util.IOUtil; +import org.tizen.common.util.OSChecker; import org.tizen.ncli.ide.CLIConstant; import org.tizen.ncli.ide.messages.TizenCLIMessages; import org.tizen.ncli.ide.util.TargetUtil; @@ -57,12 +58,17 @@ public class InstallCLICommand extends AbstractSubCommand { private String pkgName = null; private String ext = null; - private String searchPkgCommand = "ls %s"; + private String searchPkgCommand = null; private String installCommand = TizenPlatformConstants.PKG_TOOL_INSTALL_COMMAND; private static final String SUCCESS= "ok"; private final String PKGID = "pkgid["; public InstallCLICommand() { + if(OSChecker.isWindows()) { + searchPkgCommand = "dir /b %s"; + } else { + searchPkgCommand = "ls %s"; + } } @Override @@ -140,9 +146,7 @@ public class InstallCLICommand extends AbstractSubCommand { } } else { String srcFilePath = workDir + File.separatorChar + name; - String getPKGCommand =String.format(searchPkgCommand, srcFilePath); - String returnPkg = HostUtil.returnExecute(getPKGCommand); - if(srcFilePath.equals(returnPkg)) { + if(FileUtil.isExist(srcFilePath)) { result = true; pkgName = name; ext = FileUtil.getFileExtension(pkgName); @@ -161,19 +165,21 @@ public class InstallCLICommand extends AbstractSubCommand { String tpk = CLIConstant.NATIVE_PKG_EXT; String wgt = CLIConstant.WEB_PKG_EXT; + String ignore_tpk = "." + CLIConstant.NATIVE_PKG_EXT; + String ignore_wgt = "." + CLIConstant.WEB_PKG_EXT; String ext = null; String getPKGCommand =String.format(searchPkgCommand, workDir); log.debug("[Get Packages Command]: " + getPKGCommand); String returnPkgs = HostUtil.returnExecute(getPKGCommand); if(returnPkgs.length() != 0) { - String[] items = returnPkgs.split("\n"); + String[] items = returnPkgs.split(HostUtil.LINE_SEPARATOR); for(String item : items) { ext = FileUtil.getFileExtension(item); if(ext != null) { - if(tpk.equals(ext)) { + if(tpk.equals(ext) && !(ignore_tpk.equals(item))) { tpks.add(item); - } else if(wgt.equals(ext)) { + } else if(wgt.equals(ext) && !(ignore_wgt.equals(item))) { wgts.add(item); } } @@ -218,7 +224,7 @@ public class InstallCLICommand extends AbstractSubCommand { String returnResult = TargetUtil.getDefault().returnExecuteCommand(target, installCmd); log.debug(returnResult); - String[] lines = returnResult.split("\n"); + String[] lines = returnResult.split(HostUtil.LINE_SEPARATOR); for(String line : lines) { int lastIndex = line.lastIndexOf('['); if(lastIndex != -1) { @@ -244,3 +250,4 @@ public class InstallCLICommand extends AbstractSubCommand { return pkgId; } } +