diff options
author | Jenkins <taeyoung2.son@samsung.com> | 2012-09-18 13:29:31 +0900 |
---|---|---|
committer | Jenkins <taeyoung2.son@samsung.com> | 2012-09-18 13:29:31 +0900 |
commit | a5d305f40865037903ced871ccf88b44e8f3f516 (patch) | |
tree | 3c77b079d1f17ebcb7af935a2d3a2bee8c77a4cb | |
parent | f52d27f4ae7f629a0b53f7b3bb492e87fe8e247b (diff) | |
download | nativeplatform-eplugin-a5d305f40865037903ced871ccf88b44e8f3f516.tar.gz nativeplatform-eplugin-a5d305f40865037903ced871ccf88b44e8f3f516.tar.bz2 nativeplatform-eplugin-a5d305f40865037903ced871ccf88b44e8f3f516.zip |
Change-Id: Ic3992bc1d4dfd8a31f97d2918de1fd8ff1a3389c
73 files changed, 5309 insertions, 3924 deletions
diff --git a/builder/customTargets.xml b/builder/customTargets.xml deleted file mode 100644 index 6a42e92a..00000000 --- a/builder/customTargets.xml +++ /dev/null @@ -1,187 +0,0 @@ -<project name="Build specific targets and properties" default="noDefault"> - - <!-- ===================================================================== --> - <!-- Run a given ${target} on all elements being built --> - <!-- Add on <ant> task for each top level element being built. --> - <!-- ===================================================================== --> - <available property="allElementsFile" file="${builder}/allElements.xml" value="${builder}/allElements.xml"/> - <property name="allElementsFile" location="${eclipse.pdebuild.templates}/headless-build/allElements.xml"/> - - <import file="${allElementsFile}" /> - <target name="allElements"> - <ant antfile="${genericTargets}" target="${target}"> - <property name="type" value="${topLevelElementType}"/> - <property name="id" value="${topLevelElementId}"/> - </ant> - </target> - - <target - name="assemble.${topLevelElementId}.linux.gtk.x86"> - <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/> - </target> - <target - name="assemble.${topLevelElementId}.win32.win32.x86"> - <ant antfile="{$assembleScriptName}" dir="${buildDirectory}"/> - </target> - - <!-- ===================================================================== --> - <!-- ===================================================================== --> - <target name="getBaseComponents" depends="checkLocalBase" unless="skipBase"> - <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" /> - <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" /> - </target> - - <target name="checkLocalBase"> - <available file="${base}" property="skipBase" /> - </target> - - <!-- ===================================================================== --> - <!-- Check out map files from correct repository --> - <!-- Replace values for mapsCheckoutTag as desired. --> - <!-- ===================================================================== --> - <target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps"> - <property name="mapsCheckoutTag" value="HEAD" /> - <cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" /> - </target> - - <target name="checkLocalMaps"> - <available property="skipMaps" file="${buildDirectory}/maps" /> - </target> - - <target name="tagMapFiles" if="tagMaps"> - <cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" /> - </target> - - <!-- ===================================================================== --> - - <target name="clean" unless="noclean"> - <antcall target="allElements"> - <param name="target" value="cleanElement" /> - </antcall> - </target> - - <target name="gatherLogs"> - <mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" /> - <antcall target="allElements"> - <param name="target" value="gatherLogs" /> - </antcall> - <unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true"> - <fileset dir="${buildDirectory}/features"> - <include name="**/*.log.zip" /> - </fileset> - </unzip> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before setup --> - <!-- ===================================================================== --> - <target name="preSetup"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after setup but before starting the build proper --> - <!-- ===================================================================== --> - <target name="postSetup"> - <antcall target="getBaseComponents" /> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before fetching the build elements --> - <!-- ===================================================================== --> - <target name="preFetch"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after fetching the build elements --> - <!-- ===================================================================== --> - <target name="postFetch"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before the repositories are being processed --> - <!-- ===================================================================== --> - <target name="preProcessRepos"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after the repositories have been processed --> - <!-- ===================================================================== --> - <target name="postProcessRepos"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before generating the build scripts. --> - <!-- ===================================================================== --> - <target name="preGenerate"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after generating the build scripts. --> - <!-- ===================================================================== --> - <target name="postGenerate"> - <antcall target="clean" /> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before running the build.xmls for the elements being built. --> - <!-- ===================================================================== --> - <target name="preProcess"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after running the build.xmls for the elements being built. --> - <!-- ===================================================================== --> - <target name="postProcess"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before running assemble. --> - <!-- ===================================================================== --> - <target name="preAssemble"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after running assemble. --> - <!-- ===================================================================== --> - <target name="postAssemble"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do before running package. --> - <!-- ===================================================================== --> - <target name="prePackage"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after running package. --> - <!-- ===================================================================== --> - <target name="postPackage"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do after the build is done. --> - <!-- ===================================================================== --> - <target name="postBuild"> - <antcall target="gatherLogs" /> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do to test the build results --> - <!-- ===================================================================== --> - <target name="test"> - </target> - - <!-- ===================================================================== --> - <!-- Steps to do to publish the build results --> - <!-- ===================================================================== --> - <target name="publish"> - </target> - - <!-- ===================================================================== --> - <!-- Default target --> - <!-- ===================================================================== --> - <target name="noDefault"> - <echo message="You must specify a target when invoking this file" /> - </target> - -</project> diff --git a/org.tizen.nativeplatform.feature/feature.xml b/org.tizen.nativeplatform.feature/feature.xml index 164b9fc2..6b891aca 100644 --- a/org.tizen.nativeplatform.feature/feature.xml +++ b/org.tizen.nativeplatform.feature/feature.xml @@ -3,7 +3,7 @@ id="org.tizen.nativeplatform.feature" label="Tizen Native Platform" version="1.0.0.qualifier" - provider-name="Samsung" + provider-name="Tizen" plugin="org.tizen.base.platform" license-feature="org.tizen.base.feature"> @@ -12,7 +12,7 @@ </description> <copyright> - Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + Copyright (c) </copyright> <license url="http://www.example.com/license"> diff --git a/org.tizen.nativeplatform/META-INF/MANIFEST.MF b/org.tizen.nativeplatform/META-INF/MANIFEST.MF index afe74d25..88c83efc 100644 --- a/org.tizen.nativeplatform/META-INF/MANIFEST.MF +++ b/org.tizen.nativeplatform/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: Tizen Native Platform Bundle-SymbolicName: org.tizen.nativeplatform;singleton:=true Bundle-Version: 1.0.0 Bundle-Activator: org.tizen.nativeplatform.Activator -Bundle-Vendor: Samsung +Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.cdt.managedbuilder.core;bundle-version="7.0.2", diff --git a/org.tizen.nativeplatform/OSGI-INF/l10n/bundle.properties b/org.tizen.nativeplatform/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000..adb5f386 --- /dev/null +++ b/org.tizen.nativeplatform/OSGI-INF/l10n/bundle.properties @@ -0,0 +1 @@ +Bundle-Vendor = Samsung Electronics diff --git a/org.tizen.nativeplatform/build.properties b/org.tizen.nativeplatform/build.properties index 3b874924..1fad6340 100644 --- a/org.tizen.nativeplatform/build.properties +++ b/org.tizen.nativeplatform/build.properties @@ -7,4 +7,5 @@ bin.includes = plugin.xml,\ templates/,\ plugin.properties,\ about.html,\ - about_files/ + about_files/,\ + OSGI-INF/ diff --git a/org.tizen.nativeplatform/plugin.properties b/org.tizen.nativeplatform/plugin.properties deleted file mode 100644 index a1f5f1f6..00000000 --- a/org.tizen.nativeplatform/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Tizen Presentation -SLPPresentation.themelabel = Tizen Presentation -SLPPresentation.themedescription = Colors and fonts used by Tizen -SLPPresentation.editorlabel = Editor -SLPPresentation.editordescription = This font is used by Tizen's editors -SLPPresentation.fontlabel = Tizen C/C++ Editor Text Font -SLPPresentation.fontdescription = The C/C++ editor text font is used by C/C++ editors. diff --git a/org.tizen.nativeplatform/plugin.xml b/org.tizen.nativeplatform/plugin.xml index 6e8f121f..e1a9233f 100644 --- a/org.tizen.nativeplatform/plugin.xml +++ b/org.tizen.nativeplatform/plugin.xml @@ -2,6 +2,22 @@ <plugin> <!-- build start --> + <extension + id="org.tizen.nativeplatform.gdbserver" + name="org.tizen.nativeplatform.gdbserver" + point="org.tizen.common.connection.tools"> + <tools + packagename="gdbserver-platform" + sourcepath="/on-demand"> + </tools> + </extension> + + <extension point="org.eclipse.core.contenttype.contentTypes"> + <file-association + content-type="org.eclipse.cdt.make.core.makefile" + file-extensions="spec"/> + </extension> + <extension point="org.eclipse.cdt.core.templates"> <template @@ -18,6 +34,12 @@ </template> <template filterPattern=".*" + id="org.tizen.nativeapp.templates.custom.debian.AgentProject" + location="templates/InhouseFrameworkPackages/AgentProject/template.xml" + projectType="org.tizen.nativeide.buildArtefactType.platform"> + </template> + <template + filterPattern=".*" id="org.tizen.nativeapp.templates.custom.debian.EmptyProjectOld" location="templates/CustomDebianPackages/EmptyProject/template.xml" projectType="com.samsung.slp.buildArtefactType.custom.debian"> @@ -52,125 +74,17 @@ point="org.eclipse.ui.handlers"> <handler commandId="org.tizen.nativeplatform.pkgInstall.commandid.rootstrapmgr" - class="org.tizen.nativeplatform.pkgInstall.PackageManagerRootstrapHandler"> + class="org.tizen.nativeplatform.pkgmgr.PackageManagerHandler"> </handler> </extension> - <!-- 1 --> - <extension - point="org.eclipse.cdt.managedbuilder.core.buildDefinitions"> - <toolChain - configurationEnvironmentSupplier="org.tizen.nativeplatform.build.PlatformConfigurationEnvVarSupplier" - id="com.samsung.slp.nativeide.toolchain.sbi.gcc45sbox2.cdeb.base" - isAbstract="false" - name="[SBOX2] GCC-4.5 Custom Debian" - osList="linux" - superClass="com.samsung.slp.nativeide.toolchain.sbi.gnu.base"> - <builder - autoBuildTarget="build" - buildfileGenerator="org.tizen.nativecommon.build.OldProjectMakeGenerator" - cleanBuildTarget="clean" - command="sbi-make" - commandLauncher="org.tizen.nativecommon.build.CommonBuildCommandLauncher" - id="org.tizen.nativeapp.target.sbi.gcc45sbox2.builder.cdeb" - incrementalBuildTarget="build" - name="Tizen Custom Debian Builder"> - </builder> - <tool - id="com.samsung.slp.nativeide.tool.sbi.gnu.archiver.cdeb.base" - superClass="com.samsung.slp.nativeide.tool.sbi.gnu.archiver.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - <tool - id="com.samsung.slp.nativeide.tool.sbi.gnu.cpp.compiler.cdeb.base" - superClass="com.samsung.slp.nativeide.tool.sbi.gnu.cpp.compiler.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - <tool - id="com.samsung.slp.nativeide.tool.sbi.gnu.c.compiler.cdeb.base" - superClass="com.samsung.slp.nativeide.tool.sbi.gnu.c.compiler.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - <tool - id="com.samsung.slp.nativeide.tool.sbi.gnu.c.linker.cdeb.base" - superClass="com.samsung.slp.nativeide.tool.sbi.gnu.c.linker.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - <tool - id="com.samsung.slp.nativeide.tool.sbi.gnu.cpp.linker.cdeb.base" - superClass="com.samsung.slp.nativeide.tool.sbi.gnu.cpp.linker.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - <tool - id="com.samsung.tizen.nativeapp.tool.sbi.gnu.assembler.cdeb.base" - superClass="com.samsung.tizen.nativeapp.tool.sbi.gnu.assembler.base"> - <enablement - type="ALL"> - <false/> - </enablement> - </tool> - </toolChain> - - <projectType - buildArtefactType="com.samsung.slp.nativeide.buildArtefactType.cdeb" - id="com.samsung.slp.nativebuild.target.sbi.gcc45sbox2.cdeb" - isAbstract="false" - isTest="false"> - <configuration - cleanCommand="rm -f" - errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" - id="com.samsung.slp.nativeide.config.sbi.gcc45sbox2.cdeb.emulator" - name="Tizen-Emulator"> - <toolChain - id="com.samsung.slp.nativeide.toolchain.sbi.gcc45sbox2.cdeb.emulator" - superClass="com.samsung.slp.nativeide.toolchain.sbi.gcc45sbox2.cdeb.base"> - </toolChain> - </configuration> - <configuration - cleanCommand="rm -f" - errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" - id="com.samsung.slp.nativeide.config.sbi.gcc45sbox2.cdeb.device" - name="Tizen-Device"> - <toolChain - id="com.samsung.slp.nativeide.toolchain.sbi.gcc45sbox2.cdeb.device" - superClass="com.samsung.slp.nativeide.toolchain.sbi.gcc45sbox2.cdeb.base"> - </toolChain> - </configuration> - </projectType> - </extension> - - <extension - point="org.eclipse.cdt.managedbuilder.core.buildProperties"> - <propertyValue - id="com.samsung.slp.nativeide.buildArtefactType.cdeb" - name="Tizen Custom Debian Project" - property="org.eclipse.cdt.build.core.buildArtefactType"> - </propertyValue> - </extension> - - <!-- 2 --> <extension point="org.eclipse.cdt.managedbuilder.core.buildDefinitions"> <toolChain configurationEnvironmentSupplier="org.tizen.nativeplatform.build.PlatformConfigurationEnvVarSupplier" id="org.tizen.nativeide.toolchain.sbi.gcc45.platform.base" isAbstract="false" - name="GCC-4.5 Platform [SBOX2]" + name="Tizen Platform Toolchain" osList="linux" superClass="org.tizen.nativeide.toolchain.sbi.gnu.base"> <builder @@ -178,7 +92,7 @@ buildfileGenerator="org.tizen.nativeplatform.build.PlatformMakeGenerator" cleanBuildTarget="clean" command="sbi-make" - commandLauncher="org.tizen.nativecommon.build.CommonBuildCommandLauncher" + commandLauncher="org.tizen.nativeplatform.build.PlatformBuildCommandLauncher" id="org.tizen.nativeide.target.sbi.gcc45.platform.builder" incrementalBuildTarget="build" name="Tizen Platform Builder"> @@ -301,16 +215,6 @@ <!-- launching & debugging start --> <extension - id="org.tizen.nativeapp.elmscaletool" - name="org.tizen.nativeapp.elmscaletool" - point="org.tizen.common.connection.tools"> - <tools - packagename="elmscalegetter" - sourcepath="/SDK/develop-tool"> - </tools> - </extension> - - <extension point="org.eclipse.debug.core.launchConfigurationTypes"> <launchConfigurationType delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegate" @@ -583,7 +487,7 @@ </toolbar> </menuContribution> </extension> - + <extension point="org.eclipse.ui.actionSets"> <actionSet @@ -595,16 +499,18 @@ path="window/additions" id="org.tizen.nativecommon.manager"> <separator name="slot"/> - </menu> + </menu> <action id="org.tizen.nativeplatform.pkginstall.action" label="Package Manager" menubarPath="window/org.tizen.nativecommon.manager/slot" - class="org.tizen.nativeplatform.pkgInstall.DialogActionDelegate" + class="org.tizen.nativeplatform.pkgmgr.DialogActionDelegate" icon="icons/package_installer.gif"> </action> + </actionSet> </extension> + <extension point="org.eclipse.ui.popupMenus"> diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java index 9ccdbff1..2103520b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java @@ -60,13 +60,7 @@ public class Activator extends AbstractUIPlugin { */ public void start(BundleContext context) throws Exception { super.start(context); - plugin = this; - - ProjectTypeManager.registerProjectArtifactType( - PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE_OLD, - PlatformProjectDependentBuilder.getInstance(), - PlatformProjectDependentPackager.getInstance(), - false); + plugin = this; ProjectTypeManager.registerProjectArtifactType( PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE, diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/BuildPackageObjectAction.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/BuildPackageObjectAction.java index 0f08bcbf..46ba5f9a 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/BuildPackageObjectAction.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/BuildPackageObjectAction.java @@ -37,196 +37,156 @@ import org.tizen.nativecommon.build.exception.SBIException; import org.tizen.nativeplatform.Activator; public class BuildPackageObjectAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate { - protected IProject project; - protected IWorkbenchWindow window; - private IStatus status = null; - private String pkgType; - - public BuildPackageObjectAction() { - } - - public BuildPackageObjectAction(IProject project) { - this.project = project; - } - - @Override - public void run(IAction action) { - - // get pkgType - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ; - IConfiguration defaultConfig = info.getDefaultConfiguration(); - String toolchainType = ""; - try { - SmartBuildInterface sbi = SmartBuildInterface.getInstance(); - String targetID = PlatformConfigurationManager.getBuildTargetName( defaultConfig ); - toolchainType = sbi.getToolchainTypeFromToolchainID( sbi.getToolchainIDFromTargetID(targetID) ); - } catch (SBIException e1) { - } - - if ( toolchainType.contains("tizen.obs") ) { - pkgType = "RPM"; - } else { - pkgType = "DEB"; - } - - CommonBuildPackageFile.setPackageType(project, pkgType); - window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - status = null; - monitor.beginTask(CommonBuildMessages.PACKAGING_APPLICATION, -1); - - CheckCancelJob cancelJob = new CheckCancelJob(monitor); - Thread checkCancelThread = new Thread(cancelJob); - checkCancelThread.start(); - - CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project); - - try { - if ( pkgType.equals("DEB") ) { - monitor.subTask("Checking package dependency..."); - packager.buildPackageDependencyCheck(); - // check terminated - if(cancelJob.getTerminateChecker()){ - cancelJob.setFinishFlag(true); - monitor.done(); - return ; - } - - checkBuildPackageContinue checkContinueJob = new checkBuildPackageContinue(); - Display.getDefault().syncExec(checkContinueJob); - while (checkContinueJob.getResult() == -1) { - } - if (checkContinueJob.getResult() == 0) { - status = new Status(Status.OK, Activator.PLUGIN_ID, CommonBuildMessages.STOP_TO_BUILD_PACKAGE); - monitor.done(); - return; - } - } - - monitor.subTask("Building package..."); - packager.buildPackage(pkgType); - } catch (SBIException e) { - e.printStackTrace(); - status = new Status(Status.ERROR, Activator.PLUGIN_ID, CommonBuildMessages.FAIL_TO_BUILD_PACKAGE); - cancelJob.setFinishFlag(true); - monitor.done(); - return; - } - - // check terminated - if(cancelJob.getTerminateChecker()){ - cancelJob.setFinishFlag(true); - monitor.done(); - return ; - } - - monitor.done(); - } - }); - } catch (Exception e) { - e.printStackTrace(); - } - - if (status != null) { - if (status.isOK()) { - MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage()); - } else { - MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage()); - } - } - - - // refresh the project explorer - try { - project.refreshLocal(IResource.DEPTH_INFINITE, null ); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - protected File findFirstFilebyExtension(File searchPath, String ext) { - File[] allFiles = searchPath.listFiles(new ExtFilter(ext)); - if (allFiles == null || allFiles.length == 0) - return null; - return allFiles[0]; - } - - protected class ExtFilter implements FilenameFilter { - protected String ext; - - public ExtFilter(String ext) { - this.ext = ext; - } - - public boolean accept(File dir, String name) { - return name.endsWith(ext); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - Object obj = null; - - if (selection instanceof TreeSelection) { - TreeSelection _selection = (TreeSelection)selection; - - if (_selection != null) { - obj = _selection.getFirstElement(); - } - } - - if (obj != null) { - if (obj instanceof IProject) { - project = (IProject) obj; - } - } - } - - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - // do nothing - } - - @Override - public void dispose() { - // do nothing - } - - @Override - public void init(IWorkbenchWindow window) { - // do nothing - } - - private class checkBuildPackageContinue implements Runnable { - private int result = -1; - - public checkBuildPackageContinue() { - } - - @Override - public void run() { - synchronized(this) { - // TODO Auto-generated method stub - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - boolean bResult = MessageDialog.openQuestion(shell, "Question", - "Dependency checking has finished.\nDo you want to continue ?"); - if (bResult) { - result = 1; - } else { - result = 0; - } - } - } - - public int getResult() { - return this.result; - } - }; + protected IProject project; + protected IWorkbenchWindow window; + private IStatus status = null; + private final String PKGTYPE = "RPM"; + + public BuildPackageObjectAction() { + } + + public BuildPackageObjectAction(IProject project) { + this.project = project; + } + + @Override + public void run(IAction action) { + + CommonBuildPackageFile.setPackageType(project, PKGTYPE); + window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + status = null; + monitor.beginTask(CommonBuildMessages.PACKAGING_APPLICATION, -1); + + CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project); + CheckCancelJob cancelJob = new CheckCancelJob(monitor, project, packager.getSbi(), true); + Thread checkCancelThread = new Thread(cancelJob); + checkCancelThread.start(); + + try { + monitor.subTask("Building package..."); + packager.buildPackage(PKGTYPE); + } catch (SBIException e) { + e.printStackTrace(); + status = new Status(Status.ERROR, Activator.PLUGIN_ID, CommonBuildMessages.FAIL_TO_BUILD_PACKAGE); + cancelJob.setFinishFlag(true); + monitor.done(); + return; + } catch (CoreException e) { + status = new Status(Status.ERROR, Activator.PLUGIN_ID, e.getMessage()); + cancelJob.setFinishFlag(true); + monitor.done(); + return; + } + + cancelJob.setFinishFlag(true); + monitor.done(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + + if (status != null) { + if (status.isOK()) { + MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage()); + } else { + MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage()); + } + } + + + // refresh the project explorer + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null ); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + protected File findFirstFilebyExtension(File searchPath, String ext) { + File[] allFiles = searchPath.listFiles(new ExtFilter(ext)); + if (allFiles == null || allFiles.length == 0) + return null; + return allFiles[0]; + } + + protected class ExtFilter implements FilenameFilter { + protected String ext; + + public ExtFilter(String ext) { + this.ext = ext; + } + + public boolean accept(File dir, String name) { + return name.endsWith(ext); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + Object obj = null; + + if (selection instanceof TreeSelection) { + TreeSelection _selection = (TreeSelection)selection; + + if (_selection != null) { + obj = _selection.getFirstElement(); + } + } + + if (obj != null) { + if (obj instanceof IProject) { + project = (IProject) obj; + } + } + } + + @Override + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // do nothing + } + + @Override + public void dispose() { + // do nothing + } + + @Override + public void init(IWorkbenchWindow window) { + // do nothing + } + + private class checkBuildPackageContinue implements Runnable { + private int result = -1; + + public checkBuildPackageContinue() { + } + + @Override + public void run() { + synchronized(this) { + // TODO Auto-generated method stub + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + boolean bResult = MessageDialog.openQuestion(shell, "Question", + "Dependency checking has finished.\nDo you want to continue ?"); + if (bResult) { + result = 1; + } else { + result = 0; + } + } + } + + public int getResult() { + return this.result; + } + }; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildCommandLauncher.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildCommandLauncher.java new file mode 100644 index 00000000..d0c019ea --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildCommandLauncher.java @@ -0,0 +1,103 @@ +/* +* NativeApp +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Taejun Ha <taejun.ha@samsung.com> +* Jiil Hyoun <jiil.hyoun@samsung.com> +* Donghyuk Yang <donghyuk.yang@samsung.com> +* Hoon Kang <h245.kang@samsung.com> +* DongHee Yang <donghee.yang@samsung.com> +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ + +package org.tizen.nativeplatform.build; + +import org.eclipse.cdt.core.CommandLauncher; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import org.tizen.common.util.ProcessMonitorThread; +import org.tizen.nativecommon.build.CommonProjectDependentBuilder; +import org.tizen.nativecommon.build.ProjectTypeManager; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; + + +public class PlatformBuildCommandLauncher extends CommandLauncher { + @Override + public Process execute(IPath commandPath, String[] args, String[] env, + IPath changeToDirectory, IProgressMonitor monitor) throws CoreException { + + Process proc = null; + + if ( commandPath.toString().contains( "sbi-make") ) { + IProject proj = getProject(); + CommonProjectDependentBuilder builder = ProjectTypeManager.getProjectBuilderInstance(proj); + SmartBuildInterface sbi = SmartBuildInterface.getInstance(proj); + + String targetID = builder.getTargetID(); + String toolchainID = sbi.getToolchainIDFromTargetID(targetID); + String rootstrapID = sbi.getRootstrapIDFromTargetID(targetID); + + try { + if (!sbi.checkRootstrapID(rootstrapID) || !sbi.checkToolchainID(toolchainID)) { + String message = String.format( + "Current build system does not support '%s' toolchain or '%s' rootstrap\n" + + "Please select toolchain supported by current build system.", + toolchainID, rootstrapID); + + throw new SBIException(message); + } + if (!sbi.checkTargetID(targetID)) { + sbi.writeTargetCfgFile(targetID); + } + } catch (SBIException e) { + e.printStackTrace(); + e.showErrorDialog(); + } + + String options = args[0]; + for( int i = 1 ; i < args.length ; i++ ) { + options = options + " " + args[i]; + } + String cmd = String.format( "%s action %s -- make -options=\"%s\"", sbi.getSBICommandPath("sbi"), targetID, options ); + + // command parsing using SBI + String[] cmds = sbi.parseCommandString( cmd ); + String[] newArgs = new String[ cmds.length - 1]; + for( int i = 0; i < cmds.length - 1; i ++ ) { + newArgs[i]= cmds[i+1]; + } + proc = super.execute( new Path(cmds[0]), newArgs, sbi.getEnvironmentVariables(), changeToDirectory, monitor); + } else { + proc = super.execute(commandPath, args, env, changeToDirectory, monitor); + } + + ProcessMonitorThread pmt = new ProcessMonitorThread(proc, monitor); + pmt.start(); + + return proc; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformConfigurationManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformConfigurationManager.java index 65e704e1..f363bd93 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformConfigurationManager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformConfigurationManager.java @@ -66,29 +66,11 @@ public class PlatformConfigurationManager extends CommonConfigurationManager public static final String SBI_PROJECT_TYPE_ID = "org.tizen.nativebuild.target.sbi.gcc45.platform"; public static final String SBI_DEFAULT_I386_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.emulator"; public static final String SBI_DEFAULT_ARM_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.device"; - public static final String SBI_DEFAULT_TARGET_NAME = "tizen-device-1.0.sb2_gcc45sbox2.armel.cdeb"; - public static final String SBI_ARM_TOOLCHAIN_NAME = "gcc45sbox2.armel.cdeb"; - public static final String SBI_ARM_SBOX2_TOOLCHAIN_NAME = "gcc45sbox2.armel.cdeb"; - public static final String SBI_ARM_ROOTSTRAP_NAME = "tizen-device-1.0.sb2"; - public static final String SBI_I386_TOOLCHAIN_NAME = "gcc45sbox2.i386.cdeb"; - public static final String SBI_I386_SBOX2_TOOLCHAIN_NAME = "gcc45sbox2.i386.cdeb"; - public static final String SBI_I386_ROOTSTRAP_NAME = "tizen-emulator-1.0.sb2"; - - public static final String TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE_OLD = "com.samsung.slp.nativeide.buildArtefactType.cdeb"; - public static final String SBI_PROJECT_TYPE_ID_OLD = "com.samsung.slp.nativebuild.target.sbi.gcc45sbox2.cdeb"; - public static final String SBI_DEFAULT_I386_CONFIGRATION_ID_OLD = "com.samsung.slp.nativeide.config.sbi.gcc45sbox2.cdeb.emulator"; - public static final String SBI_DEFAULT_ARM_CONFIGRATION_ID_OLD = "com.samsung.slp.nativeide.config.sbi.gcc45sbox2.cdeb.device"; // get compiler flags public static String getAllCFlags( IConfiguration config ) { String c_compiler_id = SBI_BASE_C_COMPILER_TOOL_ID; - - // TODO: should be removed - if ( isOldConfiguration(config) ) { - c_compiler_id = SBI_BASE_C_COMPILER_TOOL_ID_OLD; - } - return getAllCompilerFlags( config, c_compiler_id ); } @@ -96,12 +78,6 @@ public class PlatformConfigurationManager extends CommonConfigurationManager public static String getAllCPPFlags( IConfiguration config ) { String cpp_compiler_id = SBI_BASE_CPP_COMPILER_TOOL_ID; - - // TODO: should be removed - if ( isOldConfiguration(config) ) { - cpp_compiler_id = SBI_BASE_CPP_COMPILER_TOOL_ID_OLD; - } - return getAllCompilerFlags( config, cpp_compiler_id ); } @@ -133,10 +109,7 @@ public class PlatformConfigurationManager extends CommonConfigurationManager compilerFlags = compilerFlags.trim(); return compilerFlags; - } - - - + } protected static boolean isCPPProject( IConfiguration config ) { @@ -152,75 +125,12 @@ public class PlatformConfigurationManager extends CommonConfigurationManager return false; } - - - public static void changeToolchain( IConfiguration config, ICResourceDescription cfgd, String toolchainNameInCfg) { - - IToolChainModificationManager tcmmgr = ManagedBuildManager.getToolChainModificationManager(); - IToolChain[] r_tcs = ManagedBuildManager.getRealToolChains(); - IToolChain[] v_tcs; - - IResourceInfo ri = config.getResourceInfo(cfgd.getPath(), false); - IToolListModification mod; - - if (ri instanceof IFolderInfo) { - mod = tcmmgr.createModification((IFolderInfo)ri); - } else { - mod = tcmmgr.createModification((IFileInfo)ri); - } - - IToolChain realToolChain = null; - if (ri instanceof IFolderInfo) { - IToolChain toolChainInstance = ((IFolderInfoModification)mod).getToolChain(); - realToolChain = ManagedBuildManager.getRealToolChain(toolChainInstance); - if (realToolChain==null) - realToolChain = toolChainInstance; - } - - boolean isMng = config.getBuilder().isManagedBuildOn(); - ArrayList<IToolChain> list = new ArrayList<IToolChain>(); - - IToolChain[] tcs = r_tcs; - IFolderInfoModification fim = (IFolderInfoModification)mod; - tcs = fim.getCompatibleToolChains(); - IToolChain[] tcs1 = new IToolChain[tcs.length + 1]; - System.arraycopy(tcs, 0, tcs1, 0, tcs.length); - tcs1[tcs.length] = realToolChain; // add existing toolchain - tcs = tcs1; - - for (IToolChain tc : tcs) { - if ( tc.isSystemObject() && !(((ToolChain)tc).isPreferenceToolChain() && !isMng) ) { - // NO TOOLCHAIN - continue; - } - list.add(tc); - } - - v_tcs = list.toArray(new IToolChain[list.size()]); - int x = 0; - IFolderInfoModification foim = (IFolderInfoModification)mod; - - for (int i = 0 ; i < v_tcs.length ; i++) { - if (v_tcs[i].getName().equals(toolchainNameInCfg)) { - x = i; - break; - } - } - - IToolChain tc = v_tcs[x]; - if (tc == null) return; - - - foim.setToolChain(tc); - - try { - mod.apply(); - } catch (CoreException e) { - ManagedBuilderUIPlugin.log(e); - } + public static void changeToolchain(IConfiguration config, String targetId) { + SmartBuildInterface sbi = SmartBuildInterface.getInstance(); + setBuildTargetName(config, targetId); + setToolCommand(config); } - - + /* public static String updateBuildTargetConfiguration( IConfiguration config ) throws SBIException { // get target name @@ -253,23 +163,12 @@ public class PlatformConfigurationManager extends CommonConfigurationManager // check toolchain name if ( !sbi.checkToolchainID(toolchainID) ) { - // change "gcc-4.5.3-i386.sb2" , "gcc-4.5-i386.cdeb.sb2" - if ( ( toolchainID.equals("gcc-4.5.3-i386.sb2") || toolchainID.equals("gcc-4.5-i386.cdeb.sb2") ) && - sbi.checkToolchainID( SBI_I386_SBOX2_TOOLCHAIN_NAME ) ) { - toolchainID = SBI_I386_SBOX2_TOOLCHAIN_NAME; - } - // change "gcc-4.5.3-armel.sb2" , "gcc-4.5-armel.cdeb.sb2" - else if ( ( toolchainID.equals("gcc-4.5.3-armel.sb2") || toolchainID.equals("gcc-4.5-armel.cdeb.sb2") ) && - sbi.checkToolchainID( SBI_ARM_SBOX2_TOOLCHAIN_NAME ) ) { - toolchainID = SBI_ARM_SBOX2_TOOLCHAIN_NAME; - } else { - // set default - if ( config.getName().contains(SBI_DEVICE_CONFIG_SUFFIX) ) { - toolchainID = SBI_ARM_TOOLCHAIN_NAME; - } else { - toolchainID = SBI_I386_TOOLCHAIN_NAME; - } - } + // set default + if ( config.getName().contains(SBI_DEVICE_CONFIG_SUFFIX) ) { + toolchainID = SBI_ARM_OBS_TOOLCHAIN_NAME; + } else { + toolchainID = SBI_I386_OBS_TOOLCHAIN_NAME; + } } // create target name && update configuration @@ -283,23 +182,26 @@ public class PlatformConfigurationManager extends CommonConfigurationManager return targetID; } - + */ public static String getRootstrapPath( IConfiguration config ) { try { - - // if not exist, update target configuration - String targetID = updateBuildTargetConfiguration( config ); - - // return rootstrap + String targetID = getBuildTargetName(config); + if (targetID == null) { + targetID = getDefaultBuildTargetName(config); + } SmartBuildInterface sbi = SmartBuildInterface.getInstance(); - return sbi.getRootstrapPath(targetID); - + String path = sbi.getRootstrapPath(targetID); + if (path == null) { + return ""; + } else { + return sbi.getRootstrapPath(targetID); + } } catch (SBIException e) { e.printStackTrace(); return "/"; } - } + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformMakeGenerator.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformMakeGenerator.java index eda8b6d9..faf35480 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformMakeGenerator.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformMakeGenerator.java @@ -77,7 +77,7 @@ public class PlatformMakeGenerator implements IManagedBuilderMakefileGenerator2 public IPath getBuildWorkingDir() { // return project folder if ( topBuildDir != null ) { - return topBuildDir.removeFirstSegments(1); + return topBuildDir.removeFirstSegments(1).removeLastSegments(1); } return null; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java index bf5ce7a2..57da5dba 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java @@ -31,8 +31,16 @@ package org.tizen.nativeplatform.build; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; import org.tizen.nativecommon.build.CommonProjectDependentBuilder; import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativecommon.build.obs.PasswordInputDialog; +import org.tizen.nativecommon.build.obs.UserInformation; +import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; public class PlatformProjectDependentBuilder extends CommonProjectDependentBuilder { @@ -95,20 +103,49 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild @Override protected String getDebugOption(String[] arrOption) { - String gdbOptions = "-gdb-options=\'"; - for (int i = 0 ; i < arrOption.length ; i++) { - gdbOptions = gdbOptions.concat(arrOption[i] + " "); - } - gdbOptions = gdbOptions.concat("\' "); + String options = ""; + String rootstrapPath = ""; + String targetId = getTargetID(); - String sysroot=""; - try { - sysroot = String.format("-sysroot=%s", getSbi().getRootstrapPath(getTargetID()) ); - } catch (SBIException e) { - e.printStackTrace(); + if (targetId.contains("obs")) { + String passwd = getSudoPassword(); + options = String.format("-passwd=%s -gdb-options=\'", passwd); + try { + rootstrapPath = new Path(getSbi().getRootstrapPath(getTargetID())).makeAbsolute().toOSString(); + } catch (SBIException e) { + e.printStackTrace(); + } + + for (int i = 0 ; i < arrOption.length ; i++) { + if (arrOption[i] == null) { + break; + } else if (arrOption[i].startsWith("--cd")) { + continue; + } else if (arrOption[i].contains(rootstrapPath)) { + String op = arrOption[i].replaceAll(rootstrapPath, ""); + options = options.concat(op + " "); + } else { + options = options.concat(arrOption[i] + " "); + } + } + options = options.concat("\' "); + return options; + + } else { + options = "-gdb-options=\'"; + for (int i = 0 ; i < arrOption.length ; i++) { + options = options.concat(arrOption[i] + " "); + } + options = options.concat("\' "); + String sysroot=""; + try { + rootstrapPath = getSbi().getRootstrapPath(getTargetID()); + sysroot = String.format("-sysroot=%s", rootstrapPath ); + } catch (SBIException e) { + e.printStackTrace(); + } + return options.concat(sysroot); } - - return gdbOptions + sysroot; } @Override @@ -117,14 +154,37 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild } @Override - public void setToolCommand(IConfiguration config, String rootstrapCfgName) { - PlatformConfigurationManager.setToolCommand(config, rootstrapCfgName); + public void setToolCommand(IConfiguration config) { + PlatformConfigurationManager.setToolCommand(config); } @Override - public void changeToolchain(IConfiguration config, - ICResourceDescription cfgd, String toolchainNameInCfg) { - PlatformConfigurationManager.changeToolchain(config, cfgd, toolchainNameInCfg); + public void changeToolchain(IConfiguration config, String targetId) { + PlatformConfigurationManager.changeToolchain(config, targetId); + } + + private String getSudoPassword() { + if (UserInformation.getRootPassword() == null) { + openPasswordDialog(); + } + + return UserInformation.getRootPassword(); + } + + private void openPasswordDialog(){ + + Display display = PlatformUI.getWorkbench().getDisplay(); + display.syncExec(new Runnable() { + @Override + public void run() { + Shell shell = PlatformUI.getWorkbench().getDisplay().getShells()[0]; + PasswordInputDialog passwordDialog = new PasswordInputDialog(shell, "Input password"); + if( passwordDialog.open() == Window.OK){ + UserInformation.setRootPassword(passwordDialog.getPassword()); + UserInformation.setSavePassword(passwordDialog.isSavePassword()); + } + } + }); } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java index 4245c134..5e1ff2c5 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java @@ -31,6 +31,7 @@ package org.tizen.nativeplatform.build; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -62,31 +63,44 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack super(project); } - @Override - public String getPackageOption(String pkgType) { - String workingDir = getWorkingDir(); - - String options = String.format( - "-WORKING_DIR=%s" + - " -PKG_TYPE=%s" , - workingDir , - pkgType ); - - return options; - } @Override public String getPackageOption(IConfiguration config, String pkgType) { String workingDir = getWorkingDir(config); + String options = ""; + String passwd = getSudoPassword(pkgType); + if (passwd == null) { + return null; + } - String options = String.format( - "-WORKING_DIR=%s" + - " -PKG_TYPE=%s" , - workingDir , - pkgType ); + if (RPM.equals(pkgType)) { + options = String.format( + "-PASSWD=%s " + + "-WORKING_DIR=%s " + + "-PKG_TYPE=%s" , + passwd, + workingDir, + pkgType ); + } else { + options = String.format( + "-WORKING_DIR=%s " + + "-PKG_TYPE=%s" , + workingDir, + pkgType ); + } return options; } + + private String getSudoPassword(String pkgType) { + if (UserInformation.getRootPassword() == null) { + if (!openPasswordDialog(pkgType)) { + return null; + } + } + + return UserInformation.getRootPassword(); + } public boolean openPasswordDialog(String pkgType){ if( UserInformation.isSavePassword() || !RPM.equals(pkgType)){ @@ -108,23 +122,14 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack } } }); - if( isDialogCancel){ - return false; - } - else{ - return true; - } + + return !isDialogCancel; } public void buildPackage(String pkgType) throws SBIException { - String targetID = getTargetID(); - String projectDir = getProjectPath(); - String options = getPackageOption(pkgType); + IConfiguration config = getCurrentConfiguration(); - if( openPasswordDialog(pkgType)){ - sbi.setProject(project); - sbi.actionConsole("buildpackage", options, targetID, projectDir, "Packaging" ); - } + buildPackage(config, pkgType); } @@ -139,30 +144,34 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack } } - String targetID = getTargetID(config); - String projectDir = getProjectPath(); - String options = getPackageOption(config, pkgType); - - if( openPasswordDialog(pkgType)) { - sbi.setProject(project); - sbi.actionConsole("buildpackage", options, targetID, projectDir, "Packaging" ); - } + buildPackage(config, pkgType); } + + // command "build package" from specified configuration and pkgType + private void buildPackage(IConfiguration config, String pkgType) throws SBIException { + String targetID = getTargetID(config); + String projectDir = getProjectPath(); + String options = getPackageOption(config, pkgType); + + if (options == null) { + return; + } + + sbi.actionConsole("buildpackage", options, targetID, projectDir, "Packaging" ); //$NON-NLS-1$ //$NON-NLS-2$ + } + + public void buildPackageDependencyCheck() throws SBIException { - String targetID = getTargetID(); + IConfiguration config = getCurrentConfiguration(); + String targetID = getTargetID(config); String projectDir = getProjectPath(); String options = getPackageDependencyCheckOption(); sbi.actionConsole("checkbuilddeps", options, targetID, projectDir, "Packaging" ); } - @Override - public String getTargetID() { - IConfiguration config = getConfiguration(); - return PlatformConfigurationManager.getBuildTargetName(config); - } @Override public String getTargetID(IConfiguration config) { @@ -188,4 +197,16 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack public boolean checkPackageFile(String pkgType) { return false; } + + @Override + public void buildPackage(String configName, String pkgType, boolean signApp) + throws SBIException, CoreException { + buildPackage(configName, pkgType); + } + + @Override + public void buildPackage(String pkgType, boolean signApp) + throws SBIException, CoreException { + buildPackage(pkgType); + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java index ef01062e..8ce4b9fb 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java @@ -73,11 +73,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.TwoPaneElementSelector; - +import org.tizen.common.TizenPlatformConstants; import org.tizen.common.connection.ConnectionPlugin; -import org.tizen.common.connection.debugtools.DebugTool; import org.tizen.common.util.LocalPortChecker; - import org.tizen.nativecommon.build.CommonConfigurationManager; import org.tizen.nativecommon.build.CommonProjectDependentBuilder; import org.tizen.nativecommon.build.ProjectTypeManager; @@ -91,18 +89,11 @@ import org.tizen.nativeplatform.Activator; import org.tizen.sdblib.IDevice; public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { - protected static final String PACKAGE_EXTENSION = ".deb"; - protected static final String CMD_RESULT_CHECK = "; echo $?;"; - protected static final String GDBSERVER_DIR = "gdbserver"; - protected static final String GDBSERVER_BIN = "gdbserver"; protected IConfiguration selectedConfig; protected IDevice currentDevice; protected String executeResult = ""; - protected static final String LOCALHOST = "127.0.0.1"; - protected static final String ENVIRONMENT_SETTING_CMD = "export "; protected int localDebugPort = -1; protected ICDISession debugSession; - protected static final String ELM_SCALE_GETTER = "/home/developer/sdk_tools/elm_scale_getter/get_elm_scale "; protected static final int defaultTimeOut = 60000; protected String getPluginID() { @@ -340,7 +331,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER, 1); monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER); String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); - String gdbserverCmd = DebugTool.TOOLS_TARGET_PATH + "/" + GDBSERVER_DIR + "/" + GDBSERVER_BIN + " :" + gdbserverPort; + String gdbserverCmd = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " :" + gdbserverPort; String execArg = setArguments(config); String envCmd = setEnvironments(config); String command = envCmd + gdbserverCmd + " " + execArg; @@ -388,7 +379,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException { ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true); - wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, LOCALHOST); + wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, TizenPlatformConstants.LOCALHOST); String gdbserverPort = wc.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN); try { @@ -426,7 +417,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { String envs = ""; String[] envArray = getEnvironment(config); for (String env : envArray) - envs = ENVIRONMENT_SETTING_CMD + env + " && "; + envs = TizenPlatformConstants.ENVIRONMENT_SETTING_CMD + env + " && "; return envs; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java index 8bdbe252..cf2a75fe 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java @@ -48,20 +48,19 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.TwoPaneElementSelector; -import org.tizen.common.connection.debugtools.DebugTool; +import org.tizen.common.TizenPlatformConstants; import org.tizen.nativecommon.launch.TizenDeviceProcessList; import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; import org.tizen.nativecommon.launch.TizenLaunchMessages; public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegate { protected Integer pid = Integer.valueOf(-1); - protected final String ATTACH_OPTION = " --attach "; @Override protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException { ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true); - wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, LOCALHOST); + wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, TizenPlatformConstants.LOCALHOST); String gdbserverPort = wc.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH); try { @@ -88,8 +87,8 @@ public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegat newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null); String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); - String commandArguments = ":" + gdbserverPort + ATTACH_OPTION + pid; - String gdbserverCmd = DebugTool.TOOLS_TARGET_PATH + "/" + GDBSERVER_DIR + "/" + GDBSERVER_BIN + " " + commandArguments; + String commandArguments = ":" + gdbserverPort + TizenPlatformConstants.ATTACH_OPTION + pid; + String gdbserverCmd = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " " + commandArguments; String envCmd = setEnvironments(config); String command = envCmd + gdbserverCmd; currentDevice.executeShellCommand(command); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForCore.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForCore.java index de157006..dac578d1 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForCore.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForCore.java @@ -3,13 +3,13 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * -* Contact: +* Contact: * Taejun Ha <taejun.ha@samsung.com> * Jiil Hyoun <jiil.hyoun@samsung.com> * Donghyuk Yang <donghyuk.yang@samsung.com> -* Hoon Kang <h245.kang@samsung.com> +* Hoon Kang <h245.kang@samsung.com> * DongHee Yang <donghee.yang@samsung.com> -* +* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -57,7 +57,7 @@ import org.eclipse.debug.core.model.IProcess; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; - +import org.tizen.common.TizenPlatformConstants; import org.tizen.common.connection.ui.TizenRemoteFileDialog; import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult; import org.tizen.nativecommon.launch.TizenLaunchMessages; @@ -67,7 +67,6 @@ import org.tizen.sdblib.SyncService; import org.tizen.sdblib.SyncService.SyncResult; public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate { - protected final static String DEFAULT_CORE_DIR = "/opt/bs/core"; private FileEntry coreDir = null; @Override @@ -76,7 +75,7 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); wc.doSave(); } - + @Override protected void launchApplicationForDebug(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException, OperationCanceledException { try { @@ -94,7 +93,7 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate try { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT, 2); monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT); - + ICDebugConfiguration debugConfiguration = getDebugConfig(config); String strPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, ""); @@ -105,13 +104,13 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT, null); String projectPath = project.getLocation().toOSString(); String coreFilePath = projectPath + "/core." + project.getName(); - boolean isSuccess = false; + boolean isSuccess = false; try { isSuccess = downloadCoreFile(remotePath, coreFilePath, new SubProgressMonitor(monitor, 1)); } catch (IOException e) { newCoreException(TizenLaunchMessages.CANNOT_FIND_CORE_FILE, e); } - + if(isSuccess == false) newCoreException(TizenLaunchMessages.CANNOT_FIND_CORE_FILE, null); @@ -133,7 +132,7 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate } String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); IPath hostPath = getHostPath(appPath, config); - + GDBCDIDebugger2 debugger = new GDBCDIDebugger2(); ICDISession debugSession = ((ICDIDebugger2)debugger).createSession(launch, hostPath.toFile(), new SubProgressMonitor(monitor, 1)); if(debugSession == null) @@ -164,19 +163,19 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate monitor.done(); } } - + private FileEntry promptForCoreFilePath(final IProject project, ICDebugConfiguration debugConfig) throws CoreException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); window = windows[0]; } - + final Shell shell = window.getShell(); if (shell != null) { shell.getDisplay().syncExec(new Runnable() { public void run() { - TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, "Select a directory where exist coredump file", currentDevice, true, DEFAULT_CORE_DIR); + TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, "Select a directory where exist coredump file", currentDevice, true, TizenPlatformConstants.PUBICL_PLATFORM_CORE_PATH); if (dlg.open() == TizenRemoteFileDialogResult.OK) coreDir = dlg.getSelectedFileEntry(); else @@ -217,9 +216,9 @@ public class TizenDebianLaunchDelegateForCore extends TizenDebianLaunchDelegate if (found == null) return false; - + SyncResult result = currentDevice.getSyncService().pullFile(found.getFullPath(), destFilePath, true, SyncService.getNullProgressMonitor()); - + if (result.getCode() == SyncService.RESULT_OK) return true; else diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties index 831e591b..516b3ec8 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties @@ -1,23 +1,23 @@ -CANNOT_FIND_PROJECT_NAME = Cannot find a project name. -CANNOT_CONNECT_TO_DEVICE = Cannot connect to a device. -CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP = Cannot find binary file in a host rootstrap. -CANNOT_CREATE_PACKAGE = Cannot create package. -CANNOT_TRANSFER_FILE = Cannot transfer file. -CANNOT_INSTALL = Cannot install application. -CANNOT_LAUNCH = Cannot launch application. -CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER = Cannot launch application with GDBServer. -CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT = Cannot launch application with GDBClient. -BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE = Build configuration does not match with current device type. Select correct device or build configuration. -CANNOT_FIND_HOST_ROOTSTRAP_PATH = Cannot find host rootstrap path. -CANNOT_FIND_DEBIAN_CONTROL_FILE = Cannot find debian control file. -CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE = Cannot find package section in control file. +CANNOT_FIND_PROJECT_NAME = Project name not found. +CANNOT_CONNECT_TO_DEVICE = Device connection failed. +CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP = Binary file not found in the host rootstrap. +CANNOT_CREATE_PACKAGE = Package creation failed. +CANNOT_TRANSFER_FILE = File transfer failed. +CANNOT_INSTALL = Application installation failed. +CANNOT_LAUNCH = Application launch failed. +CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER = Application launch with GDBServer failed. +CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT = Application launch with GDBClient failed. +BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE = Build configuration does not match the current device type. Select the correct device or build configuration. +CANNOT_FIND_HOST_ROOTSTRAP_PATH = Host rootstrap path not found. +CANNOT_FIND_DEBIAN_CONTROL_FILE = Debian control file not found. +CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE = Package section not found in the control file. OPERATION_CANCELED = Operation canceled. -LAUNCH_APPLICATION = Launching Application... -LAUNCH_APPLICATION_WITH_GDBSERVER = Launching application with GDBServer... -LAUNCH_APPLICATION_WITH_GDBCLIENT = Launching application with GDBClient... +LAUNCH_APPLICATION = Launching the application... +LAUNCH_APPLICATION_WITH_GDBSERVER = Launching the application with GDBServer... +LAUNCH_APPLICATION_WITH_GDBCLIENT = Launching the application with GDBClient... PREPARE_TO_LAUNCH = Preparing to launch... -START_DEPLOY_PROCESS = Start deploy process... -CREATE_PACKAGE = Creating package... -TRANSFER_PACKAGE = Transferring package... -INSTALL_PACKAGE = Installing package... +START_DEPLOY_PROCESS = Starting the deployment process... +CREATE_PACKAGE = Creating the package... +TRANSFER_PACKAGE = Transferring the package... +INSTALL_PACKAGE = Installing the package... diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/DialogActionDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/DialogActionDelegate.java deleted file mode 100644 index 42ea43f6..00000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/DialogActionDelegate.java +++ /dev/null @@ -1,106 +0,0 @@ -/* -* Inhouse -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: -* Taejun Ha <taejun.ha@samsung.com> -* Jiil Hyoun <jiil.hyoun@samsung.com> -* Donghyuk Yang <donghyuk.yang@samsung.com> -* Hoon Kang <h245.kang@samsung.com> -* DongHee Yang <donghee.yang@samsung.com> -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Contributors: -* - S-Core Co., Ltd -* -*/ -package org.tizen.nativeplatform.pkgInstall; - -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.IManagedProject; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import org.tizen.common.connection.ConnectionPlugin; - - -import org.tizen.nativecommon.build.CurrentEnabledProject; -import org.tizen.nativeplatform.build.PlatformConfigurationManager; -import org.tizen.sdblib.IDevice; - -public class DialogActionDelegate implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - - PackageManager pkgdlg; - String target = null; - boolean enableRootstrap = true; - boolean eanbleTarget = true; - @Override - public void run(IAction arg0) { - // TODO Auto-generated method stub - //DeviceMachine machine = DeviceManager.getSelectedDevice(); - IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - if (device == null) { - eanbleTarget = false; - } else { - target = device.getSerialNumber(); - if (target == null) { - eanbleTarget = false; - } - } - - IProject project = CurrentEnabledProject.getCurrentProject(); - if (project == null) { - enableRootstrap = false; - } else { - IConfiguration cfg =ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); - IManagedProject managedProject = cfg.getManagedProject(); - String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); - if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE) && - !projectArtifactType.equals(PlatformConfigurationManager.OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { - enableRootstrap = false; - }else - enableRootstrap = true; - } - - pkgdlg = new PackageManager(window.getShell(), target, enableRootstrap, eanbleTarget); - pkgdlg.open(); - - } - - @Override - public void selectionChanged(IAction arg0, ISelection arg1) { - // TODO Auto-generated method stub - - } - - @Override - public void dispose() { - // TODO Auto-generated method stub - } - - @Override - public void init(IWorkbenchWindow arg0) { - // TODO Auto-generated method stub - this.window = arg0; - this.enableRootstrap = true; - this.eanbleTarget = true; - } - -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageCommander.java deleted file mode 100644 index bc89675b..00000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageCommander.java +++ /dev/null @@ -1,706 +0,0 @@ -/* -* Inhouse -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: -* Taejun Ha <taejun.ha@samsung.com> -* Jiil Hyoun <jiil.hyoun@samsung.com> -* Donghyuk Yang <donghyuk.yang@samsung.com> -* Hoon Kang <h245.kang@samsung.com> -* DongHee Yang <donghee.yang@samsung.com> -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Contributors: -* - S-Core Co., Ltd -* -*/ -package org.tizen.nativeplatform.pkgInstall; - -import java.io.File; -import java.io.FileWriter; -import java.io.OutputStream; - -import org.tizen.common.util.HostUtil; - -import org.tizen.nativecommon.build.SmartBuildInterface; -import org.tizen.nativecommon.build.exception.SBIException; -import org.tizen.sdblib.IDevice; - -public class PackageCommander { - - private final static SmartBuildInterface sbi = SmartBuildInterface.getInstance(); - private final static int MAX_TIMEOUT = 60000; - private final static int VERIFY_SSHCONN_TIMEOUT = 30000; - - public PackageCommander() { - } - - public static String getCurrentSourceListForRootstrap(String targetID) throws SBIException { - - String result = ""; - - try { - result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'cat /etc/apt/sources.list\' -path=." ), - targetID, null ); - } catch (SBIException e) { - e.printStackTrace(); - } - - return result.trim(); - } - - public static String getCurrentSourceListForRealTarget(IDevice device, PackageManagerOuputReceiver rec) { - String command = "cat /etc/apt/sources.list"; - String result = ""; - - if (device != null) { - try { - device.executeShellCommand(command, rec, MAX_TIMEOUT); - for (String line : rec.getLog()) { - result = result + line + "\n"; - } - - } catch (Exception e) { - e.printStackTrace(); - } - - if (device.isEmulator()) { - String[] splitResult = result.split("\n"); - if (splitResult.length > 1) { - result = splitResult[1]; - } else if (splitResult.length == 1){ - result = splitResult[0]; - } - } - - } - - return result.trim(); - } - - public static void changeSourceListForRealTarget(String sourceList, IDevice device) { - String command = String.format("echo \"%s\" > /etc/apt/sources.list", sourceList); - - if (device != null) { - try { - device.executeShellCommand(command); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - public static void changeSourceListForRootstrap(String targetID, String sourceList) { - if (targetID == null) { - return; - } - - try { - String rootstrapPath = sbi.getRootstrapPath(targetID); - String sourcesListFile = rootstrapPath + "/etc/apt/sources.list"; - - /** "echo" command is not used on shell.execute() **/ - // String command = String.format("/bin/echo \"%s\" > %s/etc/apt/sources.list", sourceList, rootstrapPath); - - - File file = new File(sourcesListFile); - FileWriter writer = new FileWriter(file); - writer.write(sourceList); - writer.close(); - } catch(SBIException e) { - e.printStackTrace(); - } catch(Exception e1) { - e1.printStackTrace(); - } - } - - public static void resolveDpkgInterruptForRootstrap(String targetID, - OutputStream stdoutStream, OutputStream stderrStream) { - if (targetID == null) { - return; - } - - String command = "dpkg --configure -a"; - - try { - sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static void aptGetUpdateForRootstrap(String targetID, - OutputStream stdoutStream, OutputStream stderrStream) { - if (targetID == null) { - return; - } - - String command = "apt-get update"; - - try { - sbi.actionStream("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null, stdoutStream, stderrStream ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.setMessage("Failed to update. please check console view."); - e.printStackTrace(); - e.showErrorDialog(); - } - } - - public static boolean verifySshConnectionForRootstrap(String targetID, String remoteAddr) { - String command = "ssh -oStrictHostKeyChecking=no " + remoteAddr + " exit"; - int result = 0; - - if (targetID == null) { - return false; - } - - try { - result = sbi.actionReturnExitValue("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.setMessage(String.format("Failed to execute \"%s\"", command)); - e.printStackTrace(); - e.showErrorDialog(); - } - - if (result != 0) { - SBIException e = new SBIException( - String.format("Failed to connect \"%s\".", remoteAddr)); - e.showErrorDialog(); - return false; - } - return true; - } - - public static void aptGetUpgradeForRootstrap(String targetID, - OutputStream stdoutStream, OutputStream stderrStream) { - - if (targetID == null) { - return; - } - - String command = "apt-get --force-yes -y dist-upgrade"; - try { - sbi.actionStream("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null, stdoutStream, stderrStream ); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - - public static void aptGetInstallForRootstrap(String targetID, String pkgList, - OutputStream stdoutStream, OutputStream stderrStream) { - if (targetID == null) { - return; - } - - String command = String.format("apt-get --force-yes -y install %s", pkgList); - try { - sbi.actionStream("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null, stdoutStream, stderrStream ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - - public static void aptGetInstallForTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - String command = String.format("apt-get --force-yes -y install %s", pkgName); - - if (device != null) { - try { - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - - public static void dpkgInstallForRootstrap(String targetID, String debList, - OutputStream stdoutStream, OutputStream stderrStream) { - - if (targetID == null) { - return ; - } - - String command = String.format("dpkg -i %s", debList); - try { - sbi.actionStream("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null, stdoutStream, stderrStream ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static void aptGetUpdateForRealTarget(IDevice device, PackageManagerOuputReceiver rec) { - String command = "apt-get update"; - - if (device != null) { - try { - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - public static void fixBrokenForRootstrap(String targetID, OutputStream stdoutStream, OutputStream stderrStream) { - - if (targetID == null) { - return ; - } - - String command = "apt-get -f -y install"; - try { - sbi.actionStream("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null, stdoutStream, stderrStream ); - } catch (SBIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static void fixBrokenForRealTarget(IDevice device, PackageManagerOuputReceiver rec) { - String command = "apt-get -f -y install"; - - if (device != null) { - try { - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - public static boolean verifySshConnectionForRealTarget(IDevice device, String remoteAddr, PackageManagerOuputReceiver rec) { - String command = "ssh -oStrictHostKeyChecking=no " + remoteAddr + " exit; echo $?"; - String log = ""; - - if (device != null) { - try { - device.executeShellCommand(command, rec, VERIFY_SSHCONN_TIMEOUT); - String[] logs = rec.getLog(); - log = logs[0]; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - if (log.equals("0")) { - return true; - } else { - SBIException e = new SBIException( - String.format("Failed to connect \"%s\".", remoteAddr)); - e.showErrorDialog(); - return false; - } - } - - - public static void aptGetUpgradeForRealTarget(IDevice device, PackageManagerOuputReceiver rec) { - String command = "apt-get --force-yes -y dist-upgrade"; - - if (device != null) { - try { - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - public static String getArchForDebFile(String debPath) { - String retStr = ""; - - String command = String.format("dpkg --info %s | grep \"Architecture: \"", debPath); - String result = HostUtil.returnExecute(command); - - if (!result.contains("Architecture: ")) { - return retStr; - } - - String[] splitResult = result.split(":"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].trim(); - - return retStr; - } - - public static String getArchOfRemotePkgForRootstrap(String pkgName, String targetID) { - String retStr = ""; - if (targetID == null) { - return ""; - } - - if (!existPkgOnRemoteForRootstrap(pkgName, targetID)) { - return retStr; - } - - try { - String command = String.format("apt-cache show %s | grep \"Architecture: \"", pkgName); - String result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - - if (!result.contains("Architecture: ")) { - return retStr; - } - - result = result.split("\n")[0]; - String[] splitResult = result.split(":"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].trim(); - - } catch (SBIException e) { - } - - return retStr; - } - private static String getValue(String header, String key) { - int s_pos = 0; - int e_pos = 0; - String ret = null; - s_pos = header.indexOf(key); - if (s_pos == -1) - return ""; - e_pos = header.indexOf("\n",s_pos); - if (e_pos == -1) { - ret = header.substring(s_pos+key.length()); - } else { - ret = header.substring(s_pos+key.length(), e_pos).trim(); - } - return ret; - } - public static String getArchOfRemotePkgForRealTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - String retStr = ""; - String archKey = "Architecture: "; - if (device != null) { - if (!existPkgOnRemoteForRealTarget(pkgName, device, rec)) { - return retStr; - } - - try { - String result = ""; - String command = String.format("apt-cache show %s | grep \"Architecture: \"", pkgName); - rec.cleanLog(); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - for(String line : rec.getLog()) { - result = result + line + "\n"; - } - - retStr = getValue(result,archKey); - } catch (Exception e) { - e.printStackTrace(); - } - } - - return retStr; - } - - - public static String getPkgNameForDebFile(String debPath) { - String retStr = ""; - - String command = String.format("dpkg --info %s | grep \"Package: \"", debPath); - String result = HostUtil.returnExecute(command); - - if (!result.contains("Package: ")) { - return retStr; - } - - String[] splitResult = result.split(":"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].trim(); - - return retStr; - } - - public static String getPkgVerForDebFile(String debPath) { - String retStr = ""; - - String command = String.format("dpkg --info %s | grep \"Version: \"", debPath); - String result = HostUtil.returnExecute(command); - - if (!result.contains("Version:")) { - return retStr; - } - - String[] splitResult = result.split(":"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].trim(); - - return retStr; - } - - public static String getPkgNewVerForRootstrap(String pkgName, String targetID) { - String retStr = ""; - if (targetID == null) { - return ""; - } - - if (!existPkgOnRemoteForRootstrap(pkgName, targetID)) { - return retStr; - } - - try { - String command = String.format("apt-cache showpkg %s | grep -A 1 \"Versions:\"", pkgName); - String result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - - if (!result.contains("Versions:")) { - return retStr; - } - - String[] splitResult = result.split("\n"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].split(" ")[0]; - } catch (SBIException e) { - e.printStackTrace(); - } - return retStr; - } - - public static String getPkgNewVerForRealTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - String retStr = ""; - - if (device != null) { - if (!existPkgOnRemoteForRealTarget(pkgName, device, rec)) { - return retStr; - } - - try { - String result = ""; - String command = String.format("apt-cache showpkg %s | grep -A 1 \"Versions:\"", pkgName); - rec.cleanLog(); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - - for (String line : rec.getLog()) { - result = result + line + "\n"; - } - - if (!result.contains("Versions:")) { - return retStr; - } - - String[] splitResult = result.split("\n"); - - if (splitResult.length < 2 ) { - return retStr; - } - - retStr = splitResult[1].split(" ")[0]; - - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - return retStr; - } - - - public static String getPkgInstalledVerForRootstrap(String pkgName, String targetID) { - String retStr = ""; - if (targetID == null) { - return ""; - } - - if (!pkgInstalledSuccessfullyForRootstrap(pkgName, targetID)) { - return retStr; - } - - try { - String command = String.format("dpkg -s %s | grep \"Version: \"", pkgName); - - String result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - - if (!result.contains("Version: ")) { - return retStr; - } - - result = result.replace("\n", " "); - String[] splitResult = result.split(" "); - if (splitResult.length < 2) { - return retStr; - } - - retStr = splitResult[1].split(" ")[0]; - } catch (SBIException e) { - e.printStackTrace(); - } - - return retStr; - } - - public static String getPkgInstalledVerForRealTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - String archKey = "Version: "; - String retStr = ""; - if (device != null) { - if (!pkgInstalledSuccessfullyForRealTarget(pkgName, device, rec)) { - return retStr; - } - - try { - String result = ""; - String command = String.format("dpkg -s %s | grep \"Version: \"", pkgName); - rec.cleanLog(); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - for (String line : rec.getLog()) { - result = result + line + "\n"; - } - - retStr = getValue(result,archKey); - - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - return retStr; - } - - public static boolean pkgInstalledSuccessfullyForRootstrap(String pkgName, String targetID) { - boolean ret = false; - - if (targetID == null) { - return ret; - } - - try { - String command = String.format("dpkg -l | grep -w \"%s \" | cut -d\" \" -f1", pkgName); - String result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command ), - targetID, null ); - - result = result.trim(); - - if (result.equals("ii")) { - ret = true; - } - - } catch (SBIException e) { - e.printStackTrace(); - } - - return ret; - } - - public static boolean pkgInstalledSuccessfullyForRealTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - boolean ret = false; - if (device != null) { - try { - String command = String.format("dpkg -l | grep -w \"%s \" | cut -d' ' -f1", pkgName); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - for (String line : rec.getLog()) { - line = line.trim(); - if (line.equals("ii")) { - ret = true; - } - } - - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - return ret; - } - - public static boolean existPkgOnRemoteForRootstrap(String pkgName, String targetID) { - boolean bRet = false; - try { - String command = String.format("apt-cache search ^%s$", pkgName); - String result = sbi.actionStdOut("command", - String.format("-mode=emulate -cmd=\'%s\' -path=.", command), - targetID, null); - - for (String line : result.split("\n")) { - String l = line.split(" - ")[0]; - if (l.equals(pkgName)) { - bRet = true; - } - } - } catch (SBIException e) { - } - - return bRet; - } - - public static boolean existPkgOnRemoteForRealTarget(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { - boolean bRet = false; - try { - String command = String.format("apt-cache search ^%s$", pkgName); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - - for (String line : rec.getLog()) { - String l = line.split(" - ")[0]; - if (l.equals(pkgName)) { - bRet = true; - } - } - } catch (Exception e) { - } - - return bRet; - } - -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManager.java deleted file mode 100644 index dd65f21a..00000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManager.java +++ /dev/null @@ -1,1658 +0,0 @@ -/* -* Inhouse -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: -* Taejun Ha <taejun.ha@samsung.com> -* Jiil Hyoun <jiil.hyoun@samsung.com> -* Donghyuk Yang <donghyuk.yang@samsung.com> -* Hoon Kang <h245.kang@samsung.com> -* DongHee Yang <donghee.yang@samsung.com> -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Contributors: -* - S-Core Co., Ltd -* -*/ -package org.tizen.nativeplatform.pkgInstall; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.console.MessageConsoleStream; - -import org.osgi.framework.Bundle; -import org.tizen.common.connection.ConnectionPlugin; -import org.tizen.common.console.ConsoleManager; - - -import org.tizen.nativecommon.build.CheckCancelJob; -import org.tizen.nativecommon.build.CurrentEnabledProject; -import org.tizen.nativecommon.build.SmartBuildInterface; -import org.tizen.nativecommon.build.exception.SBIException; -import org.tizen.nativeplatform.Activator; -import org.tizen.nativeplatform.build.PlatformConfigurationManager; -import org.tizen.sdblib.IDevice; -import org.tizen.sdblib.SyncService; -import org.tizen.sdblib.SyncService.SyncResult; - - -public class PackageManager extends Dialog { - - private TableViewer viewerForRootstrap = null; - private TableViewer viewerForTarget = null; - private static TableViewer currentViewer; - private static String CURRENT_TAB_NAME; - - private static Table tableForRootstrap = null; - private static Table tableForTarget = null; - - private Button addButtonFromFile; - private Button addButtonFromRemote; - private Button installButton; - private Button removeButton; - private Button upgradeButton; - private Button updateButton; - private Button fixBrokenButton; - - private Text repositoryText; - private Text packageListText; - - private static String ROOTSTRAP_TAB_NAME = "Build System"; - private static String TARGET_TAB_NAME = "Device"; - private static String DEB_PATH= "/tmp"; - private static String DEB_COMMAND_INSTALL = "dpkg -i"; - private static String DEB_COMMAND_UPDATEMODE = "/bin/change-booting-mode.sh --update"; - - public Shell shell; - - public String target = null; - private String addPkgListForRemote; - private String repositoryForRemote; - private static String previousFilterPath = null; - private String selectedFileList; - private String configuration; - - private IDevice device; - private Display display = null; - private FileDialog fd; - private TabFolder tabFolder; - private CopyOnWriteArrayList<Package> pkgs = null; - - private boolean enableRootstrapTab = true; - private boolean enableTargetTab = true; - - private final int MAX_TIMEOUT = 150000; - - private int x = 0; - private int y = 0; - private final int width = 960; - private final int height = 600; - - private SmartBuildInterface sbi = SmartBuildInterface.getInstance(); - - private int tabIndex = 0; - - private MouseListener removeListener = new MouseListener() - { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - CopyOnWriteArrayList<Package> pkgList = PkgModelProvider.INSTANCE.getPkgs(); - for( Package pkg: pkgList) - { - boolean selected = false; - if (CURRENT_TAB_NAME.equals(ROOTSTRAP_TAB_NAME)) { - selected = pkg.getCheckColumn1(); - } else if (CURRENT_TAB_NAME.equals(TARGET_TAB_NAME)) { - selected = pkg.getCheckColumn2(); - } - if (selected) { - pkgList.remove(pkg); - } - } - if (viewerForRootstrap != null) { - viewerForRootstrap.refresh(); - } - if (viewerForTarget != null) { - viewerForTarget.refresh(); - } - - int recentTableIndex = currentViewer.getTable().getItemCount(); - - for (int i = 0; i < recentTableIndex; i++) { - TableItem item1 = null; - TableItem item2 = null;; - - if (viewerForRootstrap != null) { - item1 = viewerForRootstrap.getTable().getItem(i); - Package pkg = (Package)item1.getData(); - item1.setChecked(pkg.getCheckColumn1()); - } - if (viewerForTarget != null) { - item2 = viewerForTarget.getTable().getItem(i); - Package pkg = (Package)item2.getData(); - item2.setChecked(pkg.getCheckColumn2()); - } - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }; - - - protected PackageManager(Shell parentShell, String target) { - super(parentShell); - setBlockOnOpen(false); - this.display = parentShell.getDisplay(); - this.target = target; - this.device = ConnectionPlugin.getDefault().getCurrentDevice(); - - Rectangle bounds = parentShell.getBounds(); - x = bounds.x + (bounds.width - width)/2; - y = bounds.y + (bounds.height - height)/2; - } - - protected PackageManager(Shell parentShell, String target, boolean enableRootstrap, boolean enableTarget) { - super(parentShell); - setBlockOnOpen(false); - this.enableRootstrapTab = enableRootstrap; - this.enableTargetTab = enableTarget; - this.display = parentShell.getDisplay(); - - if (enableRootstrap) { - IProject _project = CurrentEnabledProject.getCurrentProject(); - IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration(); - this.configuration = config.getName(); - } - if (enableTarget) { - this.target = target; - this.device = ConnectionPlugin.getDefault().getCurrentDevice(); - } - - Rectangle bounds = parentShell.getBounds(); - x = bounds.x + (bounds.width - width)/2; - y = bounds.y + (bounds.height - height)/2; - } - - protected PackageManager(Shell parentShell, String target, int tabIndex) { - super(parentShell); - setBlockOnOpen(false); - this.display = parentShell.getDisplay(); - this.target = target; - this.device = ConnectionPlugin.getDefault().getCurrentDevice(); - this.tabIndex = tabIndex; - - Rectangle bounds = parentShell.getBounds(); - x = bounds.x + (bounds.width - width)/2; - y = bounds.y + (bounds.height - height)/2; - } - - private void setImage(Shell parentShell) { - try { - Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); - parentShell.setImage(new Image(Display.getCurrent(), FileLocator.toFileURL(bundle.getEntry("icons/package_installer.gif")).getPath())); - } catch (Exception e) { - } - } - - protected void setShellStyle(int newShellStyle) { - int newStyle = newShellStyle & ~SWT.APPLICATION_MODAL; - newStyle |= SWT.MODELESS; - super.setShellStyle(newStyle); - } - - @Override - public boolean close() - { - PkgModelProvider.INSTANCE.getPkgs().clear(); - return super.close(); - } - - protected void createButtonsForButtonBar(Composite parent) - { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); - } - - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("Package Manager"); - newShell.setLocation(x, y); - newShell.setSize(width, height); - setImage(newShell); - } - - @Override - protected Control createDialogArea(Composite parent) { - - - Composite composite = new Composite( parent, SWT.None ); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setLayout(new GridLayout(1, false)); - - if (!enableRootstrapTab && !enableTargetTab) { - createError( composite, "- Any project is not selected and any connection is not connected,\n" + - "- or project is not \"PLATFORM PROJECT\"." ); - } else { - //2nd basement : Sourcelist + update button - createTopComposite( composite ); - //3rd basement : Package text + +, - button - createMiddleComposite( composite ); - //5th basement : tab (upgrade/install button + table) - createBottomComposite( composite ); - } - - return null; - } - - - private void createError( Composite parent, String message ) - { - Composite com = new Composite( parent, SWT.NONE ); - com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - com.setLayout(new GridLayout(1, false)); - - Label errorLabel = new Label(com, SWT.NONE); - errorLabel.setText(message); - } - - private void createTopComposite( Composite parent ) - { - Composite com = new Composite( parent, SWT.NONE ); - com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - com.setLayout(new GridLayout(3, false)); - - Label searchLabel = new Label( com, SWT.NONE ); - searchLabel.setText("Source List : "); - - repositoryText = new Text(com, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - - GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.widthHint = 300; - repositoryText.setLayoutData(gridData); - - if (enableRootstrapTab) { - String targetID = getTargetID(); - - try { - repositoryText.setText(PackageCommander.getCurrentSourceListForRootstrap(targetID)); - } catch (SBIException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } else if (enableTargetTab) { - //repositoryText.setText(PackageCommander.getCurrentSourceListForRealTarget(getSession())); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setPrintConsole(false); - repositoryText.setText(PackageCommander.getCurrentSourceListForRealTarget(device, rec)); - } else { - repositoryText.setText(""); - } - - updateButton = new Button( com, SWT.PUSH ); - updateButton.setText("Update "); - updateButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - repositoryForRemote = repositoryText.getText(); - - if(repositoryForRemote.isEmpty()) { - MessageDialog.openError(shell, "Error", "Repository is empty.\nPlease set repository."); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("apt-get update", -1); - - CheckCancelJob cancelJob = new CheckCancelJob(monitor); - Thread checkCancelThread = new Thread(cancelJob); - checkCancelThread.start(); - - ConsoleManager cm = new ConsoleManager( "Package Installer", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setMessageConsoleStream(mcs); - - try { - if (CURRENT_TAB_NAME.equals(ROOTSTRAP_TAB_NAME)) { - String targetID = getTargetID(); - monitor.subTask("changing source list..."); - PackageCommander.changeSourceListForRootstrap(targetID, repositoryForRemote); - - Thread.sleep(500); - - int s = repositoryForRemote.indexOf("ssh://"); - if (s != -1) { - String remoteAddr = repositoryForRemote.substring(s + 6); - int e = remoteAddr.indexOf("/"); - - remoteAddr = remoteAddr.substring(0, e); - monitor.subTask(String.format("verifying connection %s", remoteAddr)); - if (!PackageCommander.verifySshConnectionForRootstrap(targetID, remoteAddr)) { - return; - } - } - - monitor.subTask("apt-get update..."); - PackageCommander.aptGetUpdateForRootstrap(targetID, mcs, mcsError); - - } else if(CURRENT_TAB_NAME.equals(TARGET_TAB_NAME)) { - if (!device.isEmulator()) { - // Change to bootmode with update - String command = DEB_COMMAND_UPDATEMODE; - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } - /** target change source list **/ - monitor.subTask("changing source list..."); - PackageCommander.changeSourceListForRealTarget(repositoryForRemote, device); - - Thread.sleep(500); - - if (!device.isEmulator()) { - // Change to bootmode with update - String command = DEB_COMMAND_UPDATEMODE; - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } - - int s = repositoryForRemote.indexOf("ssh://"); - if (s != -1) { - String remoteAddr = repositoryForRemote.substring(s + 6); - int e = remoteAddr.indexOf("/"); - - remoteAddr = remoteAddr.substring(0, e); - - if (!PackageCommander.verifySshConnectionForRealTarget(device, remoteAddr, rec)) { - return; - } - } - - monitor.subTask("apt-get update..."); - PackageCommander.aptGetUpdateForRealTarget(device, rec); - } - monitor.subTask("updating package informations..."); - updatePkgInfoAfterAptUpdate(); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - checkCancelThread.interrupt(); - //monitor.worked(1); - monitor.done(); - } - }); - } catch (Exception e1) { - e1.printStackTrace(); - } - - currentViewer.refresh(); - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - } - private void createMiddleComposite( Composite parent ) - { - Composite com = new Composite( parent, SWT.NONE ); - com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - com.setLayout(new GridLayout(4, false)); - - Label targetLabel = new Label( com, SWT.NONE ); - targetLabel.setText("Package Name: "); - - Listener AddPackageEventHandler = new Listener() - { - - @Override - public void handleEvent(Event event) { - switch ( event.type ) - { - /* package is selected for 2 cases - * 1. Edit text in packageListText then input 'Enter' key - * 2. click addButtonFromRemote button - * so, addListener for 2 case for each cases - * then, event type is SWT.Traverse then 1st case - * and, event type is SWT.MouseDown then 2nd case - */ - case SWT.Traverse: - if( event.character == SWT.CR) - { - /* if input is enter key, then we don't want to other process for 'enter key' - * then event.doit variable is set to false - */ - event.doit = false; - } - else - { - /* if input is other key, for example tab or arrow key - * then we do not add package - */ - break; - } - case SWT.MouseDown: - - int oldTableIndex = currentViewer.getTable().getItemCount(); - - addPkgListForRemote = packageListText.getText(); - - if(addPkgListForRemote.isEmpty()) { - MessageDialog.openError(shell, "Error", "Package name is empty.\nPlease input package name for installing"); - return; - } else if(addPkgListForRemote.contains("\"") || addPkgListForRemote.contains("\'") || - addPkgListForRemote.contains(":") || addPkgListForRemote.contains(",") || - addPkgListForRemote.contains(";")) { - MessageDialog.openError(shell, "Error", "Invalid character is found. (\" \' , : ; . )\n" + - "Between package names, delimeter shoud be space character.\n" + - "(ex) sqlite3 sysv-rc sglib-dev perl"); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, false, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Adding packages to list", -1); - - if (addPkgListForRemote != "") { - addPkgListForRemote = addPkgListForRemote.trim(); - String[] arrPkgs = addPkgListForRemote.split(" "); - for (String pkgName : arrPkgs) { - if (pkgName.isEmpty()) { - continue; - } - monitor.subTask(String.format("Adding %s", pkgName)); - addColumn(currentViewer, pkgName, null, Package.PKGTYPE.REMOTE); - } - } - - monitor.worked(1); - monitor.done(); - } - }); - } catch (Exception e1) { - e1.printStackTrace(); - } - - packageListText.setText(""); - - //currentViewer.refresh(); - if (viewerForRootstrap != null) { - viewerForRootstrap.refresh(); - } - if (viewerForTarget != null) { - viewerForTarget.refresh(); - } - - int recentTableIndex = currentViewer.getTable().getItemCount(); - - for (int i = oldTableIndex; i < recentTableIndex; i++) { - TableItem item1 = null; - TableItem item2 = null;; - - if (viewerForRootstrap != null) { - item1 = viewerForRootstrap.getTable().getItem(i); - Package pkg = (Package)item1.getData(); - item1.setChecked(pkg.getCheckColumn1()); - } - if (viewerForTarget != null) { - item2 = viewerForTarget.getTable().getItem(i); - Package pkg = (Package)item2.getData(); - item2.setChecked(pkg.getCheckColumn2()); - } - } - break; - } - } - }; - - packageListText = new Text(com, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - packageListText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL)); - packageListText.addListener(SWT.Traverse, AddPackageEventHandler); - - addButtonFromRemote = new Button( com, SWT.PUSH ); - addButtonFromRemote.setImage(new Image(display, - Activator.getImageDescriptor("/icons/packagelist_to_table.gif").getImageData())); - addButtonFromRemote.setToolTipText("Add packages from remote repository"); - addButtonFromRemote.addListener(SWT.MouseDown, AddPackageEventHandler); - - - addButtonFromFile = new Button( com, SWT.PUSH ); - addButtonFromFile.setImage(new Image(display, - Activator.getImageDescriptor("/icons/folder_search.gif").getImageData())); - addButtonFromFile.setToolTipText("Add packages from file system"); - addButtonFromFile.addMouseListener(new MouseListener() - { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - - int oldTableIndex = currentViewer.getTable().getItemCount(); - - fd = new FileDialog( getShell(), SWT.OPEN|SWT.MULTI); - fd.setText("Select deb file..."); - if (previousFilterPath == null) - fd.setFilterPath(null); - else - fd.setFilterPath(previousFilterPath); - String[] filterExt = { "*.deb" }; - fd.setFilterExtensions(filterExt); - selectedFileList = fd.open(); - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, false, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Adding packages to list", -1); - if( selectedFileList != null ) - { - String[] files = fd.getFileNames(); - previousFilterPath = fd.getFilterPath(); - for (int i=0, n = files.length; i<n; i++) { - monitor.subTask(String.format("Adding %s", files[i])); - StringBuffer buf = new StringBuffer(); - buf.append(fd.getFilterPath()); - if (buf.charAt(buf.length() -1) != File.separatorChar) { - buf.append(File.separatorChar); - } - buf.append(files[i]); - addColumn( currentViewer, null, buf.toString(), Package.PKGTYPE.LOCAL); - } - } - } - }); - } catch (Exception e1) { - e1.printStackTrace(); - } - - //currentViewer.refresh(); - if (viewerForRootstrap != null) { - viewerForRootstrap.refresh(); - } - if (viewerForTarget != null) { - viewerForTarget.refresh(); - } - - int recentTableIndex = currentViewer.getTable().getItemCount(); - - for (int i = oldTableIndex; i < recentTableIndex; i++) { - TableItem item1 = null; - TableItem item2 = null;; - - if (viewerForRootstrap != null) { - item1 = viewerForRootstrap.getTable().getItem(i); - Package pkg = (Package)item1.getData(); - item1.setChecked(pkg.getCheckColumn1()); - } - if (viewerForTarget != null) { - item2 = viewerForTarget.getTable().getItem(i); - Package pkg = (Package)item2.getData(); - item2.setChecked(pkg.getCheckColumn2()); - } - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - } - - private Control getRootstrapTabControl( TabFolder tabFolder ) - { - Composite composite = new Composite( tabFolder, SWT.NONE ); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setLayout(new GridLayout(1, false)); - - Composite Com = new Composite( composite, SWT.NONE ); - Com.setLayoutData(new GridData(GridData.FILL_HORIZONTAL )); - Com.setLayout(new GridLayout(2, false)); - - Composite leftCom = new Composite( Com, SWT.NONE ); - leftCom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING)); - leftCom.setLayout(new GridLayout(1, false)); - - Composite rightCom = new Composite( Com, SWT.NONE ); - rightCom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); - //rightCom.setLayout(new GridLayout(4, false)); - rightCom.setLayout(new GridLayout(3, false)); - - Label configurationLabel = new Label(leftCom, SWT.LEFT); - configurationLabel.setText(String.format("Configuration : %s", this.configuration)); - - upgradeButton = new Button( rightCom, SWT.PUSH ); - upgradeButton.setText("Upgrade"); - upgradeButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - - repositoryForRemote = repositoryText.getText(); - - if(repositoryForRemote.isEmpty()) { - MessageDialog.openError(shell, "Error", "Repository is empty.\nPlease set repository."); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("apt-get upgrade", -1); - - CheckCancelJob cancelJob = new CheckCancelJob(monitor); - Thread checkCancelThread = new Thread(cancelJob); - checkCancelThread.start(); - - ConsoleManager cm = new ConsoleManager( "Package Installer", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - MessageConsoleStream mcsError1 = cm.getMessageConsoleStream(); - MessageConsoleStream mcs1 = cm.getMessageConsoleStream(); - String targetID = getTargetID(); - - monitor.subTask("apt-get -f -y install"); - PackageCommander.fixBrokenForRootstrap(targetID, mcs, mcsError); - - monitor.subTask("apt-get -y dist-upgrade"); - PackageCommander.aptGetUpgradeForRootstrap(targetID, mcs1, mcsError1); - - //monitor.worked(1); - checkCancelThread.interrupt(); - monitor.done(); - } - }); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - installButton = new Button( rightCom, SWT.PUSH ); - installButton.setText("Install"); - installButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - pkgs = getSelectedPkg(PkgModelProvider.INSTANCE.getPkgs()); - - if(pkgs.isEmpty()) { - MessageDialog.openError(shell, "Error", "There is no selected package."); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Installing package", -1); - - CheckCancelJob cancelJob = new CheckCancelJob(monitor); - Thread checkCancelThread = new Thread(cancelJob); - checkCancelThread.start(); - - try { - String targetID = getTargetID(); - String debPathList = ""; - String debNameList = ""; - String aptPkgList = ""; - - ConsoleManager cm = new ConsoleManager( "Installing packages", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - MessageConsoleStream mcsError1 = cm.getMessageConsoleStream(); - MessageConsoleStream mcs1 = cm.getMessageConsoleStream(); - MessageConsoleStream mcsError2 = cm.getMessageConsoleStream(); - MessageConsoleStream mcs2 = cm.getMessageConsoleStream(); - - for (Package pkg : pkgs) { - if (pkg.getPkgType().equals(Package.PKGTYPE.LOCAL)) { - debPathList = debPathList.concat(pkg.getPath() + " "); - debNameList = debNameList.concat(pkg.getName() + " "); - } else if (pkg.getPkgType().equals(Package.PKGTYPE.REMOTE)) { - aptPkgList = aptPkgList.concat(pkg.getName() + " "); - } - } - - if(!aptPkgList.equals("")) { - monitor.subTask("apt-get -f -y install"); - PackageCommander.fixBrokenForRootstrap(targetID, mcs, mcsError); - monitor.subTask(String.format("apt-get install %s", aptPkgList)); - mcs1.write("***** apt-get install *****\n"); - PackageCommander.aptGetInstallForRootstrap(targetID, aptPkgList, mcs1, mcsError1); - } - - - if(!cancelJob.getTerminateChecker() && !debNameList.equals("")) { - monitor.subTask(String.format("dpkg -i %s", debNameList)); - mcs2.write("\n***** dpkg install *****\n"); - PackageCommander.dpkgInstallForRootstrap(targetID, debPathList, mcs2, mcsError2); - /** E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. **/ - PackageCommander.resolveDpkgInterruptForRootstrap(targetID, mcs2, mcsError2); - } - - for (Package pkg : pkgs) { - String installedVer = PackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), targetID); - pkg.setInstalledVersion1(installedVer); - - if (installedVer.equals("")) { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_INSTALLED); - } else if (installedVer.equals(pkg.getNewVersion1())) { - if (PackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), targetID)) { - pkg.setInstallInfo1(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } else { - pkg.setInstallInfo1(Package.INSTALLINFO.DIFFERENT_VERSION); - } - } - - } catch (IOException e) { - e.printStackTrace(); - } - - //checkCancelThread.interrupt(); - cancelJob.setFinishFlag(true); - monitor.done(); - } - }); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - currentViewer.refresh(); - //removeButtonForLocal.setEnabled(false); - //installButtonForLocal.setEnabled(false); - //localDebs.clear(); - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - /* - fixBrokenButton = new Button( rightCom, SWT.PUSH ); - fixBrokenButton.setText("Fix-Broken"); - fixBrokenButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, false, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Fix; attempt to correct a system with broken dependencies in place", -1); - monitor.subTask("apt-get -f -y install"); - String targetID = getTargetID(); - ConsoleManager cm = new ConsoleManager( "Fix broken dependencies", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - PackageCommander.fixBrokenForRootstrap(targetID, mcs, mcsError); - monitor.done(); - } - }); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - }); - */ - - removeButton = new Button( rightCom, SWT.PUSH ); - removeButton.setToolTipText("Remove checked package from list"); - removeButton.setImage(new Image(display, - Activator.getImageDescriptor("/icons/list-delete.gif").getImageData())); - removeButton.addMouseListener(removeListener); - - bottomTableForRootstrap(composite); - - return composite; - } - - private Control getTargetTabControl( TabFolder tabFolder ) - { - Composite composite = new Composite( tabFolder, SWT.NONE ); - composite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - composite.setLayout(new GridLayout(1, false)); - - Composite com = new Composite( composite, SWT.NONE ); - com.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - com.setLayout(new GridLayout(2, false)); - - Composite leftCom = new Composite( com, SWT.NONE ); - leftCom.setLayoutData(new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING)); - leftCom.setLayout(new GridLayout(1, false)); - - Composite rightCom = new Composite( com, SWT.NONE ); - rightCom.setLayoutData(new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END)); - //rightCom.setLayout(new GridLayout(4, false)); - rightCom.setLayout(new GridLayout(3, false)); - - Label configurationLabel = new Label(leftCom, SWT.LEFT); - configurationLabel.setText(String.format("Connection : %s", device.getSerialNumber())); - - upgradeButton = new Button( rightCom, SWT.PUSH ); - upgradeButton.setText("Upgrade"); - upgradeButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - repositoryForRemote = repositoryText.getText(); - - if(repositoryForRemote.isEmpty()) { - MessageDialog.openError(shell, "Error", "Repository is empty.\nPlease set repository."); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("apt-get upgrade", -1); - - ConsoleManager cm = new ConsoleManager( "Package Installer", true); - cm.clear(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setMessageConsoleStream(mcs); - - monitor.subTask("apt-get -f -y install"); - PackageCommander.fixBrokenForRealTarget(device, rec); - - monitor.subTask("apt-get -y dist-upgrade"); - PackageCommander.aptGetUpgradeForRealTarget(device, rec); - - monitor.done(); - } - }); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - installButton = new Button( rightCom, SWT.PUSH ); - installButton.setText("Install"); - installButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - pkgs = getSelectedPkg(PkgModelProvider.INSTANCE.getPkgs()); - - if(pkgs.isEmpty()) { - MessageDialog.openError(shell, "Error", "Any package is not selected."); - return; - } - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Installing deb package", -1); - - try { - String newPath = null; - ConsoleManager cm = new ConsoleManager( "Package Installer", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setMessageConsoleStream(mcs); - String command = null; - String localPkgList = ""; - String remotePkgList = ""; - - // Step 1: transfer pkg and make pkg list - for (Package pkg : pkgs) - { - if (pkg.getPkgType().equals(Package.PKGTYPE.LOCAL)) { - String debfile = new File(pkg.getPath()).getName(); - newPath = DEB_PATH + "/" + debfile; - monitor.subTask(String.format("transfer %s to target's %s",pkg.getPath(), newPath)); - if (monitor.isCanceled()) - throw new OperationCanceledException(); - SyncService syncService = device.getSyncService(); - SyncResult syncResult = syncService.pushFile(pkg.getPath(), newPath, SyncService.getNullProgressMonitor()); - if (syncResult.getCode() != SyncService.RESULT_OK) { - mcsError.println("Faild to move file from " + pkg.getPath() + " to " + newPath); - pkg.setInstallInfo2( Package.INSTALLINFO.NOT_INSTALLED); - //viewerForTarget.refresh(); - continue; - } - if (monitor.isCanceled()) - throw new OperationCanceledException(); - - if (localPkgList == "") { - localPkgList = newPath; - } else { - localPkgList = localPkgList + " " + newPath; - } - - } else if (pkg.getPkgType().equals(Package.PKGTYPE.REMOTE)) { - if (remotePkgList == "") { - remotePkgList = pkg.getName(); - } else { - remotePkgList = remotePkgList + " " + pkg.getName(); - } - } - } - - // Step 2: set update mode on device - if (!device.isEmulator()) { - // Change to bootmode with update - command = DEB_COMMAND_UPDATEMODE; - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } - - // Step 3 : apt-get install pkg - if (remotePkgList != "") { - monitor.subTask("apt-get -y -f install"); - PackageCommander.fixBrokenForRealTarget(device, rec); - monitor.subTask(String.format("apt-get install %s", remotePkgList)); - PackageCommander.aptGetInstallForTarget(remotePkgList, device, rec); - } - - if (monitor.isCanceled()) - throw new OperationCanceledException(); - - // Step 4: install deb file - if (localPkgList != "") { - command = DEB_COMMAND_INSTALL + " " + localPkgList; - monitor.subTask(command); - device.executeShellCommand(command, rec, MAX_TIMEOUT); - } - - if (monitor.isCanceled()) - throw new OperationCanceledException(); - - Thread.sleep(500); - - for (Package pkg : pkgs) { - if (monitor.isCanceled()) - throw new OperationCanceledException(); - // update status - rec.setPrintConsole(false); - String installedVer = PackageCommander.getPkgInstalledVerForRealTarget(pkg.getName(), device, rec); - pkg.setInstalledVersion2(installedVer); - - if (installedVer.equals("")) { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_INSTALLED); - } else if (installedVer.equals(pkg.getNewVersion2())) { - if (PackageCommander.pkgInstalledSuccessfullyForRealTarget(pkg.getName(), device, rec)) { - pkg.setInstallInfo2(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } else { - pkg.setInstallInfo2(Package.INSTALLINFO.DIFFERENT_VERSION); - } - if (monitor.isCanceled()) - throw new OperationCanceledException(); - } - - monitor.done(); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - }); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - viewerForTarget.refresh(); - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - - /* - fixBrokenButton = new Button( rightCom, SWT.PUSH ); - fixBrokenButton.setText("Fix-Broken"); - fixBrokenButton.addMouseListener(new MouseListener(){ - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); - - try { - dialog.run(true, false, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - monitor.beginTask("Fix; attempt to correct a system with broken dependencies in place", -1); - monitor.subTask("apt-get -f -y install"); - ConsoleManager cm = new ConsoleManager( "Fix broken dependencies", true); - cm.clear(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(false); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setMessageConsoleStream(mcs); - PackageCommander.fixBrokenForRealTarget(device, rec); - monitor.done(); - } - }); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - }); - */ - - removeButton = new Button( rightCom, SWT.PUSH ); - removeButton.setToolTipText("Remove checked package from list"); - removeButton.setImage(new Image(display, - Activator.getImageDescriptor("/icons/list-delete.gif").getImageData())); - removeButton.addMouseListener(removeListener); - - bottomTableForTarget(composite); - - return composite; - } - - private void bottomTableForRootstrap( Composite parent ) - { - Composite bottom = new Composite( parent, SWT.NONE ); - bottom.setLayoutData(new GridData(GridData.FILL_BOTH)); - bottom.setLayout(new FillLayout()); - - viewerForRootstrap = new TableViewer( bottom, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK ); - createColumns( parent, viewerForRootstrap, ROOTSTRAP_TAB_NAME ); - tableForRootstrap = viewerForRootstrap.getTable(); - tableForRootstrap.addListener( SWT.Selection, new Listener(){ - - @Override - public void handleEvent(Event event) { - if( event.detail == SWT.CHECK ) - { - Package pkg = (Package)event.item.getData(); - pkg.setCheckColumn1( !pkg.getCheckColumn1() ); - } - } - - }); - - tableForRootstrap.setHeaderVisible(true); - tableForRootstrap.setLinesVisible(true); - - viewerForRootstrap.setContentProvider(new ArrayContentProvider()); - viewerForRootstrap.setInput(PkgModelProvider.INSTANCE.getPkgs()); - - if (tabIndex == 0) { - currentViewer = viewerForRootstrap; - CURRENT_TAB_NAME = ROOTSTRAP_TAB_NAME; - } - } - - private void bottomTableForTarget( Composite parent ) - { - Composite bottom = new Composite( parent, SWT.NONE ); - bottom.setLayoutData(new GridData(GridData.FILL_BOTH)); - bottom.setLayout(new FillLayout()); - - viewerForTarget = new TableViewer( bottom, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK); - createColumns( parent, viewerForTarget, TARGET_TAB_NAME ); - tableForTarget = viewerForTarget.getTable(); - tableForTarget.addListener( SWT.Selection, new Listener(){ - - @Override - public void handleEvent(Event event) { - if( event.detail == SWT.CHECK ) - { - Package pkg = (Package)event.item.getData(); - pkg.setCheckColumn2( !pkg.getCheckColumn2() ); - } - } - - }); - - - tableForTarget.setHeaderVisible(true); - tableForTarget.setLinesVisible(true); - - viewerForTarget.setContentProvider(new ArrayContentProvider()); - viewerForTarget.setInput(PkgModelProvider.INSTANCE.getPkgs()); - - if (tabIndex == 1) { - currentViewer = viewerForTarget; - CURRENT_TAB_NAME = TARGET_TAB_NAME; - } - } - - - private void createBottomComposite( Composite parent ) - { - tabFolder = new TabFolder( parent, SWT.BORDER ); - tabFolder.setLayoutData(new GridData( GridData.FILL_BOTH)); - tabFolder.setLayout(new GridLayout(1, false)); - - tabFolder.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - try { - String tabName = tabFolder.getSelection()[0].getText(); - if (tabName.equals(ROOTSTRAP_TAB_NAME)) { - CURRENT_TAB_NAME = ROOTSTRAP_TAB_NAME; - if (enableRootstrapTab) { - String targetID = getTargetID(); - currentViewer = viewerForRootstrap; - String sourcelist = ""; - if (!sbi.checkTargetID(targetID)) { - MessageDialog.openError(shell, "Error", "Target does not exist. please build project first"); - } else { - sourcelist = PackageCommander.getCurrentSourceListForRootstrap(targetID); - } - repositoryText.setText(sourcelist); - } - - } else if (tabName.equals(TARGET_TAB_NAME)) { - CURRENT_TAB_NAME = TARGET_TAB_NAME; - if (enableTargetTab) { - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setPrintConsole(false); - currentViewer = viewerForTarget; - repositoryText.setText(PackageCommander.getCurrentSourceListForRealTarget(device, rec)); - } - } - if (currentViewer != null) { - currentViewer.refresh(); - } - } catch (SBIException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - }); - - TabItem rootstrapTab = new TabItem( tabFolder, SWT.NULL ); - rootstrapTab.setText(ROOTSTRAP_TAB_NAME); - - if (!enableRootstrapTab) { - rootstrapTab.setControl( errorTab( tabFolder , "- Any project is not selected or project is not \"PLATFORM PROJECT\".")); - tabIndex = 1; - } else { - rootstrapTab.setControl( getRootstrapTabControl( tabFolder )); - } - - TabItem deviceTab = new TabItem( tabFolder, SWT.NULL ); - deviceTab.setText(TARGET_TAB_NAME); - if (!enableTargetTab) { - deviceTab.setControl( errorTab( tabFolder, "- Any device is not connected or selected." )); - tabIndex = 0; - } else { - deviceTab.setControl( getTargetTabControl( tabFolder )); - } - - tabFolder.setSelection(tabIndex); - } - - private Control errorTab(TabFolder tabFolder, String msg) { - Composite composite = new Composite( tabFolder, SWT.NONE ); - composite.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - composite.setLayout(new GridLayout(1, false)); - - Label errorLabel = new Label(composite, SWT.LEFT); - errorLabel.setText(msg); - - return composite; - } - - private void updatePkgInfoAfterAptUpdate() { - CopyOnWriteArrayList<Package> pkgs = PkgModelProvider.INSTANCE.getPkgs(); - - for (Package pkg : pkgs) { - if (pkg.getPkgType().equals(Package.PKGTYPE.REMOTE)) { - if (CURRENT_TAB_NAME.equals(ROOTSTRAP_TAB_NAME)) { - String targetID = getTargetID(); - String newVer = PackageCommander.getPkgNewVerForRootstrap(pkg.getName(), targetID); - if (newVer.equals("")) { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_FOUND); - pkg.setCheckColumn1(false); - } else if (pkg.getInstalledVersion1().equals("")) { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_INSTALLED); - } else if (newVer.equals(pkg.getInstalledVersion1())) { - if (PackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), targetID)) { - pkg.setInstallInfo1(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } else { - pkg.setInstallInfo1(Package.INSTALLINFO.DIFFERENT_VERSION); - } - pkg.setNewVersion1(newVer); - } else if (CURRENT_TAB_NAME.equals(TARGET_TAB_NAME)) { - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setPrintConsole(false); - String newVer = PackageCommander.getPkgNewVerForRealTarget(pkg.getName(), device, rec); - if (newVer.equals("")) { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_FOUND); - pkg.setCheckColumn2(false); - } else if (pkg.getInstalledVersion2().equals("")) { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_INSTALLED); - } else if (newVer.equals(pkg.getInstalledVersion2())) { - if (PackageCommander.pkgInstalledSuccessfullyForRealTarget(pkg.getName(), device, rec)) { - pkg.setInstallInfo2(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } else { - pkg.setInstallInfo2(Package.INSTALLINFO.DIFFERENT_VERSION); - } - pkg.setNewVersion2(newVer); - } - } - } - } - - - private boolean addColumn( TableViewer viewer, String pkgName, String debPath, Package.PKGTYPE type ) - { -// viewer.add( debName ); - CopyOnWriteArrayList<Package> pkgs = PkgModelProvider.INSTANCE.getPkgs(); - Iterator<Package> debIter = pkgs.iterator(); - //String targetID = getTargetID(); - String targetID = null; - //ISession session = null; - //IDevice device = null; - - if (enableRootstrapTab) { - targetID = getTargetID(); - } - /* - if (enableTargetTab) { - session = getSession(); - } - */ - - Package pkg; - - if (pkgName == null && debPath != null) { - pkgName = PackageCommander.getPkgNameForDebFile(debPath); - } - - while( debIter.hasNext() ) - { - pkg = debIter.next(); - if( pkg.getName().equals(pkgName)) - return true; - } - - pkg = new Package(); - if (debPath != null) { - pkg.setName(PackageCommander.getPkgNameForDebFile(debPath)); - } else if (pkgName != null) { - pkg.setName(pkgName); - } - - pkg.setTarget( this.target ); - pkg.setPath(debPath); - - String newVerForRootstrap = ""; - String newVerForTarget = ""; - - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setPrintConsole(false); - - if (type.equals(Package.PKGTYPE.LOCAL)) { - pkg.setArch1(PackageCommander.getArchForDebFile(debPath)); - pkg.setArch2(PackageCommander.getArchForDebFile(debPath)); - newVerForRootstrap = PackageCommander.getPkgVerForDebFile(debPath); - newVerForTarget = newVerForRootstrap; - pkg.setNewVersion1(newVerForRootstrap); - pkg.setNewVersion2(newVerForRootstrap); - } else { - pkg.setArch1(PackageCommander.getArchOfRemotePkgForRootstrap(pkg.getName(), targetID)); - pkg.setArch2(PackageCommander.getArchOfRemotePkgForRealTarget(pkg.getName(), device, rec)); - newVerForRootstrap = PackageCommander.getPkgNewVerForRootstrap(pkg.getName(), targetID); - rec.cleanLog(); - newVerForTarget = PackageCommander.getPkgNewVerForRealTarget(pkg.getName(), device, rec); - pkg.setNewVersion1(newVerForRootstrap); - pkg.setNewVersion2(newVerForTarget); - } - - String installedVerForRootstrap = PackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), targetID); - rec.cleanLog(); - String installedVerForRealDevice = PackageCommander.getPkgInstalledVerForRealTarget(pkg.getName(), device, rec); - - pkg.setInstalledVersion1(installedVerForRootstrap); - pkg.setInstalledVersion2(installedVerForRealDevice); - - if (newVerForRootstrap.equals("")) { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_FOUND); - pkg.setCheckColumn1(false); - } else if (!installedVerForRootstrap.equals("")) { - if (!installedVerForRootstrap.equals(newVerForRootstrap)) { - pkg.setInstallInfo1(Package.INSTALLINFO.DIFFERENT_VERSION); - } else { - if (PackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), targetID)) { - pkg.setInstallInfo1(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo1(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } - } - - if (newVerForTarget.equals("")) { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_FOUND); - pkg.setCheckColumn2(false); - } else if (!installedVerForRealDevice.equals("")) { - if (!installedVerForRealDevice.equals(newVerForTarget)) { - pkg.setInstallInfo2(Package.INSTALLINFO.DIFFERENT_VERSION); - } else { - if (PackageCommander.pkgInstalledSuccessfullyForRealTarget(pkg.getName(), device, rec)) { - pkg.setInstallInfo2(Package.INSTALLINFO.INSTALLED); - } else { - pkg.setInstallInfo2(Package.INSTALLINFO.NOT_PROPERLY_INSTALLED); - } - } - } - - pkg.setPkgType(type); - - PkgModelProvider.INSTANCE.getPkgs().add(pkg); - - /* - if (type.equals(Package.PKGTYPE.LOCAL)) { - viewer.refresh(); - } - */ - - return true; - } - - - private void createColumns( Composite parent, final TableViewer viewer, final String type) - { - String[] titles = {"Install Type", "Package Name", "Arch", "New Version", "Installed Version", "Status"}; - int[] bounds = { 120, 180, 60, 200, 200, 160}; - - TableViewerColumn colInstallType = createTableViewerColumn( viewer, titles[0], bounds[0], SWT.NONE); - - colInstallType.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - return pkg.getPkgType().toString(); - } - }); - - TableViewerColumn colPackage = createTableViewerColumn( viewer, titles[1], bounds[1], SWT.NONE); - - colPackage.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - return pkg.getName(); - } - }); - - TableViewerColumn colArch = createTableViewerColumn( viewer, titles[2], bounds[2], SWT.NONE); - - colArch.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - String arch = ""; - if (type.equals(ROOTSTRAP_TAB_NAME)) { - arch = pkg.getArch1(); - } else if (type.equals(TARGET_TAB_NAME)) { - arch = pkg.getArch2(); - } - - return arch; - } - }); - - TableViewerColumn colNewVer = createTableViewerColumn( viewer, titles[3], bounds[3], SWT.NONE); - - colNewVer.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - String newVer = ""; - if (type.equals(ROOTSTRAP_TAB_NAME)) { - newVer = pkg.getNewVersion1(); - } else if (type.equals(TARGET_TAB_NAME)) { - newVer = pkg.getNewVersion2(); - } - - return newVer; - } - }); - - TableViewerColumn colInsVer = createTableViewerColumn( viewer, titles[4], bounds[4], SWT.NONE); - colInsVer.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - String installedVer = ""; - if (type.equals(ROOTSTRAP_TAB_NAME)) { - installedVer = pkg.getInstalledVersion1(); - } else if (type.equals(TARGET_TAB_NAME)) { - installedVer = pkg.getInstalledVersion2(); - } - - return installedVer; - } - }); - - TableViewerColumn colStatus = createTableViewerColumn( viewer, titles[5], bounds[5], SWT.NONE); - - colStatus.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - Package pkg = (Package)element; - String status = ""; - if (type.equals(ROOTSTRAP_TAB_NAME)) { - status = pkg.getInstallInfo1().toString(); - } else if (type.equals(TARGET_TAB_NAME)) { - status = pkg.getInstallInfo2().toString(); - } - - return status; - } - }); - } - - private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) { - - final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style); - final TableColumn column = viewerColumn.getColumn(); - column.setText(title); - column.setWidth(bound); - column.setResizable(true); - column.setMoveable(true); - return viewerColumn; - } - - - private String getTargetID() { - IProject project = CurrentEnabledProject.getCurrentProject(); - IConfiguration config = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); - String targetID = PlatformConfigurationManager.getBuildTargetName(config); - return targetID; - } - - private CopyOnWriteArrayList<Package> getSelectedPkg(CopyOnWriteArrayList<Package> pkgs) { - CopyOnWriteArrayList<Package> _pkgs = new CopyOnWriteArrayList<Package>(); - if (CURRENT_TAB_NAME.equals(ROOTSTRAP_TAB_NAME)) { - for (Package pkg : pkgs) { - if(pkg.getCheckColumn1()) { - _pkgs.add(pkg); - } - } - } else if (CURRENT_TAB_NAME.equals(TARGET_TAB_NAME)) { - for (Package pkg : pkgs) { - if(pkg.getCheckColumn2()) { - _pkgs.add(pkg); - } - } - } - - return _pkgs; - } -}
\ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PkgModelProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PkgModelProvider.java deleted file mode 100644 index a6f0a4b8..00000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PkgModelProvider.java +++ /dev/null @@ -1,215 +0,0 @@ -/* -* Inhouse -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: -* Taejun Ha <taejun.ha@samsung.com> -* Jiil Hyoun <jiil.hyoun@samsung.com> -* Donghyuk Yang <donghyuk.yang@samsung.com> -* Hoon Kang <h245.kang@samsung.com> -* DongHee Yang <donghee.yang@samsung.com> -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* Contributors: -* - S-Core Co., Ltd -* -*/ -package org.tizen.nativeplatform.pkgInstall; - -import java.util.concurrent.CopyOnWriteArrayList; - -public enum PkgModelProvider { - - INSTANCE; - - private CopyOnWriteArrayList<Package> pkgs; - - private PkgModelProvider() - { - pkgs = new CopyOnWriteArrayList <Package>(); - } - - public CopyOnWriteArrayList<Package> getPkgs() - { - return pkgs; - } -} - -class Package{ - - public static enum INSTALLINFO - { -// READY, SUCCESSED, FAILED, INSTALLED, NOT_INSTALLED - INSTALLED, NOT_INSTALLED, DIFFERENT_VERSION, NOT_FOUND, NOT_PROPERLY_INSTALLED - } - - public static enum PKGTYPE - { - LOCAL, REMOTE - } - private String target = ""; - private String path = ""; - - private String name = ""; - private String arch1 = ""; - private String arch2 = ""; - private String newVersion1 = ""; - private String newVersion2 = ""; - private String installVersion1 = ""; - private String installVersion2 = ""; - private boolean checkColumn1 = true; - private boolean checkColumn2 = true; - private INSTALLINFO installInfo1 = INSTALLINFO.NOT_INSTALLED; - private INSTALLINFO installInfo2 = INSTALLINFO.NOT_INSTALLED; - private PKGTYPE pkgType = PKGTYPE.LOCAL; - -// private Button check1 = new Button( PackageManager.getTable(), SWT.CHECK ); -// private Button check2 = new Button( PackageManager.getTable(), SWT.CHECK ); - - public PKGTYPE getPkgType() - { - return pkgType; - } - - public void setPkgType( PKGTYPE pkgType ) - { - this.pkgType = pkgType; - } - - public void setArch1(String arch) - { - this.arch1 = arch; - } - - public String getArch1() - { - return arch1; - } - - public void setArch2(String arch) - { - this.arch2 = arch; - } - - public String getArch2() - { - return arch2; - } - - public INSTALLINFO getInstallInfo1() - { - return installInfo1; - } - - public void setInstallInfo1( INSTALLINFO installInfo ) - { - this.installInfo1 = installInfo; - } - - public INSTALLINFO getInstallInfo2() - { - return installInfo2; - } - - public void setInstallInfo2( INSTALLINFO installInfo ) - { - this.installInfo2 = installInfo; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public void setInstalledVersion1(String ver) { - this.installVersion1 = ver; - } - public String getInstalledVersion1() { - return installVersion1; - } - - public void setInstalledVersion2(String ver) { - this.installVersion2 = ver; - } - - public String getInstalledVersion2() { - return installVersion2; - } - - public void setNewVersion1(String ver) { - this.newVersion1 = ver; - } - - public String getNewVersion1() { - return newVersion1; - } - - public void setNewVersion2(String ver) { - this.newVersion2 = ver; - } - - public String getNewVersion2() { - return newVersion2; - } - - public boolean getCheckColumn1() - { - return checkColumn1; - } - - public void setCheckColumn1( boolean check ) - { - this.checkColumn1 = check; - } - - public boolean getCheckColumn2() - { - return checkColumn2; - } - - public void setCheckColumn2( boolean check ) - { - this.checkColumn2 = check; - } - -// public Button getCheck1() -// { -// return check1; -// } -// -// public Button getCheck2() -// { -// return check2; -// } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/DialogActionDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/DialogActionDelegate.java new file mode 100644 index 00000000..23c788e7 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/DialogActionDelegate.java @@ -0,0 +1,96 @@ +package org.tizen.nativeplatform.pkgmgr; + +import java.util.ResourceBundle; + +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.tizen.common.connection.ConnectionPlugin; +import org.tizen.nativecommon.build.CurrentEnabledProject; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; +import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog; +import org.tizen.sdblib.IDevice; + +public class DialogActionDelegate implements IWorkbenchWindowActionDelegate { + + private IWorkbenchWindow window; + + private SmartBuildInterface sbi = null; + private final String BUNDLE_NAME = DialogActionDelegate.class.getPackage().getName() + ".RPMPackageCommands"; + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + @Override + public void run(IAction action) { + IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); + String target = null; + boolean enableRootstrap = true; + boolean enableTarget = true; + + IProject project = CurrentEnabledProject.getCurrentProject(); + Shell shell = window.getShell(); + if (project == null) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Project")); + return; + } + sbi = SmartBuildInterface.getInstance(project); + + IConfiguration cfg = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); + String targetName = PlatformConfigurationManager.getBuildTargetName(cfg); + + IManagedProject managedProject = cfg.getManagedProject(); + String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); + if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.Platformproject")); + return; + } + + if (device == null) { + enableTarget = false; + } else { + target = device.getSerialNumber(); + if (target == null) { + enableTarget = false; + } + } + + String result = ""; + try { + result = sbi.queryStdOut("command", targetName, null); + } catch (SBIException e) { + e.printStackTrace(); + } + if (!result.contains("passwd")) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.SupportedRpm")); + return; + } + RPMPackageDialog pkgdlg = new RPMPackageDialog(window.getShell(), target, enableRootstrap, enableTarget); + pkgdlg.open(); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + // TODO Auto-generated method stub + + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + @Override + public void init(IWorkbenchWindow window) { + this.window = window; + } + +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManagerRootstrapHandler.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerHandler.java index a5f72a26..b2f3071c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManagerRootstrapHandler.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerHandler.java @@ -26,7 +26,9 @@ * - S-Core Co., Ltd * */ -package org.tizen.nativeplatform.pkgInstall; +package org.tizen.nativeplatform.pkgmgr; + +import java.util.ResourceBundle; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedProject; @@ -35,13 +37,17 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.handlers.HandlerUtil; import org.tizen.common.connection.ConnectionPlugin; - +import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog; import org.tizen.nativecommon.build.CurrentEnabledProject; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.sdblib.IDevice; @@ -50,11 +56,17 @@ import org.tizen.sdblib.IDevice; * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */ -public class PackageManagerRootstrapHandler extends AbstractHandler { +public class PackageManagerHandler extends AbstractHandler { + + private SmartBuildInterface sbi = null; + + private final String BUNDLE_NAME = PackageManagerHandler.class.getPackage().getName() + ".RPMPackageCommands"; + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + /** * The constructor. */ - public PackageManagerRootstrapHandler() { + public PackageManagerHandler() { } /** @@ -64,36 +76,51 @@ public class PackageManagerRootstrapHandler extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); - IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - PackageManager pkgdlg; + IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); String target = null; boolean enableRootstrap = true; - boolean eanbleTarget = true; + boolean enableTarget = true; + + IProject project = CurrentEnabledProject.getCurrentProject(); + Shell shell = window.getShell(); + if (project == null) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Project")); + return null; + } + sbi = SmartBuildInterface.getInstance(project); + + IConfiguration cfg = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); + String targetName = PlatformConfigurationManager.getBuildTargetName(cfg); + + IManagedProject managedProject = cfg.getManagedProject(); + String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); + if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.Platformproject")); + return null; + } if (device == null) { - eanbleTarget = false; + enableTarget = false; } else { target = device.getSerialNumber(); if (target == null) { - eanbleTarget = false; + enableTarget = false; } } - IProject project = CurrentEnabledProject.getCurrentProject(); - if (project == null) { - enableRootstrap = false; - } else { - IConfiguration cfg =ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); - IManagedProject managedProject = cfg.getManagedProject(); - String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId(); - if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_CUSTOM_DEBIAN_ARTIFACT_TYPE) && - !projectArtifactType.equals(PlatformConfigurationManager.OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE)) { - enableRootstrap = false; - } - } - - pkgdlg = new PackageManager(window.getShell(), target, enableRootstrap, eanbleTarget); + String result = ""; + try { + result = sbi.queryStdOut("command", targetName, null); + } catch (SBIException e) { + e.printStackTrace(); + } + if (!result.contains("passwd")) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.SupportedRpm")); + return null; + } + RPMPackageDialog pkgdlg = new RPMPackageDialog(window.getShell(), target, enableRootstrap, enableTarget); pkgdlg.open(); + return null; } }
\ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManagerOuputReceiver.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerOuputReceiver.java index 0955cd9b..e655f075 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgInstall/PackageManagerOuputReceiver.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PackageManagerOuputReceiver.java @@ -26,7 +26,7 @@ * - S-Core Co., Ltd * */ -package org.tizen.nativeplatform.pkgInstall; +package org.tizen.nativeplatform.pkgmgr; import org.eclipse.ui.console.MessageConsoleStream; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java new file mode 100644 index 00000000..d760027d --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java @@ -0,0 +1,525 @@ +/* +* Inhouse +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Taejun Ha <taejun.ha@samsung.com> +* Jiil Hyoun <jiil.hyoun@samsung.com> +* Donghyuk Yang <donghyuk.yang@samsung.com> +* Hoon Kang <h245.kang@samsung.com> +* DongHee Yang <donghee.yang@samsung.com> +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ +package org.tizen.nativeplatform.pkgmgr; + +import java.io.OutputStream; +import java.util.ResourceBundle; + +import org.tizen.common.util.HostUtil; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver; +import org.tizen.sdblib.IDevice; + +public class RPMPackageCommander { + + private final static SmartBuildInterface sbi = SmartBuildInterface.getInstance(); + private final static int MAX_TIMEOUT = 10000; + private static String http_proxy = ""; + private static String sudo_passwd = ""; + + private static final String BUNDLE_NAME = RPMPackageCommander.class.getPackage().getName() + ".RPMPackageCommands"; + private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public RPMPackageCommander() { + } + + public static void setHttpProxy(String proxy) { + http_proxy = proxy; + } + + public static void setSudoPassword(String pwd) { + sudo_passwd = pwd; + } + + public static void InstallPkgToRootstrap(String targetID, String fileList, + OutputStream stdoutStream, OutputStream stderrStream) { + + String cmd = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileList)); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + } + + public static void InstallPkgToRootstrap(SmartBuildInterface sbi, String targetID, String fileList, + OutputStream stdoutStream, OutputStream stderrStream) { + + String cmd = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileList)); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + } + + public static void InstallPkgToDevice(String fileList, IDevice device, PackageManagerOuputReceiver rec) { + + if (device != null) { + try { + String command = String.format("%s;%s", getResetDbCmd(), getInstallLocalPkgCmd(fileList)); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + public static String getArchForFile(String filePath) { + return HostUtil.returnExecute(getQueryInfoCmd("ARCH", filePath)); + } + + public static String getPkgNameForFile(String filePath) { + return HostUtil.returnExecute(getQueryInfoCmd("NAME", filePath)); + } + + public static String getPkgVerForFile(String filePath) { + String version = HostUtil.returnExecute(getQueryInfoCmd("VERSION", filePath)); + String release = HostUtil.returnExecute(getQueryInfoCmd("RELEASE", filePath)); + + return version + "-" + release; + + } + + public static String getPkgInstalledVerForRootstrap(String pkgName, String targetID) { + String retStr = ""; + String version = ""; + String release = ""; + + if (!pkgInstalledSuccessfullyForRootstrap(pkgName, targetID)) { + return retStr; + } + + String result = null; + String cmd = String.format("%s;%s", getResetDbCmd(), getShowPkgInfoCmd(pkgName)); + String options = getSbiCommand(cmd); + + try { + result = sbi.actionStdOut("command", options, targetID, null); + } catch (SBIException e) { + e.printStackTrace(); + } + + String[] splitResult = result.split("\n"); + for (String r : splitResult) { + if (r.trim().startsWith("Version")) { + version = r.split(":")[1].trim(); + } else if (r.trim().startsWith("Release")) { + release = r.split(":")[1].trim(); + } + } + + retStr = version + "-" + release; + return retStr; + } + + public static String getPkgInstalledVerForDevice(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { + String retStr = ""; + String version = ""; + String release = ""; + + if (device != null) { + if (!pkgInstalledSuccessfullyForDevice(pkgName, device, rec)) { + return retStr; + } + + try { + String command = String.format("%s;%s", getResetDbCmd(), getShowPkgInfoCmd(pkgName)); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + for (String l : rec.getLog()) { + if (l.trim().startsWith("Version")) { + version = l.split(":")[1].trim(); + } else if (l.trim().startsWith("Release")) { + release = l.split(":")[1].trim(); + } + } + + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + retStr = version + "-" + release; + return retStr; + } + + public static boolean pkgInstalledSuccessfullyForRootstrap(String pkgName, String targetID) { + + boolean ret = false; + String result = ""; + + String cmd = String.format("%s;%s", getResetDbCmd(), getShowPkgCmd(pkgName)); + String options = getSbiCommand(cmd); + + try { + result = sbi.actionStdOut("command", options, targetID, null); + } catch (SBIException e) { + e.printStackTrace(); + } + + if (!result.isEmpty() && result.contains(pkgName)) { + ret = true; + } + + return ret; + } + + public static boolean pkgInstalledSuccessfullyForDevice(String pkgName, IDevice device, PackageManagerOuputReceiver rec) { + + boolean ret = false; + + if (device != null) { + try { + String command = String.format("%s;%s", getResetDbCmd(), getShowPkgCmd(pkgName)); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + if (rec.getLog() == null) { + return false; + } + + for (String l : rec.getLog()) { + if (l.contains(pkgName)) { + ret = true; + } + } + + return ret; + } + + public static String getRemotePackageListForRootstrap(String targetID) { + + String result = ""; + String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRemotePkgListCmd()); + String options = getSbiCommand(cmd); + + try { + result = sbi.actionStdOut("command", options, targetID, null); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String getRemotePackageListForDevice(IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRemotePkgListCmd()); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static String getRepositoryListForRootstrap(String targetID) { + + String result = ""; + String cmd = String.format("%s;%s", getResetDbCmd(), getRepoListCmd()); + String options = getSbiCommand(cmd); + + try { + result = sbi.actionStdOut("command", options, targetID, null); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String getRepositoryListForDevice(IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s", getResetDbCmd(), getRepoListCmd()); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static String refreshRepositoryForRootstrap(String targetID, OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRefreshCmd()); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String refreshRepositoryForRootstrap(SmartBuildInterface sbi, String targetID, + OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRefreshCmd()); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String refreshRepositoryForDevice(IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRefreshCmd()); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static String addRepositoryForRootstrap(String name, String uri, String targetID, OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s", getResetDbCmd(), getAddRepoCmd(uri, name)); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String addRepositoryForDevice(String name, String uri, IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s", getResetDbCmd(), getAddRepoCmd(uri, name)); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static String removeRepositoryForRootstrap(String name, String targetID, OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s", getResetDbCmd(), getRemoteRepoCmd(name)); + String options = getSbiCommand(cmd); + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String removeRepositoryForDevice(String name, IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s", getResetDbCmd(), getRemoteRepoCmd(name)); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static String installRemotePkgForRootstrap(String pkgList, String targetID, OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList)); + String options = getSbiCommand(cmd); + + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String installRemotePkgForRootstrap(SmartBuildInterface sbi, String pkgList, String targetID, + OutputStream stdoutStream, OutputStream stderrStream) { + + String result = ""; + String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList)); + String options = getSbiCommand(cmd); + + + try { + sbi.actionStream("command", options, targetID, null, stdoutStream, stderrStream); + } catch (SBIException e) { + e.printStackTrace(); + } + + return result; + } + + public static String installRemotePkgForDevice(String pkgList, IDevice device, PackageManagerOuputReceiver rec) { + + String result = ""; + + try { + String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getInstallPkgCmd(pkgList)); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + + for (String l : rec.getLog()) { + result = result.concat(l + "\n"); + } + + return result; + } + + public static void changeUpdateModeForDevice(IDevice device, PackageManagerOuputReceiver rec) { + + try { + String command = resources.getString("Command.Change.Updatemode"); + rec.cleanLog(); + device.executeShellCommand(command, rec, MAX_TIMEOUT); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static String getProxyCmd() { + return String.format(resources.getString("Command.Export.Proxy"), http_proxy); + } + + private static String getResetDbCmd() { + return String.format(resources.getString("Command.Reset.Db")); + } + + private static String getInstallPkgCmd(String pkgList) { + return String.format(resources.getString("Command.Install.Remote.Pkg"), pkgList); + } + + private static String getInstallLocalPkgCmd(String pkgList) { + return String.format(resources.getString("Command.Install.Local.Pkg"), pkgList); + } + + private static String getRemoteRepoCmd(String name) { + return String.format(resources.getString("Command.Remove.Repo"), name); + } + + private static String getAddRepoCmd(String uri, String name) { + return String.format(resources.getString("Command.Add.Repo"), uri, name); + } + + private static String getRefreshCmd() { + return resources.getString("Command.Refresh.Repo"); + } + + private static String getRepoListCmd() { + return resources.getString("Command.List.Repo"); + } + + private static String getRemotePkgListCmd() { + return resources.getString("Command.List.Remote.Pkg"); + } + + private static String getShowPkgCmd(String name) { + return String.format(resources.getString("Command.Show.Pkg"), name); + } + + private static String getShowPkgInfoCmd(String name) { + return String.format(resources.getString("Command.Show.Info.Pkg"), name); + } + + private static String getQueryInfoCmd(String tag, String name) { + return String.format(resources.getString("Command.Info.Pkg.File"), tag, name); + } + + private static String getSbiCommand(String cmd) { + return String.format("-passwd=%s -path=. -cmd=\"%s\"", sudo_passwd, cmd); + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties new file mode 100644 index 00000000..6c326568 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties @@ -0,0 +1,18 @@ +Command.Export.Proxy = export http_proxy=%s +Command.Reset.Db = rm -f /var/lib/rpm/__db* +Command.Install.Remote.Pkg = zypper --non-interactive in %s +Command.Install.Local.Pkg = rpm -ihv %s --ignoreos --force +Command.Remove.Repo = zypper rr %s +Command.Add.Repo = zypper ar %s %s +Command.Refresh.Repo = zypper refresh +Command.List.Repo = zypper lr -u +Command.List.Remote.Pkg = zypper pa +Command.Show.Pkg = rpm -qa %s +Command.Show.Info.Pkg = rpm -qi %s +Command.Info.Pkg.File = rpm -qp --qf "%%{%s}\n" %s +Command.Change.Updatemode = /bin/change-booting-mode.sh --update + +PkgMgr.Error.Noselected.Project = No project selected. Select a Tizen platform project. +PkgMgr.Error.Not.Platformproject = The selected project is not a Tizen platform project. +PkgMgr.Error.Not.SupportedRpm = RPM package not supported by the build system. +PkgMgr.Error.Not.RpmProject = The project is not RPM project. diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPackage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPackage.java new file mode 100644 index 00000000..5550054d --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPackage.java @@ -0,0 +1,18 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +public class LocalPackage extends Package { + + private String path = ""; + + public LocalPackage() { + super(); + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPkgProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPkgProvider.java new file mode 100644 index 00000000..a3614af1 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/LocalPkgProvider.java @@ -0,0 +1,22 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +import java.util.concurrent.CopyOnWriteArrayList; +public enum LocalPkgProvider { + INSTANCE; + + private CopyOnWriteArrayList<LocalPackage> pkgs; + + private LocalPkgProvider() + { + pkgs = new CopyOnWriteArrayList <LocalPackage>(); + } + + public void clear() { + pkgs.clear(); + } + + public CopyOnWriteArrayList<LocalPackage> getPkgs() + { + return pkgs; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Package.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Package.java new file mode 100644 index 00000000..6f148e66 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Package.java @@ -0,0 +1,85 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +public class Package { + public static enum INSTALLINFO + { + INSTALLED, NOT_INSTALLED, DIFFERENT_VERSION + } + + public static enum PKGTYPE + { + LOCAL, REMOTE + } + + private String name = ""; + private String arch = ""; + private String newVersion = ""; + private String installVersion = ""; + private boolean checkColumn = true; + private INSTALLINFO installInfo = INSTALLINFO.NOT_INSTALLED; + private PKGTYPE pkgType = PKGTYPE.LOCAL; + + public PKGTYPE getPkgType() + { + return pkgType; + } + + public void setPkgType( PKGTYPE pkgType ) + { + this.pkgType = pkgType; + } + + public void setArch(String arch) + { + this.arch = arch; + } + + public String getArch() + { + return arch; + } + + public INSTALLINFO getInstallInfo() + { + return installInfo; + } + + public void setInstallInfo( INSTALLINFO installInfo ) + { + this.installInfo = installInfo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void setInstalledVersion(String ver) { + this.installVersion = ver; + } + + public String getInstalledVersion() { + return installVersion; + } + + public void setNewVersion(String ver) { + this.newVersion = ver; + } + + public String getNewVersion() { + return newVersion; + } + + public boolean getCheckColumn() + { + return checkColumn; + } + + public void setCheckColumn( boolean check ) + { + this.checkColumn = check; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/PackageProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/PackageProvider.java new file mode 100644 index 00000000..ab621371 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/PackageProvider.java @@ -0,0 +1,31 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +import java.util.concurrent.CopyOnWriteArrayList; + +public enum PackageProvider { + INSTANCE; + + private CopyOnWriteArrayList<Package> buildsystem_pkgs; + private CopyOnWriteArrayList<Package> device_pkgs; + + private PackageProvider() + { + buildsystem_pkgs = new CopyOnWriteArrayList <Package>(); + device_pkgs = new CopyOnWriteArrayList <Package>(); + } + + public void clear() { + buildsystem_pkgs.clear(); + device_pkgs.clear(); + } + + public CopyOnWriteArrayList<Package> getBuildsystemPkgs() + { + return buildsystem_pkgs; + } + + public CopyOnWriteArrayList<Package> getDevicePkgs() + { + return device_pkgs; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePackage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePackage.java new file mode 100644 index 00000000..e0ea9e47 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePackage.java @@ -0,0 +1,31 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +public class RemotePackage extends Package { + + private String repository = ""; + private boolean checkGrayed = false; + + public RemotePackage() { + super(); + } + + public void setRepo(String repository) + { + this.repository = repository; + } + + public String getRepo() + { + return repository; + } + + public boolean getCheckGrayed() + { + return checkGrayed; + } + + public void setCheckGrayed( boolean check ) + { + this.checkGrayed = check; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePkgProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePkgProvider.java new file mode 100644 index 00000000..ffb8ba32 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RemotePkgProvider.java @@ -0,0 +1,30 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +import java.util.concurrent.CopyOnWriteArrayList; +public enum RemotePkgProvider { + INSTANCE; + + private CopyOnWriteArrayList<RemotePackage> pkgs; + private CopyOnWriteArrayList<RemotePackage> selected_pkgs; + + private RemotePkgProvider() + { + pkgs = new CopyOnWriteArrayList <RemotePackage>(); + selected_pkgs = new CopyOnWriteArrayList <RemotePackage>(); + } + + public void clear() { + pkgs.clear(); + selected_pkgs.clear(); + } + + public CopyOnWriteArrayList<RemotePackage> getPkgs() + { + return pkgs; + } + + public CopyOnWriteArrayList<RemotePackage> getSelectedPkgs() + { + return selected_pkgs; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Repository.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Repository.java new file mode 100644 index 00000000..1f73604e --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/Repository.java @@ -0,0 +1,48 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +public class Repository { + private String name = ""; + private String uri = ""; + private boolean dirty = false; + private boolean checkColumn = false; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getUri() + { + return uri; + } + + public void setUri(String uri) + { + this.uri = uri; + } + + public boolean getCheckColumn() + { + return checkColumn; + } + + public void setCheckColumn( boolean check ) + { + this.checkColumn = check; + } + + public boolean getCheckDirty() + { + return dirty; + } + + public void setCheckDirty( boolean check ) + { + this.dirty = check; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RepositoryProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RepositoryProvider.java new file mode 100644 index 00000000..5edc939b --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/model/RepositoryProvider.java @@ -0,0 +1,33 @@ +package org.tizen.nativeplatform.pkgmgr.model; + +import java.util.concurrent.CopyOnWriteArrayList; + +public enum RepositoryProvider { + + INSTANCE; + + private CopyOnWriteArrayList<Repository> buildsystem_repos; + private CopyOnWriteArrayList<Repository> device_repos; + + private RepositoryProvider() + { + buildsystem_repos = new CopyOnWriteArrayList <Repository>(); + device_repos = new CopyOnWriteArrayList <Repository>(); + } + + public void clear() + { + buildsystem_repos.clear(); + device_repos.clear(); + } + + public CopyOnWriteArrayList<Repository> getBuildsystemRepos() + { + return buildsystem_repos; + } + + public CopyOnWriteArrayList<Repository> getDeviceRepos() + { + return device_repos; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java new file mode 100644 index 00000000..8ef4dc56 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRemotePackageDialog.java @@ -0,0 +1,274 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.util.ResourceBundle; + +import org.eclipse.swt.graphics.Color; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +import org.tizen.nativeplatform.pkgmgr.model.Package; +import org.tizen.nativeplatform.pkgmgr.model.RemotePackage; +import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider; + +public class AddRemotePackageDialog extends Dialog { + + private TableViewer packageViewer; + private int selectedColumn = 0; + private Display disp = null; + + private int x = 0; + private int y = 0; + private final int width = 800; + private final int height = 800; + + private final String BUNDLE_NAME = AddRemotePackageDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + protected AddRemotePackageDialog(Shell parentShell) { + super(parentShell); + + Rectangle bounds = parentShell.getBounds(); + x = bounds.x + (bounds.width - width)/2; + y = bounds.y + (bounds.height - height)/2; + this.disp = parentShell.getDisplay(); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText(resources.getString("AddRemotePkg.Title")); + newShell.setLocation(x, y); + newShell.setSize(width, height); + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite composite = new Composite( parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setLayout(new GridLayout(1, false)); + + createTable(composite); + return null; + } + + private void createTable( Composite parent ) + { + + Composite bottom = new Composite( parent, SWT.NONE ); + bottom.setLayoutData(new GridData(GridData.FILL_BOTH)); + bottom.setLayout(new GridLayout(1, false)); + + Composite b2 = new Composite( bottom, SWT.NONE ); + b2.setLayoutData(new GridData(GridData.FILL_BOTH)); + b2.setLayout(new FillLayout()); + + packageViewer = new TableViewer( b2, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK); + createColumns(); + Table table = packageViewer.getTable(); + table.addListener( SWT.Selection, new Listener(){ + + @Override + public void handleEvent(Event event) { + if( event.detail == SWT.CHECK ) { + RemotePackage pkg = (RemotePackage)event.item.getData(); + pkg.setCheckColumn( !pkg.getCheckColumn() ); + } + } + }); + + table.setHeaderVisible(true); + table.setLinesVisible(true); + + packageViewer.setContentProvider(new ArrayContentProvider()); + packageViewer.setInput(RemotePkgProvider.INSTANCE.getPkgs()); + + updateCheck(); + } + + private void createColumns() + { + String[] titles = {"Package Name", "Repository", "Arch", "Version", "Status"}; + int[] bounds = { 250, 120, 60, 150, 160}; + + TableViewerColumn colPackage = createTableViewerColumn( titles[0], bounds[0], SWT.NONE); + + colPackage.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + return pkg.getName(); + } + }); + + TableViewerColumn colInstallType = createTableViewerColumn( titles[1], bounds[1], SWT.NONE); + + colInstallType.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + RemotePackage pkg = (RemotePackage)element; + return pkg.getRepo(); + } + }); + + TableViewerColumn colArch = createTableViewerColumn( titles[2], bounds[2], SWT.NONE); + + colArch.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + RemotePackage pkg = (RemotePackage)element; + String arch = ""; + arch = pkg.getArch(); + return arch; + } + }); + + TableViewerColumn colNewVer = createTableViewerColumn( titles[3], bounds[3], SWT.NONE); + + colNewVer.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + RemotePackage pkg = (RemotePackage)element; + String newVer = ""; + newVer = pkg.getNewVersion(); + return newVer; + } + }); + + TableViewerColumn colStatus = createTableViewerColumn( titles[4], bounds[4], SWT.NONE); + + colStatus.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + RemotePackage pkg = (RemotePackage)element; + String status = ""; + status = pkg.getInstallInfo().toString(); + return status; + } + }); + } + + private TableViewerColumn createTableViewerColumn( String title, int bound, int Style) { + + final TableViewerColumn viewerColumn = new TableViewerColumn( packageViewer, Style); + final TableColumn column = viewerColumn.getColumn(); + column.addSelectionListener(new TableSelectionAdapter()); + column.setText(title); + column.setWidth(bound); + column.setResizable(true); + column.setMoveable(true); + return viewerColumn; + } + + @Override + protected void okPressed() { + + for(RemotePackage p : RemotePkgProvider.INSTANCE.getPkgs()) { + if (p.getCheckColumn() && !Package.INSTALLINFO.INSTALLED.equals(p.getInstallInfo())) { + RemotePkgProvider.INSTANCE.getSelectedPkgs().add(p); + } + } + + super.okPressed(); + } + + private class TableSelectionAdapter extends SelectionAdapter + { + public void widgetSelected(SelectionEvent e) { + selectedColumn = packageViewer.getTable().indexOf((TableColumn) e.widget); + packageViewer.getTable().setSortColumn((TableColumn)e.widget); + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + packageViewer.getTable().setSortDirection(SWT.UP); + } else { + packageViewer.getTable().setSortDirection(SWT.DOWN); + } + + packageViewer.setSorter(new ViewerSorter() { + public int compare(Viewer viewer, Object e1, Object e2) { + int result = 0; + + RemotePackage entry_1 = (RemotePackage)e1; + RemotePackage entry_2 = (RemotePackage)e2; + + switch (selectedColumn) { + case 0: + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getName().compareTo(entry_2.getName()); + } else { + result = entry_2.getName().compareTo(entry_1.getName()); + } + break; + case 1: + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getRepo().compareTo(entry_2.getRepo()); + } else { + result = entry_2.getRepo().compareTo(entry_1.getRepo()); + } + break; + case 2: + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getArch().compareTo(entry_2.getArch()); + } else { + result = entry_2.getArch().compareTo(entry_1.getArch()); + } + break; + case 3: + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getNewVersion().compareTo(entry_2.getNewVersion()); + } else { + result = entry_2.getNewVersion().compareTo(entry_1.getNewVersion()); + } + break; + case 4: + if (packageViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getInstallInfo().toString().compareTo(entry_2.getInstallInfo().toString()); + } else { + result = entry_2.getInstallInfo().toString().compareTo(entry_1.getInstallInfo().toString()); + } + break; + } + + return result; + } + }); + updateCheck(); + } + } + + private void updateCheck() { + int recentTableIndex = packageViewer.getTable().getItemCount(); + Color installedColor = disp.getSystemColor(SWT.COLOR_LIST_SELECTION); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = packageViewer.getTable().getItem(i); + RemotePackage pkg = (RemotePackage)item.getData(); + item.setChecked(pkg.getCheckColumn()); + if (Package.INSTALLINFO.INSTALLED.equals(pkg.getInstallInfo())) { + item.setBackground(installedColor); + } + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java new file mode 100644 index 00000000..31ca1646 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java @@ -0,0 +1,120 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.util.ResourceBundle; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import org.tizen.common.util.DialogUtil; +import org.tizen.nativeplatform.pkgmgr.model.Repository; +import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider; + +public class AddRepoDialog extends Dialog { + + private Text nameText; + private Text uriText; + private String tab; + + private int x = 0; + private int y = 0; + private final int width = 500; + private final int height = 200; + + private final String BUNDLE_NAME = AddRepoDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + protected AddRepoDialog(Shell parentShell) { + super(parentShell); + } + + public AddRepoDialog(Shell parentShell, String tab) { + super(parentShell); + this.tab = tab; + Rectangle bounds = parentShell.getBounds(); + x = bounds.x + (bounds.width - width)/2; + y = bounds.y + (bounds.height - height)/2; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText(resources.getString("AddRepo.Title")); + newShell.setLocation(x, y); + newShell.setSize(width, height); + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite composite = new Composite( parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setLayout(new GridLayout(2, false)); + + Label nameLabel = new Label(composite, SWT.NONE); + nameLabel.setText(resources.getString("AddRepo.Label.Name")); + nameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.widthHint = 500; + nameText.setLayoutData(gridData); + + Label urlLabel = new Label(composite, SWT.NONE); + urlLabel.setText(resources.getString("AddRepo.Label.Uri")); + uriText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.widthHint = 500; + uriText.setLayoutData(gridData); + + return null; + } + + @Override + protected void okPressed() { + + CopyOnWriteArrayList<Repository> list = null; + Repository repo = new Repository(); + repo.setName(nameText.getText()); + repo.setUri(uriText.getText()); + + if (resources.getString("PkgMgr.Tab.Buildsystem").equals(tab)) { + list = RepositoryProvider.INSTANCE.getBuildsystemRepos(); + // if repository name or url already exist, then return + if (checkRepoExists(list, repo)) { + return; + } else { + repo.setCheckDirty(true); + RepositoryProvider.INSTANCE.getBuildsystemRepos().add(repo); + } + } else if (resources.getString("PkgMgr.Tab.Device").equals(tab)) { + list = RepositoryProvider.INSTANCE.getDeviceRepos(); + // if repository name or url already exist, then return + if (checkRepoExists(list, repo)) { + return; + } else { + repo.setCheckDirty(true); + RepositoryProvider.INSTANCE.getDeviceRepos().add(repo); + } + } + + super.okPressed(); + } + + private boolean checkRepoExists(CopyOnWriteArrayList<Repository> list, Repository repo) { + for( Repository r : list) { + if (r.getName().equals(repo.getName()) || r.getUri().equals(repo.getUri())) { + DialogUtil.openMessageDialog(resources.getString("AddRepo.Message.AlreadyExist")); + return true; + } + } + return false; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java new file mode 100644 index 00000000..a7641794 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/BuildSystemTab.java @@ -0,0 +1,972 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.ResourceBundle; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.console.MessageConsoleStream; +import org.tizen.common.ui.view.console.ConsoleManager; +import org.tizen.common.util.DialogUtil; +import org.tizen.common.util.FileUtil; +import org.tizen.nativecommon.build.CheckCancelJob; +import org.tizen.nativecommon.build.CurrentEnabledProject; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.pkgmgr.model.Package; +import org.tizen.nativeplatform.pkgmgr.model.PackageProvider; +import org.tizen.nativeplatform.pkgmgr.model.RemotePackage; +import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider; +import org.tizen.nativeplatform.pkgmgr.model.Repository; +import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider; + +public class BuildSystemTab { + + private IProject project; + private TabFolder folder = null; + private String conf = null; + private String targetId = null; + private TableViewer repoViewer = null; + private TableViewer pkgViewer = null; + private final Shell shell; + private FileDialog fd; + private String previousFilterPath = null; + private String selectedFileList; + private CopyOnWriteArrayList<Package> pkgs; + private SmartBuildInterface sbi = null; + + private final String BUNDLE_NAME = BuildSystemTab.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public BuildSystemTab(Shell shell, TabFolder folder, String conf, String targetId) { + this.shell = shell; + this.folder = folder; + this.conf = conf; + this.targetId = targetId; + this.project = CurrentEnabledProject.getCurrentProject(); + this.sbi = SmartBuildInterface.getInstance(project); + } + + public void createTab() { + initialize(); + createBuildsystemTab(folder); + } + + private void initialize() { + RepositoryProvider.INSTANCE.getBuildsystemRepos().clear(); + PackageProvider.INSTANCE.getBuildsystemPkgs().clear(); + + String result = RPMPackageCommander.getRepositoryListForRootstrap(targetId); + String[] splitStr = result.split("\n"); + // url list starts at 3 line + for (int i = 3 ; i < splitStr.length ; i++) { + String s = splitStr[i]; + s = s.replaceAll(" ", ""); + String[] part = s.split("\\|"); + String name = part[1]; + String uri = part[5]; + + Repository repo = new Repository(); + repo.setName(name); + repo.setUri(uri); + + RepositoryProvider.INSTANCE.getBuildsystemRepos().add(repo); + } + } + + private void createBuildsystemTab( TabFolder parent ) + { + TabItem buildsystemTab = new TabItem( parent, SWT.NULL ); + buildsystemTab.setText(resources.getString("PkgMgr.Tab.Buildsystem")); + + Composite composite = new Composite(folder, SWT.NONE); + buildsystemTab.setControl(composite); + composite.setLayout(new GridLayout(1, false)); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createInfoComposite( composite ); + createRepositoryGroup( composite ); + createPackageGroup( composite ); + } + + private void createInfoComposite( Composite parent ) + { + Composite info_comp = new Composite( parent, SWT.NONE ); + info_comp.setLayoutData(new GridData(GridData.BEGINNING)); + info_comp.setLayout(new GridLayout(1, false)); + + Label configurationLabel = new Label(info_comp, SWT.LEFT); + configurationLabel.setText(String.format("%s %s", resources.getString("PkgMgr.Label.Configuration"), conf)); + } + + private void createRepositoryGroup( Composite parent ) + { + Group grpRepo = new Group(parent, SWT.NONE); + grpRepo.setText(resources.getString("PkgMgr.Frame.Respository")); + grpRepo.setLayout(new GridLayout(1, false)); + GridData repo_gd = new GridData(GridData.FILL_BOTH); + grpRepo.setLayoutData(repo_gd); + + Composite repo_comp = new Composite( grpRepo, SWT.NONE ); + repo_comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp.setLayout(new GridLayout(2, false)); + + Composite repo_comp_table = new Composite( repo_comp, SWT.NONE ); + repo_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp_table.setLayout(new FillLayout()); + + Composite repo_comp_buttons = new Composite( repo_comp, SWT.NONE ); + repo_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp_buttons.setLayout(new GridLayout(1, false)); + + createRepositoryTable( repo_comp_table ); + createRepositoryButtons( repo_comp_buttons ); + } + + private void createPackageGroup( Composite parent ) + { + Group grpPkg = new Group(parent, SWT.NONE); + grpPkg.setText(resources.getString("PkgMgr.Frame.Package")); + grpPkg.setLayout(new GridLayout(1, false)); + GridData pkgs_gd = new GridData(GridData.FILL_BOTH); + pkgs_gd.heightHint = shell.getBounds().height / 3; + grpPkg.setLayoutData(pkgs_gd); + + Composite pkg_comp = new Composite( grpPkg, SWT.NONE ); + pkg_comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp.setLayout(new GridLayout(2, false)); + + Composite pkg_comp_table = new Composite( pkg_comp, SWT.NONE ); + pkg_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp_table.setLayout(new FillLayout()); + + Composite pkg_comp_buttons = new Composite( pkg_comp, SWT.NONE ); + pkg_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp_buttons.setLayout(new GridLayout(1, false)); + + createPackageTable( pkg_comp_table ); + createPackageButtons( pkg_comp_buttons ); + } + + private void createRepositoryTable( Composite parent) + { + repoViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK ); + createColumnsForRepoTable( parent ); + Table tableForRepository = repoViewer.getTable(); + tableForRepository.addListener( SWT.Selection, new Listener(){ + + @Override + public void handleEvent(Event event) { + if( event.detail == SWT.CHECK ) + { + Repository repo = (Repository)event.item.getData(); + repo.setCheckColumn( !repo.getCheckColumn() ); + } + } + }); + tableForRepository.setHeaderVisible(true); + tableForRepository.setLinesVisible(true); + repoViewer.setContentProvider(new ArrayContentProvider()); + repoViewer.setInput(RepositoryProvider.INSTANCE.getBuildsystemRepos()); + } + + private void createRepositoryButtons( Composite parent ) + { + Button add_bt = new Button( parent, SWT.PUSH ); + add_bt.setText(resources.getString("PkgMgr.Button.AddRepo")); + add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip")); + add_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + AddRepoDialog dialog = new AddRepoDialog(shell, resources.getString("PkgMgr.Tab.Buildsystem")); + dialog.open(); + repoViewer.refresh(); + + int recentTableIndex = 0; + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + + if (repo.getCheckDirty()) { + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), targetId, mcs, mcsError); + repo.setCheckDirty(false); + } + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + Button modify_bt = new Button( parent, SWT.PUSH ); + modify_bt.setText(resources.getString("PkgMgr.Button.ModifyRepo")); + modify_bt.setToolTipText(resources.getString("PkgMgr.Button.ModifyRepo.Tooltip")); + modify_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getBuildsystemRepos(); + + Repository selectedRepo = null; + int count = 0; + + for( Repository repo : list) { + if (repo.getCheckColumn()) { + count++; + selectedRepo = repo; + } + } + + if (count != 1 ) { + DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage")); + return; + } + + ModifyRepoDialog dialog = new ModifyRepoDialog(shell, resources.getString("PkgMgr.Tab.Buildsystem"), + selectedRepo.getName(), selectedRepo.getUri()); + dialog.open(); + + repoViewer.refresh(); + + int recentTableIndex = 0; + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + + if (repo.getCheckDirty()) { + list.remove(selectedRepo); + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + RPMPackageCommander.removeRepositoryForRootstrap(selectedRepo.getName(), targetId, mcs, mcsError); + + cm.clear(); + mcsError = cm.getMessageConsoleStream(); + mcs = cm.getMessageConsoleStream(); + RPMPackageCommander.addRepositoryForRootstrap(repo.getName(), repo.getUri(), targetId, mcs, mcsError); + repo.setCheckDirty(false); + } + } + + repoViewer.refresh(); + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + Button remove_bt = new Button( parent, SWT.PUSH ); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip")); + remove_bt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getBuildsystemRepos(); + + for( Repository repo : list) + { + boolean selected = false; + selected = repo.getCheckColumn(); + + if (selected) { + list.remove(repo); + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + RPMPackageCommander.removeRepositoryForRootstrap(repo.getName(), targetId, mcs, mcsError); + } + } + + repoViewer.refresh(); + int recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + } + + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + Button refresh_bt = new Button( parent, SWT.PUSH ); + refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo")); + refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip")); + refresh_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1); + + CheckCancelJob cancelJob = new CheckCancelJob(monitor, project, sbi, true); + + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + Thread checkCancelThread = new Thread(cancelJob); + checkCancelThread.start(); + + RPMPackageCommander.refreshRepositoryForRootstrap(sbi, targetId, mcs, mcsError); + + cancelJob.setFinishFlag(true); + } + }); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + } + + private void createPackageTable( Composite parent ) + { + pkgViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK ); + createColumns( parent ); + Table packageTable = pkgViewer.getTable(); + packageTable.addListener( SWT.Selection, new Listener(){ + + @Override + public void handleEvent(Event event) { + if( event.detail == SWT.CHECK ) + { + Package pkg = (Package)event.item.getData(); + pkg.setCheckColumn( !pkg.getCheckColumn() ); + } + } + }); + + packageTable.setHeaderVisible(true); + packageTable.setLinesVisible(true); + + pkgViewer.setContentProvider(new ArrayContentProvider()); + pkgViewer.setInput(PackageProvider.INSTANCE.getBuildsystemPkgs()); + } + + private void createPackageButtons( Composite parent ) + { + Button add_rtpkg_bt = new Button( parent, SWT.PUSH ); + add_rtpkg_bt.setText(resources.getString("PkgMgr.Button.AddRPackage")); + add_rtpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRPackage.Tooltip")); + add_rtpkg_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + RemotePkgProvider.INSTANCE.getPkgs().clear(); + RemotePkgProvider.INSTANCE.getSelectedPkgs().clear(); + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Getting.RemotePackage"), -1); + genRemotePkgList(); + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + AddRemotePackageDialog dlg = new AddRemotePackageDialog(shell); + dlg.open(); + + dialog = new ProgressMonitorDialog(shell); + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1); + for (RemotePackage p : RemotePkgProvider.INSTANCE.getSelectedPkgs()) { + addRemotePackage(p); + } + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + pkgViewer.refresh(); + int recentTableIndex = pkgViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + Button add_lcpkg_bt = new Button( parent, SWT.PUSH ); + add_lcpkg_bt.setText(resources.getString("PkgMgr.Button.AddLPackage")); + add_lcpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddLPackage.Tooltip")); + add_lcpkg_bt.addMouseListener(new MouseListener() + { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + int oldTableIndex = pkgViewer.getTable().getItemCount(); + + fd = new FileDialog( shell, SWT.OPEN|SWT.MULTI); + fd.setText(resources.getString("FileDlg.Title")); + if (previousFilterPath == null) + fd.setFilterPath(null); + else + fd.setFilterPath(previousFilterPath); + String[] filterExt = { resources.getString("FileDlg.Filter.Ext") }; + fd.setFilterExtensions(filterExt); + + try { + String arch = sbi.getArchitectureFromToolchainID(sbi.getToolchainIDFromTargetID(targetId)); + String _arch = ""; + if ("armel".equals(arch)) { + _arch = "armv7l"; + } else if ("i386".equals(arch)) { + _arch = "i586"; + } else { + _arch = arch; + } + String rootstrapPath = sbi.getRootstrapPath(targetId); + String defaultPath = rootstrapPath + resources.getString("FileDlg.Default.Path") + _arch; + fd.setFilterPath(defaultPath); + } catch (SBIException e2) { + e2.printStackTrace(); + } + + selectedFileList = fd.open(); + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, false, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1); + if( selectedFileList != null ) + { + String[] files = fd.getFileNames(); + previousFilterPath = fd.getFilterPath(); + for (int i=0, n = files.length; i<n; i++) { + monitor.subTask(String.format("Adding %s", files[i])); + StringBuffer buf = new StringBuffer(); + buf.append(fd.getFilterPath()); + if (buf.charAt(buf.length() -1) != File.separatorChar) { + buf.append(File.separatorChar); + } + buf.append(files[i]); + addLocalPackage( buf.toString()); + } + } + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + pkgViewer.refresh(); + + int recentTableIndex = pkgViewer.getTable().getItemCount(); + + for (int i = oldTableIndex; i < recentTableIndex; i++) { + TableItem item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + Button remove_bt = new Button( parent, SWT.PUSH ); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveList")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveList.Tooltip")); + remove_bt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + CopyOnWriteArrayList<Package> pkgList = PackageProvider.INSTANCE.getBuildsystemPkgs(); + for( Package pkg: pkgList) + { + boolean selected = false; + selected = pkg.getCheckColumn(); + if (selected) { + pkgList.remove(pkg); + } + } + pkgViewer.refresh(); + + int recentTableIndex = pkgViewer.getTable().getItemCount(); + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + + Button install_bt = new Button( parent, SWT.PUSH ); + install_bt.setText(resources.getString("PkgMgr.Button.Install")); + install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip")); + install_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + pkgs = getSelectedPkg(PackageProvider.INSTANCE.getBuildsystemPkgs()); + + if(pkgs.isEmpty()) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Package")); + return; + } + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1); + + CheckCancelJob cancelJob = new CheckCancelJob(monitor, project, sbi, true); + + try { + String rpmPathList = ""; + String localPkgList = ""; + String remotePkgList = ""; + String rootstrapPath = sbi.getRootstrapPath(targetId); + + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + MessageConsoleStream mcs1 = cm.getMessageConsoleStream(); + MessageConsoleStream mcsError2 = cm.getMessageConsoleStream(); + MessageConsoleStream mcs2 = cm.getMessageConsoleStream(); + + for (Package pkg : pkgs) { + if (pkg instanceof LocalPackage) { + LocalPackage p = (LocalPackage)pkg; + String filePath = p.getPath(); + String filename = new File(filePath).getName(); + String pathOnRootstrap = "/tmp/" + filename; + String copyToPath = rootstrapPath + pathOnRootstrap; + FileUtil.copyTo(filePath, copyToPath); + rpmPathList = rpmPathList.concat(pathOnRootstrap + " "); + localPkgList = localPkgList.concat(pkg.getName() + " "); + } else if (pkg instanceof RemotePackage) { + remotePkgList = remotePkgList.concat(pkg.getName() + " "); + } + } + + Thread checkCancelThread = new Thread(cancelJob); + checkCancelThread.start(); + + if(!"".equals(remotePkgList)) { + monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), remotePkgList)); + mcs1.write(resources.getString("PkgMgr.Console.Remote.Install")); + RPMPackageCommander.installRemotePkgForRootstrap(sbi, remotePkgList, targetId, mcs, mcsError); + } + + if(!"".equals(localPkgList)) { + monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), localPkgList)); + mcs1.write(resources.getString("PkgMgr.Console.Local.Install")); + RPMPackageCommander.InstallPkgToRootstrap(sbi, targetId, rpmPathList, mcs2, mcsError2); + for (String p : rpmPathList.split(" ")) { + File f = new File(rootstrapPath + p); + if (f.exists()) { + f.delete(); + } + } + } + + for (Package pkg : pkgs) { + String installedVer = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), targetId); + pkg.setInstalledVersion(installedVer); + if ("".equals(installedVer)) { + pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED); + } else if (installedVer.equals(pkg.getNewVersion())) { + if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), targetId)) { + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } else { + pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED); + } + } else { + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } + } + + } catch (IOException e) { + cancelJob.setFinishFlag(true); + e.printStackTrace(); + } catch (SBIException e) { + cancelJob.setFinishFlag(true); + e.printStackTrace(); + } + + cancelJob.setFinishFlag(true); + monitor.done(); + } + }); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + pkgViewer.refresh(); + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + } + + private void createColumnsForRepoTable( Composite parent ) + { + String[] titles = {"Name", "Reposity URL"}; + int[] bounds = { 200, 600 }; + + TableViewerColumn colName = createTableViewerColumn( repoViewer, titles[0], bounds[0], SWT.NONE); + TableColumn column = colName.getColumn(); + column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer)); + + colName.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Repository repo = (Repository)element; + return repo.getName(); + } + }); + + TableViewerColumn colUrl = createTableViewerColumn( repoViewer, titles[1], bounds[1], SWT.NONE); + column = colUrl.getColumn(); + column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer)); + + colUrl.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Repository repo = (Repository)element; + return repo.getUri(); + } + }); + } + + private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) { + + final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style); + final TableColumn column = viewerColumn.getColumn(); + column.addSelectionListener(new PackageTableSelectionAdapter(pkgViewer)); + column.setText(title); + column.setWidth(bound); + column.setResizable(true); + column.setMoveable(true); + return viewerColumn; + } + + private void createColumns( Composite parent ) + { + String[] titles = {"Install Type", "Package Name", "Arch", "New Version", "Installed Version", "Status"}; + int[] bounds = { 120, 250, 60, 150, 150, 150}; + + TableViewerColumn colInstallType = createTableViewerColumn( pkgViewer, titles[0], bounds[0], SWT.NONE); + + colInstallType.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + return pkg.getPkgType().toString(); + } + }); + + TableViewerColumn colPackage = createTableViewerColumn( pkgViewer, titles[1], bounds[1], SWT.NONE); + + colPackage.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + return pkg.getName(); + } + }); + + TableViewerColumn colArch = createTableViewerColumn( pkgViewer, titles[2], bounds[2], SWT.NONE); + + colArch.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String arch = pkg.getArch(); + return arch; + } + }); + + TableViewerColumn colNewVer = createTableViewerColumn( pkgViewer, titles[3], bounds[3], SWT.NONE); + + colNewVer.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String newVer = pkg.getNewVersion(); + return newVer; + } + }); + + TableViewerColumn colInsVer = createTableViewerColumn( pkgViewer, titles[4], bounds[4], SWT.NONE); + colInsVer.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String installedVer = pkg.getInstalledVersion(); + return installedVer; + } + }); + + TableViewerColumn colStatus = createTableViewerColumn( pkgViewer, titles[5], bounds[5], SWT.NONE); + + colStatus.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String status = pkg.getInstallInfo().toString(); + return status; + } + }); + } + + private void genRemotePkgList() { + + String list = RPMPackageCommander.getRemotePackageListForRootstrap(targetId); + String[] splitStr = list.split("\n"); + + // Package list starts at 5 line + for (int i = 5 ; i < splitStr.length ; i++) { + String s = splitStr[i]; + s = s.replaceAll(" ", ""); + String[] part = s.split("\\|"); + String status = part[0]; + String repo = part[1]; + String name = part[2]; + String version = part[3]; + String arch = part[4]; + + RemotePackage pkg = new RemotePackage(); + pkg.setName(name); + pkg.setArch(arch); + pkg.setNewVersion(version); + pkg.setRepo(repo); + pkg.setCheckColumn(false); + if ("i".equals(status)) { + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } else if ("v".equals(status)) { + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } + + RemotePkgProvider.INSTANCE.getPkgs().add(pkg); + } + } + + private void addRemotePackage( RemotePackage p ) { + CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getBuildsystemPkgs(); + Iterator<Package> debIter = pkgs.iterator(); + + while( debIter.hasNext() ) { + Package pkg = debIter.next(); + if( pkg.getName().equals(p.getName()) && + pkg.getNewVersion().equals(p.getNewVersion()) ) { + return; + } + } + + String installedVer = RPMPackageCommander.getPkgInstalledVerForRootstrap(p.getName(), targetId); + p.setInstalledVersion(installedVer); + p.setCheckColumn(true); + p.setPkgType(Package.PKGTYPE.REMOTE); + PackageProvider.INSTANCE.getBuildsystemPkgs().add(p); + } + + private void addLocalPackage( String rpmPath ) + { + CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getBuildsystemPkgs(); + Iterator<Package> debIter = pkgs.iterator(); + + String pkgName = RPMPackageCommander.getPkgNameForFile(rpmPath); + String newVer = RPMPackageCommander.getPkgVerForFile(rpmPath); + + while( debIter.hasNext() ) { + Package pkg = debIter.next(); + if( pkg.getName().equals(pkgName) && pkg.getNewVersion().equals(newVer)) { + return; + } + } + + LocalPackage pkg = new LocalPackage(); + pkg.setName(pkgName); + pkg.setPath(rpmPath); + pkg.setPkgType(Package.PKGTYPE.LOCAL); + pkg.setArch(RPMPackageCommander.getArchForFile(rpmPath)); + pkg.setNewVersion(newVer); + + String installedVerForRootstrap = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), targetId); + pkg.setInstalledVersion(installedVerForRootstrap); + + if ("".equals(newVer)) { + pkg.setCheckColumn(false); + } else if (!"".equals(installedVerForRootstrap)) { + if (!installedVerForRootstrap.equals(newVer)) { + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } else { + if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkgName, targetId)) { + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } + } + } + + PackageProvider.INSTANCE.getBuildsystemPkgs().add(pkg); + } + + private CopyOnWriteArrayList<Package> getSelectedPkg(CopyOnWriteArrayList<Package> pkgs) { + CopyOnWriteArrayList<Package> _pkgs = new CopyOnWriteArrayList<Package>(); + for (Package pkg : pkgs) { + if(pkg.getCheckColumn()) { + _pkgs.add(pkg); + } + } + + return _pkgs; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java new file mode 100644 index 00000000..2cb0e9ac --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java @@ -0,0 +1,988 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.Iterator; +import java.util.ResourceBundle; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.console.MessageConsoleStream; +import org.tizen.common.ui.view.console.ConsoleManager; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; +import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver; +import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.pkgmgr.model.Package; +import org.tizen.nativeplatform.pkgmgr.model.PackageProvider; +import org.tizen.nativeplatform.pkgmgr.model.RemotePackage; +import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider; +import org.tizen.nativeplatform.pkgmgr.model.Repository; +import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider; +import org.tizen.sdblib.IDevice; +import org.tizen.sdblib.SyncService; +import org.tizen.sdblib.SyncService.SyncResult; + +public class DeviceTab { + + private TabFolder folder = null; + private String targetId = null; + private TableViewer repoViewer = null; + private TableViewer pkgViewer = null; + private final Shell shell; + private FileDialog fd; + private String previousFilterPath = null; + private String selectedFileList; + private final IDevice device; + private CopyOnWriteArrayList<Package> pkgs; + private final SmartBuildInterface sbi = SmartBuildInterface.getInstance(); + + private final String TMP_PATH= "/tmp"; + private final String BUNDLE_NAME = DeviceTab.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public DeviceTab(Shell shell, TabFolder folder, String targetId, IDevice dev) { + this.shell = shell; + this.folder = folder; + this.targetId = targetId; + this.device = dev; + } + + public void createTab() { + initialize(); + createDeivceTab(folder); + } + + private void initialize() { + RepositoryProvider.INSTANCE.getDeviceRepos().clear(); + PackageProvider.INSTANCE.getDevicePkgs().clear(); + + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + String result = RPMPackageCommander.getRepositoryListForDevice(device, rec); + String[] splitStr = result.split("\n"); + for (int i = 2 ; i < splitStr.length ; i++) { + String s = splitStr[i]; + s = s.replaceAll(" ", ""); + String[] part = s.split("\\|"); + String name = part[1]; + String uri = part[5]; + + Repository repo = new Repository(); + repo.setName(name); + repo.setUri(uri); + + RepositoryProvider.INSTANCE.getDeviceRepos().add(repo); + } + } + + private void createDeivceTab( TabFolder parent ) + { + TabItem deviceTab = new TabItem( parent, SWT.NULL ); + deviceTab.setText(resources.getString("PkgMgr.Tab.Device")); + + Composite composite = new Composite(folder, SWT.NONE); + deviceTab.setControl(composite); + composite.setLayout(new GridLayout(1, false)); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createInfoComposite( composite ); + createRepositoryGroup( composite ); + createPackageGroup( composite ); + } + + private void createInfoComposite( Composite parent ) + { + Composite info_comp = new Composite( parent, SWT.NONE ); + info_comp.setLayoutData(new GridData(GridData.BEGINNING)); + info_comp.setLayout(new GridLayout(1, false)); + + Label configurationLabel = new Label(info_comp, SWT.LEFT); + configurationLabel.setText(String.format("%s %s", resources.getString("PkgMgr.Label.Connection"), device.getSerialNumber())); + } + + private void createRepositoryGroup( Composite parent ) + { + Group grpRepo = new Group(parent, SWT.NONE); + grpRepo.setText(resources.getString("PkgMgr.Frame.Respository")); + grpRepo.setLayout(new GridLayout(1, false)); + GridData repo_gd = new GridData(GridData.FILL_BOTH); + grpRepo.setLayoutData(repo_gd); + + Composite repo_comp = new Composite( grpRepo, SWT.NONE ); + repo_comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp.setLayout(new GridLayout(2, false)); + + Composite repo_comp_table = new Composite( repo_comp, SWT.NONE ); + repo_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp_table.setLayout(new FillLayout()); + + Composite repo_comp_buttons = new Composite( repo_comp, SWT.NONE ); + repo_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH)); + repo_comp_buttons.setLayout(new GridLayout(1, false)); + + createRepositoryTable( repo_comp_table ); + createRepositoryButtons( repo_comp_buttons ); + } + + private void createPackageGroup( Composite parent ) + { + Group grpPkg = new Group(parent, SWT.NONE); + grpPkg.setText(resources.getString("PkgMgr.Frame.Package")); + grpPkg.setLayout(new GridLayout(1, false)); + GridData pkgs_gd = new GridData(GridData.FILL_BOTH); + pkgs_gd.heightHint = shell.getBounds().height / 3; + grpPkg.setLayoutData(pkgs_gd); + + Composite pkg_comp = new Composite( grpPkg, SWT.NONE ); + pkg_comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp.setLayout(new GridLayout(2, false)); + + Composite pkg_comp_table = new Composite( pkg_comp, SWT.NONE ); + pkg_comp_table.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp_table.setLayout(new FillLayout()); + + Composite pkg_comp_buttons = new Composite( pkg_comp, SWT.NONE ); + pkg_comp_buttons.setLayoutData(new GridData(GridData.FILL_BOTH)); + pkg_comp_buttons.setLayout(new GridLayout(1, false)); + + createPackageTable( pkg_comp_table ); + createPackageButtons( pkg_comp_buttons ); + } + + private void createRepositoryTable( Composite parent) + { + // Build System Tab + repoViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK ); + createColumnsForRepoTable( parent ); + Table tableForRepository = repoViewer.getTable(); + tableForRepository.addListener( SWT.Selection, new Listener(){ + + @Override + public void handleEvent(Event event) { + if( event.detail == SWT.CHECK ) + { + Repository repo = (Repository)event.item.getData(); + repo.setCheckColumn( !repo.getCheckColumn() ); + } + } + }); + tableForRepository.setHeaderVisible(true); + tableForRepository.setLinesVisible(true); + repoViewer.setContentProvider(new ArrayContentProvider()); + repoViewer.setInput(RepositoryProvider.INSTANCE.getDeviceRepos()); + } + + private void createRepositoryButtons( Composite parent ) + { + Button add_bt = new Button( parent, SWT.PUSH ); + add_bt.setText(resources.getString("PkgMgr.Button.AddRepo")); + add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip")); + add_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + AddRepoDialog dialog = new AddRepoDialog(shell, resources.getString("PkgMgr.Tab.Device")); + dialog.open(); + repoViewer.refresh(); + + int recentTableIndex = 0; + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + + if (repo.getCheckDirty()) { + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + RPMPackageCommander.addRepositoryForDevice(repo.getName(), repo.getUri(), device, rec); + repo.setCheckDirty(false); + } + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + Button modify_bt = new Button( parent, SWT.PUSH ); + modify_bt.setText(resources.getString("PkgMgr.Button.ModifyRepo")); + modify_bt.setToolTipText(resources.getString("PkgMgr.Button.ModifyRepo.Tooltip")); + modify_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getDeviceRepos(); + + Repository selectedRepo = null; + int count = 0; + + for( Repository repo : list) { + if (repo.getCheckColumn()) { + count++; + selectedRepo = repo; + } + } + + if (count != 1 ) { + DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage")); + return; + } + + ModifyRepoDialog dialog = new ModifyRepoDialog(shell, resources.getString("PkgMgr.Tab.Device"), + selectedRepo.getName(), selectedRepo.getUri()); + dialog.open(); + + repoViewer.refresh(); + + int recentTableIndex = 0; + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + + if (repo.getCheckDirty()) { + list.remove(selectedRepo); + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + RPMPackageCommander.removeRepositoryForDevice(selectedRepo.getName(), device, rec); + + rec.cleanLog(); + RPMPackageCommander.addRepositoryForDevice(repo.getName(), repo.getUri(), device, rec); + repo.setCheckDirty(false); + } + } + + repoViewer.refresh(); + recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + + Button remove_bt = new Button( parent, SWT.PUSH ); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip")); + remove_bt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + CopyOnWriteArrayList<Repository> list = RepositoryProvider.INSTANCE.getDeviceRepos(); + + for( Repository repo : list) + { + boolean selected = false; + selected = repo.getCheckColumn(); + + if (selected) { + list.remove(repo); + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + RPMPackageCommander.removeRepositoryForDevice(repo.getName(), device, rec); + } + } + + repoViewer.refresh(); + int recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = repoViewer.getTable().getItem(i); + Repository repo = (Repository)item.getData(); + item.setChecked(repo.getCheckColumn()); + } + + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + Button refresh_bt = new Button( parent, SWT.PUSH ); + refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo")); + refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip")); + refresh_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1); + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + RPMPackageCommander.refreshRepositoryForDevice(device, rec); + } + }); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + } + + private void createPackageTable( Composite parent ) + { + pkgViewer = new TableViewer( parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK ); + createColumns( parent ); + Table packageTable = pkgViewer.getTable(); + packageTable.addListener( SWT.Selection, new Listener(){ + + @Override + public void handleEvent(Event event) { + if( event.detail == SWT.CHECK ) + { + Package pkg = (Package)event.item.getData(); + pkg.setCheckColumn( !pkg.getCheckColumn() ); + } + } + }); + + packageTable.setHeaderVisible(true); + packageTable.setLinesVisible(true); + + pkgViewer.setContentProvider(new ArrayContentProvider()); + pkgViewer.setInput(PackageProvider.INSTANCE.getDevicePkgs()); + } + + private void createPackageButtons( Composite parent ) + { + Button add_rtpkg_bt = new Button( parent, SWT.PUSH ); + add_rtpkg_bt.setText(resources.getString("PkgMgr.Button.AddRPackage")); + add_rtpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRPackage.Tooltip")); + add_rtpkg_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + RemotePkgProvider.INSTANCE.getPkgs().clear(); + RemotePkgProvider.INSTANCE.getSelectedPkgs().clear(); + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Getting.RemotePackage"), -1); + genRemotePkgList(); + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + AddRemotePackageDialog dlg = new AddRemotePackageDialog(shell); + dlg.open(); + + dialog = new ProgressMonitorDialog(shell); + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1); + for (RemotePackage p : RemotePkgProvider.INSTANCE.getSelectedPkgs()) { + addRemotePackage(p); + } + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + pkgViewer.refresh(); + int recentTableIndex = pkgViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + + Button add_lcpkg_bt = new Button( parent, SWT.PUSH ); + add_lcpkg_bt.setText(resources.getString("PkgMgr.Button.AddLPackage")); + add_lcpkg_bt.setToolTipText(resources.getString("PkgMgr.Button.AddLPackage.Tooltip")); + add_lcpkg_bt.addMouseListener(new MouseListener() + { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + int oldTableIndex = pkgViewer.getTable().getItemCount(); + + fd = new FileDialog( shell, SWT.OPEN|SWT.MULTI); + fd.setText(resources.getString("FileDlg.Title")); + if (previousFilterPath == null) + fd.setFilterPath(null); + else + fd.setFilterPath(previousFilterPath); + String[] filterExt = { resources.getString("FileDlg.Filter.Ext") }; + fd.setFilterExtensions(filterExt); + + try { + String arch = sbi.getArchitectureFromToolchainID(sbi.getToolchainIDFromTargetID(targetId)); + String _arch = ""; + if ("armel".equals(arch)) { + _arch = "armv7l"; + } else if ("i386".equals(arch)) { + _arch = "i586"; + } else { + _arch = arch; + } + String rootstrapPath = sbi.getRootstrapPath(targetId); + String defaultPath = rootstrapPath + resources.getString("FileDlg.Default.Path") + _arch; + fd.setFilterPath(defaultPath); + } catch (SBIException e2) { + e2.printStackTrace(); + } + + selectedFileList = fd.open(); + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, false, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Adding.Package"), -1); + if( selectedFileList != null ) + { + String[] files = fd.getFileNames(); + previousFilterPath = fd.getFilterPath(); + for (int i=0, n = files.length; i<n; i++) { + monitor.subTask(String.format("Adding %s", files[i])); + StringBuffer buf = new StringBuffer(); + buf.append(fd.getFilterPath()); + if (buf.charAt(buf.length() -1) != File.separatorChar) { + buf.append(File.separatorChar); + } + buf.append(files[i]); + addLocalPackage( buf.toString()); + } + } + } + }); + } catch (Exception e1) { + e1.printStackTrace(); + } + + pkgViewer.refresh(); + + int recentTableIndex = pkgViewer.getTable().getItemCount(); + + for (int i = oldTableIndex; i < recentTableIndex; i++) { + TableItem item = null; + + item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + + Button remove_bt = new Button( parent, SWT.PUSH ); + remove_bt.setText(resources.getString("PkgMgr.Button.RemoveList")); + remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveList.Tooltip")); + remove_bt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + CopyOnWriteArrayList<Package> pkgList = PackageProvider.INSTANCE.getDevicePkgs(); + for( Package pkg: pkgList) + { + boolean selected = false; + selected = pkg.getCheckColumn(); + if (selected) { + pkgList.remove(pkg); + } + } + pkgViewer.refresh(); + + int recentTableIndex = pkgViewer.getTable().getItemCount(); + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = null; + item = pkgViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + Button install_bt = new Button( parent, SWT.PUSH ); + install_bt.setText(resources.getString("PkgMgr.Button.Install")); + install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip")); + install_bt.addMouseListener(new MouseListener(){ + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + pkgs = getSelectedPkg(PackageProvider.INSTANCE.getDevicePkgs()); + + if(pkgs.isEmpty()) { + MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Package")); + return; + } + + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1); + + try { + String newPath = null; + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); + rec.setMessageConsoleStream(mcs); + String localPkgList = ""; + String remotePkgList = ""; + + // Step 1: transfer pkg and make pkg list + for (Package pkg : pkgs) + { + if (pkg instanceof LocalPackage) { + LocalPackage p = (LocalPackage)pkg; + String file = new File(p.getPath()).getName(); + newPath = TMP_PATH + "/" + file; + monitor.subTask(String.format(resources.getString("PkgMgr.Message.Transfer.File"), p.getPath(), newPath)); + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + SyncService syncService = device.getSyncService(); + SyncResult syncResult = syncService.pushFile(p.getPath(), newPath, SyncService.getNullProgressMonitor()); + if (syncResult.getCode() != SyncService.RESULT_OK) { + mcsError.println(String.format(resources.getString("PkgMgr.Error.Failtransfer.File"), p.getPath(), newPath)); + p.setInstallInfo( Package.INSTALLINFO.NOT_INSTALLED); + continue; + } + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + if (localPkgList == "") { + localPkgList = newPath; + } else { + localPkgList = localPkgList + " " + newPath; + } + + } else if (pkg instanceof RemotePackage) { + if (remotePkgList == "") { + remotePkgList = pkg.getName(); + } else { + remotePkgList = remotePkgList + " " + pkg.getName(); + } + } + } + + + // Step 2: set update mode on device + if (!device.isEmulator()) { + RPMPackageCommander.changeUpdateModeForDevice(device, rec); + } + + if (remotePkgList != "") { + monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), remotePkgList)); + RPMPackageCommander.installRemotePkgForDevice(remotePkgList, device, rec); + } + + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + + if (localPkgList != "") { + monitor.subTask(String.format("%s %s", resources.getString("PkgMgr.Message.Installing.Package"), localPkgList)); + RPMPackageCommander.InstallPkgToDevice(localPkgList, device, rec); + } + + if (monitor.isCanceled()) + throw new OperationCanceledException(); + + Thread.sleep(500); + + for (Package pkg : pkgs) { + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + // update status + rec.setPrintConsole(false); + String installedVer = RPMPackageCommander.getPkgInstalledVerForDevice(pkg.getName(), device, rec); + pkg.setInstalledVersion(installedVer); + + if ("".equals(installedVer)) { + pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED); + } else if (installedVer.equals(pkg.getNewVersion())) { + if (RPMPackageCommander.pkgInstalledSuccessfullyForDevice(pkg.getName(), device, rec)) { + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } else { + pkg.setInstallInfo(Package.INSTALLINFO.NOT_INSTALLED); + } + } else { + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } + if (monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + monitor.done(); + } + }); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + pkgViewer.refresh(); + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + } + + private void createColumnsForRepoTable( Composite parent ) + { + String[] titles = {"Name", "Reposity URL"}; + int[] bounds = { 200, 600 }; + + TableViewerColumn colName = createTableViewerColumn( repoViewer, titles[0], bounds[0], SWT.NONE); + TableColumn column = colName.getColumn(); + column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer)); + + colName.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Repository repo = (Repository)element; + return repo.getName(); + } + }); + + TableViewerColumn colUrl = createTableViewerColumn( repoViewer, titles[1], bounds[1], SWT.NONE); + column = colUrl.getColumn(); + column.addSelectionListener(new RepoTableSelectionAdapter(repoViewer)); + + colUrl.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Repository repo = (Repository)element; + return repo.getUri(); + } + }); + } + + private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) { + + final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style); + final TableColumn column = viewerColumn.getColumn(); + column.addSelectionListener(new PackageTableSelectionAdapter(pkgViewer)); + column.setText(title); + column.setWidth(bound); + column.setResizable(true); + column.setMoveable(true); + return viewerColumn; + } + + private void createColumns( Composite parent ) + { + String[] titles = {"Install Type", "Package Name", "Arch", "New Version", "Installed Version", "Status"}; + int[] bounds = { 120, 250, 60, 150, 150, 150}; + + TableViewerColumn colInstallType = createTableViewerColumn( pkgViewer, titles[0], bounds[0], SWT.NONE); + + colInstallType.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + return pkg.getPkgType().toString(); + } + }); + + TableViewerColumn colPackage = createTableViewerColumn( pkgViewer, titles[1], bounds[1], SWT.NONE); + + colPackage.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + return pkg.getName(); + } + }); + + TableViewerColumn colArch = createTableViewerColumn( pkgViewer, titles[2], bounds[2], SWT.NONE); + + colArch.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String arch = pkg.getArch(); + return arch; + } + }); + + TableViewerColumn colNewVer = createTableViewerColumn( pkgViewer, titles[3], bounds[3], SWT.NONE); + + colNewVer.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String newVer = pkg.getNewVersion(); + return newVer; + } + }); + + TableViewerColumn colInsVer = createTableViewerColumn( pkgViewer, titles[4], bounds[4], SWT.NONE); + colInsVer.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String installedVer = pkg.getInstalledVersion(); + return installedVer; + } + }); + + TableViewerColumn colStatus = createTableViewerColumn( pkgViewer, titles[5], bounds[5], SWT.NONE); + + colStatus.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + Package pkg = (Package)element; + String status = pkg.getInstallInfo().toString(); + return status; + } + }); + } + + private void genRemotePkgList() { + + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + String list = RPMPackageCommander.getRemotePackageListForDevice(device, rec); + + String[] splitStr = list.split("\n"); + + for (int i = 4 ; i < splitStr.length ; i++) { + String s = splitStr[i]; + s = s.replaceAll(" ", ""); + String[] part = s.split("\\|"); + String status = part[0]; + String repo = part[1]; + String name = part[2]; + String version = part[3]; + String arch = part[4]; + + RemotePackage pkg = new RemotePackage(); + pkg.setName(name); + pkg.setArch(arch); + pkg.setNewVersion(version); + pkg.setRepo(repo); + if ("i".equals(status)) { + pkg.setCheckColumn(true); + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } else if ("v".equals(status)) { + pkg.setCheckColumn(false); + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } else { + pkg.setCheckColumn(false); + } + + RemotePkgProvider.INSTANCE.getPkgs().add(pkg); + } + } + + private void addRemotePackage( RemotePackage p ) { + CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getDevicePkgs(); + Iterator<Package> debIter = pkgs.iterator(); + + while( debIter.hasNext() ) { + Package pkg = debIter.next(); + if( pkg.getName().equals(p.getName()) && + pkg.getNewVersion().equals(p.getNewVersion()) ) { + return; + } + } + + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + String installedVer = RPMPackageCommander.getPkgInstalledVerForDevice(p.getName(), device, rec); + + p.setInstalledVersion(installedVer); + p.setCheckColumn(true); + p.setPkgType(Package.PKGTYPE.REMOTE); + PackageProvider.INSTANCE.getDevicePkgs().add(p); + } + + private void addLocalPackage( String rpmPath ) + { + CopyOnWriteArrayList<Package> pkgs = PackageProvider.INSTANCE.getDevicePkgs(); + Iterator<Package> debIter = pkgs.iterator(); + + String pkgName = RPMPackageCommander.getPkgNameForFile(rpmPath); + String newVer = RPMPackageCommander.getPkgVerForFile(rpmPath); + + while( debIter.hasNext() ) { + Package pkg = debIter.next(); + if( pkg.getName().equals(pkgName) && pkg.getNewVersion().equals(newVer)) { + return; + } + } + + LocalPackage pkg = new LocalPackage(); + pkg.setName(pkgName); + pkg.setPath(rpmPath); + pkg.setPkgType(Package.PKGTYPE.LOCAL); + pkg.setArch(RPMPackageCommander.getArchForFile(rpmPath)); + pkg.setNewVersion(newVer); + + PackageManagerOuputReceiver rec = getNewOuputReceiver(); + String installedVerForRootstrap = RPMPackageCommander.getPkgInstalledVerForDevice(pkg.getName(), device, rec); + pkg.setInstalledVersion(installedVerForRootstrap); + + if ("".equals(newVer)) { + pkg.setCheckColumn(false); + } else if (!"".equals(installedVerForRootstrap)) { + if (!installedVerForRootstrap.equals(newVer)) { + pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION); + } else { + if (RPMPackageCommander.pkgInstalledSuccessfullyForDevice(pkgName, device, rec)) { + pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); + } + } + } + + PackageProvider.INSTANCE.getDevicePkgs().add(pkg); + } + + private CopyOnWriteArrayList<Package> getSelectedPkg(CopyOnWriteArrayList<Package> pkgs) { + CopyOnWriteArrayList<Package> _pkgs = new CopyOnWriteArrayList<Package>(); + for (Package pkg : pkgs) { + if(pkg.getCheckColumn()) { + _pkgs.add(pkg); + } + } + + return _pkgs; + } + + private PackageManagerOuputReceiver getNewOuputReceiver() { + ConsoleManager cm = new ConsoleManager(resources.getString("PkgMgr.Console.Name"), true); + cm.clear(); + MessageConsoleStream mcsError = cm.getMessageConsoleStream(); + MessageConsoleStream mcs = cm.getMessageConsoleStream(); + PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); + rec.setMessageConsoleStream(mcs); + + return rec; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java new file mode 100644 index 00000000..27278f5b --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java @@ -0,0 +1,103 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.util.ResourceBundle; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import org.tizen.nativeplatform.pkgmgr.model.Repository; +import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider; + +public class ModifyRepoDialog extends Dialog { + + private Text nameText; + private Text uriText; + private String tab; + private String name; + private String value; + + private int x = 0; + private int y = 0; + private final int width = 500; + private final int height = 200; + + private final String BUNDLE_NAME = ModifyRepoDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + protected ModifyRepoDialog(Shell parentShell) { + super(parentShell); + } + + public ModifyRepoDialog(Shell parentShell, String tab, String name, String value) { + super(parentShell); + this.tab = tab; + this.name = name; + this.value = value; + Rectangle bounds = parentShell.getBounds(); + x = bounds.x + (bounds.width - width)/2; + y = bounds.y + (bounds.height - height)/2; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText(resources.getString("ModifyRepo.Title")); + newShell.setLocation(x, y); + newShell.setSize(width, height); + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite composite = new Composite( parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setLayout(new GridLayout(2, false)); + + Label nameLabel = new Label(composite, SWT.NONE); + nameLabel.setText(resources.getString("ModifyRepo.Label.Name")); + nameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.widthHint = 500; + nameText.setLayoutData(gridData); + nameText.setText(name); + nameText.setEnabled(false); + + Label urlLabel = new Label(composite, SWT.NONE); + urlLabel.setText(resources.getString("ModifyRepo.Label.Uri")); + uriText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.widthHint = 500; + uriText.setLayoutData(gridData); + uriText.setText(value); + + return null; + } + + @Override + protected void okPressed() { + + Repository repo = new Repository(); + if (!uriText.getText().equals(value)) { + repo.setName(nameText.getText()); + repo.setUri(uriText.getText()); + repo.setCheckDirty(true); + + if (resources.getString("PkgMgr.Tab.Buildsystem").equals(tab)) { + RepositoryProvider.INSTANCE.getBuildsystemRepos().add(repo); + } else if (resources.getString("PkgMgr.Tab.Device").equals(tab)) { + RepositoryProvider.INSTANCE.getDeviceRepos().add(repo); + } + } + + super.okPressed(); + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java new file mode 100644 index 00000000..143f62ec --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java @@ -0,0 +1,98 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; + +import org.tizen.nativeplatform.pkgmgr.model.Package; + +public class PackageTableSelectionAdapter extends SelectionAdapter { + private TableViewer repoViewer; + private int selectedColumn = 0; + public PackageTableSelectionAdapter(TableViewer v) { + super(); + this.repoViewer = v; + } + + public void widgetSelected(SelectionEvent e) { + selectedColumn = repoViewer.getTable().indexOf((TableColumn) e.widget); + repoViewer.getTable().setSortColumn((TableColumn)e.widget); + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + repoViewer.getTable().setSortDirection(SWT.UP); + } else { + repoViewer.getTable().setSortDirection(SWT.DOWN); + } + + repoViewer.setSorter(new ViewerSorter() { + public int compare(Viewer viewer, Object e1, Object e2) { + int result = 0; + + Package entry_1 = (Package)e1; + Package entry_2 = (Package)e2; + + switch (selectedColumn) { + case 0: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getPkgType().compareTo(entry_2.getPkgType()); + } else { + result = entry_2.getPkgType().compareTo(entry_1.getPkgType()); + } + break; + case 1: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getName().compareTo(entry_2.getName()); + } else { + result = entry_2.getName().compareTo(entry_1.getName()); + } + break; + case 2: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getArch().compareTo(entry_2.getArch()); + } else { + result = entry_2.getArch().compareTo(entry_1.getArch()); + } + break; + case 3: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getNewVersion().compareTo(entry_2.getNewVersion()); + } else { + result = entry_2.getNewVersion().compareTo(entry_1.getNewVersion()); + } + break; + case 4: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getInstalledVersion().compareTo(entry_2.getInstalledVersion()); + } else { + result = entry_2.getInstalledVersion().compareTo(entry_1.getInstalledVersion()); + } + break; + case 5: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getInstallInfo().toString().compareTo(entry_2.getInstallInfo().toString()); + } else { + result = entry_2.getInstallInfo().toString().compareTo(entry_1.getInstallInfo().toString()); + } + break; + } + + return result; + } + }); + updateCheck(); + } + + private void updateCheck() { + int recentTableIndex = repoViewer.getTable().getItemCount(); + + for (int i = 0; i < recentTableIndex; i++) { + TableItem item = repoViewer.getTable().getItem(i); + Package pkg = (Package)item.getData(); + item.setChecked(pkg.getCheckColumn()); + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties new file mode 100644 index 00000000..6477a35b --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PkgMgrUIMessages.properties @@ -0,0 +1,52 @@ +PkgMgr.Title = Package Manager +PkgMgr.Frame.Description = Install packages to the build system or device. +PkgMgr.Frame.Respository = Repositories +PkgMgr.Frame.Package = Packages +PkgMgr.Tab.Buildsystem = Build System +PkgMgr.Tab.Device = Device +PkgMgr.Console.Name = Package Manager +PkgMgr.Error.Noselected = - No project is selected, no device is connected, or the selected project is not a Tizen project +PkgMgr.Error.Noselected.Package = No package selected. +PkgMgr.Error.Failtransfer.File = Moving the file from %s to %s failed. +PkgMgr.Warn.Notset.Proxy = (Warning: HTTP Proxy environment variable (OBS_HTTP_PROXY) is not set) +PkgMgr.Label.Configuration = Selected configuration: +PkgMgr.Label.Connection = Selected connection: +PkgMgr.Button.AddRepo = Add +PkgMgr.Button.AddRepo.Tooltip = Add a repository +PkgMgr.Button.ModifyRepo = Modify +PkgMgr.Button.ModifyRepo.Tooltip = Modify a repository +PkgMgr.Button.RemoveRepo = Remove +PkgMgr.Button.RemoveRepo.Tooltip = Remove the selected repositories +PkgMgr.Button.RefreshRepo = Refresh +PkgMgr.Button.RefreshRepo.Tooltip = Refresh all repositories +PkgMgr.Button.AddRPackage = Add Remote Package +PkgMgr.Button.AddRPackage.Tooltip = Add remote packages from repositories +PkgMgr.Button.AddLPackage = Add Local Package +PkgMgr.Button.AddLPackage.Tooltip = Add local packages from file system +PkgMgr.Button.RemoveList = Remove List +PkgMgr.Button.RemoveList.Tooltip = Remove selected packages from list +PkgMgr.Button.Install = Install Package +PkgMgr.Button.Install.Tooltip = Install selected packages +PkgMgr.Message.Refreshing = Refreshing the repository... +PkgMgr.Message.Adding.Package = Adding selected packages to the table... +PkgMgr.Message.Getting.RemotePackage = Getting the remote package list... +PkgMgr.Message.Installing.Package = Installing packages... +PkgMgr.Message.Select.OnePackage = Please select one repository +PkgMgr.Message.Transfer.File = Transferring %s to target's %s... +PkgMgr.Console.Remote.Install = ***** Installing a remote package *****\n +PkgMgr.Console.Local.Install = \n***** Installing a local package *****\n + +AddRepo.Title = Add Package Repository +AddRepo.Label.Name = Name: +AddRepo.Label.Uri = URI: +AddRepo.Message.AlreadyExist = The repository already exists + +ModifyRepo.Title = Modify Package Repository +ModifyRepo.Label.Name = Name: +ModifyRepo.Label.Uri = URI: + +AddRemotePkg.Title = Add Remote Packages + +FileDlg.Title = Select RPM files... +FileDlg.Filter.Ext = *.rpm +FileDlg.Default.Path = /home/abuild/rpmbuild/RPMS/ diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java new file mode 100644 index 00000000..428ed889 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RPMPackageDialog.java @@ -0,0 +1,288 @@ +/* +* Inhouse +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Taejun Ha <taejun.ha@samsung.com> +* Jiil Hyoun <jiil.hyoun@samsung.com> +* Donghyuk Yang <donghyuk.yang@samsung.com> +* Hoon Kang <h245.kang@samsung.com> +* DongHee Yang <donghee.yang@samsung.com> +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ +package org.tizen.nativeplatform.pkgmgr.ui; + +import java.util.ResourceBundle; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.ui.PlatformUI; + +import org.osgi.framework.Bundle; +import org.tizen.common.connection.ConnectionPlugin; + +import org.tizen.nativecommon.build.CurrentEnabledProject; +import org.tizen.nativecommon.build.obs.PasswordInputDialog; +import org.tizen.nativecommon.build.obs.UserInformation; +import org.tizen.nativeplatform.Activator; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; +import org.tizen.sdblib.IDevice; +import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; +import org.tizen.nativeplatform.pkgmgr.model.LocalPkgProvider; +import org.tizen.nativeplatform.pkgmgr.model.PackageProvider; +import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider; + +public class RPMPackageDialog extends Dialog { + + + private String configuration; + private IDevice device; + private TabFolder tabFolder; + + private boolean enableRootstrapTab = true; + private boolean enableTargetTab = true; + private int tabIndex = 0; + private String http_proxy = ""; + private String password = ""; + + private int x = 0; + private int y = 0; + private final int width = 1100; + private final int height = 800; + + private final String BUNDLE_NAME = RPMPackageDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public RPMPackageDialog(Shell parentShell, String target, boolean enableRootstrap, boolean enableTarget) { + super(parentShell); + setBlockOnOpen(false); + this.enableRootstrapTab = enableRootstrap; + this.enableTargetTab = enableTarget; + + Rectangle bounds = parentShell.getBounds(); + x = bounds.x + (bounds.width - width)/2; + y = bounds.y + (bounds.height - height)/2; + + if (enableRootstrap) { + IProject _project = CurrentEnabledProject.getCurrentProject(); + IConfiguration config = ManagedBuildManager.getBuildInfo( _project ).getDefaultConfiguration(); + configuration = config.getName(); + http_proxy = getHttpProxy(_project); + RPMPackageCommander.setHttpProxy(this.http_proxy); + } + if (enableTarget) { + device = ConnectionPlugin.getDefault().getCurrentDevice(); + } + + password = getSudoPassword(); + RPMPackageCommander.setSudoPassword(password); + } + + private String getSudoPassword() { + if (UserInformation.getRootPassword() == null) { + openPasswordDialog(); + } + + return UserInformation.getRootPassword(); + } + + + private String getHttpProxy(IProject project) { + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ; + IConfiguration cfg = info.getDefaultConfiguration(); + ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg); + IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); + + // append "OBS_HTTP_PROXY" + IEnvironmentVariable var = mngr.getVariable("OBS_HTTP_PROXY", cfgDes, true); + if ( var != null ) { + return var.getValue(); + } + return ""; + } + + private void setImage(Shell parentShell) { + try { + Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); + parentShell.setImage(new Image(Display.getCurrent(), FileLocator.toFileURL(bundle.getEntry("icons/package_installer.gif")).getPath())); + } catch (Exception e) { + } + } + + protected void setShellStyle(int newShellStyle) { + int newStyle = newShellStyle & ~SWT.APPLICATION_MODAL; + newStyle |= SWT.MODELESS; + super.setShellStyle(newStyle); + } + + @Override + public boolean close() + { + RemotePkgProvider.INSTANCE.clear(); + LocalPkgProvider.INSTANCE.clear(); + PackageProvider.INSTANCE.clear(); + return super.close(); + } + + protected void createButtonsForButtonBar(Composite parent) + { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(resources.getString("PkgMgr.Title")); + + if (!enableRootstrapTab && !enableTargetTab) { + newShell.setLocation(x, y); + newShell.setSize(width/2, height/4); + setImage(newShell); + } else { + newShell.setLocation(x, y); + newShell.setSize(width, height); + setImage(newShell); + } + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite container = new Composite( parent, SWT.None ); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + container.setLayout(new GridLayout(1, false)); + + if (!enableRootstrapTab && !enableTargetTab) { + createError( container, resources.getString("PkgMgr.Error.Noselected")); + } else { + createDialogDescription ( container ); + createTabs ( container ); + } + return null; + } + + + private void createError( Composite parent, String message ) + { + Composite com = new Composite( parent, SWT.NONE ); + com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + com.setLayout(new GridLayout(1, false)); + + Label errorLabel = new Label(com, SWT.NONE); + errorLabel.setText(message); + } + + private void createDialogDescription(Composite composite) + { + Composite comp_descrip = new Composite(composite, SWT.NONE); + Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255); + Color warningColor = composite.getDisplay().getSystemColor(SWT.COLOR_RED); + + comp_descrip.setLayout(new GridLayout(1, false)); + GridData comp_descrip_gd = new GridData(GridData.FILL_HORIZONTAL); + comp_descrip_gd.heightHint = height/12; + comp_descrip.setLayoutData(comp_descrip_gd); + comp_descrip.setBackground(whiteColor); + + Label label = new Label(comp_descrip, SWT.NONE); + label.setText(resources.getString("PkgMgr.Frame.Description")); + label.setBackground(whiteColor); + + if ("".equals(http_proxy)) { + Label warning_label = new Label(comp_descrip, SWT.NONE); + warning_label.setText(resources.getString("PkgMgr.Warn.Notset.Proxy")); + warning_label.setBackground(whiteColor); + warning_label.setForeground(warningColor); + } + } + + private void createTabs( Composite parent ) + { + tabFolder = new TabFolder( parent, SWT.BORDER ); + tabFolder.setLayoutData(new GridData( GridData.FILL_BOTH)); + tabFolder.setLayout(new GridLayout(1, false)); + + tabFolder.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // TODO: + } + }); + + + if (enableRootstrapTab) { + BuildSystemTab tab = new BuildSystemTab(getShell(), tabFolder, configuration, getTargetID()); + tab.createTab(); + } + if (enableTargetTab) { + DeviceTab tab = new DeviceTab(getShell(), tabFolder, getTargetID(), device); + tab.createTab(); + } + + tabFolder.setSelection(tabIndex); + } + + private String getTargetID() { + IProject project = CurrentEnabledProject.getCurrentProject(); + IConfiguration config = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration(); + String targetID = PlatformConfigurationManager.getBuildTargetName(config); + return targetID; + } + + private void openPasswordDialog(){ + + Display display = PlatformUI.getWorkbench().getDisplay(); + display.syncExec(new Runnable() { + @Override + public void run() { + Shell shell = PlatformUI.getWorkbench().getDisplay().getShells()[0]; + PasswordInputDialog passwordDialog = new PasswordInputDialog(shell, "Input password"); + if( passwordDialog.open() == Window.OK){ + UserInformation.setRootPassword(passwordDialog.getPassword()); + UserInformation.setSavePassword(passwordDialog.isSavePassword()); + } + } + }); + } + +}
\ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java new file mode 100644 index 00000000..0b030c09 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java @@ -0,0 +1,57 @@ +package org.tizen.nativeplatform.pkgmgr.ui; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.TableColumn; +import org.tizen.nativeplatform.pkgmgr.model.Repository; + +public class RepoTableSelectionAdapter extends SelectionAdapter { + private TableViewer repoViewer; + private int selectedColumn = 0; + public RepoTableSelectionAdapter(TableViewer v) { + super(); + this.repoViewer = v; + } + + public void widgetSelected(SelectionEvent e) { + selectedColumn = repoViewer.getTable().indexOf((TableColumn) e.widget); + repoViewer.getTable().setSortColumn((TableColumn)e.widget); + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + repoViewer.getTable().setSortDirection(SWT.UP); + } else { + repoViewer.getTable().setSortDirection(SWT.DOWN); + } + + repoViewer.setSorter(new ViewerSorter() { + public int compare(Viewer viewer, Object e1, Object e2) { + int result = 0; + + Repository entry_1 = (Repository)e1; + Repository entry_2 = (Repository)e2; + + switch (selectedColumn) { + case 0: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getName().compareTo(entry_2.getName()); + } else { + result = entry_2.getName().compareTo(entry_1.getName()); + } + break; + case 1: + if (repoViewer.getTable().getSortDirection() == SWT.DOWN) { + result = entry_1.getUri().compareTo(entry_2.getUri()); + } else { + result = entry_2.getUri().compareTo(entry_1.getUri()); + } + break; + } + + return result; + } + }); + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java index 5cee2f9b..0f5e5053 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenDebianProjectWizard.java @@ -88,7 +88,7 @@ public class TizenDebianProjectWizard extends CDTCommonProjectWizard{ IProject prj = super.getProject(defaults, onFinish); // Marking project version - PlatformConfigurationManager.setProjectVersion( prj, PlatformConfigurationManager.CURRENT_SLP_PROJECT_VERSION ); + PlatformConfigurationManager.setProjectVersion( prj, PlatformConfigurationManager.CURRENT_SLP_PROJECT_VERSION, true); return prj; } diff --git a/org.tizen.nativeplatform/templates/CustomDebianPackages/EmptyProject/template.properties b/org.tizen.nativeplatform/templates/CustomDebianPackages/EmptyProject/template.properties index 7afbfe8f..c96e082d 100644 --- a/org.tizen.nativeplatform/templates/CustomDebianPackages/EmptyProject/template.properties +++ b/org.tizen.nativeplatform/templates/CustomDebianPackages/EmptyProject/template.properties @@ -1,5 +1,5 @@ -EmptyProject.Ctemplate.label=Empty Debian Project -EmptyProject.Ctemplate.description=Empty Debian Project +EmptyProject.Ctemplate.label=Empty Platform Project +EmptyProject.Ctemplate.description=Empty Platform Project EmptyProject.basics.label=Advanced Settings EmptyProject.basics.description=Advanced properties of a project EmptyProject.author.label=Author diff --git a/org.tizen.nativeplatform/templates/CustomDebianPackages/HelloWorldProject/template.xml b/org.tizen.nativeplatform/templates/CustomDebianPackages/HelloWorldProject/template.xml index 8e42f4ce..1bd95a78 100644 --- a/org.tizen.nativeplatform/templates/CustomDebianPackages/HelloWorldProject/template.xml +++ b/org.tizen.nativeplatform/templates/CustomDebianPackages/HelloWorldProject/template.xml @@ -1,95 +1,99 @@ <?xml version="1.0" encoding="ISO-8859-1"?> <template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="Intel Corporation" - copyright="Copyright (c) 2007 Intel Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" - id="HelloWorldProject" label="%HelloWorldProject.Ctemplate.label" description="%HelloWorldProject.Ctemplate.description" - help="help.html"> - <property-group id="basics" label="%HelloWorldProject.basics.label" description="%HelloWorldProject.basics.description" type="PAGES-ONLY" help="help.html"> - <property id="author" - label="%HelloWorldProject.author.label" - description="%HelloWorldProject.author.description" - type="input" - pattern=".*" - default="%HelloWorldProject.author.default" - hidden="false" - persist="false"/> - <property id="copyright" - label="%HelloWorldProject.copyright.label" - description="%HelloWorldProject.copyright.description" - type="input" - pattern=".*" - default="%HelloWorldProject.copyright.default" - hidden="false" - persist="false"/> - <property id="description" - label="%HelloWorldProject.description.label" - description="%HelloWorldProject.description.description" - type="input" - pattern=".*" - default="%HelloWorldProject.description.default" - hidden="false" - persist="false"/> - <property id="vendor" - label="%HelloWorldProject.vendor.label" - description="%HelloWorldProject.vendor.description" - type="input" - pattern=".*" - default="%HelloWorldProject.vendor.default" - hidden="false" - persist="false"/> - <property id="e-mail" - label="%HelloWorldProject.e-mail.label" - description="%HelloWorldProject.e-mail.description" - type="input" - pattern=".*" - default="%HelloWorldProject.e-mail.default" - hidden="false" - persist="false"/> - </property-group> - - <process type="org.tizen.nativecommon.TizenCreateSourceFolder"> - <simple name="projectName" value="$(projectName)"/> - <simple name="path" value="src"/> - </process> - - <process type="org.eclipse.cdt.core.AddFiles"> - <simple name="projectName" value="$(projectName)"/> - <complex-array name="files"> - <element> - <simple name="source" value="src/hello.c"/> - <simple name="target" value="src/hello.c"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/rules"/> - <simple name="target" value="debian/rules"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/compat"/> - <simple name="target" value="debian/compat"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/control"/> - <simple name="target" value="debian/control"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/changelog"/> - <simple name="target" value="debian/changelog"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/com.samsung.hello.install"/> - <simple name="target" value="debian/com.samsung.hello.install"/> - <simple name="replaceable" value="true"/> - </element> - </complex-array> - </process> + copyright="Copyright (c) 2007 Intel Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" + id="HelloWorldProject" label="%HelloWorldProject.Ctemplate.label" description="%HelloWorldProject.Ctemplate.description" + help="help.html"> + <property-group id="basics" label="%HelloWorldProject.basics.label" description="%HelloWorldProject.basics.description" type="PAGES-ONLY" help="help.html"> + <property id="author" + label="%HelloWorldProject.author.label" + description="%HelloWorldProject.author.description" + type="input" + pattern=".*" + default="%HelloWorldProject.author.default" + hidden="false" + persist="false"/> + <property id="copyright" + label="%HelloWorldProject.copyright.label" + description="%HelloWorldProject.copyright.description" + type="input" + pattern=".*" + default="%HelloWorldProject.copyright.default" + hidden="false" + persist="false"/> + <property id="description" + label="%HelloWorldProject.description.label" + description="%HelloWorldProject.description.description" + type="input" + pattern=".*" + default="%HelloWorldProject.description.default" + hidden="false" + persist="false"/> + <property id="vendor" + label="%HelloWorldProject.vendor.label" + description="%HelloWorldProject.vendor.description" + type="input" + pattern=".*" + default="%HelloWorldProject.vendor.default" + hidden="false" + persist="false"/> + <property id="e-mail" + label="%HelloWorldProject.e-mail.label" + description="%HelloWorldProject.e-mail.description" + type="input" + pattern=".*" + default="%HelloWorldProject.e-mail.default" + hidden="false" + persist="false"/> + </property-group> + + <process type="org.tizen.nativecommon.TizenCreateSourceFolder"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="pathList"> + <element> + <simple name="path" value="src"/> + </element> + </complex-array> + </process> + + <process type="org.eclipse.cdt.core.AddFiles"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="files"> + <element> + <simple name="source" value="src/hello.c"/> + <simple name="target" value="src/hello.c"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/rules"/> + <simple name="target" value="debian/rules"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/compat"/> + <simple name="target" value="debian/compat"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/control"/> + <simple name="target" value="debian/control"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/changelog"/> + <simple name="target" value="debian/changelog"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/com.samsung.hello.install"/> + <simple name="target" value="debian/com.samsung.hello.install"/> + <simple name="replaceable" value="true"/> + </element> + </complex-array> + </process> - <process type="org.tizen.nativecommon.SetSBITarget"> - <simple name="projectName" value="$(projectName)"/> - </process> - - + <process type="org.tizen.nativecommon.SetSBITarget"> + <simple name="projectName" value="$(projectName)"/> + </process> + + </template> diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/CMakeLists.txt b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/CMakeLists.txt new file mode 100644 index 00000000..f2f4b283 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/CMakeLists.txt @@ -0,0 +1,72 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT($(projectName) C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(LIBDIR "${PREFIX}/lib") +SET(DATADIR "${PREFIX}/data") +SET(LOCALEDIR "${RESDIR}/locale") +SET(ICONDIR "${RESDIR}/icons/default/small") +SET(EDJDIR "${RESDIR}/edje") +SET(IMGDIR "${RESDIR}/images") + +ADD_DEFINITIONS("-DPACKAGE=\"${PROJECT_NAME}\"") +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") +ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"") +ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"") +ADD_DEFINITIONS("-DIMGDIR=\"${IMGDIR}\"") +ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"") + +ADD_DEFINITIONS("-DSLP_DEBUG") + +SET(SRCS + src/${PROJECT_NAME}.c +) + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "Debug") +ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") +MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED dlog appcore-agent capi-appfw-application) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Wl,--unresolved-symbols=ignore-in-shared-libs") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") +SET(CMAKE_LDFLAGS "-Wl,-zdefs") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") +ADD_DEFINITIONS("-fpie") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CMAKE_LDFLAGS} ${pkgs_LDFLAGS} "-pie") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) + +# install desktop file & icon +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/com.samsung.${PROJECT_NAME}.desktop.in ${CMAKE_CURRENT_SOURCE_DIR}/com.samsung.${PROJECT_NAME}.desktop) + +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/com.samsung.${PROJECT_NAME}.desktop DESTINATION /opt/share/applications) + +INSTALL(DIRECTORY DESTINATION ${DATADIR}) +INSTALL(DIRECTORY DESTINATION ${LIBDIR}) +INSTALL(DIRECTORY DESTINATION ${RESDIR})
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/INSTALL b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/INSTALL new file mode 100644 index 00000000..ddf4e78a --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/INSTALL @@ -0,0 +1,33 @@ +1. make the build directory + + ex) + + $ mkdir build + + +2. change the working directory to the build directory + + ex) + + $ cd build + + +3. run 'cmake' + + $ cmake ${SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=/usr + + ex) + + $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr + + or + + $ cmake .. + + +4. make & make install + + ex) + + $ make -j 2 && make install + diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/LICENSE b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/LICENSE new file mode 100644 index 00000000..de71bda1 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/LICENSE @@ -0,0 +1,17 @@ +Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + +PROPRIETARY/CONFIDENTIAL + +This software is the confidential and proprietary information of +SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that +this software is owned by Samsung and you +shall not disclose such Confidential Information and shall +use it only in accordance with the terms of the license agreement +you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no +representations or warranties about the suitability +of the software, either express or implied, including but not +limited to the implied warranties of merchantability, fitness for +a particular purpose, or non-infringement. +SAMSUNG shall not be liable for any damages suffered by licensee arising out of or +related to this software. + diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/NOTICE b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/NOTICE new file mode 100644 index 00000000..4297ee33 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/com.samsung.agent.desktop.in b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/com.samsung.agent.desktop.in new file mode 100644 index 00000000..71bf3344 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/com.samsung.agent.desktop.in @@ -0,0 +1,8 @@ +Name=$(projectName) +Exec=${PREFIX}/bin/$(projectName) +Comment=Sample agent application +Type=Application +Nodisplay=True +X-SLP-TaskManage=False +Version=@VERSION@ + diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/changelog b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/changelog new file mode 100644 index 00000000..8feee670 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/changelog @@ -0,0 +1,5 @@ +$(projectName) (0.0.0-1) unstable; urgency=low + + * initial release + + -- $(author) <$(e-mail)> Thu, 26 Jan 2012 14:52:56 +0900 diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/org.tizen.hello.install b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/com.samsung.agent.install index 0b11bef6..0b11bef6 100644 --- a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/org.tizen.hello.install +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/com.samsung.agent.install diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/compat b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/compat new file mode 100644 index 00000000..7ed6ff82 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/compat @@ -0,0 +1 @@ +5 diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/control b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/control new file mode 100644 index 00000000..9795dd12 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/control @@ -0,0 +1,16 @@ +Source: $(projectName) +Priority: extra +Maintainer: $(author) <$(e-mail)> +Build-Depends: debhelper (>= 5), libappcore-agent-dev, dlog-dev +Standards-Version: 0.1.0 + +Package: com.samsung.$(projectName) +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: $(description) + +Package: com.samsung.$(projectName)-dbg +Section: debug +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: agent application (unstripped)
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/dirs b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/dirs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/dirs @@ -0,0 +1 @@ + diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/docs b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/docs new file mode 100644 index 00000000..a0f00082 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/docs @@ -0,0 +1 @@ +CMakeLists.txt diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/postinst b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/postinst new file mode 100755 index 00000000..79aac7e8 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/postinst @@ -0,0 +1,7 @@ +#! /bin/sh + +if [ ${USER} == "root" ] +then + # do not use relative path + chown -R app:app /opt/apps/com.samsung.$(projectName)/data +fi
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/rules b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/rules new file mode 100644 index 00000000..390480a8 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/debian/rules @@ -0,0 +1,132 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +CFLAGS ?= -Wall -g +PREFIX ?= /opt/apps/com.samsung.$(projectName) +RESDIR ?= /opt/apps/com.samsung.$(projectName)/res +DATADIR ?= /opt/apps/com.samsung.$(projectName)/data +LDFLAGS ?= --Wl,--rpath=$(PREFIX)/lib --Wl,--as-needed +DATADIR ?= /opt +VERSION ?= `head -n 1 debian/changelog | awk 'BEGIN {FS="[()]"}{print $$2}'` + +CFLAGS += -fPIC +CXXFLAGS += -fPIC +LDFLAGS += -Wl,--hash-style=both -Wl,--as-needed + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DVERSION=$(VERSION) + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/info-alarm.sgml > info-alarm.1 + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + cat $$f > $${f%.in}; \ + sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ + sed -i -e "s#@RESDIR@#$(RESDIR)#g" $${f%.in}; \ + sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ + done + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + rm -rf CMakeCache.txt + rm -rf CMakeFiles + rm -rf cmake_install.cmake + rm -rf Makefile + rm -rf install_manifest.txt + rm -rf *.so + rm -rf po/CMakeCache.txt + rm -rf po/CMakeFiles + rm -rf po/cmake_install.cmake + rm -rf po/Makefile + rm -rf po/install_manifest.txt + rm -rf po/*.so + rm -rf data/CMakeCache.txt + rm -rf data/CMakeFiles + rm -rf data/cmake_install.cmake + rm -rf data/Makefile + rm -rf data/install_manifest.txt + rm -rf data/*.so + + for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ + rm -f $${f%.in}; \ + done + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/info-alarm. + $(MAKE) DESTDIR=$(CURDIR)/debian/com.samsung.$(projectName) install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip --dbg-package=com.samsung.$(projectName)-dbg + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/include/agent.h b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/include/agent.h new file mode 100644 index 00000000..d89135e0 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/include/agent.h @@ -0,0 +1,5 @@ + +#ifndef __APP_COMMON_H__ +#define __APP_COMMON_H__ + +#endif /* __APP_COMMON_H__ */ diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/packaging/agent.spec b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/packaging/agent.spec new file mode 100644 index 00000000..0c470bb2 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/packaging/agent.spec @@ -0,0 +1,49 @@ +Name: com.samsung.$(projectName) +Version: 0.1.0 +Release: 1 +License: To be filled +Summary: agent application +Packager: $(author) <$(e-mail)> +Group: Application +Source: %{name}-%{version}.tar.gz + +BuildRequires: cmake +BuildRequires: pkgconfig(appcore-agent) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(dlog) + +%description +$(description) + +%define PREFIX "/opt/apps/com.samsung.$(projectName)" +%define RESDIR "/opt/apps/com.samsung.$(projectName)/res" + +%prep +%setup -q + +%build +export LDFLAGS="${LDFLAGS} -Wl,--rpath,/usr/lib -Wl,--rpath,%{PREFIX}/lib -Wl,--hash-style=both -Wl,--as-needed" +export CFLAGS="${CFLAGS} -fPIC" +export CXXFLAGS="${CXXFLAGS} -fPIC" +cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DVERSION=%{Version} +# Call make instruction with smp support +make %{?jobs:-j%jobs} +touch configure-stamp + +%install +%make_install + +%clean +rm -f build-stamp configure-stamp + +%files +%defattr(644, app, app) +%attr(755, app, app) /opt/apps/%{name}/bin +/opt/apps/%{name}/lib +/opt/apps/%{name}/data +/opt/apps/%{name}/res/ +/opt/share/applications + +%changelog +* Thu Jan 26 2012 $(author) <$(e-mail)> + - initial release
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/src/agent.c b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/src/agent.c new file mode 100644 index 00000000..9c3a82a1 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/src/agent.c @@ -0,0 +1,62 @@ +#include <stdio.h> +#include <bundle.h> +#include <dlog.h> +#include <appcore-agent.h> +#include "$(projectName).h" + +#undef LOG_TAG +#define LOG_TAG "AGENT_TEST" + +static int __app_create(void *data) +{ + /*struct appdata *ad = data; */ + LOGD("__app_create"); + + // Todo: add your code here. + + return 0; +} + + +static int __app_terminate(void *data) +{ + /*struct appdata *ad = data; */ + LOGD("__app_terminate"); + + // Todo: add your code here. + + return 0; +} + + +static int __app_service(service_h service, void *data) +{ + /*struct appdata *ad = data; */ + char *test_data = (char*)data; + char *op; + + LOGD("requset : %s", test_data); + + service_get_operation(service, &op); + + LOGD("operation : %s", op); + + // Todo: add your code here. + + return 0; +} + +int main(int argc, char* argv[]) +{ + char ad[50] = "test data"; + + struct agentcore_ops ops = { + .create = __app_create, + .terminate = __app_terminate, + .service = __app_service, + }; + + ops.data = ad; + + appcore_agent_main(argc, argv, &ops); +} diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.properties b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.properties new file mode 100644 index 00000000..8376e2d8 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.properties @@ -0,0 +1,19 @@ +AgentProject.Ctemplate.label=Agent Project +AgentProject.Ctemplate.description=Agent Project +AgentProject.basics.label=Advanced Settings +AgentProject.basics.description=Advanced properties of a project +AgentProject.author.label=Author +AgentProject.author.description=Name of the author +AgentProject.author.default=Author +AgentProject.copyright.label=Copyright +AgentProject.copyright.description=Your copyright notice +AgentProject.copyright.default=Your copyright notice +AgentProject.vendor.label=Vendor +AgentProject.vendor.default=samsung +AgentProject.vendor.description=Enter your company or organization. +AgentProject.description.default=Agent Project +AgentProject.description.description=Enter a description about your application. +AgentProject.description.label=Description +AgentProject.e-mail.default=E-mail +AgentProject.e-mail.description=Enter your email address +AgentProject.e-mail.label=E-mail diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.xml b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.xml new file mode 100644 index 00000000..5c44b695 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/AgentProject/template.xml @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="Intel Corporation" + copyright="Copyright (c) 2007 Intel Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" + id="AgentProject" label="%AgentProject.Ctemplate.label" description="%AgentProject.Ctemplate.description" + help="help.html"> + <property-group id="basics" label="%AgentProject.basics.label" description="%AgentProject.basics.description" type="PAGES-ONLY" help="help.html"> + <property id="author" + label="%AgentProject.author.label" + description="%AgentProject.author.description" + type="input" + pattern=".*" + default="%AgentProject.author.default" + hidden="false" + persist="false"/> + <property id="copyright" + label="%AgentProject.copyright.label" + description="%AgentProject.copyright.description" + type="input" + pattern=".*" + default="%AgentProject.copyright.default" + hidden="false" + persist="false"/> + <property id="description" + label="%AgentProject.description.label" + description="%AgentProject.description.description" + type="input" + pattern=".*" + default="%AgentProject.description.default" + hidden="false" + persist="false"/> + <property id="vendor" + label="%AgentProject.vendor.label" + description="%AgentProject.vendor.description" + type="input" + pattern=".*" + default="%AgentProject.vendor.default" + hidden="false" + persist="false"/> + <property id="e-mail" + label="%AgentProject.e-mail.label" + description="%AgentProject.e-mail.description" + type="input" + pattern=".*" + default="%AgentProject.e-mail.default" + hidden="false" + persist="false"/> + </property-group> + + <process type="org.tizen.nativecommon.TizenCreateSourceFolder"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="pathList"> + <element> + <simple name="path" value="src"/> + </element> + </complex-array> + </process> + + <process type="org.eclipse.cdt.core.AddFiles"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="files"> + <element> + <simple name="source" value="CMakeLists.txt"/> + <simple name="target" value="CMakeLists.txt"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="com.samsung.agent.desktop.in"/> + <simple name="target" value="com.samsung.$(projectName).desktop.in"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="include/agent.h"/> + <simple name="target" value="include/$(projectName).h"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="src/agent.c" /> + <simple name="target" value="src/$(projectName).c" /> + <simple name="replaceable" value="true" /> + </element> + <element> + <simple name="source" value="debian/rules"/> + <simple name="target" value="debian/rules"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/compat"/> + <simple name="target" value="debian/compat"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/control"/> + <simple name="target" value="debian/control"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/changelog"/> + <simple name="target" value="debian/changelog"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/com.samsung.agent.install"/> + <simple name="target" value="debian/com.samsung.$(projectName).install"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/postinst"/> + <simple name="target" value="debian/postinst"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="packaging/agent.spec" /> + <simple name="target" value="packaging/$(projectName).spec" /> + <simple name="replaceable" value="true" /> + </element> + </complex-array> + </process> + + <process type="org.tizen.nativecommon.SetSBITarget"> + <simple name="projectName" value="$(projectName)"/> + </process> + + +</template> diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/EmptyProject/template.properties b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/EmptyProject/template.properties index 7afbfe8f..c96e082d 100644 --- a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/EmptyProject/template.properties +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/EmptyProject/template.properties @@ -1,5 +1,5 @@ -EmptyProject.Ctemplate.label=Empty Debian Project -EmptyProject.Ctemplate.description=Empty Debian Project +EmptyProject.Ctemplate.label=Empty Platform Project +EmptyProject.Ctemplate.description=Empty Platform Project EmptyProject.basics.label=Advanced Settings EmptyProject.basics.description=Advanced properties of a project EmptyProject.author.label=Author diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/changelog b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/changelog index 8e1d2160..99516aa3 100644 --- a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/changelog +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/changelog @@ -1,4 +1,4 @@ -org.tizen.$(projectName) (0.0.0-1) unstable; urgency=low +$(projectName) (0.0.0-1) unstable; urgency=low * initial release diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/com.samsung.hello.install b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/com.samsung.hello.install new file mode 100644 index 00000000..0b11bef6 --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/com.samsung.hello.install @@ -0,0 +1 @@ +/usr/bin
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/control b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/control index d002497a..2a60cb31 100644 --- a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/control +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/debian/control @@ -2,10 +2,10 @@ # THIS FILE IS CREATED AUTOMATICALLY. DO NOT DELETE OR MODIFY THIS FILE. ################################################################################# -Source: org.tizen.$(projectName) +Source: com.samsung.$(projectName) Maintainer: $(author) <$(e-mail)> Standards-Version: 0.0.1 -Package: org.tizen.$(projectName) +Package: com.samsung.$(projectName) description: $(description) Architecture: any
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/packaging/hello.spec b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/packaging/hello.spec new file mode 100644 index 00000000..95e5905f --- /dev/null +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/packaging/hello.spec @@ -0,0 +1,34 @@ +Name: com.samsung.$(projectName) +Version: 0.0.1 +Release: 1 +License: To be filled +Summary: helloworld application (unstripped) +Packager: $(author) <$(e-mail)> +Group: Application +Source: %{name}-%{version}.tar.gz +%description +$(description) + +%prep +%setup -q + +%build +mkdir -p bin +gcc src/$(projectName).c -o bin/$(projectName) +touch build-stamp + +%install +echo "INSTALL" +mkdir -p $RPM_BUILD_ROOT/usr/bin +cp bin/$(projectName) $RPM_BUILD_ROOT/usr/bin + +%clean +rm -f build-stamp configure-stamp + +%files +%defattr(644, root, root) +%attr(755, root, root) /usr/bin + +%changelog +* Sat Mar 24 2012 Author <E-mail> + - initial release
\ No newline at end of file diff --git a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/template.xml b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/template.xml index 10a2cd0c..0244ab91 100644 --- a/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/template.xml +++ b/org.tizen.nativeplatform/templates/InhouseFrameworkPackages/HelloWorldProject/template.xml @@ -1,95 +1,104 @@ <?xml version="1.0" encoding="ISO-8859-1"?> <template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="Intel Corporation" - copyright="Copyright (c) 2007 Intel Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" - id="HelloWorldProject" label="%HelloWorldProject.Ctemplate.label" description="%HelloWorldProject.Ctemplate.description" - help="help.html"> - <property-group id="basics" label="%HelloWorldProject.basics.label" description="%HelloWorldProject.basics.description" type="PAGES-ONLY" help="help.html"> - <property id="author" - label="%HelloWorldProject.author.label" - description="%HelloWorldProject.author.description" - type="input" - pattern=".*" - default="%HelloWorldProject.author.default" - hidden="false" - persist="false"/> - <property id="copyright" - label="%HelloWorldProject.copyright.label" - description="%HelloWorldProject.copyright.description" - type="input" - pattern=".*" - default="%HelloWorldProject.copyright.default" - hidden="false" - persist="false"/> - <property id="description" - label="%HelloWorldProject.description.label" - description="%HelloWorldProject.description.description" - type="input" - pattern=".*" - default="%HelloWorldProject.description.default" - hidden="false" - persist="false"/> - <property id="vendor" - label="%HelloWorldProject.vendor.label" - description="%HelloWorldProject.vendor.description" - type="input" - pattern=".*" - default="%HelloWorldProject.vendor.default" - hidden="false" - persist="false"/> - <property id="e-mail" - label="%HelloWorldProject.e-mail.label" - description="%HelloWorldProject.e-mail.description" - type="input" - pattern=".*" - default="%HelloWorldProject.e-mail.default" - hidden="false" - persist="false"/> - </property-group> + copyright="Copyright (c) 2007 Intel Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" + id="HelloWorldProject" label="%HelloWorldProject.Ctemplate.label" description="%HelloWorldProject.Ctemplate.description" + help="help.html"> + <property-group id="basics" label="%HelloWorldProject.basics.label" description="%HelloWorldProject.basics.description" type="PAGES-ONLY" help="help.html"> + <property id="author" + label="%HelloWorldProject.author.label" + description="%HelloWorldProject.author.description" + type="input" + pattern=".*" + default="%HelloWorldProject.author.default" + hidden="false" + persist="false"/> + <property id="copyright" + label="%HelloWorldProject.copyright.label" + description="%HelloWorldProject.copyright.description" + type="input" + pattern=".*" + default="%HelloWorldProject.copyright.default" + hidden="false" + persist="false"/> + <property id="description" + label="%HelloWorldProject.description.label" + description="%HelloWorldProject.description.description" + type="input" + pattern=".*" + default="%HelloWorldProject.description.default" + hidden="false" + persist="false"/> + <property id="vendor" + label="%HelloWorldProject.vendor.label" + description="%HelloWorldProject.vendor.description" + type="input" + pattern=".*" + default="%HelloWorldProject.vendor.default" + hidden="false" + persist="false"/> + <property id="e-mail" + label="%HelloWorldProject.e-mail.label" + description="%HelloWorldProject.e-mail.description" + type="input" + pattern=".*" + default="%HelloWorldProject.e-mail.default" + hidden="false" + persist="false"/> + </property-group> - <process type="org.tizen.nativecommon.TizenCreateSourceFolder"> - <simple name="projectName" value="$(projectName)"/> - <simple name="path" value="src"/> - </process> + <process type="org.tizen.nativecommon.TizenCreateSourceFolder"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="pathList"> + <element> + <simple name="path" value="src"/> + </element> + </complex-array> + </process> - <process type="org.eclipse.cdt.core.AddFiles"> - <simple name="projectName" value="$(projectName)"/> - <complex-array name="files"> - <element> - <simple name="source" value="src/hello.c"/> - <simple name="target" value="src/$(projectName).c"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/rules"/> - <simple name="target" value="debian/rules"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/compat"/> - <simple name="target" value="debian/compat"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/control"/> - <simple name="target" value="debian/control"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/changelog"/> - <simple name="target" value="debian/changelog"/> - <simple name="replaceable" value="true"/> - </element> - <element> - <simple name="source" value="debian/org.tizen.hello.install"/> - <simple name="target" value="debian/org.tizen.$(projectName).install"/> - <simple name="replaceable" value="true"/> - </element> - </complex-array> - </process> + <process type="org.eclipse.cdt.core.AddFiles"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="files"> + <element> + <simple name="source" value="src/hello.c"/> + <simple name="target" value="src/$(projectName).c"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/rules"/> + <simple name="target" value="debian/rules"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/compat"/> + <simple name="target" value="debian/compat"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/control"/> + <simple name="target" value="debian/control"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/changelog"/> + <simple name="target" value="debian/changelog"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="debian/com.samsung.hello.install"/> + <simple name="target" value="debian/com.samsung.$(projectName).install"/> + <simple name="replaceable" value="true"/> + </element> + <element> + <simple name="source" value="packaging/hello.spec"/> + <simple name="target" value="packaging/$(projectName).spec"/> + <simple name="replaceable" value="true"/> + </element> + </complex-array> + </process> - <process type="org.tizen.nativecommon.SetSBITarget"> - <simple name="projectName" value="$(projectName)"/> - </process> + <process type="org.tizen.nativecommon.SetSBITarget"> + <simple name="projectName" value="$(projectName)"/> + </process> </template> diff --git a/package/build.linux b/package/build.linux index 741790cc..6b67ea51 100755 --- a/package/build.linux +++ b/package/build.linux @@ -1,292 +1,87 @@ -#!/bin/bash -x - -build_path=${SRCDIR}/build_result - -__set_parameter() -{ - build_id=${package_name} - build_type=N - build_result_directory=${build_type}.${build_id} - build_result_path="$build_path/$build_result_directory" - architecture=x86 - ide_root_path_name=IDE - - case ${platform} in - linux) - archive_platform_name=linux - windowing=gtk - ;; - windows) - archive_platform_name=win32 - windowing=win32 - ;; - *) - echo "${platform} is not support yet." - ;; - esac - - result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip -} - -__set_build_parameter() -{ - case ${platform} in - linux) - reference_ide_path=${ROOTDIR}/indigo-pde/eclipse - ;; - windows) - reference_ide_path=${ROOTDIR}/indigo-winpde/eclipse - ;; - *) - echo "${platform} is not support yet." - ;; - esac -} - -__set_install_parameter() -{ - INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${platform}/data -} - -__clean_build_environment() -{ - if [ -d $build_path ] - then - echo "Build result directory : [$build_path]" - else - echo "Make build result directory [$build_path]" - mkdir -p $build_path - fi - - echo "Remove legacy build files..." - if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ] - then - rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} - fi - if [ -e ${build_result_path}/${result_archive_file} ] - then - rm -rf ${build_result_path}/${result_archive_file} - fi - if [ -d ${build_path}/tmp ] - then - rm -rf ${build_path}/tmp - fi - - if [ -d ${build_path}/buildRepo ] - then - rm -rf ${build_path}/buildRepo - fi - - rm -r ${build_path}/*.xml - rm -r ${build_path}/*.properties - rm -r ${build_path}/*.clean - - - if [ -d $build_path/plugins ] - then - echo "plugins directory recreate..." - rm -rf $build_path/plugins - mkdir $build_path/plugins - else - echo "Make plugins directory..." - mkdir $build_path/plugins - fi - if [ -d $build_path/features/ ] - then - echo "features directory recreate..." - rm -rf $build_path/features - mkdir $build_path/features - else - echo "Make features directory..." - mkdir $build_path/features - fi - -} - -__copy_build_sources() -{ - echo "Copy features from $SRCDIR to $build_path/features" - cp -r $SRCDIR/*.feature $build_path/features - - echo "Copy plugins from $SRCDIR to $build_path/plugins" - cp -r $SRCDIR/* $build_path/plugins - rm -rf $build_path/plugins/*.feature -} - -__copy_dependency_plugins() -{ - dependency_plugin_path=${ROOTDIR}/${ide_root_path_name} - if [ -d ${dependency_plugin_path} ] - then - cp -rf ${dependency_plugin_path}/features/* ${build_path}/features/ - cp -rf ${dependency_plugin_path}/plugins/* ${build_path}/plugins/ - fi -} - -__make_ant_build_properties_file() -{ - builder_path="${SRCDIR}/builder" - parent_path_of_based_eclipse=${reference_ide_path}/.. - - echo "Make build.properties file..." - if [ ! -e $builder_path/build.properties.clean ] ; then - echo "ERROR : \"build.properties.clean\" file does not exist..." - exit 1 - fi - cp $builder_path/build.properties.clean $build_path - cp $builder_path/customTargets.xml $build_path - - if [ -d $reference_ide_path ] - then - sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" \ - -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" \ - -e "s;\(^baseLocation=\).*;\1${reference_ide_path};g" \ - -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" \ - -e "s;\(^buildType=\).*;\1${build_type};g" \ - -e "s;\(^buildId=\).*;\1${build_id};g" \ - -e "s;\(^archivePrefix=\).*;\1${build_id};g" \ - < $build_path/build.properties.clean > $build_path/build.properties - - else - echo "ERROR : target eclipse is not exist." - exit 1 - fi -} - -__execute_pde_build() -{ - echo "Execute Product Ant Builder..." - equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar` - pde_build=`echo org.eclipse.pde.build_*` - - java -jar ${reference_ide_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${reference_ide_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path -Dosgi.locking=none 2>&1 - - if [ $? != 0 ]; - then - echo "Build failed..." - exit 1 - fi -} - -__unzip_plugin_pack() -{ - echo "unzip to $build_result_path" - unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture} -} - -build_plugins() -{ - case ${platform} in - linux) - echo "build plugin for ${platform}" - ;; - windows) - echo "build plugin for ${platform}" - ;; - *) - echo "${platform} is not support yet." - exit 1 - ;; - esac - - __set_parameter - __set_build_parameter - __clean_build_environment - __copy_build_sources - __copy_dependency_plugins - __make_ant_build_properties_file - __execute_pde_build - __unzip_plugin_pack - - echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"." -} - -__clean_packaging_environment() -{ - - if [ -d ${INSTALL_DIR} ] - then - rm -rf ${INSTALL_DIR} - else - mkdir -p ${INSTALL_DIR} - fi -} +#!/bin/bash -xe __copy_necessary_binaries() { - echo "add necessary files." - ## ex) cp -rf ~~~~/file.file ${INSTALL_DIR}/${ide_root_path_name}/ + echo "add necessary files." + ## ex) + ## ide_root_path_name=IDE + ## cp -rf ~~~~/file.file ${INSTALL_DIR}/${ide_root_path_name}/ } -packaging_plugins() +__set_parameter() { - __set_parameter - __set_install_parameter - - __clean_packaging_environment - __copy_necessary_binaries - - install_ide_path=${INSTALL_DIR}/${ide_root_path_name} - - if [ ! -d ${install_ide_path} ] - then - mkdir -p ${install_ide_path} - fi - - cp -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}/${package_name}/* ${install_ide_path}/ + case ${TARGET_OS} in + ubuntu-32|ubuntu-64) + pde_path=${ROOTDIR}/indigo-pde + ;; + windows-32|windows-64) + pde_path=${ROOTDIR}/indigo-winpde + ;; + macos-64) + pde_path=${ROOTDIR}/indigo-macpde + ;; + *) + echo "${TARGET_OS} is not support yet." + exit 1 + ;; + esac + + build_script_path=${pde_path}/pde_build } # clean clean() { - echo "=========================================CLEAN============================================" - make clean - rm -rf ${SRCDIR}/*.zip - rm -rf ${SRCDIR}/*.tar.gz - rm -rf ${build_path} + echo "=========================================CLEAN============================================" + __set_parameter + ${build_script_path}/clean.sh ${package_name} } # build build() { - echo "=========================================BUILD============================================" - pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` - for pkgname_and_platform in ${pkgname_and_platform_list} - do - pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` - package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` - platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` - - if [ "x${BUILD_TARGET_OS}" = "x${platform}" ] - then - build_plugins - else - echo "" - fi - done + echo "=========================================BUILD============================================" + pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` + for pkgname_and_platform in ${pkgname_and_platform_list} + do + pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` + package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` + platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` + + if [ "x${TARGET_OS}" = "x${platform}" ] + then + __set_parameter + ${build_script_path}/build.sh ${package_name} + else + echo "" + fi + done } # install install() { - pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` - for pkgname_and_platform in ${pkgname_and_platform_list} - do - echo "=========================================INSTALL============================================" - pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` - package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` - platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` - - if [ "x${BUILD_TARGET_OS}" = "x${platform}" ] - then - packaging_plugins - else - echo "" - fi - done + pkgname_and_platform_list=`awk 'BEGIN{RS="\n\n"; FS="\n"} /Package:/{for(i=1;i<NF;i++){if($i ~ /^OS:/){print $1,$i}}}' ${SRCDIR}/package/pkginfo.manifest | tr ' ' '@'` + for pkgname_and_platform in ${pkgname_and_platform_list} + do + echo "=========================================INSTALL============================================" + pkgname_and_platform=`echo $pkgname_and_platform | tr '@' ' '` + package_name=`echo ${pkgname_and_platform} | cut -f1 -d " " | cut -f2 -d ":"` + platform=`echo ${pkgname_and_platform} | cut -f2 -d " " | cut -f2 -d ":"` + + if [ "x${TARGET_OS}" = "x${platform}" ] + then + __set_parameter + INSTALL_DIR=${SRCDIR}/package/${package_name}.package.${TARGET_OS}/data + mkdir -p ${INSTALL_DIR} + __copy_necessary_binaries + ${build_script_path}/install.sh ${package_name} + else + echo "" + fi + done } [ "$1" = "clean" ] && clean [ "$1" = "build" ] && build [ "$1" = "install" ] && install -exit 0 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index c5a2c58c..87cee038 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,9 +1,24 @@ -Package:nativeplatform-eplugin -Version:1.0.12 -OS:linux -Build-host-os:linux -Build-dependency:indigo-pde [linux], base-ide-product [linux], common-eplugin [linux], nativecommon-eplugin [linux] -Install-dependency:base-ide-product [linux], common-eplugin [linux], nativecommon-eplugin [linux] +Version:1.0.21 Source:nativeplatform-eplugin Maintainer:Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park<yoonki.park@samsung.com>, Hyunsik Noh<hyunsik.noh@samsung.com>, Gun Kim<gune.kim@samsung.com>, Ho Namkoong<ho.namkoong@samsung.com>, Taeyoung Son<taeyoung2.son@samsung.com> + +Package:nativeplatform-eplugin +OS:ubuntu-32 +Build-host-os:ubuntu-32 +Build-dependency:indigo-pde [ubuntu-32], base-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32] +Install-dependency:base-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32] +Description:Nativeplatform plugin + +Package:nativeplatform-eplugin +OS:ubuntu-64 +Build-host-os:ubuntu-32 +Build-dependency:indigo-pde [ubuntu-64], base-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64] +Install-dependency:base-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64] +Description:Nativeplatform plugin + +Package:nativeplatform-eplugin +OS:macos-64 +Build-host-os:ubuntu-32 +Build-dependency:indigo-macpde [macos-64], base-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64] +Install-dependency:base-ide-product [macos-64], common-eplugin [macos-64], nativecommon-eplugin [macos-64] Description:Nativeplatform plugin |