RDS is supported on windows. It is applied in case of running a project.
Change-Id: I45ce2b5ffc79e595b0d5e5425edb9439fa32dcf3
Signed-off-by: donghyuk,yang <donghyuk.yang@samsung.com>
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+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.widgets.Display;
import org.tizen.common.util.OSChecker;
import org.tizen.common.util.log.UserInteraction;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
import org.tizen.nativeplatform.remote.connection.RootstrapSyncronizer;
import org.tizen.nativeplatform.remote.connection.WorkspaceDeltaManager;
import org.tizen.nativeplatform.remote.connection.WorkspaceResourceDelta;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.util.PackageUtil;
import org.tizen.nativeplatform.util.PlatformProjectUtil;
+import org.tizen.nativeplatform.util.RootstrapUtil;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class PlatformExternalBuildRunner extends ExternalBuildRunner {
String targetId = PlatformConfigurationManager.getBuildTargetName(configuration);
String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
final PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
- boolean needRemoteSync = OSChecker.isWindows() && buildArgs[0].equals("clean");
+ boolean needCacheChecksum = !buildArgs[0].equals("clean");
+ boolean needRemoteSync = OSChecker.isWindows() && !buildArgs[0].equals("clean");
if (needRemoteSync) {
syncWorkspace(project, configuration, monitor);
readySyncRootstrap(rootstrap);
markerGenerator, projectBuilder, monitor);
UserLogger.end(UserInteraction.CATE_PLATFORM_BUILD);
final PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- pkgUtil.cachePkgChecksum(project, configuration);
- }
- });
+ if (needCacheChecksum) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ pkgUtil.cachePkgChecksum(project, configuration);
+ }
+ });
+ }
if (needRemoteSync) {
/*
}
IResourceDelta delta = resourceDelta.computeDelta();
boolean needSync = false;
- if (delta == null) {
+ String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean workspaceExists = false;
+ try {
+ workspaceExists = filetool.hasFile(remoteWorkspacePath, new NullProgressMonitor());
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+
+ if (delta == null || !workspaceExists) {
needSync = true;
} else {
IResourceDelta[] deltas = delta.getAffectedChildren();
import org.eclipse.ptp.remotetools.exception.RemoteOperationException;
import org.tizen.common.util.FileUtil;
import org.tizen.common.util.OSChecker;
-import org.tizen.common.util.log.UserInteraction;
import org.tizen.common.util.log.UserLogger;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.build.IBuildResultProcessor;
import org.tizen.nativeplatform.filefilter.RpmFileFilter;
import org.tizen.nativeplatform.filefilter.XmlFileFilter;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
-import org.tizen.nativeplatform.remote.connection.RootstrapSyncronizer;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.util.PlatformUserInteraction;
import org.tizen.nativeplatform.util.RootstrapUtil;
IProject project = (IProject) config.getOwner();
IPath configPath = project.getLocation().append(config.getName());
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
- for (String rpm : rpms) {
- try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
+ IPath remoteConfigPath = new Path(remoteWorkspacePath).append(config.getName());
+ try {
+ filetool.assureDirectory(remoteConfigPath.toString(), new NullProgressMonitor());
+ for (String rpm : rpms) {
String filename = FileUtil.getFileNameFromPath(rpm);
String targetPath = configPath.append(filename).toOSString();
+ String remoteTargetPath = remoteConfigPath.append(filename).toString();
+ filetool.copyFile(rpm, remoteTargetPath, new NullProgressMonitor());
copytool.downloadFileToFile(rpm, targetPath);
- rpmfiles.add(targetPath);
- } catch (RemoteConnectionException e) {
- e.printStackTrace();
- } catch (RemoteOperationException e) {
- e.printStackTrace();
- } catch (CancelException e) {
- e.printStackTrace();
- }
+ rpmfiles.add(targetPath);
+ }
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
}
List<String> xmls = getRemoteXmlFiles(rootstrap);
for (String xml : xmls) {
// start process
Process proc = null;
BufferedReader input = null;
+ BufferedReader err = null;
StringBuilder contents = null;
try {
proc = CommandUtil.createProcess(command, workingDir, includeStdErr);
RemoteProcess proc = null;
try {
- IRemoteExecutionTools exectool = RemoteConnectionManager.getRemoteTools().getExecTool();
+ IRemoteExecutionTools exectool = RemoteConnectionManager.getRemoteTools().getExecTool();
IRemoteScript script = exectool.createScript();
if (workingDir != null && !workingDir.isEmpty()) {
String[] commands = {"cd " + workingDir, command};
public static final Logger logger = LoggerFactory.getLogger(RemoteScriptProvider.class);
public static synchronized String genCacheChecksumScript(IProject project, String filePaths) {
- return null;
+ PrintWriter pw = null;
+ String cacheChecksumScript = null;
+ String cachingDir = CommandUtil.getCachingDir(project);
+ String workingDir = CommandUtil.getWorkingDir();
+
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ filetool.assureDirectory(workingDir, new NullProgressMonitor());
+
+ String randomNum = CommandUtil.getRandomNum();
+ String fileName = ScriptProvider.CACHE_CHECKSUM_FILENAME + "_" + randomNum + ScriptProvider.SHELL_EXT;
+
+ cacheChecksumScript = new Path(workingDir).append(fileName).toString();
+ boolean exist = filetool.hasFile(cacheChecksumScript, new NullProgressMonitor());
+ if (exist) {
+ filetool.removeFile(cacheChecksumScript, new NullProgressMonitor());
+ }
+ filetool.createFile(cacheChecksumScript, new NullProgressMonitor());
+ OutputStream out = filetool.getOutputStream(cacheChecksumScript, IRemoteFileTools.NONE,
+ new NullProgressMonitor());
+ pw = new PrintWriter(out);
+ pw.write("#!/bin/sh -ee");
+ pw.write('\n');
+ pw.write(String.format("rm -rf %s/*", cachingDir));
+ pw.write('\n');
+ pw.write(String.format("mkdir -p %s", cachingDir));
+ pw.write('\n');
+ pw.write(String.format("cd %s", cachingDir));
+ pw.write('\n');
+ pw.write(String.format("for file in `ls %s`", filePaths));
+ pw.write('\n');
+ pw.write("do");
+ pw.write('\n');
+ pw.write(" checksum=`md5sum ${file} | awk '{print $1}'`");
+ pw.write('\n');
+ pw.write(" pkgfile=`basename ${file}`");
+ pw.write('\n');
+ pw.write(" pkgdir=\"${pkgfile}_${checksum}\"");
+ pw.write('\n');
+ pw.write(" rm -rf ${pkgdir}");
+ pw.write('\n');
+ pw.write(" mkdir ${pkgdir}");
+ pw.write('\n');
+ pw.write(" cd ${pkgdir}");
+ pw.write('\n');
+ pw.write(" rpm2cpio ${file} | cpio -idm --quiet");
+ pw.write('\n');
+ pw.write(" echo \"key: ${pkgdir}\"");
+ pw.write('\n');
+ pw.write(" cd ..");
+ pw.write('\n');
+ pw.write(" find ${pkgdir} -type f -printf '\"%p\"\\n' | xargs md5sum");
+ pw.write('\n');
+ pw.write("done");
+ pw.close();
+
+ IRemoteItem item = filetool.getFile(cacheChecksumScript, new NullProgressMonitor());
+ if (item.exists()) {
+ item.setExecutable(true);
+ item.commitAttributes(new NullProgressMonitor());
+ }
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ } finally {
+ tryClose(pw);
+ }
+
+ return cacheChecksumScript;
}
// return generate expect script and return script path
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.types.CmdTargetTypes;
import org.tizen.nativeplatform.util.PackageUtil;
+import org.tizen.nativeplatform.util.PlatformFileUtil;
import org.tizen.nativeplatform.util.PlatformLaunchUtil;
import org.tizen.nativeplatform.util.PlatformProjectUtil;
import org.tizen.nativeplatform.util.PlatformUserInteraction;
String appPath = config
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
IPath hostPath = getHostPath(appPath, config);
- boolean exists = false;
if (hostPath != null) {
- if (OSChecker.isWindows()) {
- IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
- try {
- exists = filetool.hasFile(hostPath.toString(), new NullProgressMonitor());
- } catch (RemoteOperationException e) {
- e.printStackTrace();
- } catch (RemoteConnectionException e) {
- e.printStackTrace();
- } catch (CancelException e) {
- e.printStackTrace();
- }
- } else {
- exists = hostPath.toFile().exists();
- }
- }
- if (!exists) {
- newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
- null);
+ if (!PlatformFileUtil.existsFile(hostPath.toString())) {
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ null);
+ }
}
}
PackageManagerOutputReceiver getOutputReceiver();
void setHttpProxy(String proxy);
+
+ String getArchFromRemoteFile(String filePath);
+
+ String getNameFromRemoteFile(String filePath);
+
+ String getVerFromRemoteFile(String filePath);
String getArchFromFile(String filePath);
public interface IPkgModelMaker {
IPackage makeModel(String filePath);
+ IPackage makeRemoteModel(String filePath);
IPackage makeModel(String filePath, boolean needsFilter);
+ List<IPackage> makeRemoteModels(List<String> filePaths);
List<IPackage> makeModels(List<String> filePaths);
List<IPackage> makeModels(List<String> filePaths, boolean needsFilter);
}
@Override
public void cancelExecution() {
}
+
+ @Override
+ public String getArchFromRemoteFile(String filePath) {
+ return "";
+ }
+
+ @Override
+ public String getNameFromRemoteFile(String filePath) {
+ return "";
+ }
+
+ @Override
+ public String getVerFromRemoteFile(String filePath) {
+ return "";
+ }
}
printResultLog(String.format("Set proxy: %s", proxy));
}
}
+
+ public String getArchFromRemoteFile(String filePath) {
+ return "";
+ }
+
+ public String getNameFromRemoteFile(String filePath) {
+ return "";
+ }
+
+ public String getVerFromRemoteFile(String filePath) {
+ return "";
+ }
public String getArchFromFile(String filePath) {
return "";
public ICommandStatus copyFilesToTmpDir(String[] fileList) {
return null;
}
+
+ public String getArchFromRemoteFile(String filePath) {
+ String result = "";
+ if (!RemoteConnectionManager.connected()) {
+ return "";
+ }
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasFile(filePath, new NullProgressMonitor());
+ if (!exists) {
+ return result;
+ }
+ String command = RpmTool.fileArchCommand(filePath);
+ result = HostCommandLauncher.executeOutput(command);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (CancelException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ }
+
+ String[] name = result.split(",");
+ if (name.length > 0) {
+ return name[0];
+ } else {
+ return "";
+ }
+ }
public String getArchFromFile(String filePath) {
String result = "";
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
copytool.uploadFileToFile(filePath, remotepath);
- String command = RpmTool.fileArchCommand(remotepath);
- result = HostCommandLauncher.executeOutput(command);
+ result = getArchFromRemoteFile(remotepath);
filetool.removeFile(remotepath, new NullProgressMonitor());
} catch (RemoteConnectionException e) {
e.printStackTrace();
} catch (CancelException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
+ }
+ return result;
+ }
+
+ public String getNameFromRemoteFile(String filePath) {
+ String result = "";
+ if (!RemoteConnectionManager.connected()) {
+ return "";
+ }
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasFile(filePath, new NullProgressMonitor());
+ if (!exists) {
+ return result;
+ }
+ String command = RpmTool.fileNameCommand(filePath);
+ result = HostCommandLauncher.executeOutput(command);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (CancelException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
} catch (InterruptedException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return "";
}
}
-
public String getNameFromFile(String filePath) {
String result = "";
if (!new File(filePath).exists()) {
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
copytool.uploadFileToFile(filePath, remotepath);
- String command = RpmTool.fileNameCommand(remotepath);
- result = HostCommandLauncher.executeOutput(command);
+ result = getNameFromRemoteFile(remotepath);
filetool.removeFile(remotepath, new NullProgressMonitor());
} catch (RemoteConnectionException e) {
e.printStackTrace();
} catch (CancelException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
+ }
+ return result;
+ }
+
+ public String getVerFromRemoteFile(String filePath) {
+ String result = "";
+ if (!RemoteConnectionManager.connected()) {
+ return "";
+ }
+ try {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ boolean exists = filetool.hasFile(filePath, new NullProgressMonitor());
+ if (!exists) {
+ return result;
+ }
+ String command = RpmTool.fileFullVerCommand(filePath);
+ result = HostCommandLauncher.executeOutput(command);
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
+ } catch (CancelException e) {
+ e.printStackTrace();
+ logger.error(e.getMessage(), e);
} catch (InterruptedException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
+
String[] name = result.split(",");
if (name.length > 0) {
return name[0];
IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
copytool.uploadFileToFile(filePath, remotepath);
- String command = RpmTool.fileFullVerCommand(remotepath);
- result = HostCommandLauncher.executeOutput(command);
+ result = getVerFromRemoteFile(remotepath);
filetool.removeFile(remotepath, new NullProgressMonitor());
} catch (RemoteConnectionException e) {
e.printStackTrace();
} catch (CancelException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
- } catch (InterruptedException e) {
- e.printStackTrace();
- logger.error(e.getMessage(), e);
- }
- String[] name = result.split(",");
- if (name.length > 0) {
- return name[0];
- } else {
- return "";
}
+ return result;
}
@Override
pkg.setVer(ver);
return pkg;
}
+
+ private Package _makeRemoteModel(String filePath) {
+ Package pkg = new Package();
+ String name = target.getCommander(CmdTargetTypes.HOST, false).getNameFromRemoteFile(filePath);
+ String ver = target.getCommander(CmdTargetTypes.HOST, false).getVerFromRemoteFile(filePath);
+ String arch = target.getCommander(CmdTargetTypes.HOST, false).getArchFromRemoteFile(filePath);
+ pkg.setPath(filePath);
+ pkg.setName(name);
+ pkg.setArch(arch);
+ pkg.setVer(ver);
+ return pkg;
+ }
public IPackage makeModel(String filePath) {
Package pkg = _makeModel(filePath);
}
return pkg;
}
+
+ public IPackage makeRemoteModel(String filePath) {
+ Package pkg = _makeRemoteModel(filePath);
+ if (pkg == null) {
+ return null;
+ }
+ return pkg;
+ }
public IPackage makeModel(String filePath, boolean needsFilter) {
Package pkg = _makeModel(filePath);
pkg.setNeedsFilter(needsFilter);
return pkg;
}
+
+ public IPackage makeRemoteModel(String filePath, boolean needsFilter) {
+ Package pkg = _makeRemoteModel(filePath);
+ if (pkg == null) {
+ return null;
+ }
+ pkg.setNeedsFilter(needsFilter);
+ return pkg;
+ }
+
+ public List<IPackage> makeRemoteModels(List<String> filePaths) {
+ List<IPackage> pkgs = new ArrayList<IPackage>();
+ for (String path : filePaths) {
+ IPackage pkg = makeRemoteModel(path);
+ if (pkg != null) {
+ pkgs.add(pkg);
+ }
+ }
+ return pkgs;
+ }
public List<IPackage> makeModels(List<String> filePaths) {
List<IPackage> pkgs = new ArrayList<IPackage>();
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.rds.ui.preference.RdsPreferencePage;
+import org.tizen.common.util.OSChecker;
import org.tizen.common.util.log.UserInteraction;
import org.tizen.common.util.log.UserLogger;
import org.tizen.nativecommon.launch.TizenLaunchMessages;
import org.tizen.nativeplatform.pkg.model.IPackage;
import org.tizen.nativeplatform.pkg.model.PkgStatus;
import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
+import org.tizen.nativeplatform.rds.RemoteRpmRapidDeployer;
import org.tizen.nativeplatform.rds.RpmRapidDeployer;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
import org.tizen.nativeplatform.types.CmdTargetTypes;
}
private boolean internalProcessRDS(final IPkgCommander commander, List<IPackage> packages,
- boolean worksSmack, IProgressMonitor monitor) {
- RpmRapidDeployer rpmRds = new RpmRapidDeployer(project, commander, packages);
- return rpmRds.process();
+ boolean worksSmack, IProgressMonitor monitor) {
+ if (OSChecker.isWindows()) {
+ RemoteRpmRapidDeployer rpmRds = new RemoteRpmRapidDeployer(project, commander, packages);
+ return rpmRds.process();
+ } else {
+ RpmRapidDeployer rpmRds = new RpmRapidDeployer(project, commander, packages);
+ return rpmRds.process();
+ }
}
private String newline() {
String getVer();
String getArch();
String getPath();
+ void setPath(String path);
PkgTypes getType();
boolean needsFilter();
IPackage clonePkg();
import java.util.Map;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.tizen.nativeplatform.command.launcher.CommandUtil;
+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.tizen.common.util.OSChecker;
import org.tizen.nativeplatform.command.launcher.HostCommandLauncher;
import org.tizen.nativeplatform.command.launcher.ScriptProvider;
import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.util.PlatformFileUtil;
public class CachePackageChecksum {
/*
}
if (strs[0].equals("key:")) {
key = strs[1];
+ key = key.replace("\r", "");
put(key, new HashMap<String, String>());
} else {
String s = (strs[1].startsWith(".")) ? strs[1].substring(1) : strs[1];
+ s = s.replace("\r", "");
Map<String, String> value = get(key);
if (value == null) {
put(key, new HashMap<String, String>());
return false;
}
return true;
- }
+ }
public static boolean cachePkgChecksum(IProject project, List<IPackage> pkgFiles)
throws InterruptedException {
StringBuffer sbNeedCachingPkgs = new StringBuffer();
Map<String, String> result = new HashMap<String, String>();
for (String path : pkgPaths.split(" ")) {
- // packages should exist.
- if (!new File(path).exists()) {
- return null;
- }
+ // packages should exist.
+ if (!PlatformFileUtil.existsFile(path)) {
+ return null;
+ }
String pkgName = new Path(path).lastSegment();
// key = <package filename>_<checksum>
// = aul-devel-0.0.280-1.i586.rpm_1c8812299688a58503949ee804b26532
}
public static String getCacheKey(String pkgPath) throws InterruptedException {
- if (!new File(pkgPath).exists()) {
+ if (!PlatformFileUtil.existsFile(pkgPath)) {
return "";
}
- String workingPath = new Path(pkgPath).removeLastSegments(1).toOSString();
+ String workingPath = new Path(pkgPath).removeLastSegments(1).toString();
String pkgFile = new Path(pkgPath).lastSegment();
- String command = String.format("md5sum %s | awk '{print $2 \"_\" $1}'", pkgFile);
+ //String command = String.format("md5sum %s | awk '{print $2 \"_\" $1}'", pkgFile);
+ String command = String.format("md5sum %s", pkgFile);
// output should be "<package path>_<checksum>" format
- String output = HostCommandLauncher.executeOutput(command, workingPath, false, null);
+ String output = HostCommandLauncher.executeOutput(command, workingPath, true, null);
+ String[] content = output.trim().split(" ");
+ if (content.length >= 2) {
+ output = String.format("%s_%s", content[content.length-1], content[0]);
+ }
return output;
}
}
--- /dev/null
+package org.tizen.nativeplatform.rds;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ptp.remotetools.core.IRemoteCopyTools;
+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;
+import org.tizen.common.util.FilenameUtil;
+import org.tizen.nativeplatform.command.launcher.CommandUtil;
+import org.tizen.nativeplatform.command.launcher.LocalCommandUtil;
+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.model.IPackage;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.types.CmdTargetTypes;
+import org.tizen.nativeplatform.util.RootstrapUtil;
+
+public class RemoteRpmRapidDeployer {
+ private IProject project;
+ private IPkgCommander commander;
+ private List<IPackage> packages;
+ private CmdTargetTypes cmdType;
+ private final Logger logger = LoggerFactory.getLogger(RemoteRpmRapidDeployer.class);
+
+ public RemoteRpmRapidDeployer(IProject project, IPkgCommander commander, List<IPackage> packages) {
+ this.project = project;
+ this.commander = commander;
+ for (IPackage pkg : packages) {
+ String path = pkg.getPath();
+ String[] segments = new Path(path).segments();
+ String configNamae = segments[segments.length - 2];
+ String fileNamae = segments[segments.length - 1];
+ String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
+ String remotePkgPath = new Path(remoteWorkspacePath).append(configNamae).append(fileNamae).toString();
+ pkg.setPath(remotePkgPath);
+ }
+ this.packages = packages;
+ this.cmdType = commander.getCommandType();
+ }
+
+ public boolean process() {
+ StringBuffer sbPkgList = new StringBuffer();
+ for (IPackage pkg : packages) {
+ sbPkgList.append(pkg.getPath());
+ sbPkgList.append(" ");
+ }
+ String pkgList = sbPkgList.toString().trim();
+ Map<String, String> sourceChecksums = null;
+ // get cached checksum information
+ try {
+ sourceChecksums = CachePackageChecksum.getPkgChecksum(project, pkgList);
+ } catch (InterruptedException e) {
+ logger.error(PlatformLaunchMessages.FAILED_CHECK_FILE_CHECKSUM, e);
+ return false;
+ }
+ if (sourceChecksums == null || sourceChecksums.isEmpty()) {
+ return false;
+ }
+ StringBuffer sbCheckFiles = new StringBuffer();
+ for (String file : sourceChecksums.keySet()) {
+ // key = <package filename>_<checksum>/<filepath>
+ sbCheckFiles.append("\"");
+ sbCheckFiles.append(new Path(file).removeFirstSegments(1).toString());
+ sbCheckFiles.append("\" ");
+ }
+ String needCheckFiles = sbCheckFiles.toString().trim();
+ Map<String, String> targetChecksums = getTargetChecksumMap(needCheckFiles);
+ if (targetChecksums == null) {
+ return false;
+ }
+
+ List<String> copyList = new ArrayList<String>();
+ List<String> addList = new ArrayList<String>();
+ List<String> remainList = new ArrayList<String>();
+ List<String> removeList = new ArrayList<String>();
+ String copyFileList = groupFiles(sourceChecksums, targetChecksums, copyList, addList,
+ remainList, removeList);
+ if (isDeviceCommander()) {
+ // If there are added files, install packages normally.
+ if (!addList.isEmpty()) {
+ return false;
+ }
+ // If copied files are more than 20, install packages normally. It might be better.
+ if (copyList.size() > 20) {
+ return false;
+ }
+ }
+ Map<String, String[]> smackInfo = null;
+ if (isDeviceCommander()) {
+ smackInfo = getSmackInfo(copyFileList);
+ if (smackInfo == null) {
+ return false;
+ }
+ }
+ LocalCommandUtil.clearCachingDir();
+ String cachingDir = LocalCommandUtil.getCachingDir(project);
+ FileUtil.createDirectory(cachingDir);
+
+ if (!processCopiedFiles(copyList)) {
+ return false;
+ }
+ if (!processAddedFiles(addList, smackInfo)) {
+ return false;
+ }
+ if (!processRemovedFiles(removeList)) {
+ return false;
+ }
+ if (isDeviceCommander()) {
+ if (!applySmack(smackInfo)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean processCopiedFiles(List<String> fileList) {
+ String cachingDir = LocalCommandUtil.getCachingDir(project);
+ IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool();
+ for (final String file : fileList) {
+ String remoteFilepath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString();
+ String filename = FilenameUtil.getFilename(file);
+ String srcPath = new Path(cachingDir).append(filename).toOSString();
+ try {
+ copytool.downloadFileToFile(remoteFilepath, srcPath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ String targetFilePath = new Path(file).removeFirstSegments(1).toString();
+ ICommandStatus status = commander.copyFile(srcPath, targetFilePath);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to copy files [%s]", srcPath));
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean processAddedFiles(List<String> fileList, Map<String, String[]> smackInfo) {
+ for (String file : fileList) {
+ IPath filePath = new Path(file);
+ String targetFilePath = filePath.removeFirstSegments(1).toOSString();
+ String targetPath = filePath.removeFirstSegments(1).removeLastSegments(1).toOSString();
+ String srcFilePath = new Path(CommandUtil.getCachingDir(project)).append(file)
+ .toOSString();
+ ICommandStatus status = commander.makeDir(targetPath);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to make directory [%s]", targetPath));
+ return false;
+ }
+ status = commander.copyFile(srcFilePath, targetFilePath);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to copy files [%s]", srcFilePath));
+ return false;
+ }
+ if (smackInfo != null && isDeviceCommander()) {
+ String[] labels = { "_", "_" };
+ smackInfo.put(targetFilePath, labels);
+ }
+ }
+ return true;
+ }
+
+ private boolean processRemovedFiles(List<String> fileList) {
+ for (String file : fileList) {
+ ICommandStatus status = commander.removeFile(file);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to remove files [%s]", file));
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isDeviceCommander() {
+ return (cmdType == CmdTargetTypes.DEVICE);
+ }
+
+ // Maintain smack information of copied file same as before.
+ private boolean applySmack(Map<String, String[]> smackInfo) {
+ if (!smackInfo.isEmpty()) {
+ try {
+ // Sleep guarantee changing of smack information.
+ // "chsmack" command after pushing file is not completed.
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ for (Entry<String, String[]> entry : smackInfo.entrySet()) {
+ String file = entry.getKey();
+ String[] value = entry.getValue();
+ ICommandStatus status = commander.changeSmack(file, value[0], value[1]);
+ if (status == null || !status.isOk()) {
+ logger.error(String.format("Failed to change smack [%s]", file));
+ return false;
+ }
+ }
+ 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,
+ List<String> remainList, List<String> removeList) {
+
+ StringBuffer sbCopyFiles = new StringBuffer();
+ for (Entry<String, String> entry : sourceChecksums.entrySet()) {
+ // key = aul-0.0.280-1.i586.rpm_d986faacda139c2d2d9c19c792ef07bc/etc/init.d/launchpad_run
+ String key = entry.getKey();
+ // s_value = 50155d2eaed43a6cbf2632b38dd37242
+ String s_value = entry.getValue();
+ // target_key = etc/init.d/launchpad_run
+ String target_key = new Path(key).removeFirstSegments(1).toString();
+ if (targetChecksums.containsKey(target_key)) {
+ // d_value = 50155d2eaed43a6cbf2632b38dd37242
+ String d_value = targetChecksums.get(target_key);
+ // As comparing keys, divide files into 2 parts (copy list, remain list)
+ if (!s_value.equals(d_value)) {
+ copyList.add(key);
+ sbCopyFiles.append("\"" + target_key + "\" ");
+ } else {
+ remainList.add(key);
+ }
+ // if targetChecksums contains source key, remove the key from targetChecksums.
+ // it is for removing unused files on device later.
+ targetChecksums.remove(target_key);
+ } else {
+ // if targetChecksums does not contains source key, it should be copied.
+ if (!key.equals("-")) {
+ addList.add(key);
+ }
+ }
+ }
+ // if targetChecksums has keys, it should be removed.
+ for (String key : targetChecksums.keySet()) {
+ removeList.add(key);
+ }
+ return sbCopyFiles.toString().trim();
+ }
+
+ // get checksum information for files in target
+ private Map<String, String> getTargetChecksumMap(String fileList) {
+ Map<String, String> checksumMap = new HashMap<String, String>();
+ // if command is too long, split it.
+ 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.getMd5Checksum(arg);
+ if (status == null) {
+ return null;
+ }
+ List<String> values = status.getValues();
+ if (values == null) {
+ logger.error(String.format("%s: src:%s",
+ PlatformLaunchMessages.FAILED_CHECK_FILE_CHECKSUM, arg));
+ return null;
+ }
+ Map<String, String> data = getChecksumMap(values);
+ if (data.isEmpty()) {
+ logger.error(String.format("%s: checksum is empty. src:%s",
+ PlatformLaunchMessages.FAILED_CHECK_FILE_CHECKSUM, arg));
+ return null;
+ } else {
+ checksumMap.putAll(data);
+ }
+ }
+ return checksumMap;
+ }
+
+ private Map<String, String> getChecksumMap(List<String> sources) {
+ Map<String, String> result = new HashMap<String, String>();
+ for (String value : sources) {
+ String[] v = value.split(" ");
+ if (v.length != 2) {
+ continue;
+ }
+ String key = (v[1].startsWith(".")) ? v[1].substring(1) : v[1];
+ result.put(key, v[0]);
+ }
+ return result;
+ }
+}
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;
public class RpmRapidDeployer {
private IProject project;
public class RsyncProcessor {\r
String host = "";\r
String user = "";\r
- String sshKeyPath = "";\r
+ String sshPrivateKey = "";\r
\r
- public RsyncProcessor(String host, String user, String sshKeyPath) {\r
+ public RsyncProcessor(String host, String user, String sshPrivateKey) {\r
this.host = host;\r
this.user = user;\r
- this.sshKeyPath = sshKeyPath;\r
+ this.sshPrivateKey = sshPrivateKey;\r
}\r
\r
public boolean downloadSync(String remotePath, String localPath, IProgressMonitor monitor) throws InterruptedException {\r
cmd.append(" -c \"");\r
cmd.append("rsync -avz --delete -e");\r
cmd.append("'ssh -i ");\r
- cmd.append(sshKeyPath);\r
+ cmd.append(sshPrivateKey);\r
cmd.append(" -o StrictHostKeyChecking=no");\r
cmd.append("' ");\r
cmd.append(user);\r
}\r
}\r
String excludeCmd = "";\r
- for (String exclude : excludes) {\r
- excludeCmd += String.format("--exclude=%s ", exclude);\r
+ if (excludes != null) {\r
+ for (String exclude : excludes) {\r
+ excludeCmd += String.format("--exclude=%s ", exclude);\r
+ }\r
}\r
\r
String msysBinPath = sbi.getMsysBinPath();\r
cmd.append(" -c \"");\r
cmd.append("rsync -avz --delete -e ");\r
cmd.append("'ssh -i ");\r
- cmd.append(sshKeyPath);\r
+ cmd.append(sshPrivateKey);\r
cmd.append(" -o StrictHostKeyChecking=no");\r
cmd.append("' ");\r
if (!excludeCmd.isEmpty()) {\r
latestTempRootstrap = new PlatformRootstrap(id, id, arch, tempDirPath, null, "", false);
// use rogen
- String rogen = RootstrapUtil.getRogenPath();
+ String rogen = RootstrapUtil.getRogenBinPath();
String baseArch = RootstrapUtil.getBaseArchitecture(arch);
String urlData = "";
for (String url : reposURLs) {
latestTempRootstrap = new PlatformRootstrap(id, id, arch, tempDirPath, null, "", false);
// use rogen
- String rogen = RootstrapUtil.getRemoteRogenPath();
+ String rogen = RootstrapUtil.getRemoteRogenBinPath();
String baseArch = RootstrapUtil.getBaseArchitecture(arch);
String urlData = "";
for (String url : reposURLs) {
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
+import org.eclipse.ptp.remotetools.core.IRemoteItem;
+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.ArrayUtil;
+import org.tizen.common.util.FilenameUtil;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativeplatform.filefilter.RpmFileFilter;
import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
import org.tizen.nativeplatform.pkg.model.IPackage;
+import org.tizen.nativeplatform.pkg.model.Package;
import org.tizen.nativeplatform.rds.CachePackageChecksum;
+import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.types.CmdTargetTypes;
import org.tizen.nativeplatform.types.PkgTypes;
public class PackageUtil {
}
return true;
}
-
- public void cachePkgChecksum(IProject project, IConfiguration config) {
+
+ public void cacheLocalpkgChecksum(IProject project, IConfiguration config) {
try {
if(!CachePackageChecksum.cachePkgChecksum(project, getPackages(project, config))) {
logger.error(PlatformLaunchMessages.FAILED_CACHE_PACKAGE_CHECKSUM);
e.printStackTrace();
}
}
+
+ public void cacheRemotepkgChecksum(IProject project, IConfiguration config) {
+ try {
+ if(!CachePackageChecksum.cachePkgChecksum(project, getRemotePackages(project, config))) {
+ logger.error(PlatformLaunchMessages.FAILED_CACHE_PACKAGE_CHECKSUM);
+ }
+ } catch (InterruptedException e) {
+ logger.error(PlatformLaunchMessages.FAILED_CACHE_PACKAGE_CHECKSUM);
+ e.printStackTrace();
+ }
+ }
+
+ public void cachePkgChecksum(IProject project, IConfiguration config) {
+ if (OSChecker.isWindows()) {
+ cacheRemotepkgChecksum(project, config);
+ } else {
+ cacheLocalpkgChecksum(project, config);
+ }
+ }
+
+ public List<IPackage> getRemotePackages(IProject project, IConfiguration config) {
+ List<String> pkgs = new ArrayList<String>();
+ String targetPath = RootstrapUtil.getUserSyncWorkspacePath(project.getName());
+ String configPath = new Path(targetPath).append(config.getName()).toString();
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ try {
+ IRemoteItem[] items = filetool.listItems(configPath, new NullProgressMonitor());
+ for (IRemoteItem item : items) {
+ String path = item.getPath();
+ String filename = FilenameUtil.getFilename(path);
+ String ext = FilenameUtil.getExtension(filename);
+ if (ext.equals("rpm")) {
+ pkgs.add(path);
+ }
+ }
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ }
+ return modelMaker.makeRemoteModels(pkgs);
+ }
public List<IPackage> getPackages(IProject project, IConfiguration config) {
List<String> pkgs = new ArrayList<String>();
import java.io.File;
import java.io.FilenameFilter;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.ptp.remotetools.core.IRemoteFileTools;
+import org.tizen.common.util.OSChecker;
import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
public class PlatformFileUtil {
return name.endsWith(ext);
}
}
+
+ public static boolean existsFile(String path) {
+ boolean exists = false;
+ if (OSChecker.isWindows()) {
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ try {
+ exists = filetool.hasFile(path, new NullProgressMonitor());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ exists = !new File(path).exists();
+ }
+ return exists;
+ }
}
TizenLaunchCommand command, IPath srcPath) throws CoreException, TimeoutException,
SdbCommandRejectedException, IOException, Exception {
String gdbserverPath = srcPath.toString();
- File gdbserver = new File(gdbserverPath);
- if (OSChecker.isWindows()) {
-
- IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
- boolean exists = filetool.hasFile(gdbserverPath, new NullProgressMonitor());
- if (!exists) {
- IPkgCommander commander = cmdTarget.getCommander(CmdTargetTypes.ROOTSTRAP);
- commander.installRemotePkg("gdb-server", null);
- }
- exists = filetool.hasFile(gdbserverPath, new NullProgressMonitor());
- if (!exists) {
- LaunchUtils.newCoreException(
- NLS.bind(TizenLaunchMessages.GDBSERVER_NOT_INSTALLED, device.getDeviceName()),
- null);
- }
- } else {
- if (!gdbserver.exists()) {
- IPkgCommander commander = cmdTarget.getCommander(CmdTargetTypes.ROOTSTRAP);
- commander.installRemotePkg("gdb-server", null);
- }
-
- if (!gdbserver.exists()) {
- LaunchUtils.newCoreException(
- NLS.bind(TizenLaunchMessages.GDBSERVER_NOT_INSTALLED, device.getDeviceName()),
- null);
- }
+ if (!PlatformFileUtil.existsFile(gdbserverPath)) {
+ IPkgCommander commander = cmdTarget.getCommander(CmdTargetTypes.ROOTSTRAP);
+ commander.installRemotePkg("gdb-server", null);
+ }
+ if (!PlatformFileUtil.existsFile(gdbserverPath)) {
+ LaunchUtils.newCoreException(
+ NLS.bind(TizenLaunchMessages.GDBSERVER_NOT_INSTALLED, device.getDeviceName()),
+ null);
}
-
if (!checkGdbServerInDevice(device, command)) {
copyFileToDevice(cmdTarget.getRootstrap(), device, gdbserverPath,
TizenPlatformConstants.GDBSERVER_PLATFORM_CMD);
private static final String REMOTE_TIZEN_SDK_DIR_NAME = "tizen-sdk-remote-data";
private static final String REMOTE_CONNECTION_DIR = "connection";
private static final String REMOTE_CONNECTION_FILE = "info";
- private static final String REMOTE_SOURCE_DIR_NAME = "source";
+ private static final String REMOTE_TOOLS_DIR_NAME = "tools";
private static final String REMOTE_WORKSPACE_DIR = "workspace";
private static final String REMOTE_ROOSTRAP_PLUGINS_DIR_NAME = "user-rootstrap-plugins";
String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).toString();
}
- /*
- public static String getRemoteSourcePath() {
- return new Path(getRemoteRootstrapBasePath()).append(REMOTE_SOURCE_DIR_NAME).toString();
+
+ public static String getRemoteToolsPath() {
+ return new Path(getRemoteRootstrapBasePath()).append(REMOTE_TOOLS_DIR_NAME)
+ .toString();
}
- */
+
public static String getRemoteRootstrapPluginPath() {
return new Path(getRemoteRootstrapBasePath()).append(REMOTE_ROOSTRAP_PLUGINS_DIR_NAME)
.toString();
public static String getRemotePluginXML(String id) {
return new Path(getRemoteRootstrapPluginPath()).append(id + ".xml").toString();
}
-
- public static String getRogenPath() {
- return new Path(InstallPathConfig.getSDKPath()).append("tools").append("rogen")
- .append("bin").append("rogen.rb").toString();
+
+ public static IPath getRogenPath() {
+ return new Path(InstallPathConfig.getSDKPath()).append("tools").append("rogen");
}
- public static String getRemoteRogenPath() {
+ public static IPath getRemoteRogenPath() {
String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
- return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append("tools").append("rogen")
- .append("bin").append("rogen.rb").toString();
+ return new Path(userhome).append(REMOTE_TIZEN_SDK_DIR_NAME).append("tools").append("rogen");
+ }
+
+ public static String getRogenBinPath() {
+ return getRogenPath().append("bin").append("rogen.rb").toString();
+ }
+
+ public static String getRemoteRogenBinPath() {
+ return getRemoteRogenPath().append("bin").append("rogen.rb").toString();
}
}
private Text hostText;
private Text userText;
private Text passText;
- private Text sudoText;
private Text sshPrivateText;
private Text sshPublicText;
private int y = 0;
private int width = 400;
private int height = 250;
+
+ private boolean connected = false;
private final String BUNDLE_NAME = RemoteConnectionDialog.class.getPackage().getName()
+ ".RootstrapUIMessages";//$NON-NLS-1$
IRemoteExecutionTools exectool = RemoteConnectionManager.getRemoteTools().getExecTool();
IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
String userhome = RemoteConnectionManager.getRemoteTools().getUserhome();
- String remoteAuthfile = new Path(userhome).append(".ssh").append("authorized_keys").toString();
+ IPath remoteSshPath = new Path(userhome).append(".ssh");
+ String remoteAuthfile = remoteSshPath.append("authorized_keys").toString();
boolean needSet = true;
if (filetool.hasFile(remoteAuthfile, new NullProgressMonitor())) {
String cmd = String.format("grep -rn \"%s\" %s", pubkey, remoteAuthfile);
}
}
if (needSet) {
+ filetool.assureDirectory(remoteSshPath.toString(), new NullProgressMonitor());
String cmd = String.format("echo \"%s\" >> %s", pubkey, remoteAuthfile);
exectool.executeBashCommand(cmd);
}
}
}
+ public boolean connected() {
+ return connected;
+ }
+
@Override
protected void okPressed() {
final String host = hostText.getText();
monitor.beginTask(resources.getString("RemoteConnDlg.Progress.Creating"), 1);
try {
UserLogger.start(PlatformUserInteraction.CONNECT_SSH);
- boolean result = RemoteConnectionManager.createConnection(host, user, pass, publicKey, privateKey,
+ connected = RemoteConnectionManager.createConnection(host, user, pass, publicKey, privateKey,
new SubProgressMonitor(monitor, 1));
UserLogger.end(PlatformUserInteraction.CONNECT_SSH);
- if (!result) {
+ if (!connected) {
DialogUtil.openMessageDialog(getShell(), "Failed to connect");
} else {
registerAuthorizedKey(publicKey);
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
Table table = reposURLViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
-
+ int width = computeDefaultColumnWidth();
reposURLViewer.setLabelProvider(new RepoTableViewerProvider());
reposURLViewer.setContentProvider(new ArrayContentProvider());
column = new TableColumn(table, SWT.NONE);
column.setResizable(true);
column.setText(resources.getString("GenRootDlg.Tree.Column.URL"));
- column.setWidth(300);
+ column.setWidth(width-50);
GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL
| GridData.VERTICAL_ALIGN_BEGINNING);
tableGridData.heightHint = 200;
table.setLayoutData(tableGridData);
-
reposURLViewer.setInput(new ArrayList<ICheckTreeItem>());
}
+ /**
+ * Return the default width of the column; this should be the width of the client area.
+ * The table won't tell us the real width of the client area; this is an approximate calculation.
+ * This accounts for the size of the data and the visibility of the scrollbar.
+ * @return
+ */
+ private int computeDefaultColumnWidth()
+ {
+ // Many of the padding are on both sides, have to double them to get the full size
+ Table table = reposURLViewer.getTable();
+ GridLayout parentLayout = (GridLayout)table.getParent().getLayout();
+
+ // determine the padding from the parent composite
+ int windowHorizontalPadding = (2 * parentLayout.horizontalSpacing)
+ + (2 * parentLayout.marginWidth);
+ // determine the extra space the table displays that isn't the column
+ int tablePadding = 2 * table.getBorderWidth();
+ // If the scrollbar is displayed, need to account for its size.
+ if (isScrollBarVisible())
+ {
+ tablePadding += table.getVerticalBar().getSize().x;
+ }
+ // finish computing the width.
+ int totalPadding = tablePadding + windowHorizontalPadding;
+ int defaultWidth = table.getShell().getClientArea().width - totalPadding;
+
+ return defaultWidth;
+ }
+ /**
+ * Return true if the scroll bar is visible.
+ * The scrollbar won't tell us if it is visible, so this is an approximate calculation.
+ * This will tell us if it is likely that the scrollbar is visible.
+ * @return true if the scroll bar is visible
+ */
+ private boolean isScrollBarVisible()
+ {
+ // Many of the padding are on both sides, have to double them to get the full size
+ Table table = reposURLViewer.getTable();
+ GridLayout parentLayout = (GridLayout)table.getParent().getLayout();
+
+ // need to figure out if the scroll bar will be displayed...
+ // determine how high the data rows are
+ int rowsHeight = table.getItemCount() * (table.getItemHeight() + table.getGridLineWidth());
+ // figure out the extra composite padding
+ int windowVerticalPadding = (2 * parentLayout.verticalSpacing)
+ + (2 * parentLayout.marginHeight);
+ // Manually determined vertical size of the remaining window's stuff (Button, etc).
+ int rowPadding = 29;
+ // mix it all up to figure out how tall the table would be with all the data displayed
+ int rowsComputedHeight = rowsHeight + windowVerticalPadding + rowPadding;
+ int availableHeight = table.getShell().getClientArea().height;
+ boolean isScrollVisible = (rowsComputedHeight> availableHeight);
+
+ return isScrollVisible;
+ }
+
@Override
public String getArchitecture() {
return architecture;
}
private void createTabs(Composite parent) {
- tabFolder = new TabFolder(parent, SWT.BORDER);
+ tabFolder = new TabFolder(parent, SWT.NONE);
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = 400;
package org.tizen.nativeplatform.views.ui;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
+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.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.tizen.common.TizenHelpContextIds;
import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.util.DialogUtil;
-import org.tizen.common.util.FileUtil;
import org.tizen.common.util.ImageUtil;
import org.tizen.common.util.OSChecker;
import org.tizen.common.util.SWTUtil;
private void showConnectDialog() {
RemoteConnectionDialog dlg = new RemoteConnectionDialog(shell);
- if (dlg.open() == Dialog.OK) {
+ if (dlg.open() == Dialog.OK) {
+ if (!RemoteConnectionManager.connected()) {
+ return;
+ }
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
dialog.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- monitor.beginTask("Synchronizing...", 3);
+ monitor.beginTask("Synchronizing...", 4);
try {
monitor.subTask("Synchronizing rootstraps...");
RootstrapManager.reinitialize(new SubProgressMonitor(monitor, 1));
monitor.subTask("Clear platform temp directory");
CommandUtil.clearPlatformTempDir();
monitor.worked(1);
+ initBuildserver(new SubProgressMonitor(monitor, 1));
SWTUtil.syncExec(new Runnable() {
public void run() {
updateToolbarEnable();
}
}
+ private void initBuildserver(IProgressMonitor monitor) {
+ monitor.beginTask("Setting build server...", 3);
+ IRemoteFileTools filetool = RemoteConnectionManager.getRemoteTools().getFileTool();
+ String basedir = RootstrapUtil.getRemoteToolsPath();
+ try {
+ filetool.assureDirectory(basedir, new SubProgressMonitor(monitor, 1));
+ IPath remoteRogenPath = RootstrapUtil.getRemoteRogenPath();
+ boolean exists = filetool.hasDirectory(remoteRogenPath.toString(), new SubProgressMonitor(monitor, 1));
+ if (!exists) {
+ String host = RemoteConnectionManager.getRemoteTools().getHost();
+ String user = RemoteConnectionManager.getRemoteTools().getUser();
+ String sshKey = RemoteConnectionManager.getRemoteTools().getPrivateKey();
+ String localRogenPath = RootstrapUtil.getRogenPath().toOSString();
+ RsyncProcessor processor = new RsyncProcessor(host, user, sshKey);
+ processor.uploadSync(localRogenPath, basedir, null, new SubProgressMonitor(monitor, 1));
+ }
+ } catch (RemoteOperationException e) {
+ e.printStackTrace();
+ } catch (RemoteConnectionException e) {
+ e.printStackTrace();
+ } catch (CancelException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ monitor.done();
+ }
+
+ }
+
private void syncIncludes() {
doActionForEntry(new IActionForEntry() {
@Override