+++ /dev/null
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@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.installmanager.updater;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class InstallManagerUpdater {
- private static PrintWriter writer;
-
- private static void initWriter() {
- try {
- writer = new PrintWriter(new File(System.getProperty("user.dir") +
- File.separator +"updater.log"));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- public boolean moveFile(String from, String to) {
- return moveFile(new File(from), new File(to));
- }
-
- public boolean moveFile(File from, File to) {
- writer.println("Move " + from + " to " + to);
- if (!from.exists()) {
- writer.println("File not found: "+from);
- return false;
- } else {} //nothing
-
- if (to.exists()) {
- writer.println("File exists. try to delete : "+to);
- if(to.delete()) {
- writer.println("deleted");
- } else {
- writer.println("delete fail");
- return false;
- }
- } else {}
-
- return from.renameTo(to);
- }
-
- /**
- * Moves new IM to old IM and run the IM.
- * @param args args[0] is path of new IM. args[1] is path of old IM.
- */
- public static void main(String[] args) {
- initWriter();
-
- if (args.length < 2) {
- return;
- }
-
- try {
- writer.println("sleep 3000");
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- String[] imargs = new String[args.length-2];
- for(int i = 0; i < args.length-2; i++) {
- imargs[i] = args[i+2];
- }
-
- InstallManagerUpdater upInstallManager = new InstallManagerUpdater();
- upInstallManager.update(args[0], args[1], imargs);
- }
-
- private void update(String newIM, String oldIM, String[] imargs) {
- boolean bResult = moveFile(newIM, oldIM);
- String imarg = "";
- for(String a : imargs) {
- imarg = imarg + " " + a;
- }
-
- if (bResult){
- writer.println("move success");
- try {
- File toFile = new File(oldIM);
- toFile.setExecutable(true);
- writer.println("run IM");
- Runtime.getRuntime().exec("java -jar " + toFile.getAbsolutePath() + " -updated " + imarg);
- } catch (IOException e) {
- writer.println("run failed");
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- writer.println("move failed");
- }
- writer.close();
- }
-
-}
if [ -e InstallManager.jar ]
then
java -jar InstallManager.jar $*
-elif [ -e $HOME/.TizenSDK/tizensdkpath ]
+elif [ -e $HOME/tizen-sdk-data/tizensdkpath ]
then
- tizenpath=`grep TIZEN_SDK_INSTALLED_PATH $HOME/.TizenSDK/tizensdkpath`
+ tizenpath=`grep TIZEN_SDK_INSTALLED_PATH $HOME/tizen-sdk-data/tizensdkpath`
SDK_PATH=`echo $tizenpath | cut -f2 -d"="`
if [ "x$SDK_PATH" != "x" ]
then
- cd $SDK_PATH/InstallManager
+ cd $SDK_PATH/install-manager
if [ -e InstallManager.jar ]
then
java -jar InstallManager.jar $*
<property name="swtjar" value="org.eclipse.swt.gtk.linux.x86_3.6.2.v3659b.jar"/>
<property name="PLATFORM" value="linux"/>
</target>
+ <target name="init-windows-64" if="is-windows">
+ <property name="swtjar" value="swt-win32-64.jar"/>
+ <property name="PLATFORM" value="windows64"/>
+ </target>
+ <target name="init-linux-64" if="is-linux">
+ <property name="swtjar" value="swt-linux-64.jar"/>
+ <property name="PLATFORM" value="linux64"/>
+ </target>
- <target name="init" depends="init-linux,init-windows">
+ <target name="init" depends="init-linux,init-windows,init-linux-64,init-windows-64">
<property name="distlib.dir" value="${dist.dir}/${PLATFORM}/InstallManager_lib"/>
<path id="build-classpath">
<fileset dir="${basedir}/lib">
+++ /dev/null
-InstallManager-Version: 1.15.0
-
+++ /dev/null
-Repository: http://172.21.17.55/dibs/unstable_release
-InstallManager-Repository: http://172.21.17.55/Tizen-PackageServer_Internal/InstallManager/Linux
-InstallManager-Version: 1.20.0
-
+++ /dev/null
-Repository: http://172.21.111.180/Tizen-PackageServer_Internal/current/windows-packages/
-InstallManager-Repository: http://172.21.111.180/Tizen-PackageServer_Internal/InstallManager/Windows
-InstallManager-Version: 1.20.0
-
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.core;
+ * 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.installmanager.core;
import java.io.File;
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.util.Arrays;
import java.util.Collection;
-import java.util.LinkedList;
+import java.util.Collections;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.lib.Log;
import org.tizen.installmanager.lib.Platform;
-import org.tizen.installmanager.lib.Registry;
import org.tizen.installmanager.pkg.model.ConfigFile;
import org.tizen.installmanager.pkg.model.Version;
import org.tizen.installmanager.util.PathUtil;
* This class manages to configure installmanager.
*
* @author shihyun kim <Shihyun.kim@samsung.com>
- *
+ *
*/
public class Config {
public static final String SDK_NAME = "Tizen SDK";
-
- //Directory and Execute file name.
+
+ // Directory and Execute file name.
public static final String INSTALL_MANAGER_FILE_NAME = "InstallManager";
- public static final String INSTALL_MANAGER_DIRECTORY = "InstallManager";
+ public static final String INSTALL_MANAGER_DIRECTORY = "install-manager";
+ public static final String OLD_INSTALL_MANAGER_DIRECTORY = "InstallManager";
public static final String INSTALL_MANAGER_BINARY = "InstallManager.jar";
public static final String INSTALL_MANAGER_UPDATER_BINARY = "InstallManagerUpdater.jar";
public static final String EXECUTE_FILE_NAME_OF_INSTALL_MANAGER = getExecuteFileNameOfInstallManager();
- public static final String EXECUTE_FILE_PATH_OF_INSTALL_MANAGER = PathUtil.get(INSTALL_MANAGER_DIRECTORY, EXECUTE_FILE_NAME_OF_INSTALL_MANAGER);
- public static final String SDK_DIRECTORY = "tizen_sdk";
-
- //config File
- public static final String CONFIG_DIRECTORY_NAME = ".TizenSDK";
+ public static final String EXECUTE_FILE_NAME_OF_INSTALL_MANAGER_PARTNER =
+ getExecuteFileNameOfInstallManagerPartner();
+ public static final String EXECUTE_FILE_PATH_OF_INSTALL_MANAGER = PathUtil
+ .get(INSTALL_MANAGER_DIRECTORY,
+ EXECUTE_FILE_NAME_OF_INSTALL_MANAGER);
+ public static final String SDK_DIRECTORY = "tizen-sdk";
+
+ // config File
+ public static final String CONFIG_DIRECTORY_NAME = "tizen-sdk-data";
public static final String CONFIG_HOME = getConfigHome();
public static final String INFO_DIRECTORY = ".info";
-// public static final String INFO_DIRECTORY_PATH = PathUtil.getFromInstalledPath(INFO_DIRECTORY);
- //old config File
+ public static final String OLD_CONFIG_DIRECTORY_NAME = ".TizenSDK";
+ public static final String OLD_CONFIG_HOME = getOldConfigHome();
+ // public static final String INFO_DIRECTORY_PATH =
+ // PathUtil.getFromInstalledPath(INFO_DIRECTORY);
+
+ // old config File
public static final String OLD_INFO_DIRECTORY = "info";
- public static final String OLD_INFO_DIRECTORY_PATH = PathUtil.get(CONFIG_HOME, OLD_INFO_DIRECTORY);
+ public static final String OLD_INFO_DIRECTORY_PATH = PathUtil.get(
+ CONFIG_HOME, OLD_INFO_DIRECTORY);
public static final String OLD_INFO_REMOVESCRIPT_DIRECTORY = "removescript";
- public static final String OLD_INFO_REMOVESCRIPT_PATH = PathUtil.get(OLD_INFO_DIRECTORY_PATH, OLD_INFO_REMOVESCRIPT_DIRECTORY);
+ public static final String OLD_INFO_REMOVESCRIPT_PATH = PathUtil.get(
+ OLD_INFO_DIRECTORY_PATH, OLD_INFO_REMOVESCRIPT_DIRECTORY);
public static final String OLD_INSTALLED_FILE_LIST_DIRECTORY = "installedlist";
- public static final String OLD_INSTALLED_FILE_LIST_DIRECTORY_PATH = PathUtil.get(OLD_INFO_DIRECTORY_PATH, OLD_INSTALLED_FILE_LIST_DIRECTORY);
-
- //IM config file.
+ public static final String OLD_INSTALLED_FILE_LIST_DIRECTORY_PATH = PathUtil
+ .get(OLD_INFO_DIRECTORY_PATH, OLD_INSTALLED_FILE_LIST_DIRECTORY);
+
+ // IM config file.
public static final String INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME = "installmanager.conf";
- public static final String INSTALL_MANAGER_DEFAULT_CONFIG_FILE_PATH = PathUtil.get(INSTALL_MANAGER_DIRECTORY, INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME);
-
- //Programs shortcut path
+ public static final String INSTALL_MANAGER_DEFAULT_CONFIG_FILE_PATH = PathUtil
+ .get(INSTALL_MANAGER_DIRECTORY,
+ INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME);
+
+ // Programs shortcut path
public static final String SDK_PROGRAMS_SHORTCUT_MENU_PATH = getSLPSDKShortcutPath();
public static final String SDK_PROGRAMS_SHORTCUT_MENU_FILENAME = "tizen-sdk-menu.directory";
- public static final String SDK_PROGRAMS_SHORTCUT_MENU_ICON_PATH = PathUtil.getFromHome(".local/share/icons/tizen-sdk-menu.png");
-
- //InstallManager Shortcut PathUtil
+ public static final String SDK_PROGRAMS_SHORTCUT_MENU_ICON_PATH = PathUtil
+ .getFromHome(".local/share/icons/tizen-sdk-menu.png");
+
+ // InstallManager Shortcut PathUtil
public static final String SHORTCUT_DIRECTORY = "Tizen SDK";
public static final String INSTALL_MANAGER_SHORTCUT = "InstallManager";
public static final String INSTALL_MANAGER_SHORTCUT_PATH = getInstallManagerShortcutPath();
public static final String INSTALL_MANAGER_SHORTCUT_FILENAME = "tizen-sdk-installmanager.desktop";
public static final String INSTALL_MANAGER_SHORTCUT_ICON_PATH = getInstallManagerShortcutIconPath();
-
- //OLD SHORTCUT
+
+ // OLD SHORTCUT
public static final String OLD_SHORTCUT_DIRECTORY = "Samsung Linux Platform";
public static final String OLD_SDK_PROGRAMS_SHORTCUT_MENU_PATH = getOldSLPSDKShortcutPath();
public static final String OLD_SDK_PROGRAMS_SHORTCUT_MENU_FILENAME = "samsung-sdk_menu.directory";
- public static final String OLD_SDK_PROGRAMS_SHORTCUT_MENU_ICON_PATH = PathUtil.getFromHome(".local/share/icons/samsung-sdk-menu.ico");
-
- public static final String OLD_INSTALL_MANAGER_SHORTCUT_PATH = PathUtil.getFromHome(".local/share/applications/samsung-sdk-installmanager.desktop");
+ public static final String OLD_SDK_PROGRAMS_SHORTCUT_MENU_ICON_PATH = PathUtil
+ .getFromHome(".local/share/icons/samsung-sdk-menu.ico");
+
+ public static final String OLD_INSTALL_MANAGER_SHORTCUT_PATH = PathUtil
+ .getFromHome(".local/share/applications/samsung-sdk-installmanager.desktop");
public static final String OLD_INSTALL_MANAGER_SHORTCUT_FILENAME = "samsung-sdk-installmanager.desktop";
- public static final String OLD_INSTALL_MANAGER_SHORTCUT_ICON_PATH = PathUtil.getFromHome(".local/share/icons/samsung-sdk-installmanager.ico");
+ public static final String OLD_INSTALL_MANAGER_SHORTCUT_ICON_PATH = PathUtil
+ .getFromHome(".local/share/icons/samsung-sdk-installmanager.ico");
- //Packages info
+ // Packages info
public static final String BINARY_DIRECTORY = "binary";
- public static final String PACKAGE_LIST_FILE_LINUX = "pkg_list_linux";
- public static final String PACKAGE_LIST_FILE_WINDOWS = "pkg_list_windows";
- public static final String PACKAGE_LIST_LOCAL_DIRECTORY = PathUtil.getFromCurrDir(Config.BINARY_DIRECTORY);
- public static final String PACKAGE_LIST_LOCAL_FILE_PATH = setPkglistLocalPath();
+ public static final String PACKAGE_LIST_FILE_LINUX_32 = "pkg_list_ubuntu-32";
+ public static final String PACKAGE_LIST_FILE_LINUX_64 = "pkg_list_ubuntu-64";
+ public static final String PACKAGE_LIST_FILE_WINDOWS_32 = "pkg_list_windows-32";
+ public static final String PACKAGE_LIST_FILE_WINDOWS_64 = "pkg_list_windows-64";
+ public static final String PACKAGE_LIST_FILE_MACOS_64 = "pkg_list_darwin-64";
+ public static final String PACKAGE_BINARY_LOCAL_DIRECTORY_PATH = PathUtil
+ .getFromCurrDir(Config.BINARY_DIRECTORY);
+ public static final String PACKAGE_LIST_LOCAL_DIRECTORY_PATH = PathUtil
+ .getCurrentDir();
+// public static String PACKAGE_LIST_FILE_PATH = ""; // path includes pkg list file name by using configuration dialog.
+// public static String PACKAGE_LIST_FILE_DIR = ""; // path excepts pkg list file name by using configuration dialog.
public static final String INSTALLED_PACKAGE_LIST_FILE_NAME = "installedpackage.list";
-// public static final String INSTALLED_PACKAGE_LIST_FILE_PATH = PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY), INSTALLED_PACKAGE_LIST_FILE_NAME);
-
- //Install temp directory
+// public static String SDK_IMAGE_PATH = "";
+
+ // Install temp directory
public static final String TEMP_DIRECTORY = "temp";
public static final String DATA_DIRECTORY = "data";
public static final String SDK_TEMP_DIR = "tizensdk";
-
- //batch file
+ public static final String SDK_TEMP_DIR_PATH = PathUtil.getFromTempDir(Config.SDK_TEMP_DIR);
+
+ // batch file
public static final String INSTALL_MANAGER_REMOVE_BATCH_SCRIPT_FILE_NAME = "removeSDKDirectory.bat";
public static final String INSTALL_MANAGER_REMOVE_VB_SCRIPT_FILE_NAME = "removeSDKDirectory.vbs";
+ // repository
+ public static final String REPOSITORY_DISTRIBUTION_INFO_FILE = "distribution.info";
+ public static final String REPOSITORY_SNAPSHOT_INFO_FILE = "snapshot.info";
+ public static final String REPOSITORY_DEFAULT_TYPE = "develop";
+
+ private String localRepository = "";
+ private String confFilePath = null;
+
+ // configuration dialog
+ public static ConfDialog fromWhere = ConfDialog.NORMAL; // where does information come from in configuration dialog.
+
+ private ServerType serverType = ServerType.SNAPSHOT;
+ public static Status status = Status.INSTALL;
+
+ /**
+ * This enumeration where does information come from in configuration dialog.</br>
+ * NORMAL is just push 'next' button.</br>
+ * SNAPSHOT is information from snapshot table in configuration dialog.</br>
+ * LOCAL_IMAGE is information from file dialog in configuration dialog.</br>
+ * USER_SPECIFIC is information from text editor in configuration dialog.</br>
+ */
+ public enum ConfDialog {
+ NORMAL, SNAPSHOT, LOCAL_IMAGE, USER_SPECIFIC;
+ }
+
+ public enum Status {
+ INSTALL, UPDATE, UNINSTALL;
+ }
+
+ public enum ServerType{
+ SNAPSHOT("snapshot"),
+ PACKAGE("package"),
+ LOCAL("local");
+
+ private String type = "";
+ ServerType(String type){
+ this.type = type;
+ }
+
+ public String toString() {
+ return type;
+ }
+ }
+
// exit codes of Install Manager
public static final int EXITCODE_NORMAL = 0;
public static final int EXITCODE_HAS_SELF_UPDATE = 1;
public static final int EXITCODE_ONLY_DOWNLOAD = 3;
public static final int EXITCODE_UNKNOWN_ERROR = 4;
- //release note file
- public static final String RELEASE_NOTE = "RELEASE_NOTE.txt";
- private ConfigFile mConfigFile;
- private String mTargetDir = "";
-
- public Config() {
- String confPath = getConfigFilePath();
- mConfigFile = new ConfigFile(confPath);
- }
-
- private static String setPkglistLocalPath() {
- String path = null;
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- path = PathUtil.getFromCurrDir(PACKAGE_LIST_FILE_LINUX);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- path = PathUtil.getFromCurrDir(PACKAGE_LIST_FILE_WINDOWS);
- } else {
- Log.err("Not supportted platform");
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
-
- if (path == null) {
- Log.err("Not supportted platform");
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
-
- return path;
- }
-
- /**
- * @return filename of install manager executable
- */
- private static String getExecuteFileNameOfInstallManager() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return "InstallManager";
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return "InstManager.exe";
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- private static String getInstallManagerShortcutPath() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getFromHome(".local/share/applications/"+Config.INSTALL_MANAGER_SHORTCUT_FILENAME);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return "";
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- private static String getInstallManagerShortcutIconPath() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getFromHome(".local/share/icons/tizen-sdk-installmanager.png");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return "";
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- private static String getConfigHome() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getFromHome(Config.CONFIG_DIRECTORY_NAME);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return PathUtil.getFromAppData(Config.CONFIG_DIRECTORY_NAME);
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- private static String getSLPSDKShortcutPath() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getFromHome(".local/share/desktop-directories/"+Config.SDK_PROGRAMS_SHORTCUT_MENU_FILENAME);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ // release note file
+ public static final String RELEASE_NOTE = "release-note.txt";
+ private ConfigFile mConfigFile = null;
+ private String mTargetDir = "";
+
+ private static Config config = null;
+
+ private Config() {
+ confFilePath = getConfigFilePath();
+ mConfigFile = new ConfigFile(confFilePath);
+ }
+
+ /**
+ * @return filename of install manager executable
+ */
+ private static String getExecuteFileNameOfInstallManager() {
+ if (Platform.isLinux() || Platform.isMacOS() ) {
+ return "InstallManager";
+ } else if ( Platform.isWindows() ) {
+ return "InstManager.exe";
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ /**
+ * @return filename of install manager executable for Partner SDK
+ */
+ private static String getExecuteFileNameOfInstallManagerPartner() {
+ if (Platform.isLinux() || Platform.isMacOS() ) {
+ return "InstallManagerP";
+ } else if ( Platform.isWindows() ) {
+ return "InstManager.exe";
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ private static String getInstallManagerShortcutPath() {
+ if (Platform.isUbuntu()) {
+ return PathUtil.getFromHome(".local/share/applications/"
+ + Config.INSTALL_MANAGER_SHORTCUT_FILENAME);
+ } else if (Platform.isWindows()) {
+ return "";
+ } else if (Platform.isMacOS()) {
+ return "";
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ private static String getInstallManagerShortcutIconPath() {
+ if (Platform.isUbuntu()) {
+ return PathUtil
+ .getFromHome(".local/share/icons/tizen-sdk-installmanager.png");
+ } else if (Platform.isWindows()) {
+ return "";
+ } else if (Platform.isMacOS()) {
+ return "";
+ }
+ else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ public static String getConfigHome() {
+ if (Platform.isLinux() || Platform.isMacOS()) {
+ return PathUtil.getFromHome(Config.CONFIG_DIRECTORY_NAME);
+ } else if (Platform.isWindows()) {
+ return PathUtil.getFromAppData(Config.CONFIG_DIRECTORY_NAME);
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ public static String getOldConfigHome() {
+ if (Platform.isLinux() || Platform.isMacOS()) {
+ return PathUtil.getFromHome(Config.OLD_CONFIG_DIRECTORY_NAME);
+ } else if (Platform.isWindows()) {
+ return PathUtil.getFromAppData(Config.OLD_CONFIG_DIRECTORY_NAME);
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ private static String getSLPSDKShortcutPath() {
+ if (Platform.isUbuntu()) {
+ return PathUtil.getFromHome(".local/share/desktop-directories/"
+ + Config.SDK_PROGRAMS_SHORTCUT_MENU_FILENAME);
+ } else if (Platform.isWindows()) {
return Config.SHORTCUT_DIRECTORY;
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- private static String getOldSLPSDKShortcutPath() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getFromHome(".local/share/desktop-directories/samsung-sdk_menu.directory");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.isMacOS()) {
+ return "";
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ private static String getOldSLPSDKShortcutPath() {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32) {
+ return PathUtil
+ .getFromHome(".local/share/desktop-directories/samsung-sdk_menu.directory");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32) {
return Config.OLD_SHORTCUT_DIRECTORY;
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- /**
- * Set target directory to member variable.
- * @param targetDir
- */
- public void setTargetDir(String targetDir) {
- mTargetDir = targetDir;
- }
-
- /**
- * Get ConfigFile Class instance
- * @return
- */
- public ConfigFile getConfigFile() {
- return mConfigFile;
- }
-
- /**
- * Get repositories.
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ * Set target directory to member variable.
+ *
+ * @param targetDir
+ */
+ public void setTargetDir(String targetDir) {
+ mTargetDir = targetDir;
+ }
+
+ /**
+ * Get ConfigFile Class instance
+ *
+ * @return
+ */
+ public ConfigFile getConfigFile() {
+ return mConfigFile;
+ }
+
+ private String[] getSDKRepositories() {
+ String repo = mConfigFile.getRepository();
+
+ String[] repos = repo.split(",");
+
+ for (int i=0; i<repos.length; i++) {
+ repos[i] = repos[i].trim();
+ }
+
+ return repos;
+ }
+
+ /**
+ * Get repositories of SDK.
+ *
* @return string array.
- */
- public String[] getRepositories() {
- String repo = mConfigFile.getRepository();
- if (repo == null || repo.equals("")) {
- Log.log("Repository doesn't exist in conf file.");
- return null;
- }
-
- String[] repos = repo.split(",");
-
- for(int i=0; i<repos.length; i++) {
- repos[i] = repos[i].trim();
- }
-
- return repos;
- }
-
- /**
- * Get repositories and make collection of URL.
- * @return Collection of URL.
- */
- public Collection<URL> getRepositoryPackagesURLs() {
- String[] repos = getRepositories();
-
- if (repos == null) {
- Log.log("Repository doesn't exist in config file");
- return null;
- }
-
- LinkedList<URL> urls = new LinkedList<URL>();
-
- for(String repo : repos) {
- try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- urls.add(new URL(repo + "/" + Config.PACKAGE_LIST_FILE_LINUX));
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- urls.add(new URL(repo + "/" + Config.PACKAGE_LIST_FILE_WINDOWS));
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
+ */
+ public Collection<String> getSDKRepositoryList() {
+ String[] repos = getSDKRepositories();
+
+ return Arrays.asList(repos);
+ }
+
+ /**
+ * Set snapshot path from repository.
+ * @return
+ */
+ public String getSnapshotPath() {
+ return mConfigFile.getSnapshotPath();
+ }
+
+ /**
+ * Set snapshot path from repository.
+ * @param snapshotPath if <code>snapshotPath</code> is empty(""), always update latest version.
+ */
+ public void setSnapshotPath(String snapshotPath) {
+ mConfigFile.setSnapshotPath(snapshotPath);
+ }
+
+ /**
+ * Always update latest version.
+ */
+ public void setLatestSnapshotPath() {
+ mConfigFile.setSnapshotPath("");
+ }
+
+ /**
+ * Get repositories.
+ *
+ * @return List of packgae repositories.
+ */
+ public Collection<String> getSDKPackageServerList() {
+ if (serverType == ServerType.SNAPSHOT) {
+ String[] repos = getSDKRepositories();
+
+ if (repos.length <= 0) {
+ return Collections.emptyList();
+ }
+
+ for (int i=0; i<repos.length; i++) {
+ repos[i] = addDistribution(repos[i]);
+ }
+
+ return Arrays.asList(repos);
+ } else {
+ String[] repos = {localRepository};
+
+ return Arrays.asList(repos);
+ }
+ }
+
+ public ServerType getServerType() {
+ return serverType;
+ }
+
+ public String getReleaseNoteUrl() {
+ return mConfigFile.getReleaseNoteUrl();
+ }
+
+ private String addDistribution(String repository) {
+ if (repository == null || repository.isEmpty()) {
+ return null;
+ }
+
+ //server type
+ String distribution = mConfigFile.getDistribution();
+
+ //if distribution is empty, add default distribution.
+ if (distribution == null || distribution.isEmpty()) {
+ return PathUtil.addURLPath(repository, Config.REPOSITORY_DEFAULT_TYPE);
+
+ //else if serv
+ } else {
+ return PathUtil.addURLPath(repository, distribution);
+ }
+ }
+ /**
+ * Set information of server.
+ * @param repository Base-repository of sdk. if repository is null, it do not set repository.
+ * @param distribution distribution of repository. if distribution is null, it do not set type.
+ * @param packageServer package server of sdk. if packageServer is null, it do not set packageServer.
+ * @param serverType if serverType is null, it do not set serverType.
+ */
+ public void saveConfiguration(String repository, String distribution, ServerType serverType, String snapshotPath) {
+ if (serverType != null) {
+ this.serverType = serverType;
+
+ if (serverType == ServerType.SNAPSHOT) {
+ if (repository != null && !repository.isEmpty()) {
+ mConfigFile.setRepository(repository);
+ }
- } catch (MalformedURLException e) {
- Log.err("Ignore invalid repository location: "+repo);
- Log.ExceptionLog(e);
+ mConfigFile.setSnapshotPath(snapshotPath);
+ } else {
+ File repositoryFile = new File(repository);
+
+ if (repositoryFile.exists()) {
+ this.localRepository = repositoryFile.toURI().toString();
+ }
}
- }
- return urls;
- }
+ }
+
+ if (distribution != null && !distribution.isEmpty()) {
+ mConfigFile.setDistribution(distribution);
+ }
+
+ saveConfig();
+ }
+
+ public void setServerType(ServerType serverType) {
+ this.serverType = serverType;
+ }
+
+ /**
+ * Set type of repository.
+ * @param type
+ */
+ public void setRepositoryType(String type) {
+ mConfigFile.setDistribution(type);
+ }
- /**
+ /**
* Create configuration directory.
+ *
* @return
- */
- public boolean makeConfigHome() {
- boolean bResult = true;
-
- File configHomeDirFile = new File(Config.CONFIG_HOME);
- if (!configHomeDirFile.exists()) {
- bResult = configHomeDirFile.mkdirs();
- }
-
- if (bResult) {
- try {
+ */
+ public boolean makeConfigHome() {
+ boolean bResult = true;
+
+ File configHomeDirFile = new File(Config.CONFIG_HOME);
+ if (!configHomeDirFile.exists()) {
+ bResult = configHomeDirFile.mkdirs();
+ }
+
+ if (bResult) {
+ try {
PathUtil.makeHiddenFile(configHomeDirFile);
return true;
} catch (IOException e) {
Log.ExceptionLog(e);
return false;
}
- } else {
- return false;
- }
- }
-
- /**
+ } else {
+ return false;
+ }
+ }
+
+ /**
* Make information directory. It can be used for installmanager.
+ *
* @return <code>true</true> if success.
- */
- public boolean makeInfoDirectory() {
-
- boolean bResult = makeConfigHome();
-
- if (bResult) {
- File configDirFile = new File(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
- configDirFile.mkdir();
- } else {
- return false;
- }
-
- return bResult;
- }
-
- /**
- * @return path of target directory
- */
+ */
+ public boolean makeInfoDirectory() {
+
+ boolean bResult = makeConfigHome();
+
+ if (bResult) {
+ File configDirFile = new File(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
+ configDirFile.mkdir();
+ } else {
+ return false;
+ }
+
+ return bResult;
+ }
+
+ /**
+ * @return path of target directory
+ */
public String getTargetDir() {
return mTargetDir;
}
-
+
/**
* @return <code>true</code> if proxy server is specified
*/
public boolean hasProxy() {
- if(mConfigFile != null) {
+ if (mConfigFile != null) {
String server = mConfigFile.getProxyServer();
int port = mConfigFile.getProxyPort();
- if(server.equals("") || port < 0) {
+ if (server.equals("") || port < 0) {
return false;
}
}
return true;
}
-
+
/**
* @return version of install manager
*/
public Version getInstallManagerVersion() {
return new Version(this.mConfigFile.getInstallManagerVersion());
}
-
+
/**
- * @return Config file Path when installer is recognize install option(-conf).
+ * @return Config file Path when installer is recognize install
+ * option(-conf).
*/
- public static String getConfigFilePath() {
- if (Options.userConfPath == null) {
- return PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME);
- } else {
- return Options.userConfPath;
- }
- }
-
- private String getSaveConfigFilePath() {
- if (Options.userConfPath == null) {
- if (Registry.getInstalledPath() == null || Registry.getInstalledPath().isEmpty()) {
- return PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME);
- } else {
- return PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_PATH);
- }
- } else {
- return Options.userConfPath;
- }
- }
-
- /**
- * save config file to TargetDirectory
- */
- public void saveConfig() {
- String configFilePath = "";
- if (mTargetDir != null) {
- configFilePath = getSaveConfigFilePath();
- }
-
- mConfigFile.saveConfig(configFilePath);
- }
-
- /**
- * Reads build version from resource which will be generated
- * @return build version
- */
- public static String getJarBuildVersion() {
- String buildversion = PathUtil.readAllTextFromResource("/res/installmanager/buildversion");
- return buildversion;
- }
+ public static String getConfigFilePath() {
+ //user config option is false.
+ if (Options.userConfPath == null) {
+ //1st, get config file from installed path.
+ File installedConfFile = new File(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME));
+ if (installedConfFile.exists()) {
+ return installedConfFile.getAbsolutePath();
+
+ //if not exist config file from installed path, 2nd get config file from current directory.
+ } else {
+ File currentDirConfFile = new File(PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME));
+
+ if (currentDirConfFile.exists()) {
+ return currentDirConfFile.getAbsolutePath();
+ } else {
+ return null;
+ }
+ }
+
+ //user config option is true,
+ } else {
+ return Options.userConfPath;
+ }
+ }
+
+ /**
+ * save config file to TargetDirectory
+ */
+ public void saveConfig() {
+ if (confFilePath == null || confFilePath.isEmpty()) {
+ return;
+ } else {
+ mConfigFile.saveConfig(confFilePath);
+ }
+ }
+
+ /**
+ * Reads build version from resource which will be generated
+ *
+ * @return build version
+ */
+ public static String getJarBuildVersion() {
+ String buildversion = PathUtil
+ .readAllTextFromResource("/res/installmanager/buildversion");
+ return buildversion;
+ }
+
+ public static Config getInstance() {
+ if (config == null) {
+ config = new Config();
+ }
+
+ return config;
+ }
}
--- /dev/null
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import org.tizen.installmanager.lib.Downloader;
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.pkg.lib.PropertyParser;
+import org.tizen.installmanager.pkg.model.Distribution;
+import org.tizen.installmanager.pkg.model.DistributionSet;
+import org.tizen.installmanager.pkg.model.PropertySection;
+import org.tizen.installmanager.pkg.model.Snapshot;
+import org.tizen.installmanager.pkg.model.SnapshotList;
+import org.tizen.installmanager.util.PathUtil;
+
+/**
+ * This class manages to distribution.
+ *
+ * @author shihyun kim <Shihyun.kim@samsung.com>
+ *
+ */
+public class DistributionController {
+ private static DistributionController distController = null;
+
+ private String MARKED_SNAPSHOT = "manual";
+
+ //distributino information
+ DistributionSet dists = new DistributionSet();
+
+ Collection<String> repositories = null;
+ HashMap<String, SnapshotList> distributionSnapshotSet = new HashMap<String, SnapshotList>();
+
+ private DistributionController(Collection<String> repos) {
+ repositories = repos;
+ }
+
+ /**
+ * initialize distribution.
+ * @return if <code>false</code>, can not read any distribuion.
+ */
+ public boolean init() {
+ if (!dists.isEmpty()) {
+ dists.clear();
+ }
+
+ loadDistribution();
+
+ if (dists.isEmpty()) {
+ return false;
+ } else {
+ for (Distribution dist : dists) {
+ loadSnapshot(dist);
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Get distribution list in repository.
+ * @return
+ */
+ public List<String> getDistributionList() {
+ List<String> distList = new ArrayList<String>();
+ for (Distribution dist : dists) {
+ if (dist.getName() != null) {
+ distList.add(dist.getName());
+ }
+ }
+
+ return distList;
+ }
+
+ /**
+ * Load distribution from repository.
+ */
+ public void loadDistribution() {
+ if (!dists.isEmpty()) {
+ dists.clear();
+ }
+
+ File tmp = null;
+ try {
+ tmp = File.createTempFile("dist", ".info");
+ tmp.deleteOnExit();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ return;
+ }
+
+ //download dist.info file from repository
+ Downloader downloader = new Downloader();
+
+ for (String repo : repositories) {
+ URL distInfoFileURL = getDistInfoFilePath(repo);
+
+ long size = downloader.download(distInfoFileURL, tmp.getAbsolutePath(), null);
+ if (size < 0) {
+ return;
+ }
+
+ //parsing dist.list file.
+ PropertyParser parser = new PropertyParser();
+ List<PropertySection> sections = parser.readFromFile(tmp);
+
+ if (sections == null) {
+ return;
+ }
+
+ for (PropertySection section : sections) {
+ dists.add(new Distribution(repo, section.getProperties()));
+ }
+
+ // temp file cleanup
+ if (tmp.exists()) {
+ tmp.delete();
+ }
+ }
+ }
+
+ private URL getDistInfoFilePath(String repo) {
+ String distInfoFilePath = PathUtil.addURLPath(repo, Config.REPOSITORY_DISTRIBUTION_INFO_FILE);
+
+ try {
+ return new URL(distInfoFilePath);
+ } catch (MalformedURLException e) {
+ Log.err("Cannot connect distribution file in repository(" + distInfoFilePath + ")");
+ return null;
+ }
+ }
+
+ /**
+ * Get all of snapshots.
+ * @return
+ */
+ public SnapshotList getSnapshotList(String distribution) {
+ SnapshotList list = distributionSnapshotSet.get(distribution);
+
+ if (list == null) {
+ return SnapshotList.EMPTY;
+ } else {
+ return list;
+ }
+ }
+
+ /**
+ * Get manual snapshot list.
+ * @param distribution
+ * @return
+ */
+ public SnapshotList getManualSnapshotList(String distribution) {
+ SnapshotList manualSnapshotList = new SnapshotList();
+
+ SnapshotList snapshotList = getSnapshotList(distribution);
+
+ for(Snapshot snapshot : snapshotList) {
+ if (snapshot.getType().equals(MARKED_SNAPSHOT)) {
+ manualSnapshotList.add(snapshot);
+ }
+ }
+
+ return manualSnapshotList;
+ }
+
+ /**
+ * Load snapshot information from repository.
+ * @param distribution selected distribution.
+ * @return SnapshotList
+ */
+ public void loadSnapshot(String distribution) {
+ Distribution dist = dists.getDistributionByName(distribution);
+ loadSnapshot(dist);
+ }
+ /**
+ * Load snapshot information from repository.
+ * @param distribution selected distribution.
+ * @return
+ */
+ private void loadSnapshot(Distribution distribution) {
+ if (distribution == null) {
+ return;
+ } else {
+ String snapshotRepo = PathUtil.addURLPath(distribution.getRepository(), distribution.getName());
+ SnapshotList list = loadSnapshotFromRepository(snapshotRepo);
+
+ //sort by date.
+ Collections.sort(list);
+
+ //read snapshots and save to distributionSnapshotSet instance.
+ //If you read snapshots next, you can find in distributionSnapshotSet instance.
+ distributionSnapshotSet.put(distribution.getName(), list);
+ }
+ }
+
+ /**
+ * Load snapshot information from repository.
+ * @param repository package repository.
+ */
+ private SnapshotList loadSnapshotFromRepository(String snapshotRepo) {
+ SnapshotList snapshots = new SnapshotList();
+
+ File tmp = null;
+
+ try {
+ tmp = File.createTempFile("snapshot", ".info");
+ tmp.deleteOnExit();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ return SnapshotList.EMPTY;
+ }
+
+ //download snapshot.list file from repository
+ Downloader downloader = new Downloader();
+ URL snapshotListURL = getSnapshotListPathInRepository(snapshotRepo);
+
+ long size = downloader.download(snapshotListURL, tmp.getAbsolutePath(), null);
+ if (size < 0) {
+ Log.err("Fail to download snapshot.info from repository.");
+ return SnapshotList.EMPTY;
+ }
+
+ //parsing snapshot.list file.
+ PropertyParser parser = new PropertyParser();
+ List<PropertySection> sections = parser.readFromFile(tmp);
+
+ if (sections == null) {
+ return SnapshotList.EMPTY;
+ }
+
+ if (Options.allSnapshots) {
+ // for showing all snapshots.
+ for (PropertySection section : sections) {
+ snapshots.add(new Snapshot(section.getProperties()));
+ }
+ } else {
+ // for showing filtered snapshots.
+ for (PropertySection section : sections) {
+ Snapshot s = new Snapshot(section.getProperties());
+ snapshots.add(s);
+ }
+ }
+
+ return snapshots;
+ }
+
+ private URL getSnapshotListPathInRepository(String snapshotRepo) {
+ if (snapshotRepo == null || snapshotRepo.isEmpty()) {
+ Log.log("Repository for snapshot do not exist.");
+ return null;
+
+ } else {
+ String snapshotListPath = PathUtil.addURLPath(snapshotRepo, Config.REPOSITORY_SNAPSHOT_INFO_FILE);
+ try {
+ Log.log("Snapshot.list url is " + snapshotListPath);
+ return new URL(snapshotListPath);
+ } catch (MalformedURLException e) {
+ Log.ExceptionLog(e);
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Filter snapshot list of distribution.
+ * @param distribution distribution for snapshot
+ * @return
+ */
+ public SnapshotList filterSnapshotByDistribution(String distribution) {
+ SnapshotList snapshots = distributionSnapshotSet.get(distribution);
+
+ if (snapshots == null) {
+ return SnapshotList.EMPTY;
+ } else {
+ return snapshots;
+ }
+ }
+
+ /**
+ * Get latest snapshot in distribution.
+ * @param distribution
+ * @return Snapshot.
+ */
+ public Snapshot getLatestSnapshot(String distribution) {
+ Snapshot latestSnapshot = null;
+
+ SnapshotList snapshotList = getSnapshotList(distribution);
+ if (!snapshotList.isEmpty()) {
+ latestSnapshot = getSnapshotList(distribution).get(0);
+ } else {
+ Log.err("There are not snapshots in distribution. : " + distribution);
+ return null;
+ }
+
+ Log.log("The latest snapshot name: " + latestSnapshot.getName());
+ return latestSnapshot;
+ }
+
+ public Collection<String> getRepositories() {
+ return repositories;
+ }
+
+ /**
+ * Get DistributionController instance.
+ * @param repository
+ * @return
+ */
+ public static DistributionController getInstance(Collection<String> repositories) {
+ if (distController == null || !distController.getRepositories().containsAll(repositories)) {
+ distController = new DistributionController(repositories);
+ }
+
+ return distController;
+ }
+
+ /**
+ * Get DistributionController instance.
+ * @param repository
+ * @return
+ */
+ public static DistributionController getInstance(String repo) {
+ Collection<String> repositories = new ArrayList<String>();
+ repositories.add(repo);
+
+ return getInstance(repositories);
+ }
+
+ /**
+ * Get DistributionController instance.
+ * @param repository
+ * @return if null, instance is not created.
+ */
+ public static DistributionController getInstance(){
+ return distController;
+ }
+}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.core;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URL;
import java.security.MessageDigest;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedList;
-import org.tizen.installmanager.lib.Documents;
import org.tizen.installmanager.lib.Checksum;
import org.tizen.installmanager.lib.Downloader;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.StartMenu;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.lib.win.WindowsProgramController;
-import org.tizen.installmanager.pkg.lib.PackageManager2;
-import org.tizen.installmanager.pkg.model.Package2;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Package;
import org.tizen.installmanager.pkg.model.PackageSet;
import org.tizen.installmanager.ui.page.InstallingPage.InstallProgressMonitor;
import org.tizen.installmanager.util.IMShellCommandFail;
import org.tizen.installmanager.util.PathUtil;
-
/**
* This class contains the main business logic of Install Manager. Use singleton
* instance.
private Config mConfig = null;
private static Downloader mDownloader = new Downloader();
- private PackageManager2 packageManager;
-
- //windows path
- private static String WINDOWS_INSTALL_MANAGER_INSTALL_SCRIPT="/res/desktop_directory/install.vbs";
- private static String WINDOWS_INSTALL_MANAGER_REMOVE_SCRIPT="/res/desktop_directory/remove.vbs";
+ private PackageManager packageManager;
+
+ // windows path
+ private static String WINDOWS_INSTALL_MANAGER_INSTALL_SCRIPT = "/res/desktop_directory/install.vbs";
+ private static String WINDOWS_INSTALL_MANAGER_REMOVE_SCRIPT = "/res/desktop_directory/remove.vbs";
private static String WINDOWS_MAKE_SHORTCUT_PATH = "/res/desktop_directory/makeshortcut.vbs";
private static String WINDOWS_REMOVE_SHORTCUT_PATH = "/res/desktop_directory/removeshortcut.vbs";
-
- //linux script
- private static String LINUX_INSTALL_MANAGER_INSTALL_SCRIPT="/res/desktop_directory/install.sh";
- private static String LINUX_INSTALL_MANAGER_REMOVE_SCRIPT="/res/desktop_directory/remove.sh";
+
+ // linux script
+ private static String LINUX_INSTALL_MANAGER_INSTALL_SCRIPT = "/res/desktop_directory/install.sh";
+ private static String LINUX_INSTALL_MANAGER_REMOVE_SCRIPT = "/res/desktop_directory/remove.sh";
private static String LINUX_MAKE_SHORTCUT_PATH = "/res/desktop_directory/makeshortcut.sh";
private static String LINUX_REMOVE_SHORTCUT_PATH = "/res/desktop_directory/removeshortcut.sh";
-
+
private File makeShortCutFile = null;
private File removeShortCutFile = null;
/**
* Load config file
*/
- public void loadConfig() {
+ public void initConfig() {
if (mConfig != null) {
return;
} else {
- mConfig = new Config();
-
- if (Options.doRepository) {
+ mConfig = Config.getInstance();
+
+ if (Options.doReplaceRepository) {
Log.log("Replace repository => " + Options.repo);
mConfig.getConfigFile().setRepository(Options.repo);
mConfig.saveConfig();
}
-
+
if (mConfig.getConfigFile() == null) {
Log.log("Loading config file failed");
throw new IMFatalException("Loading configuration file failed");
}
-
+
if (!Registry.getInstalledPath().isEmpty()) {
mConfig.setTargetDir(Registry.getInstalledPath());
}
}
}
- private boolean loadPackageList() {
- //get repositories from config file
- Collection<URL> repositoryURLs = mConfig.getRepositoryPackagesURLs();
-
- if (repositoryURLs == null || repositoryURLs.size() <=0) {
- File localPackageListFile = new File(Config.PACKAGE_LIST_LOCAL_FILE_PATH);
-
- if (localPackageListFile.exists()) {
- try {
- repositoryURLs = new LinkedList<URL>();
- URL localUrl = localPackageListFile.toURI().toURL();
- repositoryURLs.add(localUrl);
- } catch (MalformedURLException e) {
- Log.err("MalformedURLException => " + localPackageListFile);
- Log.ExceptionLog(e);
- throw new IMFatalException(ErrorCode.CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY);
- }
-
- } else {
- Log.log("Installable package.list file doesn't exist");
- }
- }
-
- return loadPackageList(repositoryURLs);
+ /**
+ * Initialize packages information.
+ */
+ public void initPackageList() {
+ Collection<String> repositoryURLs = mConfig.getSDKPackageServerList();
+
+ initPackageManager(repositoryURLs);
}
-
- private boolean loadPackageList(Collection<URL> repositoryURLs) {
-
- File installedPackageListFile = new File(PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
- Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+
+ private void initPackageManager(Collection<String> repositoryURLs) {
+
+ File installedPackageListFile = new File(PathUtil.get(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
try {
- if(installedPackageListFile.exists()) {
- this.packageManager = new PackageManager2(installedPackageListFile, repositoryURLs);
+ if (installedPackageListFile.exists()) {
+ this.packageManager = PackageManager.getInstance(installedPackageListFile, repositoryURLs);
} else {
- this.packageManager = new PackageManager2(null, repositoryURLs);
+ this.packageManager = PackageManager.getInstance(null, repositoryURLs);
}
- } catch(IOException e) {
- Log.err("Cannot load package manager =>" + installedPackageListFile + ", " + repositoryURLs);
+ } catch (IOException e) {
+ Log.err("Cannot load package manager =>" + installedPackageListFile
+ + ", " + repositoryURLs);
throw new IMFatalException(ErrorCode.CANNOT_CREATE_FILE);
}
-
- return true;
}
-
+
+ /**
+ * Initialize distribution and snapshot information
+ */
+ public boolean initDistribution() {
+ DistributionController controller =
+ DistributionController.getInstance(mConfig.getSDKRepositoryList());
+
+ return controller.init();
+ }
+
+
/**
- * Initialize installmanager.
- * It performs that read config file, make temporary files and load package list from repository.
+ * Initialize installmanager. It performs that read config file, make
+ * temporary files and load package list from repository.
+ *
* @return <code>true</code> if initialize success to install or uninstall.
*/
- public boolean init() {
- loadConfig();
-
- copyMakeShortCutFile();
- copyRemoveShortCutFile();
+ public void init() {
+ initConfig();
+ initDistribution();
+ initPackageList();
+ initConfigurationFile();
checkOldSDK();
-
- return loadPackageList();
+ }
+
+ private void initConfigurationFile() {
+ copyMakeShortCutFile();
+ copyRemoveShortCutFile();
}
/**
@Override
public boolean accept(File dir, String name) {
boolean found = false;
- String[] prefix = {"makeshortcut", "installmanager.repository", "Packages", "tizen_installmanager"};
- for(String pref : prefix) {
+ String[] prefix = { "makeshortcut", "removeshortcut",
+ "installmanager.repository", "Packages",
+ "tizen_installmanager", "checkJavaInstallation",
+ "install" };
+ for (String pref : prefix) {
found = name.startsWith(pref);
if (found == true) {
return true;
return found;
}
});
-
- for (File f: tmpFiles) {
+
+ for (File f : tmpFiles) {
f.delete();
}
}
-
+
/**
* Copy make shortcut file from resource to temp directory.
*/
private void copyMakeShortCutFile() {
try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- makeShortCutFile = PathUtil.getTempFileFromResource(LINUX_MAKE_SHORTCUT_PATH, "makeshortcut", ".sh");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- makeShortCutFile = PathUtil.getTempFileFromResource(WINDOWS_MAKE_SHORTCUT_PATH, "makeshortcut", ".vbs");
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ makeShortCutFile = PathUtil.getTempFileFromResource(
+ LINUX_MAKE_SHORTCUT_PATH, "makeshortcut", ".sh");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ makeShortCutFile = PathUtil.getTempFileFromResource(
+ WINDOWS_MAKE_SHORTCUT_PATH, "makeshortcut", ".vbs");
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ makeShortCutFile = PathUtil.getTempFileFromResource(
+ LINUX_MAKE_SHORTCUT_PATH, "makeshortcut", ".sh");
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- makeShortCutFile.setExecutable(true);
+ }
+
+ if (makeShortCutFile.exists()) {
+ makeShortCutFile.setExecutable(true);
+ }
} catch (IOException e) {
Log.err("Installer cannot make 'makeshortcut script' file.");
throw new IMFatalException(ErrorCode.CANNOT_CREATE_SHORTCUT);
}
}
-
+
/**
* Copy remove shortcut file from resource to temp directory.
*/
private void copyRemoveShortCutFile() {
try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- removeShortCutFile = PathUtil.getTempFileFromResource(LINUX_REMOVE_SHORTCUT_PATH, "removeshortcut", ".sh");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- removeShortCutFile = PathUtil.getTempFileFromResource(WINDOWS_REMOVE_SHORTCUT_PATH, "removeshortcut", ".vbs");
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ removeShortCutFile = PathUtil.getTempFileFromResource(
+ LINUX_REMOVE_SHORTCUT_PATH, "removeshortcut", ".sh");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ removeShortCutFile = PathUtil.getTempFileFromResource(
+ WINDOWS_REMOVE_SHORTCUT_PATH, "removeshortcut", ".vbs");
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ removeShortCutFile = PathUtil.getTempFileFromResource(
+ LINUX_REMOVE_SHORTCUT_PATH, "removeshortcut", ".sh");
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
+ }
removeShortCutFile.setExecutable(true);
} catch (IOException e) {
Log.err("Installer cannot make 'makeshortcut script' file.");
throw new IMFatalException(ErrorCode.CANNOT_CREATE_SHORTCUT);
}
}
-
+
/**
* get make shortcut File instance.
+ *
* @return File instance of makeshortcut script.
*/
public File getMakeShortCut() {
return makeShortCutFile;
}
-
+
/**
- * Get temporary file path.(makeshortcut script, Packages list, Installer log)
- * @return temporary file path, if not exist makeshortcut file, return empty string.
+ * Get temporary file path.(makeshortcut script, Packages list, Installer
+ * log)
+ *
+ * @return temporary file path, if not exist makeshortcut file, return empty
+ * string.
*/
public String getMakeShortCutPath() {
if (getMakeShortCut() == null) {
return getMakeShortCut().getAbsolutePath();
}
}
-
+
/**
- * Get temporary file path.(rmoveshortcut script, Packages list, Installer log)
- * @return temporary file path, if not exist removeshortcut file, return emptry string.
+ * Get temporary file path.(rmoveshortcut script, Packages list, Installer
+ * log)
+ *
+ * @return temporary file path, if not exist removeshortcut file, return
+ * emptry string.
*/
public String getRemoveShortCutPath() {
if (getRemoveShortCut() == null) {
return getRemoveShortCut().getAbsolutePath();
}
}
-
+
/**
* Get remove shortcut File instance.
+ *
* @return File instance of removeshortcut script.
*/
public File getRemoveShortCut() {
return removeShortCutFile;
}
-
+
/**
* Get Config instance
+ *
* @return
*/
public Config getConfig() {
return mConfig;
}
-
+
/**
- * Get PackageManager2 instance.
+ * Get PackageManager instance.
+ *
* @return
*/
- public PackageManager2 getPackageManager2() {
+ public PackageManager getPackageManager() {
return packageManager;
}
-
private void checkOldSDK() {
- if (Registry.getInstalledPath() == null || Registry.getInstalledPath().isEmpty()) {
+ if (Registry.getInstalledPath() == null
+ || Registry.getInstalledPath().isEmpty()) {
return;
}
-
+
File oldInfoDir = new File(Config.OLD_INFO_DIRECTORY_PATH);
-
+
if (oldInfoDir.exists()) {
moveOldInfoDirToCurrentInfoDir(oldInfoDir);
} else {
return;
}
}
-
+
private void moveOldInfoDirToCurrentInfoDir(File oldInfoDir) {
- File currentInfoDir = new File(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
+ File currentInfoDir = new File(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
if (!currentInfoDir.exists()) {
currentInfoDir.mkdirs();
}
-
- File oldInstalledList = new File(PathUtil.get(Config.OLD_INFO_DIRECTORY_PATH, Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
-
+
+ File oldInstalledList = new File(PathUtil.get(
+ Config.OLD_INFO_DIRECTORY_PATH,
+ Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+
if (oldInstalledList.exists()) {
File currentInstalledList = new File(PathUtil.get(
- PathUtil.getFromInstalledPath(
- Config.INFO_DIRECTORY), Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
PathUtil.move(oldInstalledList, currentInstalledList);
} else {
return;
}
-
- File[] oldPackageDir = new File(Config.OLD_INFO_REMOVESCRIPT_PATH).listFiles();
- for(File childFile : oldPackageDir) {
- File currentPackageDir = new File(PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY), childFile.getName()));
-
+
+ File[] oldPackageDir = new File(Config.OLD_INFO_REMOVESCRIPT_PATH)
+ .listFiles();
+ for (File childFile : oldPackageDir) {
+ File currentPackageDir = new File(PathUtil.get(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ childFile.getName()));
+
File parentDir = currentPackageDir.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
-
+
PathUtil.move(childFile, currentPackageDir);
}
-
- File[] oldInstalledFileList = new File(Config.OLD_INSTALLED_FILE_LIST_DIRECTORY_PATH).listFiles();
- for(File childFile : oldInstalledFileList) {
- File currentInstalledFile = new File(PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
- PathUtil.getFileNameWithOutExtension(childFile.getAbsolutePath()),
- childFile.getName()));
-
+
+ File[] oldInstalledFileList = new File(
+ Config.OLD_INSTALLED_FILE_LIST_DIRECTORY_PATH).listFiles();
+ for (File childFile : oldInstalledFileList) {
+ File currentInstalledFile = new File(PathUtil.get(PathUtil
+ .getFromInstalledPath(Config.INFO_DIRECTORY), PathUtil
+ .getFileNameWithOutExtension(childFile.getAbsolutePath()),
+ childFile.getName()));
+
File parentDir = currentInstalledFile.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
-
+
PathUtil.move(childFile, currentInstalledFile);
}
-
+
PathUtil.remove(oldInfoDir);
}
+
/**
* Download packages
*
- * @param packagesToDownload Set of packages to download
+ * @param packagesToDownload
+ * Set of packages to download
* @param monitor
* @return <code>true</code> if download success.
- * @throws IMExitException
+ * @throws IMExitException
*/
- private boolean downloadPackages(PackageSet downloadPkgSet, InstallProgressMonitor monitor) throws IMExitException {
+ public boolean downloadPackages(PackageSet downloadPkgSet,
+ InstallProgressMonitor monitor) throws IMExitException {
Log.log("InstallManager download start => " + downloadPkgSet);
-
+
long totalSize = 0;
- for(Package2 pkg : downloadPkgSet) {
+ for (Package pkg : downloadPkgSet) {
totalSize += pkg.getPackageSize();
}
monitor.beginTask("", total);
}
- for (Package2 pkg : downloadPkgSet) {
-
+ for (Package pkg : downloadPkgSet) {
+
if (monitor != null) {
monitor.setPackageName(pkg.getPackageName());
}
-
- if(monitor != null && monitor.isCanceled()) {
+
+ if (monitor != null && monitor.isCanceled()) {
Log.log("download canceled");
throw new IMInstallCancelException();
}
-
+
String fileName = pkg.getFileName();
boolean downloadResult = downloadPackage(pkg, PathUtil.getFromCurrDir(fileName), monitor);
-
+
if (!downloadResult) {
- Log.err("InstallManager download fail => "
- + pkg);
+ Log.err("InstallManager download fail => " + pkg);
return false;
}
}
-
+
if (monitor != null) {
monitor.workedProgressbar(100);
}
-
- if (Options.onlyDownload) {
- throw new IMExitException(Config.EXITCODE_ONLY_DOWNLOAD);
- }
return true;
}
* @param monitor
* @return <code>true</code> if success
*/
- public boolean downloadPackage(Package2 packageToDownload, String fileDownloadTargetPath,
- IIMProgressMonitor monitor) {
+ public boolean downloadPackage(Package packageToDownload,
+ String fileDownloadTargetPath, IIMProgressMonitor monitor) {
Log.log("Download package '" + packageToDownload + "'");
if (packageToDownload == null || fileDownloadTargetPath == null
|| fileDownloadTargetPath.isEmpty()) {
- Log.err("InstallManager.downloadPackage(): Invalid package: " + packageToDownload + ": This might be a bug of IM");
- throw new IMFatalException(ErrorCode.PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL);
+ Log.err("InstallManager.downloadPackage(): Invalid package: "
+ + packageToDownload + ": This might be a bug of IM");
+ throw new IMFatalException(
+ ErrorCode.PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL);
}
// Check cache foler
if (existInCacheFolder(packageToDownload, fileDownloadTargetPath)) {
if (monitor != null) {
- monitor.workedChecksum(packageToDownload.getPackageSize());
+ if (monitor.isCanceled()) {
+ throw new IMFatalException(ErrorCode.CANCEL);
+ } else {
+ monitor.workedChecksum(packageToDownload.getPackageSize());
+ }
}
Log.log("Found in cache");
return true;
}
-
- //TODO : refactoring.
+
+ // TODO : refactoring.
long size = 0;
- final int repeatCount = 3;
- for (int i = 0; i < repeatCount; i++) {
- Log.log("start download package: "+packageToDownload);
-
- URL packageUrl = packageToDownload.getURL();
- size = mDownloader.download(packageUrl, fileDownloadTargetPath, monitor);
-
- if (size >= 0) {
- Log.log("finish download");
- break;
- } else if (ErrorController.getErrorCode() == ErrorCode.NOT_LOGGED_IN) {
- Log.err("Login failed.");
- } else {
- Log.err("download failed : trial " + (i+1));
+ if (Options.onlyDownload) {
+ System.out.print("Downloading package => " + packageToDownload + " .......");
+ }
+ Log.log("start download package: " + packageToDownload);
+ URL packageUrl = packageToDownload.getURL();
+ size = mDownloader.download(packageUrl, fileDownloadTargetPath,
+ monitor);
+ if (size >= 0) {
+ if (Options.onlyDownload) {
+ System.out.println(" done.");
}
- }
- if (size < 0) {
+ Log.log("finish download");
+ } else {
Log.err("download failed => " + packageToDownload.getURL());
- throw new IMFatalException(ErrorController.getErrorCode());
+
+ String errMsg = "";
+ if (monitor.isCanceled()) {
+ errMsg = ErrorController.getErrorMessage();
+ } else {
+ errMsg = "Fail to get '" +
+ packageToDownload.getPackageName() + "'." +
+ "\n(" + ErrorController.getErrorMessage() + ")";
+ }
+ throw new IMFatalException(errMsg);
}
if (Options.doPackageValidation) {
throw new IMFatalException(ErrorCode.PACKAGE_WRONG_SIZE);
}
- //TODO :
+ // TODO :
if (!checkFileChecksum(packageToDownload,
mDownloader.getFileChecksum())) {
- Log.err("Package checksum error downloaded checksum => " + mDownloader.getFileChecksum());
+ Log.err("Package checksum error downloaded checksum => "
+ + mDownloader.getFileChecksum());
throw new IMFatalException(ErrorCode.PACKAGE_WRONG_CHECKSUM);
}
}
/**
* @param pkg
* @param filePath
- * @return <code>true</code> if the package is already downloaded to the file path
+ * @return <code>true</code> if the package is already downloaded to the
+ * file path
*/
- private boolean existInCacheFolder(Package2 pkg, String filePath) {
+ private boolean existInCacheFolder(Package pkg, String filePath) {
File file = new File(filePath);
if (!file.exists()) {
return false;
}
- if(Options.doPackageValidation) {
+ if (Options.doPackageValidation) {
return checkFileChecksum(pkg, Checksum.getSHA256(filePath));
} else {
return true;
}
}
- private boolean checkPackageSize(Package2 pkg, long size) {
+ private boolean checkPackageSize(Package pkg, long size) {
if (pkg.getPackageSize() == size) {
return true;
}
return false;
}
- private boolean checkFileChecksum(Package2 pkg, MessageDigest mDigest) {
+ private boolean checkFileChecksum(Package pkg, MessageDigest mDigest) {
if (pkg.getSHA256() == null || pkg.getSHA256().isEmpty()) {
return false;
}
if (mDigest.getAlgorithm().equals(Checksum.SHA_256_TYPE)) {
- return (pkg.getSHA256().equalsIgnoreCase(Checksum.messageDigestToString(mDigest)));
+ return (pkg.getSHA256().equalsIgnoreCase(Checksum
+ .messageDigestToString(mDigest)));
} else {
// TODO there's no checksum field in package.
return false;
/**
* Package installation management
*
- * @param pkg package to install.
- * @param targetDir target directory to install.
+ * @param pkg
+ * package to install.
+ * @param targetDir
+ * target directory to install.
* @param monitor
* @return
*/
- public boolean install(Package2 pkg, String targetDir,
- IIMProgressMonitor monitor) {
+ public boolean install(Package pkg, String targetDir,
+ IIMProgressMonitor monitor) {
Log.log("Install package '" + pkg + "'");
-
+
if (monitor != null) {
monitor.setPackageName(pkg.getPackageName());
}
- boolean isUpdatable = false;
- if (Options.useSnapShot) {
- isUpdatable = !packageManager.isInstalledVersion(pkg);
- } else {
- isUpdatable = packageManager.isUpdatable(pkg);
- }
-
- if (isUpdatable) {
- if(!removePackage(pkg, monitor)) {
- Log.err("InstallManager.install() Cannot remove Installed package => " + pkg);
- throw new IMFatalException(ErrorCode.CANNOT_REMOVE_PACKAGE);
- }
- }
-
Installer installer = new Installer();
boolean bResult = installer.install(pkg, targetDir, monitor);
if (bResult) {
- //save installed package list
+ // save installed package list
packageManager.addPackageToInstalledPackages(pkg);
packageManager.saveInstalledList(PathUtil.get(
- PathUtil.getFromInstalledPath(
- Config.INFO_DIRECTORY),
- Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
} else {
Log.err("InstallManager.install() install fail => " + pkg);
return false;
* @param targetDir
* @param monitor
* @return
- * @throws IMExitException
+ * @throws IMExitException
*/
public boolean install(PackageSet metasToInstall, String targetDir,
InstallProgressMonitor monitor) throws IMExitException {
+ targetDir);
return false;
}
-
+
PackageSet pkgsToInstall = null;
if (!Options.onlyDownload) {
-
+
// save target directory
initializeTargetDir(targetDir);
-
- //remove missing packages
+
+ // remove missing packages
removeMissingPackages(monitor);
+
+ // remove conflict packages
+ if (!removeConflictPackages(metasToInstall, monitor)) {
+ Log.err("Cannot remove conflict package");
+ throw new IMFatalException(
+ ErrorCode.CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES);
+ }
+
+ boolean result = false;
+ if (Options.snapshot) {
+ result = removeDifferentVersionPackages(metasToInstall, monitor);
+ } else {
+ result = removeUpdatablePackages(metasToInstall, monitor);
+ }
- //remove conflict packages
- removeConflictPackages(metasToInstall, monitor);
-
- //get All installable packages
- pkgsToInstall = packageManager.getToInstallPackagesInUpdate(metasToInstall);
- Log.log("Install packages: "+pkgsToInstall);
+ if (!result) {
+ Log.err("Cannot remove updatable package");
+ throw new IMFatalException(
+ ErrorCode.CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES);
+ }
+
+ // get All installable packages
+ pkgsToInstall = packageManager.getInstallablePackages(metasToInstall);
+ Log.log("Install packages: " + pkgsToInstall);
} else {
- pkgsToInstall = packageManager.dep(metasToInstall);
+ pkgsToInstall = packageManager.getDependsPackagesFromRepository(metasToInstall);
}
-
+
// download packages from repository
if (downloadPackages(pkgsToInstall, monitor)) {
Log.log("Success to download packages from repository");
if (Options.doRemovePackages) {
removePackagesDir();
}
-
+
Log.err("Fail to download packages from repository");
return false;
}
-
- // wait if cancel confirm dialog is showing. wait until user press button(cancel or not).
- while(monitor.checkCancelAndDisableCancelButton() == false) {
- if(monitor.isCanceled()) {
- throw new IMInstallCancelException();
+
+ // wait if cancel confirm dialog is showing. wait until user press
+ // button(cancel or not).
+ if (monitor != null) {
+ while (monitor.checkCancelAndDisableCancelButton() == false) {
+ if (monitor.isCanceled()) {
+ throw new IMInstallCancelException();
+ }
}
}
-
+
if (monitor != null) {
monitor.beginTask("Installing", pkgsToInstall.size() + 1);
}
installInstallManager();
int i = 0;
- for (Package2 pkg : pkgsToInstall) {
+ for (Package pkg : pkgsToInstall) {
if (monitor != null) {
monitor.worked(++i);
}
-
+
if (!install(pkg, targetDir, monitor)) {
Log.log("Installation fail => " + pkg);
throw new IMFatalException(ErrorCode.INSTALLATION_FAIL);
}
}
- //remove temp directory
+ // remove temp directory
String tempDir = targetDir + File.separator + Config.TEMP_DIRECTORY;
PathUtil.remove(tempDir);
- downloadReleaseNote();
-
// save config file
mConfig.saveConfig();
+
+ // save sdk version.
+ saveSDKVersion();
// Delete installed packages
- if(Options.doRemovePackages) {
+ if (Options.doRemovePackages) {
removePackagesDir();
}
- // move InstallMangaer to target directory
+ // move InstallManager to target directory
if (monitor != null) {
monitor.setFileName("Move to target directory...");
monitor.workedFileName();
}
private void removeMissingPackages(IIMProgressMonitor monitor) {
- PackageSet missingPackages = packageManager.getMissingPackagesWithDepends();
+ PackageSet missingPackages = packageManager
+ .getMissingPackagesFromRepository();
Log.log("Remove missing packages => " + missingPackages);
-
+
if (monitor != null) {
monitor.setPackageName("Remove Missing Packages");
}
-
- for (Package2 pkg : missingPackages) {
+
+ for (Package pkg : missingPackages) {
if (!removePackage(pkg, monitor)) {
Log.err("Cannot remove missing package");
- throw new IMFatalException(ErrorCode.CANNOT_REMOVE_MISSING_PACKAGE);
+ throw new IMFatalException(
+ ErrorCode.CANNOT_REMOVE_MISSING_PACKAGE);
}
}
}
-
- private void removeConflictPackages(PackageSet installableMetaPkgs, IIMProgressMonitor monitor) {
- PackageSet conflictPackages = packageManager.getToRemovePackagesInUpdate(installableMetaPkgs);
+
+ private boolean removeConflictPackages(PackageSet installableMetaPkgs,
+ IIMProgressMonitor monitor) {
+ PackageSet conflictPackages = packageManager
+ .getConflictPackagesInUpdate(installableMetaPkgs);
Log.log("Remove conflict packages => " + conflictPackages);
-
+
if (monitor != null) {
monitor.setPackageName("Remove Conflict Packages");
}
-
- if (!remove(conflictPackages)) {
- Log.err("Cannot remove conflict package");
- throw new IMFatalException(ErrorCode.CANNOT_REMOVE_CONFLICT_PACKAGE);
+
+ return remove(conflictPackages);
+ }
+
+ private boolean removeDifferentVersionPackages(PackageSet metasToInstall,
+ IIMProgressMonitor monitor) {
+ PackageSet updatablePackages = packageManager
+ .getdifferentVersionFromInstalledPackages(metasToInstall);
+
+ Log.log("Remove packages in snapshot => " + updatablePackages);
+
+ if (monitor != null) {
+ monitor.setPackageName("Remove updatable Packages");
}
+
+ return remove(updatablePackages);
}
-
+ private boolean removeUpdatablePackages(PackageSet metasToInstall,
+ IIMProgressMonitor monitor) {
+ PackageSet updatablePackages = packageManager
+ .getUpdatablepackagesInUpdate(metasToInstall);
+
+ Log.log("Remove updatable packages => " + updatablePackages);
+
+ if (monitor != null) {
+ monitor.setPackageName("Remove updatable Packages");
+ }
+
+ return remove(updatablePackages);
+ }
+
private boolean remove(PackageSet packages) {
- for (Package2 pkg : packages) {
-
+ for (Package pkg : packages) {
+
if (removePackage(pkg, null)) {
continue;
} else {
return false;
}
}
-
+
return true;
}
-
- /**
- * Downloads release note from one of the repositories. Uses the one first found.
- */
- private void downloadReleaseNote() {
- String[] repoPaths = mConfig.getRepositories();
-
- File targetFile = new File(PathUtil.getFromInstalledPath(Documents.RELEASE_NOTE_FILENAME));
-
- if (repoPaths != null) { // network install
- Log.log("Start downloading release note");
- String historyPath = "";
- for (String repoPath : repoPaths) {
- historyPath = repoPath + "/" + Documents.RELEASE_NOTE_FILENAME;
- URL repoUrl = null;
- try {
- repoUrl = new URL(historyPath);
- } catch (MalformedURLException e) {
- Log.ExceptionLog(e);
- Log.err("Invalid repository url: "+repoPath);
- throw new IMFatalException("Invalid repository url: "+repoPath);
- }
- Downloader dl = InstallManager.getDownloader();
- long size = dl.download(repoUrl, targetFile.getAbsolutePath(), null);
- if (size > 0) {
- Log.log("Success to download release note from : " + repoPath + " to : " + targetFile);
- break;
- } else {
- Log.log("Fail to download release note from : " + repoPath + " to : " + targetFile);
- }
- }
- } else { // local install
- // check release note exists
- File releaseNoteFile = new File(PathUtil.get(Config.PACKAGE_LIST_LOCAL_DIRECTORY,
- Documents.RELEASE_NOTE_FILENAME));
- if(releaseNoteFile.exists()) {
- try {
- PathUtil.copy(releaseNoteFile, targetFile);
- } catch (IOException e) {
- Log.err("Failed to copy release note file "+releaseNoteFile);
- // ignore
- }
- } else {
- Log.log("No release note file");
- // ignore
- }
- }
- }
/**
* Initializes target directory
// Keep target path in system
Registry.exportInstallPath(targetDir);
-
+
// Keep target path for later use
- mConfig.setTargetDir(targetDir);
-
- // Make .info directory
- if (!mConfig.makeInfoDirectory()) {
- Log.err(Config.CONFIG_HOME + " cannot create.");
- throw new IMFatalException(ErrorCode.CANNOT_CREATE_CONFIG_FILE);
- }
+ mConfig.setTargetDir(targetDir);
+
+ // Make .info directory
+ if (!mConfig.makeInfoDirectory()) {
+ Log.err(Config.CONFIG_HOME + " cannot create.");
+ throw new IMFatalException(ErrorCode.CANNOT_CREATE_CONFIG_FILE);
+ }
+ }
+
+ /**
+ * Save installed SDK version.
+ */
+ public void saveSDKVersion() {
+ Registry.saveInstallVersion(mConfig.getConfigFile().getInstallManagerVersion());
}
/**
*/
private void installInstallManager() {
Log.log("InstallManager.installInstallManager()");
-
+
// copy InstallManager to target directory
copyInstallManagerToTargetDirectory();
-
- //make icon
- StartMenu.createDesktopIcon();
- StartMenu.createInstallManagerIcon();
-
- //execute install script.
+
+ // make icon
+ StartMenu.createDesktopIcon();
+ StartMenu.createInstallManagerIcon();
+
+ // execute install script.
File installScript = getInstallScript();
- installScript.setExecutable(true);
-
- Installer installer = new Installer();
- try {
- installer.executeScript(installScript);
- } catch (IMShellCommandFail e) {
-
+ if (installScript != null) {
+ installScript.setExecutable(true);
+
+ Installer installer = new Installer();
+ try {
+ installer.executeScript(installScript);
+ } catch (IMShellCommandFail e) {
+
+ }
+ } else {
+ // when test works, install script does not need.
}
}
-
+
/**
* Get install script from resource according to each platform.
+ *
* @return
*/
private File getInstallScript() {
try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getTempFileFromResource(LINUX_INSTALL_MANAGER_INSTALL_SCRIPT, "install", ".sh");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return PathUtil.getTempFileFromResource(WINDOWS_INSTALL_MANAGER_INSTALL_SCRIPT, "install", ".vbs");
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return PathUtil.getTempFileFromResource(
+ LINUX_INSTALL_MANAGER_INSTALL_SCRIPT, "install", ".sh");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ return PathUtil.getTempFileFromResource(
+ WINDOWS_INSTALL_MANAGER_INSTALL_SCRIPT, "install",
+ ".vbs");
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ return null;
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
throw new IMFatalException(ErrorCode.CANNOT_CREATE_SHORTCUT);
}
}
-
+
private void removeInstallManager() {
Log.log("InstallManager.removeInstallManager");
-
- //execute remove script
+
+ // execute remove script
executeInstallManagerRemoveScript();
-
+
if (Registry.getInstalledPath().isEmpty()) {
return;
}
- //remove InstallManager's file
- PathUtil.remove(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER));
- PathUtil.remove(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY, Config.INSTALL_MANAGER_BINARY));
- PathUtil.remove(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY, Config.INSTALL_MANAGER_UPDATER_BINARY));
-
- //remove config file
- PathUtil.remove(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY, Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME));
-
- //remove InstallManager Directory
- File installManagerDir = new File(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY));
- File[] fileList = installManagerDir.listFiles();
- if (fileList == null || fileList.length <= 0) {
- PathUtil.remove(installManagerDir);
- }
+ // remove InstallManager's file
+ PathUtil.remove(PathUtil.getFromInstalledPath(
+ Config.INSTALL_MANAGER_DIRECTORY,
+ Config.INSTALL_MANAGER_UPDATER_BINARY));
+ PathUtil.remove(PathUtil.getFromInstalledPath(
+ Config.INSTALL_MANAGER_DIRECTORY,
+ Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER));
+ PathUtil.remove(PathUtil.getFromInstalledPath(
+ Config.INSTALL_MANAGER_DIRECTORY,
+ Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER_PARTNER));
+ PathUtil.remove(PathUtil
+ .getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY,
+ Config.INSTALL_MANAGER_BINARY));
+
+ // remove config file
+ PathUtil.remove(PathUtil.getFromInstalledPath(
+ Config.INSTALL_MANAGER_DIRECTORY,
+ Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME));
+
+ // remove InstallManager Directory
+ PathUtil.remove(PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DIRECTORY));
}
-
+
private void executeInstallManagerRemoveScript() {
File removeScript = getRemoveScript();
-
+
if (removeScript == null) {
return;
- }
-
+ }
+
removeScript.setExecutable(true);
-
+
Installer installer = new Installer();
try {
installer.executeScript(removeScript);
Log.ExceptionLog(e);
}
}
-
+
private File getRemoveScript() {
try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return PathUtil.getTempFileFromResource(LINUX_INSTALL_MANAGER_REMOVE_SCRIPT, "remove", ".sh");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return PathUtil.getTempFileFromResource(WINDOWS_INSTALL_MANAGER_REMOVE_SCRIPT, "remove", ".vbs");
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return PathUtil.getTempFileFromResource(
+ LINUX_INSTALL_MANAGER_REMOVE_SCRIPT, "remove", ".sh");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ return PathUtil
+ .getTempFileFromResource(
+ WINDOWS_INSTALL_MANAGER_REMOVE_SCRIPT,
+ "remove", ".vbs");
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ return null;
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
private void copyInstallManagerFiles(String from, String to) {
Log.log("Copy InstallManager files from " + from + " to " + to);
+ //copy execute file.
try {
- PathUtil.copy(new File(PathUtil.get(from, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER)),
- new File(PathUtil.get(to, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER)));
- new File(to + File.separator + Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER).setExecutable(true);
- PathUtil.copy(new File(PathUtil.get(from, "InstallManager.jar")),
- new File(PathUtil.get(to, "InstallManager.jar")));
- PathUtil.copy(new File(PathUtil.get(from, "InstallManagerUpdater.jar")),
- new File(PathUtil.get(to, "InstallManagerUpdater.jar")));
+ //copy execute file.
+ PathUtil.copy(
+ PathUtil.get(from,Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER),
+ PathUtil.get(to, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER));
+
+ //copy execute file for Parter SDK.
+ PathUtil.copy(
+ PathUtil.get(from,Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER_PARTNER),
+ PathUtil.get(to, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER_PARTNER));
+
+ //set executable authority.
+ new File(to + File.separator
+ + Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER)
+ .setExecutable(true);
+
+ //set executable authority.
+ new File(to + File.separator
+ + Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER_PARTNER)
+ .setExecutable(true);
+
+ //copy InstallManager.jar
+ PathUtil.copy(
+ PathUtil.get(from, "InstallManager.jar"),
+ PathUtil.get(to, "InstallManager.jar"));
+
+ //copy InstallManagerUpdater.jar
+ PathUtil.copy(
+ PathUtil.get(from, "InstallManagerUpdater.jar"),
+ PathUtil.get(to, "InstallManagerUpdater.jar"));
+
+ //copy installmanager.conf
+ PathUtil.copy(
+ PathUtil.get(from, Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME),
+ PathUtil.get(to, Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME));
} catch (IOException e) {
Log.err("Failed to copy Install Manager files");
}
}
private void removePackagesDir() {
- PathUtil.remove(Config.PACKAGE_LIST_LOCAL_DIRECTORY);
+ PathUtil.remove(Config.PACKAGE_BINARY_LOCAL_DIRECTORY_PATH);
}
/**
- * Package uninstallation management
+ * Package uninstallation management
+ *
* @param pkg
* @param monitor
* @return
*/
- public boolean removePackage(Package2 pkg, IIMProgressMonitor monitor) {
+ public boolean removePackage(Package pkg, IIMProgressMonitor monitor) {
Log.log("InstallManager package remove start => " + pkg);
if (pkg == null) {
if (monitor != null) {
monitor.setPackageName(pkg.getPackageName());
}
-
+
Installer installer = new Installer();
boolean bResult = installer.uninstall(pkg, monitor);
-
- //Remove packages in installed package list without result.
- //We don't know that failed packages are working well.
+
+ // Remove packages in installed package list without result.
+ // We don't know that failed packages are working well.
packageManager.exceptPackageFromInstalledPackages(pkg);
packageManager.saveInstalledList(PathUtil.get(
- PathUtil.getFromInstalledPath(
- Config.INFO_DIRECTORY),
- Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
-
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+
Log.log(pkg + " remove end => " + bResult);
return bResult;
}
/**
- * Packages uninstallation management
+ * Packages uninstallation management
+ *
* @param pkg
* @param monitor
* @return
*/
- public boolean removePackages(PackageSet metasToRemove, IIMProgressMonitor monitor) {
+ public boolean removePackages(PackageSet metasToRemove,
+ IIMProgressMonitor monitor) {
Log.log("InstallManager Packages remove Start => " + metasToRemove);
if (metasToRemove == null) {
return false;
}
- PackageSet pkgsToRemove = packageManager.getToRemovePackagesInRemove(metasToRemove);
- Log.log("Remove packages: "+pkgsToRemove);
-
+ PackageSet pkgsToRemove = packageManager
+ .getToRemovePackagesInRemove(metasToRemove);
+ Log.log("Remove packages: " + pkgsToRemove);
+
if (monitor != null) {
monitor.beginTask("Uninstalling...", pkgsToRemove.size() + 1);
}
-
+
int i = 0;
- for (Package2 pkg : pkgsToRemove) {
+ for (Package pkg : pkgsToRemove) {
if (monitor != null) {
monitor.worked(++i);
}
-
+
if (removePackage(pkg, monitor)) {
continue;
} else {
monitor.setFileName("Remove target directory...");
monitor.worked(pkgsToRemove.size());
}
-
+
if (packageManager.existInstalledPackages()) {
Log.log("Installed meta packages do not exist, but some packages exist.");
removeAll(monitor);
} else {
- //not exist to remove
+ // not exist to remove
removeSDK();
}
- } else {}//Donothing.
-
+ } else {
+ }// Donothing.
+
Log.log("InstallManager packages remove success. return => " + true);
return true;
}
-
+
/**
* Remove all of packages.
+ *
* @param monitor
*/
public void removeAll(IIMProgressMonitor monitor) {
Log.log("InstallManager.removeAll()");
-
+
PackageSet removablePackages = packageManager.getInstalledPackages();
-
- for (Package2 pkg : removablePackages) {
+
+ for (Package pkg : removablePackages) {
if (!removePackage(pkg, monitor)) {
Log.err("InstallManager.removeAll remove fail => " + pkg);
}
}
-
+
removeSDK();
}
// do not remove config home because it has log files
Log.log("InstallManager removeSDK end");
}
-
+
private void checkTargetDirAndRemove() {
File targetDir = new File(Registry.getInstalledPath());
if (canRemoveTargetDir(targetDir)) {
removeTargetDirectory();
} else {
- Log.err("Cannot delete target directory => " + targetDir.getAbsolutePath());
+ Log.err("Cannot delete target directory => "
+ + targetDir.getAbsolutePath());
}
}
-
+
/**
* Check status that target directory can remove or not.
+ *
* @param targetDir
* @return
*/
private boolean canRemoveTargetDir(File targetDir) {
if (targetDir.exists()) {
File[] fileList = targetDir.listFiles();
- if ((fileList == null || fileList.length <= 0)
- || (fileList.length == 1 && fileList[0].getName().equals(Config.INSTALL_MANAGER_DIRECTORY))) {
- ErrorController.setTargetDirEmpty(true);
+ if ((fileList == null || fileList.length <= 0)
+ || (fileList.length == 1 && fileList[0].getName().equals(
+ Config.OLD_INSTALL_MANAGER_DIRECTORY))) {
return true;
} else {
- Log.err("Target directory is not empty => " + fileList);
- ErrorController.setTargetDirEmpty(false);
+ ArrayList<String> fileNames = new ArrayList<String>();
+ for (File file : fileList) {
+ fileNames.add(file.getName());
+ }
+ Log.err("The SDK directory is not empty => " + fileNames);
return false;
}
} else {
- Log.err("Target direcotry is already removed");
+ Log.err("The SDK direcotry is already removed");
return false;
}
}
-
+
private void removeChangeLog() {
- File releaseNoteFile = new File(PathUtil.getFromInstalledPath(Config.RELEASE_NOTE));
-
+ File releaseNoteFile = new File(
+ PathUtil.getFromInstalledPath(Config.RELEASE_NOTE));
+
if (releaseNoteFile.exists()) {
PathUtil.remove(releaseNoteFile);
}
}
-
+
private void removeInfoDirectory() {
- //remove info directory in $HOME/.TizenSDK
- File infoDirFile = new File(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
+ // remove info directory in $HOME/tizen-sdk-data
+ File infoDirFile = new File(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
if (infoDirFile.exists()) {
PathUtil.remove(infoDirFile);
}
-
- //remove info directory in target directory
- File targetInfoFile = new File(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
-
+
+ // remove info directory in target directory
+ File targetInfoFile = new File(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY));
+
if (targetInfoFile.exists()) {
PathUtil.remove(targetInfoFile);
}
}
-
+
/**
* Remove target directory.
*/
public void removeTargetDirectory() {
Log.log("InstallManager remove target directory start");
-
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
PathUtil.remove(Registry.getInstalledPath());
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- if (!WindowsProgramController.removeRunningDir(Registry.getInstalledPath())) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ if (!WindowsProgramController.removeRunningDir(Registry
+ .getInstalledPath())) {
Log.err("Cannot remove target directory");
}
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
-
+
Log.log("InstallManager remove target directory end");
}
/**
* Singleton and global downloader shared and used by every components in IM
+ *
* @return singleton downloader object
*/
public static Downloader getDownloader() {
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.core;
import org.tizen.installmanager.lib.Registry;
import org.tizen.installmanager.lib.SDKPackageFormat;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
-import org.tizen.installmanager.pkg.model.Package2;
+import org.tizen.installmanager.pkg.model.Package;
import org.tizen.installmanager.util.IMShellCommandFail;
import org.tizen.installmanager.util.PathUtil;
import org.tizen.installmanager.util.ShellUtil;
-
/**
* This class manages lowlevel install/uninstall operations
- *
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
*/
public class Installer {
/**
- * Install a package to target directory.
- * @param pack Package to be installed.
- * @param targetDir Target directory to install.
- * @param monitor If you want to express in UI, implement IIMProgressMonitor and set this parametor.
- * if not, set <code>null</code>.
+ * Install a package to target directory.
+ *
+ * @param pack
+ * Package to be installed.
+ * @param targetDir
+ * Target directory to install.
+ * @param monitor
+ * If you want to express in UI, implement IIMProgressMonitor and
+ * set this parametor. if not, set <code>null</code>.
* @return <code>true</code>, if installation is success.
*/
- public boolean install(Package2 pack, String targetDir, IIMProgressMonitor monitor) {
- Log.log("**** installer install start => " + pack + ", target => " + targetDir);
-
- //unzip in temp dir
- String tempDir = PathUtil.get(targetDir, Config.TEMP_DIRECTORY);
-
- long unZipSize = unZipPackage(pack, tempDir, monitor);
-
- if (unZipSize <= 0) {
- Log.err("Unzip failed. => "+pack);
- PathUtil.remove(tempDir);
- throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
- }
- if (!checkUnzipSize(pack, unZipSize)) {
- Log.err("Unzip size error. => "+pack);
- PathUtil.remove(tempDir);
- throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
- }
-
- if (!moveToTargetDirectoryFromTempDirectory(tempDir, targetDir)) {
- PathUtil.remove(tempDir);
- Log.err("Moving temp to target failed. Remove temp and cancel installing.");
- throw new IMFatalException(ErrorCode.CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY);
- }
-
- List<File> missingFiles = findMissingFiles(pack);
- if(missingFiles.size() > 0) {
- Log.err("Some files are not moved properly: "+missingFiles);
- }
-
- executeInstallScript(pack, monitor, tempDir);
-
- //move removeScript file to special Directory
- File removeScriptFrom = new File(tempDir + File.separator + pack.getRemoveScript());
-
- if ((pack.getRemoveScript()!= null) && !(pack.getRemoveScript().equals("")) && (removeScriptFrom.exists())) {
- File removeScriptTo = new File(getRemoveScriptLocalPath(pack));
- if (!createRemoveScriptDir(removeScriptTo)) {
- Log.err("Cannot create remove script directory in Info directory => " + pack.getPackageName());
- return false;
- } else {
- if (removeScriptTo.exists()) {
- removeScriptTo.delete();
- }
- if (!PathUtil.moveFile(removeScriptFrom, removeScriptTo)) {
- Log.err("Cannot move removeScript to targetDir => " + pack.getPackageName());
- return false;
- }
- }
- }
- PathUtil.remove(tempDir);
- return true;
- }
-
-
- /**
- * @param pack
- * @return list of files which are not moved normally
- */
- private List<File> findMissingFiles(Package2 pack) {
+ public boolean install(Package pack, String targetDir,
+ IIMProgressMonitor monitor) {
+ Log.log("**** installer install start => " + pack + ", target => "
+ + targetDir);
+
+ // unzip in temp dir
+ String tempDir = PathUtil.get(targetDir, Config.TEMP_DIRECTORY);
+
+ long unZipSize = unZipPackage(pack, tempDir, monitor);
+
+ if (unZipSize <= 0) {
+ Log.err("Unzip failed. => " + pack);
+ PathUtil.remove(tempDir);
+ throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
+ }
+ if (!checkUnzipSize(pack, unZipSize)) {
+ Log.err("Unzip size error. => " + pack);
+ PathUtil.remove(tempDir);
+ throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
+ }
+
+ if (!moveToTargetDirectoryFromTempDirectory(tempDir, targetDir)) {
+ PathUtil.remove(tempDir);
+ Log.err("Moving temp to target failed. Remove temp and cancel installing.");
+ throw new IMFatalException(
+ ErrorCode.CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY);
+ }
+
+ List<File> missingFiles = findMissingFiles(pack);
+ if (missingFiles.size() > 0) {
+ Log.err("Some files are not moved properly: " + missingFiles);
+ }
+
+ executeInstallScript(pack, monitor, tempDir);
+
+ // move removeScript file to special Directory
+ File removeScriptFrom = new File(tempDir + File.separator
+ + pack.getRemoveScript());
+
+ if ((pack.getRemoveScript() != null)
+ && !(pack.getRemoveScript().equals(""))
+ && (removeScriptFrom.exists())) {
+ File removeScriptTo = new File(getRemoveScriptLocalPath(pack));
+ if (!createRemoveScriptDir(removeScriptTo)) {
+ Log.err("Cannot create remove script directory in Info directory => "
+ + pack.getPackageName());
+ return false;
+ } else {
+ if (removeScriptTo.exists()) {
+ removeScriptTo.delete();
+ }
+ if (!PathUtil.moveFile(removeScriptFrom, removeScriptTo)) {
+ Log.err("Cannot move removeScript to targetDir => "
+ + pack.getPackageName());
+ return false;
+ }
+ }
+ }
+ PathUtil.remove(tempDir);
+ return true;
+ }
+
+ /**
+ * @param pack
+ * @return list of files which are not moved normally
+ */
+ private List<File> findMissingFiles(Package pack) {
LinkedList<File> missingFiles = new LinkedList<File>();
File listFile = new File(getInstalledFileListPath(pack));
+ InputStream is = null;
+ BufferedReader in = null;
try {
- InputStream is = new FileInputStream(listFile);
- BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ is = new FileInputStream(listFile);
+ in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line;
- while((line = in.readLine()) != null) {
+ while ((line = in.readLine()) != null) {
File tmp = new File(PathUtil.getFromInstalledPath(line));
if (!tmp.exists()) {
- if(Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32) {
missingFiles.add(tmp);
- } else if(Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
// check if it is broken link
try {
- int exitCode = ShellUtil.execute("ls "+tmp, null);
- if(exitCode == 0) {
- Log.log("broken link "+tmp+" but no problem");
+ int exitCode = ShellUtil.execute("ls " + tmp, null);
+ if (exitCode == 0) {
+ Log.log("broken link " + tmp
+ + " but no problem");
} else {
Log.err(tmp + " not exist.");
missingFiles.add(tmp);
Log.ExceptionLog(e);
}
} else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ throw new IMFatalException(
+ ErrorCode.UNSUPPORTED_PLATFORM);
}
}
}
- } catch(IOException e) {
- Log.err("Installer.findMissingFiles() Cannot check file list: " + listFile.getAbsolutePath());
- throw new IMFatalException(ErrorCode.CANNOT_CHECK_INSTLLED_FILE_LIST);
+ } catch (IOException e) {
+ Log.err("Installer.findMissingFiles() Cannot check file list: "
+ + listFile.getAbsolutePath());
+ throw new IMFatalException(
+ ErrorCode.CANNOT_CHECK_INSTLLED_FILE_LIST);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
}
return missingFiles;
}
-
/**
* Set script running process' environment variables.
+ *
* @return Environment variables map
*/
- private Map<String, String> setEnvironmentVariable() {
- HashMap<String, String> env = new HashMap<String, String>();
-
- env.put("INSTALLED_PATH", Registry.getInstalledPath());
- env.put("MAKESHORTCUT_PATH", InstallManager.getInstance().getMakeShortCutPath());
- env.put("REMOVE_SHORTCUT", InstallManager.getInstance().getRemoveShortCutPath());
-
- return env;
+ private Map<String, String> setEnvironmentVariable() {
+ HashMap<String, String> env = new HashMap<String, String>();
+
+ env.put("INSTALLED_PATH", Registry.getInstalledPath());
+ env.put("MAKESHORTCUT_PATH", InstallManager.getInstance()
+ .getMakeShortCutPath());
+ env.put("REMOVE_SHORTCUT", InstallManager.getInstance()
+ .getRemoveShortCutPath());
+ env.put("USER_DATA_PATH", Config.getConfigHome());
+
+ if (Options.partnerSdk) {
+ env.put("PARTNER_SDK", "partner");
+ } else {
+ env.put("PARTNER_SDK", "");
+ }
+
+ return env;
}
-
- private long unZipPackage(Package2 pkg, String tempDir, IIMProgressMonitor monitor) {
- String filePath = PathUtil.getFromCurrDir(pkg.getFileName());
-
- File pkgFile = new File(filePath);
- if (!pkgFile.exists()) {
- Log.err(filePath + " doesn't exist");
- throw new IMFatalException(ErrorCode.CANNOT_FIND_FILE_IN_LOCAL);
- }
-
- SDKPackageFormat format = SDKPackageFormat.createSDKPackageFormat();
-
- //Each packages are saved installed list to file
- String installedFileListPath = getInstalledFileListPath(pkg);
-
- format.setFileOutput(installedFileListPath);
-
- return format.unZip(filePath, tempDir, monitor);
- }
-
- private String getRemoveScriptLocalPath(Package2 pkg) {
- return PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY), pkg.getPackageName(), pkg.getRemoveScript());
- }
-
- private String getInstalledFileListPath(Package2 pkg) {
- return PathUtil.get(PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY), pkg.getPackageName(), (pkg.getPackageName() + ".list"));
- }
-
- private boolean moveToTargetDirectoryFromTempDirectory(String tempDir, String targetDir) {
- Log.log("Move temp to target");
- File fromFile = new File(tempDir + File.separator + Config.DATA_DIRECTORY);
- if (!fromFile.exists()) {
- Log.err("Data directory is not exist in package.");
- return true;
- }
- File toFile = new File(targetDir);
-
- File[] fromList = fromFile.listFiles();
-
- if (fromList == null) {
- return false;
- }
-
- for(int i=0; i<fromList.length; i++) {
- boolean ret = false;
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- ret = PathUtil.copyHardLink(fromList[i], toFile);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- ret = PathUtil.move(fromList[i], new File(toFile, fromList[i].getName()));
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- if (!ret) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Uninstalls the given package
- * @param pkg package to be uninstalled
- * @param monitor
- * @return true if success. false if fatal error.
- delete failure is checked and sets error status in ErrorController but still returns true.
- if file to be deleted doesn't exist, it's not considered error.
- */
- public boolean uninstall(Package2 pkg, IIMProgressMonitor monitor) {
- Log.log("Installer uninstall start");
- int resultRemoveScript = executeRemoveScript(pkg, monitor);
-
- if (resultRemoveScript == 0) {
- Log.log("Execute remove script success.");
- } else if (resultRemoveScript == 1) {
- Log.err("Execute remove script fail.");
- } else if (resultRemoveScript == 2) {
- Log.log("This package does not need a remove script.");
- }
-
- File installedFileList = new File(getInstalledFileListPath(pkg));
-
- if (!installedFileList.exists()) {
- ErrorController.setError(ErrorCode.CANNOT_FIND_INSTALLED_FILE_LIST);
- return false;
- }
-
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(installedFileList));
-
- String line = null;
- Stack<File> dirStack = new Stack<File>();
- while((line = reader.readLine()) != null) {
- File deleteFile = new File(PathUtil.getFromInstalledPath(line));
-
- if (deleteFile.isDirectory()) {
- File[] listFiles = deleteFile.listFiles();
-
- if (listFiles == null || listFiles.length <= 0) {
- deleteIfExists(deleteFile);
- } else {
- dirStack.push(deleteFile);
- }
- } else {
- deleteIfExists(deleteFile);
- }
- }
-
-
- while(!dirStack.isEmpty()) {
- File deleteDir = dirStack.pop();
- File[] listFiles = deleteDir.listFiles();
-
- if (listFiles == null || listFiles.length <= 0) {
- deleteIfExists(deleteDir);
- }
- }
+
+ private long unZipPackage(Package pkg, String tempDir,
+ IIMProgressMonitor monitor) {
+ String filePath = PathUtil.getFromCurrDir(pkg.getFileName());
+
+ File pkgFile = new File(filePath);
+ if (!pkgFile.exists()) {
+ Log.err(filePath + " doesn't exist");
+ throw new IMFatalException(ErrorCode.CANNOT_FIND_FILE_IN_LOCAL);
+ }
+
+ SDKPackageFormat format = SDKPackageFormat.createSDKPackageFormat();
+
+ // Each packages are saved installed list to file
+ String installedFileListPath = getInstalledFileListPath(pkg);
+
+ format.setFileOutput(installedFileListPath);
+
+ return format.unZip(filePath, tempDir, monitor);
+ }
+
+ private String getRemoveScriptLocalPath(Package pkg) {
+ return PathUtil.get(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ pkg.getPackageName(), pkg.getRemoveScript());
+ }
+
+ private String getInstalledFileListPath(Package pkg) {
+ return PathUtil.get(
+ PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
+ pkg.getPackageName(), (pkg.getPackageName() + ".list"));
+ }
+
+ private boolean moveToTargetDirectoryFromTempDirectory(String tempDir,
+ String targetDir) {
+ Log.log("Move temp to target");
+ File fromFile = new File(tempDir + File.separator
+ + Config.DATA_DIRECTORY);
+ if (!fromFile.exists()) {
+ Log.err("Data directory is not exist in package.");
+ return true;
+ }
+ File toFile = new File(targetDir);
+
+ File[] fromList = fromFile.listFiles();
+
+ if (fromList == null) {
+ return false;
+ }
+
+ for (int i = 0; i < fromList.length; i++) {
+ boolean ret = false;
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ ret = PathUtil.copyHardLink(fromList[i], toFile);
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ ret = PathUtil.move(fromList[i],
+ new File(toFile, fromList[i].getName()));
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ ret = PathUtil.copyHardLink(fromList[i], toFile);
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ if (!ret) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Uninstalls the given package
+ *
+ * @param pkg
+ * package to be uninstalled
+ * @param monitor
+ * @return true if success. false if fatal error. delete failure is checked
+ * and sets error status in ErrorController but still returns true.
+ * if file to be deleted doesn't exist, it's not considered error.
+ */
+ public boolean uninstall(Package pkg, IIMProgressMonitor monitor) {
+ Log.log("Installer uninstall start");
+ int resultRemoveScript = executeRemoveScript(pkg, monitor);
+
+ if (resultRemoveScript == 0) {
+ Log.log("Execute remove script success.");
+ } else if (resultRemoveScript == 1) {
+ Log.err("Execute remove script fail.");
+ } else if (resultRemoveScript == 2) {
+ Log.log("This package does not need a remove script.");
+ }
+
+ File installedFileList = new File(getInstalledFileListPath(pkg));
+
+ if (!installedFileList.exists()) {
+ ErrorController.setError(ErrorCode.CANNOT_FIND_INSTALLED_FILE_LIST);
+ return false;
+ }
+
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(installedFileList));
+
+ String line = null;
+ Stack<File> dirStack = new Stack<File>();
+ while ((line = reader.readLine()) != null) {
+ File deleteFile = new File(PathUtil.getFromInstalledPath(line));
+
+ if (deleteFile.isDirectory()) {
+ File[] listFiles = deleteFile.listFiles();
+
+ if (listFiles == null || listFiles.length <= 0) {
+ deleteIfExists(deleteFile);
+ } else {
+ dirStack.push(deleteFile);
+ }
+ } else {
+ deleteIfExists(deleteFile);
+ }
+ }
+
+ while (!dirStack.isEmpty()) {
+ File deleteDir = dirStack.pop();
+ File[] listFiles = deleteDir.listFiles();
+
+ if (listFiles == null || listFiles.length <= 0) {
+ deleteIfExists(deleteDir);
+ }
+ }
} catch (FileNotFoundException e) {
Log.err("File not found => " + installedFileList.getAbsolutePath());
} catch (IOException e) {
Log.err("IO Exception => " + installedFileList.getAbsolutePath());
return false;
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ return false;
} finally {
try {
if (reader != null) {
reader.close();
- deleteIfExists(installedFileList);
+ deleteIfExists(installedFileList);
}
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
Log.err("Close fileoutput fail.");
}
}
- return true;
- }
-
- /**
- * Delete the <code>file</code>
- * @param file
- */
- private void deleteIfExists(File file) {
- if (!file.delete()) {
- Log.err("Delete fail -> " + file.getAbsolutePath());
- }
- }
-
- private boolean checkUnzipSize(Package2 pack, long size) {
- // TODO : impl. not supported
- return true;
- }
-
- private boolean createRemoveScriptDir(File removeScript) {
- File parentDir = removeScript.getParentFile();
-
- if (!parentDir.exists()) {
- return parentDir.mkdirs();
- } else {
- return true;
- }
- }
-
- private boolean executeInstallScript(Package2 pack,
+ return true;
+ }
+
+ /**
+ * Delete the <code>file</code>
+ *
+ * @param file
+ */
+ private void deleteIfExists(File file) {
+ if (!file.delete()) {
+ Log.err("Delete fail -> " + file.getAbsolutePath());
+ }
+ }
+
+ private boolean checkUnzipSize(Package pack, long size) {
+ // TODO : impl. not supported
+ return true;
+ }
+
+ private boolean createRemoveScriptDir(File removeScript) {
+ File parentDir = removeScript.getParentFile();
+
+ if (!parentDir.exists()) {
+ return parentDir.mkdirs();
+ } else {
+ return true;
+ }
+ }
+
+ private boolean executeInstallScript(Package pack,
IIMProgressMonitor monitor, String tempDir) {
- if (pack.getInstallScript() != null && !pack.getInstallScript().equals("")) {
- String command = PathUtil.get(tempDir, pack.getInstallScript());
- File scriptFile = new File(command);
-
- if (scriptFile.exists()) {
- Log.log("Execute install script");
-
- if (monitor != null) {
- monitor.setFileName(scriptFile.getName());
- monitor.workedFileName();
- }
- try {
- return executeScript(scriptFile);
- } catch (IMShellCommandFail e) {
- Log.ExceptionLog(e);
- throw new IMFatalException(ErrorCode.INSTALL_SCRIPT_FATAL_ERROR);
- }
- } else {
- Log.log(pack.getPackageName() + " does not have install script");
- }
- }
- return true;
+ if (pack.getInstallScript() != null
+ && !pack.getInstallScript().equals("")) {
+ String command = PathUtil.get(tempDir, pack.getInstallScript());
+ File scriptFile = new File(command);
+
+ if (scriptFile.exists()) {
+ Log.log("Execute install script");
+
+ if (monitor != null) {
+ monitor.setFileName(scriptFile.getName());
+ monitor.workedFileName();
+ }
+ try {
+ return executeScript(scriptFile);
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(
+ ErrorCode.INSTALL_SCRIPT_FATAL_ERROR);
+ }
+ } else {
+ Log.log(pack.getPackageName() + " does not have install script");
+ }
+ }
+ return true;
}
-
-
- private int executeRemoveScript(Package2 pkg, IIMProgressMonitor monitor) {
- Log.log("executeRemoveScript => " + pkg.getRemoveScript());
-
- //execute remove script
+
+ private int executeRemoveScript(Package pkg, IIMProgressMonitor monitor) {
+ Log.log("executeRemoveScript => " + pkg.getRemoveScript());
+
+ // execute remove script
String script = PathUtil.get(getRemoveScriptLocalPath(pkg));
File scriptFile = new File(script);
try {
if (executeScript(scriptFile)) {
- return 0; // succeed to execute remove script.
+ return 0; // succeed to execute remove script.
} else {
return 1; // fail to execute remove script.
}
throw new IMFatalException(ErrorCode.REMOVE_SCRIPT_FATAL_ERROR);
}
}
- return 2; // package does not need remove script.
- }
-
- /**
- * Executes the file with default environment variables
- * @param scriptFile
- * @return <code>true</code> if success
- * @throws IMShellCommandFail
- */
- public boolean executeScript(File scriptFile) throws IMShellCommandFail {
- scriptFile.setExecutable(true);
- Map<String, String>env = setEnvironmentVariable();
-
- String command = scriptFile.getAbsolutePath();
- if (PathUtil.getFileExtension(command).equalsIgnoreCase(".vbs")) {
- command = "wscript.exe " + command;
- }
-
- int exitCode = ShellUtil.execute(command, env, null, new LoggerShellParser());
-
- // check exit code
- if(exitCode == 0) {
- return true;
- } else if(exitCode > 0 && exitCode < 10) {
- Log.err("Exit code => " + Integer.toString(exitCode));
- return false;
- } else {
- Log.err("Installer.executeScript() install script error => " + scriptFile.getAbsolutePath());
- Log.err("Exit code => " + Integer.toString(exitCode));
- throw new IMFatalException(ErrorCode.INSTALL_SCRIPT_FATAL_ERROR);
- }
- }
+ return 2; // package does not need remove script.
+ }
+
+ /**
+ * Executes the file with default environment variables
+ *
+ * @param scriptFile
+ * @return <code>true</code> if success
+ * @throws IMShellCommandFail
+ */
+ public boolean executeScript(File scriptFile) throws IMShellCommandFail {
+ scriptFile.setExecutable(true);
+ Map<String, String> env = setEnvironmentVariable();
+
+ String command = ShellUtil.addInterpreter(scriptFile.getAbsolutePath());
+
+ int exitCode = ShellUtil.execute(command, env, null,
+ new LoggerShellParser());
+
+ // check exit code
+ if (exitCode == 0) {
+ return true;
+ } else if (exitCode > 0 && exitCode < 10) {
+ Log.err("Exit code => " + Integer.toString(exitCode));
+ return false;
+ } else {
+ Log.err("Installer.executeScript() install script error => "
+ + scriptFile.getAbsolutePath());
+ Log.err("Exit code => " + Integer.toString(exitCode));
+ throw new IMFatalException(ErrorCode.INSTALL_SCRIPT_FATAL_ERROR);
+ }
+ }
}
public static String userConfPath = null;
/**
+ * update installmanager.
+ * If <code>doUpdateInstallManager</code> is false, do not update installmanager binary.
+ */
+ public static boolean doUpdateInstallManager = true;
+ /**
* Do replace repository.
* If <code>doRepository</code> is true, change repository address to <code>repo</code> variable.
*/
- public static boolean doRepository = false;
+ public static boolean doReplaceRepository = false;
/**
* Do remove packages after installation
public static boolean doRemovePackages = true;
/**
+ * Do remove old sdk.
+ * If installer cannot update sdk, <code>doRemoveOldSDK</code> is true.
+ */
+ public static boolean doRemoveOldSDK = false;
+ /**
* Just check installer is available for update.
*/
public static boolean checkPackageUpdate = false;
/**
* Use Snapshot file.
*/
- public static boolean useSnapShot = false;
+ public static boolean snapshot = false;
public static String repo = null;
- public static String packageList = null;
+ public static String snapshotPath = null;
+
+ /**
+ * Use only download for making SDK image.
+ */
+ public static String boundary = null; // all, public, partner
+ public static String platForm = null;
+ public static int platFormBit = 0;
+
+ /**
+ * See all snapshots
+ */
+ public static boolean allSnapshots = false;
+
+ /**
+ * Support Partner SDK
+ */
+ public static boolean partnerSdk = false;
+ public static String purposeOfInstalling = "public";
+ /**
+ * Display InstallManager Version
+ */
+ public static boolean showVersion = false;
/**
* User-provided proxy server
}
} else if(arg.equals("-noRemovePackages")) {
doRemovePackages = false;
- } else if(arg.equals("-updated")) {
- // -updated means this execution is run again after self-updating
+ } else if(arg.equals("-skipUpdate")) {
+ doUpdateInstallManager = false;
} else if(arg.equals("-checkPackageUpdate")) {
checkPackageUpdate = true;
} else if(arg.equals("-printDepGraph")) {
Log.err("-proxy requires proxy description");
throw new IMFatalException(ErrorCode.PROXY_NOT_PROVIDED);
}
- } else if (arg.equals("-useSnapShot")) {
+ } else if (arg.equals("-snapShot")) {
if(iter.hasNext()) {
- useSnapShot = true;
- repo = iter.next();
- Log.log("User-provided repository: "+repo);
+ snapshot = true;
+ snapshotPath = iter.next();
+ Log.log("User-provided repository: " + repo);
} else {
- Log.err("-useSnapShot requires repository description");
+ Log.err("-snapShot requires repository description");
throw new IMFatalException(ErrorCode.USESNAPSHOT_REPOSITORY_NOT_PROVIDED);
}
+ } else if (arg.equals("-allSnapshots")) {
+ allSnapshots = true;
+ Log.log("Using '-allSnapshots' option, all snapshots are displaying.");
} else if (arg.equals("-onlyDownload")) {
if(iter.hasNext()) {
onlyDownload = true;
- packageList = iter.next();
- Log.log("User-provided package list: "+packageList);
+ boundary = iter.next();
+ platForm = iter.next().toLowerCase();
+ platFormBit = Integer.parseInt(iter.next());
+ Log.log("Only download boundary : "+ boundary);
} else {
Log.err("-onlyDownload requires packageList description");
throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
}
onlyDownload = true;
+ } else if (arg.equals("-version")) {
+ showVersion = true;
+ Log.log("Using '-version' option, display InstallManager version on console.");
} else if (arg.equals("-noRemoveTempTizenSDK")) {
doRemoveTempTizenSDK = false;
} else if (arg.equals("-repository")) {
if(iter.hasNext()) {
- doRepository = true;
+ doReplaceRepository = true;
repo = iter.next();
Log.log("replace repository : "+repo);
} else {
Log.err("-replaceRepository requires repository description");
throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
}
+ } else if (arg.equals("-removeOldSDK")) {
+ doRemoveOldSDK = true;
+ } else {
+ Log.err("InstallManager do not support '" + arg + "' option");
+ throw new IMFatalException(ErrorCode.WRONG_OPTION);
}
}
} catch(Throwable e) {
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.core;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedHashMap;
+
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.ConfigFile;
+import org.tizen.installmanager.pkg.model.PackageSet;
+
+/**
+ * This class can manages extension information
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public class SDKExtensionInfo {
+
+ private static SDKExtensionInfo sdkExtensionInfo = null;
+ //member variable
+ LinkedHashMap<String, String> userExtensionRepositories = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> builtInExtensionRepositories = new LinkedHashMap<String, String>();
+
+ //member func
+ private SDKExtensionInfo() {
+ load();
+ }
+
+ public boolean add(String name, String packageRepo) {
+ if (name == null || !checkPackageRepo(packageRepo)) {
+ return false;
+
+ } else {
+ if (contains(packageRepo)) {
+ return false;
+ }
+ userExtensionRepositories.put(packageRepo, name);
+ return true;
+ }
+ }
+
+ public boolean contains(String packageRepo) {
+ return userExtensionRepositories.containsKey(packageRepo);
+ }
+
+ public boolean containsBuiltIn(String packageRepo) {
+ return builtInExtensionRepositories.containsKey(packageRepo);
+ }
+
+ public void remove(String packageRepo) {
+ if (contains(packageRepo)) {
+ userExtensionRepositories.remove(packageRepo);
+ }
+ }
+
+ public void save() {
+ ConfigFile confFile = Config.getInstance().getConfigFile();
+
+ confFile.setExtensionServer(userExtensionRepositories.toString());
+
+ Config.getInstance().saveConfig();
+ }
+
+ public void load() {
+ String extensionInfo = Config.getInstance().getConfigFile().getExtensionServer();
+ String builtInExtensionInfo = Config.getInstance().getConfigFile().getBuiltInExtensionServer();
+
+ builtInExtensionRepositories = parseLocationInformationToMap(builtInExtensionInfo);
+ userExtensionRepositories = parseLocationInformationToMap(extensionInfo);
+ }
+
+ public boolean checkPackageRepo(String packageRepo) {
+ try {
+ new URL(packageRepo);
+ return true;
+ } catch (MalformedURLException e) {
+ Log.err("Extension package server is not URL format.(" + packageRepo +")");
+ return false;
+ }
+ }
+
+ private LinkedHashMap<String, String> parseLocationInformationToMap(String info) {
+ LinkedHashMap<String, String> extensionInformation = new LinkedHashMap<String, String>();
+ if (info.startsWith("{")) {
+ info = info.substring(1);
+ }
+
+ if (info.endsWith("}")) {
+ info = info.substring(0, info.length() -1);
+ }
+
+ String[] properties = info.split(",");
+
+ for(String property : properties) {
+ String[] nameValue = property.split("=");
+
+ if (nameValue.length == 2) {
+ extensionInformation.put(nameValue[0], nameValue[1]);
+ }
+ }
+ return extensionInformation;
+ }
+
+ public PackageSet getExtensionPackages() {
+ PackageManager pm = PackageManager.getInstance();
+
+ if (pm == null) {
+ return PackageSet.EMPTY;
+ } else {
+ try {
+ //Get all extension repositories.
+ LinkedHashMap<String, String> extensionRepositories = new LinkedHashMap<String, String>();
+ extensionRepositories.putAll(builtInExtensionRepositories);
+ extensionRepositories.putAll(userExtensionRepositories);
+
+ pm.loadExtensionPackages(extensionRepositories.keySet());
+ return pm.getRootMetaPackagesOfExtensionServer();
+
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ return PackageSet.EMPTY;
+ }
+ }
+ }
+
+ public LinkedHashMap<String, String> getExtensionRepositories() {
+ return userExtensionRepositories;
+ }
+
+ public LinkedHashMap<String, String> getBuiltInExtensionRepositories() {
+ return builtInExtensionRepositories;
+ }
+
+ public static SDKExtensionInfo getInstance() {
+ if (sdkExtensionInfo == null) {
+ sdkExtensionInfo = new SDKExtensionInfo();
+ }
+
+ return sdkExtensionInfo;
+ }
+}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.core;
import java.net.URL;
import org.tizen.installmanager.lib.Downloader;
-import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.pkg.model.ConfigFile;
import org.tizen.installmanager.pkg.model.Version;
import org.tizen.installmanager.util.PathUtil;
import org.tizen.installmanager.util.ShellUtil;
-
-
/**
- * This class checks the update of Install Manager itself, download it, and invokes updater process to replace the current binary.
+ * This class checks the update of Install Manager itself, download it, and
+ * invokes updater process to replace the current binary.
+ *
* @author Wooyoung Cho <wooyoung1.cho@samsung.com>
- *
+ *
*/
public class UpdateInstallManager {
-
+
private ConfigFile mCurrentConfig = null;
private ConfigFile mRepositoryConfig = null;
-
+
private Downloader mDownloader = null;
public UpdateInstallManager() {
}
private boolean setCurrentConfig() {
- InstallManager.getInstance().loadConfig();
- mCurrentConfig = InstallManager.getInstance().getConfig().getConfigFile();
-
- if(mCurrentConfig != null) {
+ InstallManager.getInstance().initConfig();
+ mCurrentConfig = InstallManager.getInstance().getConfig()
+ .getConfigFile();
+
+ if (mCurrentConfig != null) {
return true;
} else {
return false;
}
}
-
+
/**
* Download configuration file from repository and set to instance.
+ *
* @return true if success
*/
public boolean setRepositoryConfig() {
if (repository.isEmpty()) {
return false;
} else {
- String repositoryConfigPath = repository + "/" + Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME;
-
+ String repositoryConfigPath = repository + "/"
+ + Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_NAME;
+
URL repositoryConfigUrl;
try {
repositoryConfigUrl = new URL(repositoryConfigPath);
return false;
}
String downloadedConfigPath = downloadConfigFileFromRepository(repositoryConfigUrl);
- if(downloadedConfigPath != null) {
+ if (downloadedConfigPath != null) {
mRepositoryConfig = new ConfigFile(downloadedConfigPath);
return true;
} else {
}
}
}
-
+
/**
* @param repositoryConfigUrl
- * @return path to the conf file downloaded to local from the url. null if failed
+ * @return path to the conf file downloaded to local from the url. null if
+ * failed
*/
private String downloadConfigFileFromRepository(URL repositoryConfigUrl) {
- Log.log("Download conf file from repo: "+repositoryConfigUrl);
-
+ Log.log("Download conf file from repo: " + repositoryConfigUrl);
+
File tmpFile;
try {
tmpFile = File.createTempFile("installmanager.repository", ".conf");
Log.log("Cannot create temp file for conf file of repository");
return null;
}
-
+
String configToLocal = tmpFile.getAbsolutePath();
- int repeatCount = 3;
- for (int i=0; i<repeatCount; i++) {
- long size = mDownloader.download(repositoryConfigUrl, configToLocal, null);
+ long size = mDownloader.download(repositoryConfigUrl,
+ configToLocal, null);
- if (size >= 0) {
- return configToLocal;
- } else if (ErrorController.getErrorCode() == ErrorCode.NOT_LOGGED_IN) {
- Log.log("Login failed.");
- } else {
- Log.log("Download failed.");
- return null;
- }
+ if (size >= 0) {
+ return configToLocal;
+ } else {
+ Log.log("Download failed.");
+ return null;
}
- Log.log("Download failed.");
- return null;
}
-
+
private boolean downloadInstallManager() {
- String downloadInstallManagerPath = PathUtil.getFromCurrDir(Config.TEMP_DIRECTORY, Config.INSTALL_MANAGER_BINARY);
- Log.log("Download install manager: "+downloadInstallManagerPath);
-
+ String downloadInstallManagerPath = PathUtil.getFromCurrDir(
+ Config.TEMP_DIRECTORY, Config.INSTALL_MANAGER_BINARY);
+ Log.log("Download install manager: " + downloadInstallManagerPath);
+
File downloadInstallManagerFile = new File(downloadInstallManagerPath);
if (downloadInstallManagerFile.exists()) {
downloadInstallManagerFile.delete();
- } else {}
-
+ } else {
+ }
+
File parentDir = downloadInstallManagerFile.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
- } else {}
-
+ } else {
+ }
+
URL serverIntallManager = null;
try {
- serverIntallManager = new URL(mCurrentConfig.getInstallManagerRepository() + "/" + Config.INSTALL_MANAGER_BINARY);
+ serverIntallManager = new URL(
+ mCurrentConfig.getInstallManagerRepository() + "/"
+ + Config.INSTALL_MANAGER_BINARY);
} catch (MalformedURLException e) {
Log.log("Invalid install manager repository url");
return false;
}
- if (mDownloader.download(serverIntallManager, downloadInstallManagerPath, null) <= 0) {
+ if (mDownloader.download(serverIntallManager,
+ downloadInstallManagerPath, null) <= 0) {
Log.err("Failed to download install manager binary");
- return false;
+ return false;
} else {
Log.log("install manager binary download success");
return true;
}
}
-
+
private boolean downloadUpdater() {
- String path = PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_UPDATER_BINARY);
- Log.log("Download install manager updater to: "+path);
-
+ String path = PathUtil
+ .getFromCurrDir(Config.INSTALL_MANAGER_UPDATER_BINARY);
+ Log.log("Download install manager updater to: " + path);
+
File file = new File(path);
if (file.exists()) {
file.delete();
- } else {}
-
+ } else {
+ }
+
File parentDir = file.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
- } else {}
-
+ } else {
+ }
+
URL url = null;
try {
- url = new URL(mCurrentConfig.getInstallManagerRepository() +
- "/" + Config.INSTALL_MANAGER_UPDATER_BINARY);
+ url = new URL(mCurrentConfig.getInstallManagerRepository() + "/"
+ + Config.INSTALL_MANAGER_UPDATER_BINARY);
} catch (MalformedURLException e) {
Log.log("Invalid install manager repository url");
return false;
}
if (mDownloader.download(url, path, null) <= 0) {
Log.err("Failed to download install manager binary");
- return false;
+ return false;
} else {
Log.log("install manager updater binary download success");
return true;
}
}
-
- private void updateInstallManager(String newInstallManager, String oldInstallManager) throws IMExitException {
- String updaterPath = PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_UPDATER_BINARY);
-
- String command = "java -jar " + updaterPath + " " +
- newInstallManager + " " + oldInstallManager;
-
+
+ private void updateInstallManager(String newInstallManager,
+ String oldInstallManager){
+ String updaterPath = PathUtil
+ .getFromCurrDir(Config.INSTALL_MANAGER_UPDATER_BINARY);
+
+ String command = "java -jar " + updaterPath + " " + newInstallManager
+ + " " + oldInstallManager;
+
if (!Options.getArgsStr().isEmpty()) {
command = command + " " + Options.getArgsStr();
}
-
+
Process proc = ShellUtil.asyncExecute(command);
-
+
if (proc != null) {
Log.err("Exit for update");
- throw new IMExitException(Config.EXITCODE_HAS_SELF_UPDATE);
} else {
Log.err("Running updater failed");
}
}
-
+
/**
* Reads current config file and new config file.
+ *
* @return <code>true</code> if success
*/
private boolean init() {
boolean result = setCurrentConfig();
- if(!result) {
+ if (!result) {
// if current config file does not exist, it's fatal error
Log.err("UpdateInstallManager.init() Cannot read config file");
throw new IMFatalException("Cannot read config file");
} else {
Log.log("Sucess to read current config file.");
}
-
+
result = setRepositoryConfig();
- if(!result) {
+ if (!result) {
Log.log("Cannot read config file from Install Manager repository. Ignore it.");
return false;
}
-
- if (mRepositoryConfig.getRepository() != null && !mRepositoryConfig.getRepository().isEmpty()) {
+
+ if (mRepositoryConfig.getRepository() != null
+ && !mRepositoryConfig.getRepository().isEmpty()) {
mCurrentConfig.setRepository(mRepositoryConfig.getRepository());
}
+
+ if (mCurrentConfig.getDistribution().isEmpty()) {
+ mCurrentConfig.setDistribution(mRepositoryConfig.getDistribution());
+ }
+
mCurrentConfig.saveConfig(mCurrentConfig.getConfigPath());
-
return true;
}
-
+
/**
* check and try to update install manager itself
- * @throws IMExitException thrown if there's new version of IM
+ *
+ * @throws IMExitException
+ * thrown if there's new version of IM
*/
- public void update() throws IMExitException {
+ public boolean update(){
Log.log("check install manager update");
- if(!init()) {
+ if (!init()) {
Log.log("Cannot read repository config file");
- return;
+ return false;
}
-
+
if (isUpdatable()) {
Log.log("Install Manager is updatable");
-
+
boolean bResult;
bResult = updateUpdater();
if (bResult == false) {
Log.err("Updating Install Manager Updater failed");
- return;
+ return false;
}
-
+
bResult = downloadInstallManager();
-
+
if (bResult == true) {
- //update config file
- mCurrentConfig.setInstallManagerVersion(mRepositoryConfig.getInstallManagerVersion());
+ // update config file
+ mCurrentConfig.setInstallManagerVersion(mRepositoryConfig
+ .getInstallManagerVersion());
mCurrentConfig.saveConfig(mCurrentConfig.getConfigPath());
-
- String newInstallManager = PathUtil.getFromCurrDir(Config.TEMP_DIRECTORY, Config.INSTALL_MANAGER_BINARY);
- String oldInstallManager = PathUtil.getFromCurrDir(Config.INSTALL_MANAGER_BINARY);
-
+
+ String newInstallManager = PathUtil.getFromCurrDir(
+ Config.TEMP_DIRECTORY, Config.INSTALL_MANAGER_BINARY);
+ String oldInstallManager = PathUtil
+ .getFromCurrDir(Config.INSTALL_MANAGER_BINARY);
+
updateInstallManager(newInstallManager, oldInstallManager);
+ return true;
} else {
- return;
+ return false;
}
} else {
Log.log("no install manager update");
- return;
+ return false;
}
}
-
+
private boolean updateUpdater() {
boolean result = downloadUpdater();
- if(!result) {
+ if (!result) {
Log.err("Downloading Install Manager Updater failed");
return false;
} else {
if (mCurrentConfig == null || mRepositoryConfig == null) {
return false;
} else {
- String currentVersion = mCurrentConfig.getInstallManagerVersion();
- String repositoryVersion = mRepositoryConfig.getInstallManagerVersion();
-
+ String currentVersion = mCurrentConfig.getInstallManagerVersion();
+ String repositoryVersion = mRepositoryConfig
+ .getInstallManagerVersion();
+
if (currentVersion.equals("") || repositoryVersion.equals("")) {
return false;
} else {
import org.eclipse.swt.widgets.Button;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
-import org.tizen.installmanager.ui.page.CompletePage;
+import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.util.PathUtil;
-
/**
* Manages Documents for InstallManager.
* @author Yongsung Kim<yongsung1.kim@samsung.com>
*
*/
public class Documents {
- public static final String RELEASE_NOTE_FILENAME = "RELEASE_NOTE.txt";
+ public static final String RELEASE_NOTE_FILENAME = "release-note.html";
private static String OPEN_SOURCE_LICENSE_NAME = "Tizen_OpenSource_License_Information.pdf";
private static String OPEN_SOURCE_LICENCE_PATH = PathUtil.get("/res", OPEN_SOURCE_LICENSE_NAME);
* @return boolean
*/
public static boolean isChecked() {
- Button btn = CompletePage.getChkBtn();
+ Button btn = InstallManagerWindow.getInstallManagerWindow().getCompletePage().getChkBtn();
return btn.getSelection();
}
/**
* show the change log(history).
*/
- public static void ShowChangeLog() {
- String historyPath = PathUtil.getFromInstalledPath(RELEASE_NOTE_FILENAME);
- File history = new File(historyPath);
- if (history.exists()) {
- try {
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().open(history);
- }
- } catch (IOException e1) {
- Log.err("Cannot open history");
- }
- }
+ public static void showChangeLog() {
+ String releaseNotePath = PathUtil.getFromInstalledPath(RELEASE_NOTE_FILENAME);
+ File releaseNote = new File(releaseNotePath);
+
+ if (releaseNote.exists()) {
+ if (Desktop.isDesktopSupported()) {
+ Log.log("Desktop.isDesktopSupported() is true.");
+ try {
+ Desktop.getDesktop().open(releaseNote);
+ Log.log("Success to open release note. => " + releaseNotePath);
+ } catch (IOException e) {
+ Log.err("cannot open release note. => " + releaseNotePath);
+ Log.ExceptionLog(e);
+ }
+ } else {
+ Log.err("Desktop.isDesktopSupported() is false.");
+ }
+ } else {
+ Log.log("Release note not found. => " + releaseNotePath);
+ }
}
/**
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
+import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
+import java.util.NoSuchElementException;
+
+import javax.net.ssl.SSLHandshakeException;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.core.Options;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+
+
/**
* Manages downloading from url.
*
private MessageDigest mDigest;
private URLConnection mConnection = null;
- private int connectTimeout = 1000; // connection timeout: 1 sec
+ private final int CONNECT_TIMEOUT = 10000; // connection timeout: 10 sec
+ private final int READ_TIMEOUT = 20000; // connection timeout: 20 sec
+ private final int CONNECT_THREAD_JOIN_TIMEOUT = 11000; //// connection thread timeout: 11 sec
private String mUser = "";
private String mPassword = "";
}
if (!connect(sUrl) || mConnection == null) {
+ Log.err("Network connection error.\n" + sUrl);
return ERROR;
}
try {
input = mConnection.getInputStream();
} catch (FileNotFoundException e) {
- ErrorController.setError(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
- Log.err("Cannot find file => " + sUrl.toExternalForm());
+ Log.ExceptionLog(e);
+ int index = sUrl.toString().lastIndexOf("/");
+ String errUrl =sUrl.toString().substring(0, index);
+ String errorMsg = ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY.getErrorMessage()
+ + "\n(URL = " + errUrl + ")";
+ ErrorController.setErrorMessage(errorMsg);
return ERROR;
- } catch (SocketTimeoutException timeoutException) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- Log.err(ErrorController.getErrorMessage());
+ } catch (SocketTimeoutException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.SERVER_CONNECTION_TIME_OUT);
return ERROR;
} catch (NoRouteToHostException e) {
+ Log.ExceptionLog(e);
ErrorController.setError(ErrorCode.NO_ROUTE_TO_HOST);
Log.err(ErrorController.getErrorMessage());
return ERROR;
} catch (SocketException e) {
+ Log.ExceptionLog(e);
ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
Log.err(ErrorController.getErrorMessage());
return ERROR;
} catch (IOException e) {
+ Log.ExceptionLog(e);
if (e.getClass().toString().indexOf("FtpLoginException") >= 0) {
ErrorController.setError(ErrorCode.NOT_LOGGED_IN);
Log.err(ErrorController.getErrorMessage());
return ERROR;
}
-
- Log.ExceptionLog(e);
+
ErrorController.setError(ErrorCode.CANNOT_DOWNLOAD_FILE);
Log.err(ErrorController.getErrorMessage());
return ERROR;
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ ErrorController.setErrorMessage(e.getMessage());
+ return ERROR;
}
File destFile = new File(localPath);
if (!destFile.isAbsolute()) {
return ERROR;
}
-
+
File parentDir = destFile.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
try {
destFile.createNewFile();
} catch (IOException e) {
- Log.err("Can not create download file");
+ Log.ExceptionLog(e);
ErrorController.setError(ErrorCode.CANNOT_CREATE_DOWNLOAD_FILE);
return ERROR;
}
try {
output = new FileOutputStream(destFile);
} catch (FileNotFoundException e) {
- Log.err("Can not create download file");
+ Log.ExceptionLog(e);
ErrorController.setError(ErrorCode.CANNOT_CREATE_DOWNLOAD_FILE);
return ERROR;
}
long beginMS = System.currentTimeMillis();
try {
- mDigest.reset();
+ if (mDigest != null) {
+ mDigest.reset();
+ } else {
+ //TODO : Consider this condition later.
+ }
+ Log.log("File download start.");
while (totalWriteSize < totalFileSize) {
if (input.available() > 0) {
int inputReadSize = input.read(buf);
}
long endMS = System.currentTimeMillis();
- if (endMS > (beginMS + 5000)) {
+ if (endMS > (beginMS + READ_TIMEOUT)) {
+ Log.err("Can not be read during 20 seconds.");
ErrorController
.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
return ERROR;
}
}
- } catch (SocketTimeoutException timeoutException) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ } catch (SocketTimeoutException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.SERVER_CONNECTION_TIME_OUT);
return ERROR;
} catch (IOException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.ERROR);
+ return ERROR;
+ } catch (Exception e) {
+ Log.ExceptionLog(e);
ErrorController.setError(ErrorCode.ERROR);
return ERROR;
- } finally {
+ }
+ finally {
try {
if (input != null) {
input.close();
}
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+
+ try {
if (output != null) {
output.close();
}
} catch (IOException e) {
- Log.err("Downloader download fail to close output stream.");
+ Log.ExceptionLog(e);
// ignore
}
}
* @return <code>true</code> if connect success.
*/
public boolean connect(URL aUrl) {
- if (!isAvailableURL(aUrl)) {
- return false;
- }
-
- boolean bRet = false;
- URL url = null;
- try {
- if (!mUser.equals("") || !mPassword.equals("")) {
- String fullUrl = aUrl.getProtocol() + PROTOCOL_SEPARATOR
- + mUser + USER_PASSWORD_SEPARATOR + mPassword
- + ID_SEPARATOR + aUrl.getHost() + aUrl.getPath();
-
- url = new URL(fullUrl);
- } else {
- url = aUrl;
+ if (isAvailableURL(aUrl)) {
+ boolean bRet = false;
+ URL url = null;
+ try {
+ if (!mUser.equals("") || !mPassword.equals("")) {
+ String fullUrl = aUrl.getProtocol() + PROTOCOL_SEPARATOR
+ + mUser + USER_PASSWORD_SEPARATOR + mPassword
+ + ID_SEPARATOR + aUrl.getHost() + aUrl.getPath();
+
+ url = new URL(fullUrl);
+ } else {
+ url = aUrl;
+ }
+
+ bRet = connection(url);
+
+ } catch (MalformedURLException e) {
+ Log.ExceptionLog(e);
+ return false;
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ return false;
}
-
- bRet = connection(url);
-
- } catch (MalformedURLException e) {
- Log.ExceptionLog(e);
- return false;
- } catch (Exception e) {
- Log.ExceptionLog(e);
+
+ return bRet;
+ } else {
return false;
}
-
- return bRet;
}
private boolean isAvailableURL(URL url) {
socketAddress = getSocketAddress(url.getHost(), port);
} catch (IMFatalException e) {
- throw new IMFatalException(e.getMessage() + "\n(Repository: " + url
- + ").");
+ Log.ExceptionLog(e);
+ return false;
}
if (socketAddress == null) {
}
}
- private boolean connection(final URL url) {
+ private boolean connection(URL url) {
Log.log("Connect to " + url);
+ boolean bRet = false;
+ if (NetworkProxy.useProxy) {
+ bRet = connectWithProxy(url);
+
+ if (!bRet) {
+ bRet = connectWithDirect(url);
+
+ if (bRet) {
+ NetworkProxy.useProxy = false;
+ }
+ }
+ } else {
+ bRet = connectWithDirect(url);
+
+ if (!bRet) {
+ bRet = connectWithProxy(url);
+
+ if (bRet) {
+ NetworkProxy.useProxy = true;
+ }
+ }
+ }
+
+ return bRet;
+ }
+
+ private boolean connectWithProxy(URL url) {
String protocol = url.getProtocol();
Config conf = InstallManager.getInstance().getConfig();
-
+
boolean bRet = false;
-
- // connect with proxy.
- if (protocol.startsWith("file")) { // local url
+ if (protocol.startsWith("file")) {
Log.log("Connect to local path.");
- return connectToURL(url, Proxy.NO_PROXY);
+ bRet = connectToURL(url, Proxy.NO_PROXY);
} else if (Options.proxy != null) {
Log.log("Connect to repository with '-proxy' option.");
} else { // system proxy
Log.log("Connect to repository with system proxy.");
- List<Proxy> proxyList = getSystemProxyList(url);
+ List<Proxy> proxyList = NetworkProxy.getSystemProxyList(url);
for (Proxy proxy : proxyList) {
if (bRet = connectToURL(url, proxy)) {
break;
}
}
-
- // no proxy.
- if (!bRet) {
- Log.log("Connect to repository with http direct.");
- Proxy directProxy = NetworkProxy.getInstance()
- .getHttpDirectProxy(url);
-
- bRet = connectToURL(url, directProxy);
- }
}
-
+
return bRet;
}
+
+ private boolean connectWithDirect(URL url) {
+ boolean bRet = false;
+
+ String protocol = url.getProtocol();
+ if (protocol.startsWith("file")) {
+ Log.log("Connect to local path.");
+ bRet = connectToURL(url, Proxy.NO_PROXY);
- private boolean connectToURL(URL url, Proxy proxy) {
- try {
- mConnection = url.openConnection(proxy);
-
- // set connetion timeout
- if (mConnection != null) {
- mConnection.setConnectTimeout(connectTimeout);
- }
-
- mConnection.connect();
-
- } catch (ConnectException e) {
- Log.ExceptionLog(e);
- if (proxy.toString().equalsIgnoreCase("DIRECT")) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- } else {
- ErrorController.setError(ErrorCode.PROXY_CONNECT_ERROR);
- }
-
- } catch (NoRouteToHostException e) {
- Log.ExceptionLog(e);
- if (proxy.toString().equalsIgnoreCase("DIRECT")) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- } else {
- ErrorController.setError(ErrorCode.PROXY_CONNECT_ERROR);
- }
-
- return false;
-
- } catch (SocketTimeoutException e) {
- Log.ExceptionLog(e);
- if (proxy.toString().equalsIgnoreCase("DIRECT")) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- } else {
- ErrorController.setError(ErrorCode.PROXY_CONNECT_ERROR);
- }
+ } else {
+ Proxy directProxy = NetworkProxy.getHttpDirectProxy(url);
+ bRet = connectToURL(url, directProxy);
+ }
+
+ return bRet;
+ }
- return false;
+ private boolean connectToURL(final URL url, final Proxy proxy) {
- } catch (SocketException e) {
+ ConnectionThread connectionThread = new ConnectionThread(url, proxy);
+
+ connectionThread.setDaemon(true);
+ connectionThread.start();
+
+ try {
+ connectionThread.join(CONNECT_THREAD_JOIN_TIMEOUT);
+ } catch (InterruptedException e) {
Log.ExceptionLog(e);
- if (proxy.toString().equalsIgnoreCase("DIRECT")) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- } else {
- ErrorController.setError(ErrorCode.PROXY_CONNECT_ERROR);
- }
-
+ }
+
+ if (!connectionThread.getConnectionResult()) {
return false;
-
- } catch (FileNotFoundException e) {
- Log.ExceptionLog(e);
- ErrorController.setError(ErrorCode.CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY);
+ }
+
+ if (connectionThread.isAlive()) {
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ Log.err("Cannot connect to server (URL => " + url +"). Connection thread still alive.");
+ Log.err("proxy => " + proxy);
return false;
- } catch (IOException e) {
- Log.ExceptionLog(e);
+ }
+
+ if (!checkConnectionStatus(mConnection)) {
return false;
}
return true;
}
}
-
- /**
- * Get the proxy to be used for download files. Proxy is searched in the
- * following order. - User-provided proxy using -proxy option. - Proxy
- * specified in installmanager.conf file. - If both of above are not
- * provided, return direct connection proxy.
- *
- * @return proxy to be used. never <code>null</code>.
- */
- private List<Proxy> getSystemProxyList(final URL url) {
-
- NetworkProxy netProxy = NetworkProxy.getInstance();
-
- // get system proxy from NetworkProxy class
- List<Proxy> proxyList = netProxy.select(url);
- if (proxyList == null) {
- throw new IMFatalException(ErrorCode.INTERNET_CONNECTION_ERROR);
+
+ private boolean checkConnectionStatus(URLConnection connection) {
+ if (connection == null) {
+ return false;
} else {
- Log.log("Proxy list => " + proxyList);
- return proxyList;
+ String protocol = connection.getURL().getProtocol();
+ if (protocol.equalsIgnoreCase("http")) {
+ return checkHttpConnectionStatus(connection);
+ } else if (protocol.equalsIgnoreCase("ftp")) {
+ return true;
+ } else {
+ return true;
+ }
}
}
+
+ private boolean checkHttpConnectionStatus(URLConnection connection) {
+ HttpURLConnection httpCon = (HttpURLConnection)connection;
+
+ int responseCode;
+ String responseMessage = "";
+ try {
+ responseCode = httpCon.getResponseCode();
+ responseMessage = httpCon.getResponseMessage();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ return false;
+ }
+
+ Log.log(Integer.toString(responseCode));
+ Log.log(responseMessage);
+
+ switch(responseCode) {
+ case HttpURLConnection.HTTP_OK :
+ return true;
+ case HttpURLConnection.HTTP_NOT_FOUND :
+ ErrorController.setError(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
+ break;
+ case HttpURLConnection.HTTP_UNAUTHORIZED :
+ ErrorController.setError(ErrorCode.HTTP_ERROR_MESSAGE_401);
+ break;
+ case HttpURLConnection.HTTP_FORBIDDEN :
+ ErrorController.setError(ErrorCode.HTTP_ERROR_MESSAGE_403);
+ break;
+ case -1 :
+ Log.err("Http response code returns -1(null). It looks a Linux bug.");
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ break;
+ default :
+ String errMsg = "Server connection failed." +
+ "\nError message : " +
+ responseMessage +
+ "(Code number=" + Integer.toString(responseCode) + ")";
+ ErrorController.setErrorMessage(errMsg);
+ break;
+ }
+
+ return false;
+ }
private Proxy getOptionalProxy() {
Config conf = InstallManager.getInstance().getConfig();
return mConnection.getContentLength();
}
+
+ class ConnectionThread extends Thread {
+ URL url = null;
+ Proxy proxy = null;
+
+ boolean connectionResult = false;
+
+ public ConnectionThread(URL url, Proxy proxy) {
+ this.url = url;
+ this.proxy = proxy;
+ }
+
+ public void run() {
+ try {
+ if (url != null) {
+ mConnection = url.openConnection(proxy);
+ }
+
+ // set connetion timeout
+ if (mConnection != null) {
+ mConnection.setConnectTimeout(CONNECT_TIMEOUT);
+ mConnection.setReadTimeout(READ_TIMEOUT);
+ mConnection.connect();
+ }
+
+ connectionResult = true;
+ } catch (ConnectException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+
+ } catch (NoRouteToHostException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+
+ } catch (SocketTimeoutException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.SERVER_CONNECTION_TIME_OUT);
+
+ } catch (SocketException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+
+ } catch (FileNotFoundException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY);
+
+ } catch (SSLHandshakeException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.NOT_SUPPORT_HTTPS_PROTOCOL);
+
+ } catch (NoSuchElementException e) {
+ Log.ExceptionLog(e);
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ public boolean getConnectionResult() {
+ return connectionResult;
+ }
+ }
}
*
*/
public enum ErrorCode {
- CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY("Cannot find Package.list file in repository."),
- CANNOT_FIND_CONFIG_FILE("Cannot find installmanager.conf file."),
- CANNOT_FIND_FILE_IN_REPOSITROY("Cannot find file in repository. The package server could be being updated."),
- CANNOT_CREATE_DOWNLOAD_FILE("Cannot create file to download."),
- CANNOT_CHECK_INSTLLED_FILE_LIST("Cannot check installed file list."),
- CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY("Cannot move file to target directory."),
- CANNOT_CONNECT_TO_PROXY_SERVER("Cannot connect to proxy server."),
- WRONG_PACKAGE_URL("URLs of packages are invalid."),
- CANCEL("Download is canceled."),
- ERROR("Error occurred from unknown cause."),
- UNKNOWN_PACKAGE_EXTENSION("not supported pakckage extension"),
+ CANNOT_FIND_CONFIG_FILE("The installmanager.conf file not found."),
+ CANNOT_FIND_FILE_IN_REPOSITROY("Cannot connect to SDK package server."),
+ CANNOT_CREATE_DOWNLOAD_FILE("Download file cannot be created."),
+ CANNOT_CHECK_INSTLLED_FILE_LIST("Installed file list cannot be checked."),
+ CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY("File cannot be moved to the target directory."),
+ CANNOT_CONNECT_TO_PROXY_SERVER("Proxy server connection fails."),
+ WRONG_PACKAGE_URL("Package URLs are invalid."),
+ CANCEL("Download canceled."),
+ ERROR("Unknown error."),
+ UNKNOWN_PACKAGE_EXTENSION("Package extension not supported."),
INVALID_PACKAGE_VERSION("Invalid package version."),
- CANNOT_FIND_INSTALLABLE_OR_REMOVABLE_PACKAGES("Cannot find installable or removable packages. The network connection might be failed."),
- CANNOT_FIND_FILE_IN_LOCAL("Cannot find file in local."),
- CANNOT_SAVE_CONFIG("Cannot save config file."),
- CANNOT_CREATE_SHORTCUT("Cannot create shortcut."),
- CANNOT_CREATE_INSTALL_LIST("Cannot create install list."),
- CANNOT_CREATE_CONFIG_FILE("Cannot create config directory or files."),
- CANNOT_FIND_USER_CONFIG_FILE("Cannot find user config file"),
- CANNOT_REGISTER_TARGET_DIR("Cannot register a target directory"),
- CANNOT_PARSING_TEXT("Cannot parsing installmanager.conf or Package.list file"),
- CANNOT_SAVE_PROPERTY_FILE("Cannot save installmanager.conf or Package.file"),
- CANNOT_UNPACK_PACKAGE("Cannot unpack package.zip file"),
- CANNOT_CREATE_RESOURCE("Cannot create resource file."),
- CANNOT_FIND_PACKAGE("Cannot find required packages. The package server might be invalid."),
- CANNOT_REMOVE_PACKAGE("Cannot remove package."),
- CANNOT_REMOVE_CONFLICT_PACKAGE("Cannot remove conflict package."),
- CANNOT_REMOVE_MISSING_PACKAGE("Cannot remove missing package."),
- CANNOT_ACCESS_FILE("Cannot access file."),
- CANNOT_REMOVE_OLDSDK("Cannot remove old SDK"),
- COPY_FILE_IS_FAIL("Copy file to target directory is failed."),
- OLD_TIZEN_SDK_EXISTS("Old version(Tizen SDK) is installed. Remove it first and run Tizen SDK Install Manager again."),
- UNSUPPORTED_PLATFORM("Platform is not supported"),
- REMOVE_SCRIPT_NOT_EXISTS("Remove script not exists."),
- REMOVE_SCRIPT_FATAL_ERROR("Fatal error occurred while uninstalling Tizen SDK."),
- INSTALLATION_FAIL("Installation is Failed."),
- INSTALL_CANCELED("Installation is canceled"),
- INSTALLED_VERSION_IS_HIGH("Installed package's version is high. Cannot progress installation."),
- CANNOT_CREATE_FILE("Cannot create file"),
- THREAD_INTERRUPTED("Execution is interrupted"),
- CIRCULAR_PACKAGE_DEPENDENCY("Circular package dependency is detected"),
-
+ CANNOT_FIND_INSTALLABLE_OR_REMOVABLE_PACKAGES("Install or uninstall packages not found. Network connection may have failed."),
+ CANNOT_FIND_FILE_IN_LOCAL("Local file not found."),
+ CANNOT_SAVE_CONFIG("Configuration file cannot be saved."),
+ CANNOT_CREATE_SHORTCUT("Shortcut creation failed."),
+ CANNOT_CREATE_INSTALL_LIST("Install list creation failed."),
+ CANNOT_CREATE_CONFIG_FILE("Configuration directory or file creation failed."),
+ CANNOT_FIND_USER_CONFIG_FILE("User configuration file creation failed."),
+ CANNOT_REGISTER_TARGET_DIR("Target directory registration failed."),
+ CANNOT_PARSING_TEXT("Configuration file parsing failed."),
+ CANNOT_SAVE_PROPERTY_FILE("The installmanager.conf or Package file cannot be saved."),
+ CANNOT_UNPACK_PACKAGE("The package.zip file unpackaging failed."),
+ CANNOT_CREATE_RESOURCE("Resource file creation failed."),
+ CANNOT_FIND_PACKAGE("Required packages not found. The package server may be invalid."),
+ CANNOT_REMOVE_PACKAGE("Package removal failed."),
+ CANNOT_REMOVE_MISSING_PACKAGE("Missing package cannot be removed."),
+ CANNOT_ACCESS_FILE("File access failed."),
+ CANNOT_REMOVE_OLDSDK("Old SDK removal failed."),
+ COPY_FILE_IS_FAIL("Copying the file to the target directory failed."),
+ OLD_TIZEN_SDK_EXISTS("Old Tizen SDK is installed. Remove the old SDK and run the Tizen SDK Install Manager again."),
+ UNSUPPORTED_PLATFORM("Platform not supported."),
+ REMOVE_SCRIPT_NOT_EXISTS("Removal script not found."),
+ REMOVE_SCRIPT_FATAL_ERROR("Fatal error occurred while uninstalling the Tizen SDK."),
+ INSTALLATION_FAIL("Installation failed."),
+ INSTALL_CANCELED("Installation canceled."),
+ INSTALLED_VERSION_IS_HIGH("Installation progress failed due to high installed package version."),
+ CANNOT_CREATE_FILE("File creation failed."),
+ THREAD_INTERRUPTED("Thread execution interrupted."),
+ CIRCULAR_PACKAGE_DEPENDENCY("Circular package dependency detected."),
+
+ //Configuration file error
+ CONFIG_CANNOT_PARSING_PACKAGE_LIST("Package list cannot be read. Check the repository or proxy server."),
+ CONFIG_CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY("Package list file not found in the repository."),
+ CONFIG_CANNOT_REMOVE_CONFLICT_PACKAGES("Conflict package removal failed."),
+ CONFIG_CANNOT_REMOVE_UPDATABLE_PACKAGES("Updatable package removal failed."),
+ CONFIG_CANNOT_READ_SERVER_TYPE("Server type cannot be read. Check the server type in the installmanager.conf file."),
+
//Package error
- PACKAGE_WRONG_SIZE("Size of package is wrong."),
+ PACKAGE_WRONG_SIZE("Package size incorrect."),
PACKAGE_WRONG_CHECKSUM("Package file checksum error."),
- PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL("Installable or removable packages do not exist."),
- INSTALL_SCRIPT_NOT_EXISTS("There are no install script files."),
- INSTALL_SCRIPT_FATAL_ERROR("Fatal error occurred while installing Tizen SDK."),
+ PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL("Install or uninstall package not found."),
+ INSTALL_SCRIPT_NOT_EXISTS("Install script files not found."),
+ INSTALL_SCRIPT_FATAL_ERROR("Fatal error occurred while installing the Tizen SDK."),
// Network error
- INTERNET_CONNECTION_ERROR("Fail to connect to server. Please check your network status or try again with '-proxy <address>:<port>'."),
- PROXY_NOT_PROVIDED("Proxy setting is not provided. Use option '-proxy <proxy-address>:<port>'."),
- PROXY_SERVER_IS_WRONG("Cannot connect to proxy server. Please check your proxy server."),
- PROXY_CONNECT_ERROR("Fail to connect to your proxy server. Please check it."),
- URL_SECURITY_EXCEPTION("There are some security problem with proxy."),
- URL_ADDRESS_IS_WRONG("Wrong address."),
- URL_PORT_IS_WRONG("Wrong port number."),
- NO_ROUTE_TO_HOST("Cannot find server. Please check url."),
- NOT_LOGGED_IN("Cannot login."),
+ INTERNET_CONNECTION_ERROR("Server connection failed. Check the network status or try again with the '-proxy <address>:<port>'."),
+ SERVER_CONNECTION_TIME_OUT("Server connection timed out."),
+ PROXY_NOT_PROVIDED("Proxy setting missing. Use the '-proxy <proxy-address>:<port>' option."),
+ PROXY_SERVER_IS_WRONG("Proxy server connection failed. Check the proxy server."),
+ PROXY_CONNECT_ERROR("Proxy server connection failed. Check the proxy server."),
+ URL_SECURITY_EXCEPTION("Proxy server URL security error."),
+ URL_ADDRESS_IS_WRONG("Incorrect URL."),
+ URL_PORT_IS_WRONG("Incorrect port number."),
+ NO_ROUTE_TO_HOST("Server not found. Check the URL."),
+ NOT_LOGGED_IN("Login failed."),
+ NOT_SUPPORT_HTTPS_PROTOCOL("HTTPS not supported."),
+
+ //Http Socket error message
+ HTTP_ERROR_MESSAGE_403("403 Forbidden is returned by http protocol. " +
+ "The server can be reached, but the server declined to allow access to the page."),
+ HTTP_ERROR_MESSAGE_401("Server requires authentication."),
+
+ //option
+ WRONG_OPTION("Incorrect option. Check it."),
+ USESNAPSHOT_REPOSITORY_NOT_PROVIDED("Repository setting is missing. Use the '-snapShot <repository>' option."),
+ REPOSITORY_NOT_PROVIDED("Repository setting is missing. Use the '-repository <repository>' option."),
+ PACKAGES_NOT_PROVIDED("Repository setting is missing. Use the '-proxy <repository>' option."),
//etc
- CANNOT_FIND_INSTALLED_FILE_LIST("Cannot find installed file list."),
- CANNOT_REMOVE_TARGET_DIR("Cannot remove target directory."),
- INSTALLATION_STOP("All packages are not installed for META package."),
- UNINSTALLATION_FAIL("Uninstallation is Failed."),
- FILE_NOT_FOUND("File not found"),
- REMOVE_OLD_SDK_OK("Old SDK is removed OK. Please restart InstallManager."),
- INVALID_INSTALL_PATH("Install path is invalid"),
- USESNAPSHOT_REPOSITORY_NOT_PROVIDED("Repository setting is not provided. Use command line option '-useSnapShot <repository>'"),
- REPOSITORY_NOT_PROVIDED("Repository setting is not provided. Use command line option '-repository <repository>'"),
- PACKAGES_NOT_PROVIDED("Repository setting is not provided. Use command line option '-proxy <repository>'"),
- DOWNLOAD_AND_EXIT("Download packages are success and exit installmanager."),
- CANNOT_DOWNLOAD_FILE("Cannot download file."),
- CANNOT_FIND_JAVA("Cannot find \'JAVA\'. Please check your java installation.");
-
- private String errorMessage;
+ CANNOT_FIND_INSTALLED_FILE_LIST("Installation file list not found."),
+ CANNOT_REMOVE_TARGET_DIR("Target directory removal failed."),
+ INSTALLATION_STOP("Required packages for the META package not installed."),
+ UNINSTALLATION_FAIL("Uninstallation failed."),
+ FILE_NOT_FOUND("File not found."),
+ REMOVE_OLD_SDK_OK("Old SDK uninstallation completed. Restart Install Manager."),
+ INVALID_INSTALL_PATH("Invalid installation path."),
+ DOWNLOAD_AND_EXIT("Packages downloaded successfully. Exit Install Manager."),
+ CANNOT_DOWNLOAD_FILE("File download failed."),
+ CANNOT_FIND_JAVA("\'JAVA\' not found. Check the java installation."),
+ UNKOWN_ERROR("Unknown error."),
+ NO_ERROR("Install Manager error. Send the log file to the Tizen SDK team."),
+ ERROR_TEMP("Information retrieval from the default SDK package server failed.\n In Advanced Configuration, select the package server and distribution."),
+
+ SNAPSHOT_PATH_IS_NULL("Snapshot path missing."),
+ FAIL_TO_EXTRACT_SDK_IMAGE_FILE("SDK image file extraction failed."),
+
+ //Using add extra repository dialog
+ SPACE_IN_REPOSITORY_NAME("Name cannot contain spaces."),
+ NOTHING_TO_REPOSITORY_NAME("Name must be more than 1 character long."),
+ HANGUL_IN_REPOSITORY_NAME("Repository name must be in English."),
+ WRONG_PACKAGE_SERVER("Package list files not found. Check the package list files on the package server."),
+ WRONG_PACKAGE_LIST_FORMAT("Mandatory field missing in the package list file."),
+ WRONG_URL_FORMAT_HTTP("URL must begin with 'http://'."),
+ WRONG_URL_FORMAT("Incorrect URL format. Enter the URL in the correct format."),
+ CANNOT_CONNECT_URL_ADDRESS("Connection to the URL failed. Enter the correct URL."),
+ PACKAGE_NOT_IN_EXTENSION_SERVER("Package file not found on the package server."),
+ OVERLAP_EXTENSION_REPOSITORY("Extension repository URL already exists.\nEnter a different extension repository URL."),
+ OVERLAP_BUILT_IN_EXTENSION_REPOSITORY("Built-in extension repository URL already exists.\nEnter a different extension repository URL.");
+
+ private String errorMessage = "";
ErrorCode(String arg) {
errorMessage = arg;
}
- private String getErrorMessage() {
+ public String getErrorMessage() {
return errorMessage;
}
errorMessage = msg;
}
}
+
+ static public boolean isInstallManagerUpdatable = false;
- static private ErrorCode mErrorCode = null;
+ static private ErrorCode mErrorCode = ErrorCode.NO_ERROR;
static private boolean mInstallationStatus = true;
-
- /**
- * true if target directory is empty
- */
- static private boolean targetDirEmpty = true;
+ static private String errorMsg = "";
private static int exitCode = Config.EXITCODE_NORMAL;
* @return Latest error message.
*/
static public String getErrorMessage() {
- if (mErrorCode != null) {
- String errorMsg = mErrorCode.getErrorMessage();
-
- return errorMsg;
+ if (mErrorCode != null) {
+ return mErrorCode.getErrorMessage();
} else {
- if (checkInstallationSuccess()) {
- return "No Error";
- } else {
- return "Error occurred from unknown cause.";
- }
+ return errorMsg;
}
}
static public void setErrorMessage(String msg) {
- mErrorCode.setErrorMessage(msg);
+ mErrorCode = null;
+ errorMsg = msg;
}
/**
}
/**
- * @return <code>true</code> if some files exist in target directory.
- */
- public static boolean isTargetDirEmpty() {
- return targetDirEmpty;
- }
-
- /**
- * Sets some files are exist in target directory.
- *
- * @param isTargetDirEmpty
- */
- public static void setTargetDirEmpty(boolean isTargetDirEmpty) {
- ErrorController.targetDirEmpty = isTargetDirEmpty;
- }
-
- /**
* Get error message of e
* @param e
* @return
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.lib;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.util.PathUtil;
-
/**
* Manages log message.
*
* @author Yongsung Kim <yongsung1.kim@samsung.com>
- *
+ *
*/
public class Log {
private static File mLogFile;
private static String newLine = "";
-
+
private static FileWriter objfile = null;
private final static Date startTime = new Date();
private final static String logfileNameHead = "tizen_installmanager";
- private final static SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
-
+ // log file dir
+ private final static String LOG_FILE_DIRECTORY = "install-log";
static {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- newLine = "\n";
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ newLine = "\n";
} else {
- newLine = "\r\n";
+ newLine = "\r\n";
}
}
/**
- * This function must be before Logging.
- * Create log file.
+ * This function must be before Logging. Create log file.
*/
public static void open() {
removeTooOldLogs();
-
+
// open log file
- mLogFile = new File(PathUtil.get(Config.CONFIG_HOME,
- logfileNameHead + "_" +
- new SimpleDateFormat("yyyyMMdd-HHmmss").format(startTime) +
- ".log"));
-
+ mLogFile = new File(PathUtil.get(
+ Config.CONFIG_HOME,
+ LOG_FILE_DIRECTORY,
+ logfileNameHead
+ + "_"
+ + new SimpleDateFormat("yyyyMMdd-HHmmss")
+ .format(startTime) + ".log"));
File parentDir = mLogFile.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
-
+
try {
mLogFile.createNewFile();
} catch (IOException e) {
- //log file is not create.
+ // log file is not create.
return;
}
-
+
try {
objfile = new FileWriter(mLogFile);
} catch (IOException e1) {
- //log file is not create.
+ // log file is not create.
return;
}
* remove logs except latest 5 logs
*/
private static void removeTooOldLogs() {
- File confDir = new File(Config.CONFIG_HOME);
+ File confDir = new File(PathUtil.get(
+ Config.CONFIG_HOME,
+ LOG_FILE_DIRECTORY));
+
File[] logs = confDir.listFiles(new FileFilter() {
-
+
@Override
public boolean accept(File file) {
return file.getAbsolutePath().contains(logfileNameHead);
}
-
+
});
- if(logs == null) {
+ if (logs == null) {
return;
}
Arrays.sort(logs, new Comparator<File>() {
public int compare(File arg0, File arg1) {
return arg0.compareTo(arg1);
}
-
+
});
-
- for(int i = 0; i < logs.length-5; i++) {
+
+ for (int i = 0; i < logs.length - 5; i++) {
logs[i].delete();
}
-
+
}
/**
*/
public static void close() {
try {
- if(objfile != null) {
+ if (objfile != null) {
objfile.flush();
objfile.close();
}
return;
}
}
-
+
/**
* Logging title
*/
public static void LogTitle(String msg) {
- if(objfile == null) {
+ if (objfile == null) {
return;
}
StringBuffer bufLogTitle = new StringBuffer();
-
+
bufLogTitle.append("********************** ");
bufLogTitle.append(msg);
bufLogTitle.append(" **********************");
-
+
try {
objfile.write(bufLogTitle.toString());
objfile.write(newLine);
} catch (IOException e) {
}
}
-
+
/**
* Tracing Log Method
*/
public static void log(String msg) {
write("[Trace] " + msg);
}
-
+
/**
* Error Log Method
*/
public static void err(String msg) {
write("[Error] " + msg);
}
-
+
/**
* Exception Log Method
*/
PrintWriter pw = new PrintWriter(objfile);
e.printStackTrace(pw);
}
-
+
/**
* Write a string to logfile with timestamp
+ *
* @param str
*/
private static void write(String str) {
- if(objfile == null) {
+ if (objfile == null) {
return;
}
objfile.flush();
} catch (IOException e) {
- }
+ }
}
-
+
/**
* @return time string
*/
private static String timeStr() {
- return formatter.format(new Date());
+ return getTimeStr();
+ }
+
+ private static String getTimeStr() {
+ String timeStr = getFormatter().format(new Date());
+ return timeStr;
+ }
+
+ private static SimpleDateFormat getFormatter() {
+ SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
+ return formatter;
}
}
import java.net.URL;
import java.util.List;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+
/**
*
* @author Shihyun Kim<shihyun.kim@samsung.com>
*
*/
-public class NetworkProxy {
- private static NetworkProxy netProxy = null;
+public class NetworkProxy{
+ public static boolean useProxy = true;
+ private static NetworkProxy netProxy = null;
private static final String PROXY_PROPERTY = "java.net.useSystemProxies";
//member variable
proxySelector = selector;
}
- private NetworkProxy() {
- String proxyPropertyBefore = System.getProperty(PROXY_PROPERTY);
- /*
- * "useSystemProxies" property set true.
- * because get the system proxy in ProxySelector class.
- */
- System.setProperty(PROXY_PROPERTY, "true");
-
- proxySelector = ProxySelector.getDefault();
-
- if (proxyPropertyBefore != null) {
- System.setProperty(PROXY_PROPERTY, proxyPropertyBefore);
- } else {
- System.setProperty(PROXY_PROPERTY, "null");
- }
- }
-
/**
* Get proxy list from <code>url</code> parameter.
* @param url
return null;
}
+
Log.log("proxy select uri => " + uri.toString());
try {
- return proxySelector.select(uri);
-
+ if (proxySelector == null) {
+ return ProxySelector.getDefault().select(uri);
+ } else {
+ return proxySelector.select(uri);
+ }
} catch (IllegalArgumentException e) {
Log.ExceptionLog(e);
return null;
} catch (Exception e) {
Log.ExceptionLog(e);
return null;
- }
+ }
}
/**
* @param url is connected by proxy.
* @return Direct proxy instance.
*/
- public Proxy getHttpDirectProxy(URL url) {
+ public static Proxy getHttpDirectProxy(URL url) {
String host = url.getHost();
int port = url.getPort();
if (port < 0) {
return directProxy;
}
- public static NetworkProxy getInstance() {
- if (netProxy == null) {
- netProxy = new NetworkProxy();
+ /**
+ * Get system proxy list to connect.
+ * @param url
+ * @return
+ */
+ public static List<Proxy> getSystemProxyList(URL url) {
+ String proxyPropertyBefore = System.getProperty(PROXY_PROPERTY);
+ /*
+ * "useSystemProxies" property set true.
+ * because get the system proxy in ProxySelector class.
+ */
+ System.setProperty(PROXY_PROPERTY, "true");
+
+ NetworkProxy netProxy = NetworkProxy.getInstance(ProxySelector.getDefault());
+
+ // get system proxy from NetworkProxy class
+ List<Proxy> proxyList = null;
+ try {
+ proxyList = netProxy.select(url.toURI());
+ } catch (URISyntaxException e) {
+ Log.ExceptionLog(e);
}
- return netProxy;
+ if (proxyPropertyBefore != null) {
+ System.setProperty(PROXY_PROPERTY, proxyPropertyBefore);
+ } else {
+ System.setProperty(PROXY_PROPERTY, "null");
+ }
+
+ if (proxyList == null) {
+ throw new IMFatalException(ErrorCode.INTERNET_CONNECTION_ERROR);
+ } else {
+ Log.log("Proxy list => " + proxyList);
+ return proxyList;
+ }
}
public static NetworkProxy getInstance(ProxySelector selector) {
}
private String getTargetPathFromWindowsRegistry(RegistryInfo info) {
- if (Platform.CURRENT_PLATFORM != Platform.WINDOWS) {
+ if (Platform.CURRENT_PLATFORM != Platform.WINDOWS_32) {
return null;
}
private String getPathFromRegistryKey(String path, String registryKey) {
File file = new File(path);
- if (!file.exists()) {
+ if (!file.exists() || !file.isFile()) {
return "";
}
result = readLine.substring(startChar+1);
}
}
- fis.close();
- isr.close();
- br.close();
+
return result;
} catch (IOException ioe) {
Log.err("OldRegistry.getPathFromRegistryKey() Cannot read install path from .tizensdk file => " + path + ", " + registryKey);
throw new IMFatalException("Cannot read install path from .tizensdk file");
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ if (isr != null) {
+ try {
+ isr.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
}
}
*/
public void remove() {
Log.log("Remove Old SDK start");
- if(Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if(Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+
try {
File script = PathUtil.getTempFileFromResource("/res/desktop_directory/removeOldSDK.sh", "removeOldSDK", ".sh");
script.setExecutable(true);
Log.ExceptionLog(e);
throw new IMFatalException(ErrorCode.CANNOT_REMOVE_OLDSDK);
}
- } else if(Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if(Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
WindowsRegistry.removeRegistry("slpsdk-installpath");
WindowsRegistry.removeRegistry("tizensdk-installpath");
Map<String, String> env = new HashMap<String, String>();
env.put("INSTALLED_PATH", getOldTargetPath());
try {
- ShellUtil.execute("wscript.exe " + script.getAbsolutePath(), env, null, new LoggerShellParser());
+ String command = ShellUtil.addInterpreter(script.getAbsolutePath());
+ ShellUtil.execute(command, env, null, new LoggerShellParser());
} catch (IMShellCommandFail e) {
Log.ExceptionLog(e);
throw new IMFatalException(ErrorCode.CANNOT_REMOVE_OLDSDK);
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.lib;
/**
* Check the platform.
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
public class Platform {
+
+ // Code for each OS and bits
+ public static final int UNKNOWN = 0;
+ public static final int LINUX_32 = 1; // for normal Linux
+ public static final int LINUX_64 = 1 << 2;
+ public static final int WINDOWS_32 = 1 << 3; // for MS Windows
+ public static final int WINDOWS_64 = 1 << 4;
+ public static final int MACOS_32 = 1 << 5; // for Apple MacOS
+ public static final int MACOS_64 = 1 << 6;
+ public static final int UBUNTU_32 = 1 << 7; // for Ubuntu Linux
+ public static final int UBUNTU_64 = 1 << 8;
- public static final int UNKNOWN = 0;
- public static final int LINUX = 1;
- public static final int WINDOWS = 2;
- public static final int MAC_OS = 3;
+ // Code for generic OS
+ public static final int GENERIC_LINUX = LINUX_32 | LINUX_64 | UBUNTU_32 | UBUNTU_64;
+ public static final int GENERIC_WINDOWS = WINDOWS_32 | WINDOWS_64;
+ public static final int GENERIC_MACOS = MACOS_32 | MACOS_64;
+ public static final int GENERIC_UBUNTU = UBUNTU_32 | UBUNTU_64;
+
public static final int CURRENT_PLATFORM = getCurrentPlatform();
public static final String CURRENT_CHARSET = getCurrentCharset();
-
+
+ //data model
+ public static final String DATA_MODEL_32 = "32";
+ public static final String DATA_MODEL_64 = "64";
/**
- * Get current platform.
- * UNKOWN = 0,
- * LINUX = 1,
- * WINDOWS = 2,
- * MAC_OS = 3
+ * Get current platform. UNKOWN = 0, LINUX = 1, WINDOWS = 2, MAC_OS = 3
+ * TODO must check ubuntu or fedora.
+ *
* @return
*/
- private static int getCurrentPlatform() {
- String os = System.getProperty("os.name");
+ private static int getCurrentPlatform() {
+ String os = System.getProperty("os.name");
+ String dataModel = System.getProperty("sun.arch.data.model");
- if (os.startsWith("Linux")) {
- return LINUX;
- } else if (os.startsWith("Windows")) {
- return WINDOWS;
- } else if (os.startsWith("Mac OS")) {
- return MAC_OS;
- }
-
- throw new RuntimeException("unknown Platform - " + os);
- }
+ if (os.startsWith("Linux")) {
+ if (dataModel.equals(DATA_MODEL_32)) {
+ return LINUX_32;
+ } else if (dataModel.equals(DATA_MODEL_64)) {
+ return LINUX_64;
+ }
+ } else if (os.startsWith("Windows")) {
+ if (dataModel.equals(DATA_MODEL_32)) {
+ return WINDOWS_32;
+ } else if (dataModel.equals(DATA_MODEL_64)) {
+ return WINDOWS_64;
+ }
+ } else if (os.startsWith("Mac OS")) {
+ return MACOS_64;
+ }
+
+ throw new RuntimeException("unknown Platform - " + os);
+ }
- private static String getCurrentCharset() {
- return System.getProperty("sun.jnu.encoding");
- }
+ private static String getCurrentCharset() {
+ return System.getProperty("sun.jnu.encoding");
+ }
- /**
- * @return platform information
- */
- public static String getPlatformInfo() {
- String info = "";
- info = info + "OS Name: " + System.getProperty("os.name") + "\n";
- info = info + "OS Version: " + System.getProperty("os.version") + "\n";
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ /**
+ * @return platform information
+ */
+ public static String getPlatformInfo() {
+ String info = "";
+ info = info + "OS Name: " + System.getProperty("os.name") + "\n";
+ info = info + "OS Version: " + System.getProperty("os.version") + "\n";
+ info = info + "Data Model: " + System.getProperty("sun.arch.data.model") + "\n";
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32) {
String filePath = "/etc/lsb-release";
info = info + PathUtil.readAllTextFromFile(filePath) + "\n";
}
- info = info + "java : " + System.getProperty("java.runtime.name") + "\n";
- info = info + "vm version : " + System.getProperty("java.vm.version") + "\n";
-
+ info = info + "java : " + System.getProperty("java.runtime.name")
+ + "\n";
+ info = info + "vm version : " + System.getProperty("java.vm.version")
+ + "\n";
+
return info;
- }
+ }
+
+
+ /**
+ * Check whether current platform is linux.
+ * @return If current platform is linux, return true. If not, return false
+ */
+ public static boolean isLinux()
+ {
+ return ( CURRENT_PLATFORM & GENERIC_LINUX ) > 0;
+ }
+
+ /**
+ * Check whether current platform is Ubuntu, but not implemented yet.
+ * TODO must implement soon.
+ * @return If current platform is Ubunut, return true. If not, return false
+ */
+ public static boolean isUbuntu()
+ {
+ return isLinux();
+ }
+
+
+ /**
+ * Check whether current platform is MacOS.
+ * @return If current platform is MacOS, return true. If not, return false
+ */
+ public static boolean isMacOS()
+ {
+ return ( CURRENT_PLATFORM & GENERIC_MACOS ) > 0;
+ }
+
+
+ /**
+ * Check whether current platform is linux.
+ * @return If current platform is MacOS, return true. If not, return false
+ */
+ public static boolean isWindows()
+ {
+ return ( CURRENT_PLATFORM & GENERIC_WINDOWS ) > 0;
+ }
}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.lib;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.lib.linux.LinuxProgramController;
+import org.tizen.installmanager.lib.mac.MacProgramController;
import org.tizen.installmanager.lib.win.WindowsProgramController;
-
/**
* Manages process.
*
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
abstract public class ProgramController {
-
- private static LinuxProgramController mLinuxController = new LinuxProgramController();
- private static WindowsProgramController mWindowsController = new WindowsProgramController();
-
+
+ private static LinuxProgramController linuxController = new LinuxProgramController();
+ private static WindowsProgramController windowsController = new WindowsProgramController();
+ private static MacProgramController macController = new MacProgramController();
+
/**
* Terminates running SDK processes
*/
abstract public void terminateRunningProgram();
+
/**
* @return list of pid strings.
*/
abstract public List<Integer> getSDKPidList();
+
/**
* Checks if SDK processes are running
- * @return <code>true</code> if at least one SDK process is running
+ *
+ * @return <code>true</code> if at least one SDK process is running
*/
abstract public boolean runningProgramExists();
+
/**
* Removes unpack directory
+ *
* @return <code>true</code> if success
*/
abstract public boolean removeSDKTempDir();
-
- /**
- * Get instance in accordance with platform
- * @return
- */
- public static ProgramController createProgramController() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- if (mLinuxController == null) {
- mLinuxController = new LinuxProgramController();
- }
- return mLinuxController;
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- if (mWindowsController == null) {
- mWindowsController = new WindowsProgramController();
- }
- return mWindowsController;
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
- }
-
- /**
- * set environment variable.
- * @param environmentSet save key and value to environmentSet.
- * @param key
- * @param value
- * @return environmentSet.
- */
- public static Map<String, String> setEnvironmentVariable(Map<String, String> environmentSet, String key, String value) {
- if (environmentSet == null) {
- environmentSet = new HashMap<String, String>();
- } else {}
-
- environmentSet.put(key, value);
- return environmentSet;
+
+ /**
+ * Get instance in accordance with platform
+ *
+ * @return
+ */
+ public static ProgramController createProgramController() {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ if (linuxController == null) {
+ linuxController = new LinuxProgramController();
+ }
+ return linuxController;
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ if (windowsController == null) {
+ windowsController = new WindowsProgramController();
+ }
+ return windowsController;
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ if (macController == null) {
+ macController = new MacProgramController();
+ }
+ return macController;
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
+ }
+
+ /**
+ * set environment variable.
+ *
+ * @param environmentSet
+ * save key and value to environmentSet.
+ * @param key
+ * @param value
+ * @return environmentSet.
+ */
+ public static Map<String, String> setEnvironmentVariable(
+ Map<String, String> environmentSet, String key, String value) {
+ if (environmentSet == null) {
+ environmentSet = new HashMap<String, String>();
+ } else {
+ }
+
+ environmentSet.put(key, value);
+ return environmentSet;
}
}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.lib;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.util.PathUtil;
-
/**
* Manages target path to the registry file.
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
public class Registry {
- public static final String REGISTRY_FILE_NAME = "tizensdkpath";
- public static final String REGISTRY_FILE_PATH = PathUtil.get(Config.CONFIG_HOME, REGISTRY_FILE_NAME);
- public static final String INSTALLED_PATH_KEY = "TIZEN_SDK_INSTALLED_PATH";
-
- private static final OldRegistry oldRegistry = new OldRegistry();
- /**
- * Exports target path to the registry file.
- * @param targetPath
- */
- public static void exportInstallPath(String targetPath) {
- if (targetPath == null || targetPath.isEmpty()) {
- Log.err("Install path is invalid: "+targetPath+". This might be a bug of IM");
- throw new IMFatalException(ErrorCode.INVALID_INSTALL_PATH);
- }
-
- String parameter = INSTALLED_PATH_KEY + "=" + targetPath;
-
- File file = new File(REGISTRY_FILE_PATH);
-
- if (file.exists()) {
- file.delete();
- }
- file.getParentFile().mkdirs();
-
- try {
- file.createNewFile();
+ //installed path.
+ private static final String REGISTRY_FILE_NAME = "tizensdkpath";
+ private static final String REGISTRY_FILE_PATH = PathUtil.get(
+ Config.CONFIG_HOME, REGISTRY_FILE_NAME);
+ private static final String INSTALLED_PATH_KEY = "TIZEN_SDK_INSTALLED_PATH";
+
+ //installed version
+ private static final String INSTALLED_VERSION_FILE_NAME = "version";
+ private static final String INSTALLED_VERSION_FILE_PATH = PathUtil.get(
+ Config.CONFIG_HOME, INSTALLED_VERSION_FILE_NAME);
+ private static final String INSTALLED_VERSION_KEY = "INSTALLED_VERSION";
+
+ //registry information seperator
+ private static final String REGISTRY_SEPERATOR = "=";
+
+ /**
+ * Exports target path to the registry file.
+ *
+ * @param targetPath
+ */
+ public static void exportInstallPath(String targetPath) {
+ if (targetPath == null || targetPath.isEmpty()) {
+ Log.err("Install path is invalid: " + targetPath
+ + ". This might be a bug of IM");
+ throw new IMFatalException(ErrorCode.INVALID_INSTALL_PATH);
+ }
+
+ String parameter = INSTALLED_PATH_KEY + REGISTRY_SEPERATOR + targetPath;
+
+ File installedPathFile = null;
+ try {
+ installedPathFile = PathUtil.makeNewFile(REGISTRY_FILE_PATH);
} catch (IOException e) {
- Log.err("Cannot create file. "+file.getAbsolutePath());
- throw new IMFatalException(ErrorCode.CANNOT_REGISTER_TARGET_DIR);
+ Log.ExceptionLog(e);
+ return;
}
-
- BufferedWriter bw = null;
- try {
- FileWriter fw = new FileWriter(file);
- bw = new BufferedWriter(fw);
- bw.write(parameter);
- bw.flush();
-
- } catch (Exception e) {
- Log.err("Cannot register to file. "+file.getAbsolutePath());
+
+ if (installedPathFile == null) {
+ return;
+ }
+
+ BufferedWriter bw = null;
+ try {
+ FileWriter fw = new FileWriter(installedPathFile);
+ bw = new BufferedWriter(fw);
+ bw.write(parameter);
+ bw.flush();
+
+ } catch (Exception e) {
+ Log.err("Cannot register to file. " + installedPathFile.getAbsolutePath());
throw new IMFatalException(ErrorCode.CANNOT_REGISTER_TARGET_DIR);
-
- } finally {
- if (bw != null) {
- try {
+
+ } finally {
+ if (bw != null) {
+ try {
bw.close();
-
+
} catch (IOException e) {
- // TODO Auto-generated catch block
Log.ExceptionLog(e);
}
+ }
+ }
+ }
+
+ /**
+ * @return path in which SDK is installed. empty string if not found.
+ */
+ public static String getInstalledPath() {
+ return getPathFromRegistryKey(REGISTRY_FILE_PATH, INSTALLED_PATH_KEY);
+ }
+
+ private static String getPathFromRegistryKey(String path, String registryKey) {
+ File file = new File(path);
+
+ if (!file.exists()) {
+ return "";
+ }
+
+ FileInputStream fis = null;
+ InputStreamReader isr = null;
+ BufferedReader br = null;
+
+ String readLine;
+ String result = "";
+ try {
+ fis = new FileInputStream(file);
+ isr = new InputStreamReader(fis);
+ br = new BufferedReader(isr);
+
+ while ((readLine = br.readLine()) != null) {
+ if (readLine.startsWith(registryKey)) {
+ int startChar = readLine.indexOf("=");
+ if (startChar == -1) {
+ Log.err("OldRegistry.getPathFromRegistryKey() Invalid registry file => "
+ + path + ", " + registryKey);
+ throw new IMFatalException("Invalid registry file");
+ }
+ result = readLine.substring(startChar + 1);
+ }
+ }
+
+ return result;
+ } catch (IOException ioe) {
+ Log.err("OldRegistry.getPathFromRegistryKey() Cannot read install path from .tizensdk file => "
+ + path + ", " + registryKey);
+ throw new IMFatalException(
+ "Cannot read install path from .tizensdk file");
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ if (isr != null) {
+ try {
+ isr.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
}
- }
- }
-
- /**
- * @return path in which SDK is installed. empty string if not found.
- */
- public static String getInstalledPath() {
- return getPathFromRegistryKey(REGISTRY_FILE_PATH, INSTALLED_PATH_KEY);
- }
-
- private static String getPathFromRegistryKey(String path, String registryKey) {
- File file = new File(path);
-
- if (!file.exists()) {
- return "";
- }
- FileInputStream fis = null;
- InputStreamReader isr = null;
- BufferedReader br = null;
-
- String readLine;
- String result = "";
- try {
- fis = new FileInputStream(file);
- isr = new InputStreamReader(fis);
- br = new BufferedReader(isr);
-
- while ((readLine = br.readLine()) != null) {
- if (readLine.startsWith(registryKey)) {
- int startChar = readLine.indexOf("=");
- if(startChar == -1) {
- Log.err("OldRegistry.getPathFromRegistryKey() Invalid registry file => " + path + ", " + registryKey);
- throw new IMFatalException("Invalid registry file");
- }
- result = readLine.substring(startChar+1);
- }
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
}
- fis.close();
- isr.close();
- br.close();
- return result;
- } catch (IOException ioe) {
- Log.err("OldRegistry.getPathFromRegistryKey() Cannot read install path from .tizensdk file => " + path + ", " + registryKey);
- throw new IMFatalException("Cannot read install path from .tizensdk file");
}
- }
-
- /**
- * remove target path in the registry file.
- */
- public static void removeRegistry() {
- File file = new File(REGISTRY_FILE_PATH);
-
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * @return <code>true</code> if old sdk(Tizen SDK) is installed.
- */
- public static boolean isOldSDKInstalled() {
- if (oldRegistry.exists()) {
- return true;
- } else {
- return false;
- }
- }
+ }
+
+ /**
+ * remove target path in the registry file.
+ */
+ public static void removeRegistry() {
+ File file = new File(REGISTRY_FILE_PATH);
+
+ if (file.exists()) {
+ file.delete();
+ }
+
+ removeOldFiles();
+ }
+
+ /**
+ * Save installed version.
+ */
+ public static void saveInstallVersion(String version) {
+ File versionFile = null;
+ try {
+ versionFile = PathUtil.makeNewFile(INSTALLED_VERSION_FILE_PATH);
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ return;
+ }
+
+ if (versionFile == null) {
+ return;
+ }
+
+
+ BufferedWriter bw = null;
+ try {
+ FileWriter fw = new FileWriter(versionFile);
+ bw = new BufferedWriter(fw);
+
+ String versionInformation = INSTALLED_VERSION_KEY + REGISTRY_SEPERATOR + version;
+ bw.write(versionInformation);
+ bw.flush();
+
+ } catch (Exception e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.CANNOT_REGISTER_TARGET_DIR);
+
+ } finally {
+ if (bw != null) {
+ try {
+ bw.close();
+
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get installed version.
+ * @return
+ */
+ public static String getInstalledVersion() {
+ return getPathFromRegistryKey(INSTALLED_VERSION_FILE_PATH, INSTALLED_VERSION_KEY);
+ }
+
+ public static boolean isInstallManagerInstalled() {
+ String installedPath = getInstalledPath();
+
+ if (installedPath == null || installedPath.isEmpty()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Temporary code to update.
+ */
+ private static void removeOldFiles() {
+ File file = new File(Config.OLD_CONFIG_HOME);
+
+ if (file.exists()) {
+ PathUtil.remove(file);
+ }
+ }
}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.lib;
import org.tizen.installmanager.lib.win.WindowsSDKPackageFormat;
import org.tizen.installmanager.util.PathUtil;
-
/**
* Manages to unpack package of tizen sdk.
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
public abstract class SDKPackageFormat {
protected FileOutputStream mFileOutput = null;
protected final String SDK_PACKAGE_ZIP_EXTENTION = ".zip";
protected final String SDK_PACKAGE_TAR_GZ_EXTENTION = ".gz";
-
- public enum PackageType {ELSE, ZIP, TAR_GZ};
-
- protected final static int ERROR = -1;
- protected final static int SUCCESS = 1;
-
- //abstract method
- /**
- * Unzip package.
- * @param fileFullPath Absolute path of package file.
- * @param targetDir
- * @param monitor
- * @return
- */
- protected abstract long unZip(File fileFullPath, File targetDir, IIMProgressMonitor monitor);
-
+
+ public enum PackageType {
+ ELSE, ZIP, TAR_GZ
+ };
+
+ protected final static int ERROR = -1;
+ protected final static int SUCCESS = 1;
+
+ // abstract method
+ /**
+ * Unzip package.
+ *
+ * @param fileFullPath
+ * Absolute path of package file.
+ * @param targetDir
+ * @param monitor
+ * @return
+ */
+ protected abstract long unZip(File fileFullPath, File targetDir,
+ IIMProgressMonitor monitor);
+
/**
* unzip SDK package to target directory
+ *
* @param fileFullPath
* @param targetDir
* @param monitor
* @return
*/
- public long unZip(String fileFullPath, String targetDir, IIMProgressMonitor monitor) {
+ public long unZip(String fileFullPath, String targetDir,
+ IIMProgressMonitor monitor) {
return unZip(new File(fileFullPath), new File(targetDir), monitor);
}
-
+
/**
* get package extension type
+ *
* @param fileFullPath
* @return package extension
*/
return PackageType.ELSE;
}
}
-
+
/**
- * set FileOutput instance
- * It will be used to save installing file list.
- * @param installedListFilePath file path that save installing file list.
+ * set FileOutput instance It will be used to save installing file list.
+ *
+ * @param installedListFilePath
+ * file path that save installing file list.
*/
public void setFileOutput(String installedListFilePath) {
- setFileOutput(new File(installedListFilePath));
- }
-
+ setFileOutput(new File(installedListFilePath));
+ }
+
/**
- * set FileOutput instance
- * It will be used to save installing file list.
- * @param installedListFilePath file path that save installing file list.
+ * set FileOutput instance It will be used to save installing file list.
+ *
+ * @param installedListFilePath
+ * file path that save installing file list.
*/
- public void setFileOutput(File installedListFile) {
- if (installedListFile == null) {
- return;
- }
-
- if (installedListFile.exists()) {
- installedListFile.delete();
- }
-
- File installedListDir = installedListFile.getParentFile();
- if (!installedListDir.exists()) {
- installedListDir.mkdirs();
- }
-
- try {
+ public void setFileOutput(File installedListFile) {
+ if (installedListFile == null) {
+ return;
+ }
+
+ if (installedListFile.exists()) {
+ installedListFile.delete();
+ }
+
+ File installedListDir = installedListFile.getParentFile();
+ if (!installedListDir.exists()) {
+ installedListDir.mkdirs();
+ }
+
+ try {
installedListFile.createNewFile();
} catch (IOException e) {
throw new IMFatalException(ErrorCode.CANNOT_CREATE_INSTALL_LIST);
}
-
+
try {
mFileOutput = new FileOutputStream(installedListFile);
} catch (FileNotFoundException e) {
throw new IMFatalException(ErrorCode.CANNOT_CREATE_INSTALL_LIST);
}
- }
-
- /**
- * Close FileOutput instance.
- */
- public void closeFileOutput() {
- if (mFileOutput != null) {
- try {
+ }
+
+ /**
+ * Close FileOutput instance.
+ */
+ public void closeFileOutput() {
+ if (mFileOutput != null) {
+ try {
mFileOutput.close();
} catch (IOException e) {
Log.err("SDKPackageFormat fail to close output stream.");
}
mFileOutput = null;
- }
- }
-
- /**
- * Get SDKPackageFormat instance.
- * @return
- */
+ }
+ }
+
+ /**
+ * Get SDKPackageFormat instance.
+ *
+ * @return
+ */
public static SDKPackageFormat createSDKPackageFormat() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return new LinuxSDKPackageFormat();
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
- return new WindowsSDKPackageFormat();
- } else {
- throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
- }
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return new LinuxSDKPackageFormat();
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ return new WindowsSDKPackageFormat();
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ return new LinuxSDKPackageFormat();
+ } else {
+ throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
+ }
}
}
private static final String INSTALLMANAGER_ICON_RESOURCE_PATH = "/res/desktop_directory/"+INSTALLMANAGER_ICON;
private static String getMenuIcon() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
return "tizen-sdk-menu.png";
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
return "tizen-sdk-menu.ico";
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64){
+ return "";
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
}
private static String getInstallManagerIcon() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
return "tizen-sdk-installmanager.png";
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
return "tizen-sdk-installmanager.ico";
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ return "";
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
import java.util.StringTokenizer;
import org.tizen.installmanager.lib.IFileSystemInformation;
+import org.tizen.installmanager.lib.Log;
/**
@Override
public List<File> getListMounts() {
List<File> mountList = new ArrayList<File>();
+ BufferedReader reader = null;
+ InputStreamReader ipStream = null;
try
{
Process p=Runtime.getRuntime().exec("df -k");
p.waitFor();
- BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ ipStream = new InputStreamReader(p.getInputStream());
+ reader = new BufferedReader(ipStream);
String line = reader.readLine();
String partition = "";
mountList.remove(0);
} catch(IOException e1) {
-
+ Log.ExceptionLog(e1);
} catch(InterruptedException e2) {
+ Log.ExceptionLog(e2);
+ } finally {
+ if (ipStream != null) {
+ try {
+ ipStream.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
- }
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+ }
return mountList;
}
* @return
*/
private boolean isSDKProcess(int pid) {
+ Log.log("Check running process for sdk.");
+ if (checkCommandLine(pid) || checkExecutePath(pid)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean checkCommandLine(int pid) {
+ String pidCmd = "cat -A /proc/" + pid + "/cmdline";
+
+ ShellParser parser = new ShellParser();
+ try {
+ ShellUtil.execute(pidCmd, parser);
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ // ignore
+ return false;
+ }
+
+ String output = parser.getStdout();
+
+ return isProcessRunningInInstalledPath(output);
+ }
+
+ private boolean checkExecutePath(int pid) {
String pidCmd = "readlink -m /proc/" + pid + "/exe";
- ShellParser parser = new ShellParser();
- try {
- ShellUtil.execute(pidCmd, parser);
- } catch (IMShellCommandFail e) {
- Log.ExceptionLog(e);
- // ignore
- return false;
- }
- String output = parser.getStdout();
- if (output.toString().indexOf(Registry.getInstalledPath()) >= 0) {
- if (!isInstallManager(output)) {
- Log.log("readlink process => " + output);
- return true;
- }
- }
+ ShellParser parser = new ShellParser();
+ try {
+ ShellUtil.execute(pidCmd, parser);
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ // ignore
return false;
+ }
+
+ String output = parser.getStdout();
+ return isProcessRunningInInstalledPath(output);
}
public List<Integer> getSDKPidList() {
return listSDKPIDs;
}
+ private boolean isProcessRunningInInstalledPath(String output) {
+ if (output.toString().indexOf(Registry.getInstalledPath()) >= 0) {
+ if (!isInstallManager(output)) {
+ Log.log("readlink exe for process => " + output);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* @param path
* @return <code>true</code> if the path includes the install manager filename
private boolean isInstallManager(String path) {
String fileName = PathUtil.getFileName(path);
- if (fileName.equalsIgnoreCase(Config.INSTALL_MANAGER_FILE_NAME)) {
+ if (fileName.startsWith(Config.INSTALL_MANAGER_FILE_NAME)
+ || fileName.equalsIgnoreCase(Config.INSTALL_MANAGER_BINARY)) {
return true;
} else {
return false;
throw new IMShellCommandFail();
case 2:
Log.err("a generic error in the zipfile format was detected. Processing may have completed" +
- "success‐fully anyway; some broken zipfiles created by other archivers have simple work-arounds.");
+ "successfully anyway; some broken zipfiles created by other archivers have simple work-arounds.");
throw new IMShellCommandFail();
case 3:
Log.err("a severe error in the zipfile format was detected. Processing probably failed immediately.");
Log.err("unzip was unable to allocate memory for one or more buffers during program initialization.");
throw new IMShellCommandFail();
case 5:
- Log.err("unzip was unable to allocate memory or unable to obtain a tty to read the decryption pass‐word(s).");
+ Log.err("unzip was unable to allocate memory or unable to obtain a tty to read the decryption password(s).");
throw new IMShellCommandFail();
case 6:
Log.err("unzip was unable to allocate memory during decompression to disk.");
--- /dev/null
+package org.tizen.installmanager.lib.mac;
+
+import java.util.List;
+
+import org.tizen.installmanager.lib.ProgramController;
+
+public class MacProgramController extends ProgramController{
+
+ @Override
+ public void terminateRunningProgram() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Integer> getSDKPidList() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean runningProgramExists() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean removeSDKTempDir() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.lib.Log;
private final String VBSCRIPT_NAME_OF_CHECKING_RUNNING_PROGRAM = "checkRunningTaskList";
private final String VBSCRIPT_EXTENTION_OF_CHECKING_RUNNING_PROGRAM = ".vbs";
-// private List<String> mPIDList = null;
@Override
public void terminateRunningProgram() {
// ignore kill failure
}
}
+
+ findAndKillEmulatorManagerProcess();
+ findAndKillWebSimulator();
}
@Override
* @return <code>true</code>if success
*/
public static boolean removeRunningDir(String targetDir) {
- Log.log("WindowsProgramController.removeRunningDir() start");
+// Log.log("WindowsProgramController.removeRunningDir() start");
+//
+// File targetFile = new File(targetDir);
+// if (!targetFile.exists()) {
+// Log.log("Target directory does not exist => " + targetDir);
+// return true;
+// }
+//
+// try {
+// File removeScriptFile = PathUtil.getTempFileFromResource("/res/installmanager/removetizentemp.bat", "removetizentemp", ".bat", false);
+//
+// Map<String, String> env = setRemoveDirEnvironment(targetDir, removeScriptFile.getAbsolutePath());
+//
+// Process proc = ShellUtil.asyncExecute(removeScriptFile.getAbsolutePath()
+// , env
+// , new File(PathUtil.getTempDir())
+// , new ShellParser(false));
+//
+// if (proc != null) {
+// return true;
+// } else {
+// return false;
+// }
+// } catch (IOException e) {
+// Log.err("removetizentemp.bat file doesn't exist");
+// return false;
+// }
+ return true;
+ }
+
+// private static Map<String, String> setRemoveDirEnvironment(String targetDir, String removeScript) {
+// Map<String, String> env = new HashMap<String, String>();
+//
+// setEnvironmentVariable(env, "TARGET_DIR", targetDir);
+// setEnvironmentVariable(env, "REMOVE_SCRIPT_PATH", removeScript);
+//
+// return env;
+// }
+
+ private void findAndKillEmulatorManagerProcess() {
+ ShellParser parser = new ShellParser();
+ try {
+ ShellUtil.execute("tasklist /FI \"WINDOWTITLE eq Emulator Manager\" /FO csv /NH", parser);
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ return;
+ }
- File targetFile = new File(targetDir);
- if (!targetFile.exists()) {
- Log.log("Target directory does not exist => " + targetDir);
- return true;
+ String pid = getPidFromOutput(parser.getStdout());
+
+ String command = "TASKKILL /F /PID " + pid;
+ try {
+ ShellUtil.execute(command);
+ } catch (IMShellCommandFail e) {
+ Log.err("Failed to kill "+pid);
+ // ignore kill failure
}
- try {
- File removeScriptFile = PathUtil.getTempFileFromResource("/res/installmanager/removetizentemp.bat", "removetizentemp", ".bat", false);
-
- Map<String, String> env = setRemoveDirEnvironment(targetDir, removeScriptFile.getAbsolutePath());
-
- Process proc = ShellUtil.asyncExecute(removeScriptFile.getAbsolutePath()
- , env
- , new File(PathUtil.getTempDir())
- , new ShellParser(false));
-
- if (proc != null) {
- return true;
- } else {
- return false;
- }
- } catch (IOException e) {
- Log.err("removetizentemp.bat file doesn't exist");
- return false;
+ }
+
+ private void findAndKillWebSimulator() {
+ ShellParser parser = new ShellParser();
+ try {
+ ShellUtil.execute("tasklist /FI \"WINDOWTITLE eq Web Simulator\" /FO csv /NH", parser);
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ return;
+ }
+
+ String pid = getPidFromOutput(parser.getStdout());
+
+ String command = "TASKKILL /F /PID " + pid;
+ try {
+ ShellUtil.execute(command);
+ } catch (IMShellCommandFail e) {
+ Log.err("Failed to kill "+pid);
+ // ignore kill failure
}
+
}
- private static Map<String, String> setRemoveDirEnvironment(String targetDir, String removeScript) {
- Map<String, String> env = new HashMap<String, String>();
-
- setEnvironmentVariable(env, "TARGET_DIR", targetDir);
- setEnvironmentVariable(env, "REMOVE_SCRIPT_PATH", removeScript);
-
- return env;
+ private String getPidFromOutput(String output) {
+ String[] info = output.split(",");
+
+ if (info.length < 2) {
+ return "";
+ }
+
+ return info[1];
}
}
//Shell Folder.name
public static final String REGISTRY_PROGRAMS_OF_SHELL_FOLDER = "Programs";
-// public static final String REGISTRY_APP_DATA_OF_SHELL_FOLDER = "AppData";
public static final String REGISTRY_LOCAL_APP_DATA_OF_SHELL_FOLDER = "\"Local AppData\"";
//User key
* @return
*/
public static String getRegistryValue(String node, String key) {
- if (Platform.CURRENT_PLATFORM != Platform.WINDOWS) {
+ if (!Platform.isWindows()) {
return null;
}
BufferedReader br = null;
return SUCCESS;
}
- private long unZipPackage(File fileFullPath, File targetDir, IIMProgressMonitor monitor) {
- ZipInputStream zipInStream = null;
- FileOutputStream zipOutput = null;
- ZipEntry zipEntry = null;
-
- try {
- //mFileOutput = getFileListOutput(PathUtil.getFileNameWithOutExtension(fileFullPath));
- zipInStream = new ZipInputStream(new FileInputStream(fileFullPath));
- zipEntry = zipInStream.getNextEntry();
-
- long totalUnZipSize = 0;
- while (zipEntry != null) {
-
- if (monitor != null) {
- String fileName = PathUtil.getFileName(zipEntry.getName());
-
- monitor.setFileName(fileName);
- monitor.workedFileName();
- }
-
- String targetPath = targetDir.getAbsolutePath() + File.separator + zipEntry.getName();
-
- //make directory
- File targetFile = new File(targetPath);
- if (targetFile.exists() && targetFile.isDirectory()) {
- writeFileList(zipEntry.getName());
- zipEntry = zipInStream.getNextEntry();
- continue;
- }
-
- File parentFile = targetFile.getParentFile();
- if (!parentFile.exists()) {
- parentFile.mkdirs();
- }
-
- if (targetPath.endsWith("/")) {//zipEntry.isDirectory()) {
- new File(targetPath).mkdir();
- zipInStream.closeEntry();
- writeFileList(zipEntry.getName());
- zipEntry = zipInStream.getNextEntry();
- continue;
- }
-
-
- zipOutput =new FileOutputStream(targetPath);
-
- byte[] zipBuf = new byte[BUF_SIZE];
- int readByte = 0;
-
- while ((readByte = zipInStream.read(zipBuf)) >= 0) {
- zipOutput.write(zipBuf, 0, readByte);
- zipOutput.flush();
- totalUnZipSize += readByte;
- }
-
- writeFileList(zipEntry.getName());
-
- File outFile = new File(targetPath);
- if (outFile.isFile() && (PathUtil.getFileExtension(outFile.getName()).equals("") || PathUtil.getFileExtension(outFile.getName()).equals("sh"))) {
- outFile.setExecutable(true);
- }
-
- if (zipOutput != null) {
- zipOutput.close();
- }
-
- if (zipEntry != null) {
- zipInStream.closeEntry();
- }
- zipEntry = zipInStream.getNextEntry();
- }
-
- return totalUnZipSize;
-
- } catch (IOException e) {
- Log.err("Fail to unpack" + zipEntry.getName());
- throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
- } finally {
- try {
- if (zipOutput != null) {
- zipOutput.close();
- }
- if (zipInStream != null) {
- zipInStream.closeEntry();
- zipInStream.close();
- }
- if (mFileOutput != null) {
- mFileOutput.close();
- }
- } catch (IOException e) {
- Log.err("Fail to close output stream : " + zipEntry.getName());
- throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
- }
-
- closeFileOutput();
- }
- }
+ private long unZipPackage(File fileFullPath, File targetDir,
+ IIMProgressMonitor monitor) {
+ ZipInputStream zipInStream = null;
+ FileOutputStream zipOutput = null;
+ ZipEntry zipEntry = null;
+
+ try {
+ // mFileOutput =
+ // getFileListOutput(PathUtil.getFileNameWithOutExtension(fileFullPath));
+ zipInStream = new ZipInputStream(new FileInputStream(fileFullPath));
+ zipEntry = zipInStream.getNextEntry();
+
+ long totalUnZipSize = 0;
+ while (zipEntry != null) {
+
+ if (monitor != null) {
+ String fileName = PathUtil.getFileName(zipEntry.getName());
+
+ monitor.setFileName(fileName);
+ monitor.workedFileName();
+ }
+
+ String targetPath = targetDir.getAbsolutePath()
+ + File.separator + zipEntry.getName();
+
+ // make directory
+ File targetFile = new File(targetPath);
+ if (targetFile.exists() && targetFile.isDirectory()) {
+ writeFileList(zipEntry.getName());
+ zipEntry = zipInStream.getNextEntry();
+ continue;
+ }
+
+ File parentFile = targetFile.getParentFile();
+ if (!parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ if (targetPath.endsWith("/")) {// zipEntry.isDirectory()) {
+ new File(targetPath).mkdir();
+ zipInStream.closeEntry();
+ writeFileList(zipEntry.getName());
+ zipEntry = zipInStream.getNextEntry();
+ continue;
+ }
+
+ zipOutput = new FileOutputStream(targetPath);
+
+ byte[] zipBuf = new byte[BUF_SIZE];
+ int readByte = 0;
+
+ while ((readByte = zipInStream.read(zipBuf)) >= 0) {
+ zipOutput.write(zipBuf, 0, readByte);
+ zipOutput.flush();
+ totalUnZipSize += readByte;
+ }
+
+ writeFileList(zipEntry.getName());
+
+ File outFile = new File(targetPath);
+ if (outFile.isFile()
+ && (PathUtil.getFileExtension(outFile.getName())
+ .equals("") || PathUtil.getFileExtension(
+ outFile.getName()).equals("sh"))) {
+ outFile.setExecutable(true);
+ }
+
+ if (zipOutput != null) {
+ zipOutput.close();
+ }
+
+ if (zipEntry != null) {
+ zipInStream.closeEntry();
+ }
+ zipEntry = zipInStream.getNextEntry();
+ }
+
+ return totalUnZipSize;
+
+ } catch (IOException e) {
+ if (zipEntry != null) {
+ Log.err("Fail to unpack" + zipEntry.getName());
+ }
+
+ throw new IMFatalException(ErrorCode.CANNOT_UNPACK_PACKAGE);
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(e.getMessage());
+ } finally {
+ try {
+ if (zipOutput != null) {
+ zipOutput.close();
+ }
+ } catch (IOException e) {
+ if (zipEntry != null) {
+ Log.err("Fail to close output stream : "
+ + zipEntry.getName());
+ } else {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ try {
+ if (zipInStream != null) {
+ zipInStream.closeEntry();
+ }
+ } catch (IOException e) {
+ if (zipEntry != null) {
+ Log.err("Fail to close output stream : "
+ + zipEntry.getName());
+ } else {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ if (zipInStream != null) {
+ try {
+ zipInStream.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ try {
+ if (mFileOutput != null) {
+ mFileOutput.close();
+ }
+ } catch (IOException e) {
+ if (zipEntry != null) {
+ Log.err("Fail to close output stream : "
+ + zipEntry.getName());
+ } else {
+ Log.ExceptionLog(e);
+ }
+ }
+
+ closeFileOutput();
+ }
+ }
private void writeFileList(String filePath) {
if (filePath == null || filePath.equals("")) {
executeFilePath = new File(infos[1]).getCanonicalPath();
targetPath = targetPathFile.getCanonicalPath();
} catch (IOException e) {
- Log.err("Cannot get canonical paths: "+executeFilePath + ", "+targetPath);
+ Log.err("Cannot get canonical paths: " + infos[1] +
+ ", " + Registry.getInstalledPath());
Log.ExceptionLog(e);
return;
}
int pid = Integer.parseInt(infos[0]);
mSDKProcessID.add(pid);
} catch(NumberFormatException e) {
- // ignore non-integer string
+ Log.ExceptionLog(e);
}
} else {
return;
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Wooyoung Cho <wooyoung1.cho@samsung.com>
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Taeyoung Son <taeyoung2.son@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.pkg.lib;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.DistributionController;
+import org.tizen.installmanager.core.IMExitException;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.Downloader;
+import org.tizen.installmanager.lib.ErrorController;
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+import org.tizen.installmanager.lib.Platform;
+import org.tizen.installmanager.pkg.lib.darwin.DarwinPackageManager;
+import org.tizen.installmanager.pkg.lib.linux.LinuxPackageManager;
+import org.tizen.installmanager.pkg.lib.win.WindowsPackageManager;
+import org.tizen.installmanager.pkg.model.IMPackageNotFound;
+import org.tizen.installmanager.pkg.model.Package;
+import org.tizen.installmanager.pkg.model.PackageSet;
+import org.tizen.installmanager.pkg.model.Properties;
+import org.tizen.installmanager.pkg.model.PropertySection;
+import org.tizen.installmanager.pkg.model.Snapshot;
+import org.tizen.installmanager.pkg.model.Version;
+import org.tizen.installmanager.util.PathUtil;
+
+
+/**
+ * Package Manager
+ * <p>
+ * This class provides various methods for managing packages.
+ * Most of the methods handle packages symbolically. Namely, they are identified by its package name not the object if not specially mentioned.
+ * <p>
+ * Some methods are carefully designed to preserve the order of packages because the order of packages is important sometimes.
+ * See the details in the documentation of each methods.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public abstract class PackageManager {
+ /**
+ * Packages that are already installed in the system.
+ */
+ private PackageSet installedPackages;
+ /**
+ * packages that are available in the repositories(package servers).
+ */
+ private PackageSet repoPackages;
+ /**
+ * packages that combines <code>installedPackages</code> and <code>repoPackages</code>.
+ * This includes only the latest package from the several versions of a package.
+ * This is used as the universe set(base set) of packages available.
+ */
+ private PackageSet recentPackages;
+
+ /**
+ * Packages from extension package server.111
+ */
+ private PackageSet extensionPackages = new PackageSet();
+
+ private static PackageManager pm = null;
+
+ private enum State {
+ INSTALL,
+ UNINSTALL;
+ }
+
+ //abstract method
+ /**
+ * Get package list file name.
+ * @return
+ */
+ abstract public String getPackageListFileName();
+
+ /**
+ * Creates and initializes Package Manager instance.
+ * This combines installed packages and packages from the repositories.
+ *
+ * @param installed a file in which installed packages are specified. This can be <code>null</code> if no packages are installed.
+ * @param repoPackagesUrls a collection of URLs of repositories(package servers). This cannot be <code>null</code>.
+ * @throws IOException if temporary file cannot created
+ */
+ protected PackageManager(File installed, Collection<String> repoPackagesUrls) throws IOException {
+ setInstalledPackageList(installed);
+ loadRepositoryPackageList(repoPackagesUrls);
+ getRecentPackages();
+ }
+
+ /**
+ * Initializes package manager with information of installed packages and packages of repository
+ * @param sectionsInstalled a list of property sections of the installed packages
+ * @param repoToSectionsMap a map from base url of repository to a list of property sections of the repository
+ */
+ protected PackageManager(List<PropertySection> sectionsInstalled, Map<String,List<PropertySection>> repoToSectionsMap) {
+ setInstalledPackageList(sectionsInstalled);
+ setRepoPackages(repoToSectionsMap);
+ getRecentPackages();
+ }
+
+ /**
+ * set repository url to each package.(reposistory url plus package name is complete url.)
+ * @param repoPackagesUrls
+ * @throws IOException
+ */
+ public void loadRepositoryPackageList(Collection<String> repoPackagesUrls) throws IOException {
+ HashMap<String,List<PropertySection>> r2sMap = null;
+ if (Config.fromWhere == Config.ConfDialog.LOCAL_IMAGE) { // Using SDK Image
+ r2sMap = getRepositoryAndPackageList(repoPackagesUrls, false);
+ } else {
+ r2sMap = getRepositoryAndPackageList(repoPackagesUrls, true);
+ }
+
+ setRepoPackages(r2sMap);
+ }
+
+ /**
+ * set repository url to each package.(reposistory url plus package name is complete url.)
+ * @param repoPackagesUrls Packgae server list.
+ * @throws IOException
+ */
+ public void loadExtensionPackages(Collection<String> repoPackagesUrls) throws IOException {
+ HashMap<String,List<PropertySection>> repoToSectionsMap = getRepositoryAndPackageList(repoPackagesUrls, false);
+ setExtensionPackages(repoToSectionsMap);
+ setExtensionPackagesToRecentPackages();
+ }
+
+ private HashMap<String,List<PropertySection>> getRepositoryAndPackageList
+ (Collection<String> repoPackagesUrls, boolean isSnapshotServer) throws IOException {
+ PropertyParser parser = new PropertyParser();
+ HashMap<String,List<PropertySection>> r2sMap = new HashMap<String,List<PropertySection>>();
+
+ if(repoPackagesUrls != null) {
+ for(String repo : repoPackagesUrls) {
+ URL packageListURL = getPackageListPath(repo, isSnapshotServer);
+
+ File packageListFile = downloadPackageListFile(packageListURL);
+
+ if(packageListFile != null) {
+ r2sMap.put(repo, parser.readFromFile(packageListFile));
+ } else {
+ Log.err("Ignore invalid repository: "+repo);
+ }
+ }
+ } else {
+ Log.log("Cannot find repository. This is local installer.");
+ }
+
+ return r2sMap;
+ }
+
+ private File downloadPackageListFile(URL packageListURL) throws IOException {
+ if (packageListURL == null) {
+ return null;
+ }
+ Downloader dl = InstallManager.getDownloader();
+ File tmp = null;
+
+ if (Options.onlyDownload) {
+ tmp = new File(PathUtil.getFromCurrDir(getPackageListFileName()));
+ } else {
+ tmp = File.createTempFile("Packages", ".list");
+ tmp.deleteOnExit();
+ }
+
+ long size = dl.download(packageListURL, tmp.getAbsolutePath(), null);
+
+ if (size > 0) {
+ return tmp;
+ } else {
+ return null;
+ }
+ }
+
+ private void setExtensionPackages(HashMap<String,List<PropertySection>> repoToSectionsMap) {
+ extensionPackages = new PackageSet();
+ setPackages(extensionPackages, repoToSectionsMap, true);
+ }
+
+ /**
+ * Get packages from extension package server.
+ * @return set of packages
+ */
+ public PackageSet getExtensionPackages() {
+ return extensionPackages;
+ }
+
+ public PackageSet getInstalledExtensionPackages() {
+ PackageSet extensionPackages = new PackageSet();
+
+ for (Package pkg : extensionPackages) {
+ if (pkg.isExtensionPackage()) {
+ extensionPackages.add(pkg);
+ }
+ }
+
+ return extensionPackages;
+ }
+
+ /**
+ * Set installed packages.
+ * @param installedPackageListPath
+ */
+ public void setInstalledPackageList(File installedPackageListPath) {
+ List<PropertySection> sectionsInstalled = null;
+ PropertyParser parser = new PropertyParser();
+
+ if(installedPackageListPath != null) {
+ sectionsInstalled = parser.readFromFile(installedPackageListPath);
+ } else {
+ sectionsInstalled= new LinkedList<PropertySection>();
+ }
+
+ setInstalledPackageList(sectionsInstalled);
+ }
+
+ /**
+ * Set installed packages
+ * @param sections
+ */
+ private void setInstalledPackageList(List<PropertySection> sections) {
+ installedPackages = new PackageSet();
+
+ for(PropertySection sect : sections) {
+ installedPackages.add(new Package(sect.getProperties()));
+ }
+ }
+
+ /**
+ * Get package list file path from url.
+ * @param url
+ * @return Full url path
+ */
+ private URL getPackageListPath(String url, boolean isSnapshotServer) {
+ if (url == null || url.isEmpty()) {
+ return null;
+ } else {
+ String packageListURL = "";
+
+ if (isSnapshotServer) {
+ String snapshotPath = Config.getInstance().getSnapshotPath();
+
+ if (snapshotPath == null || snapshotPath.isEmpty()) {
+ String distribution = Config.getInstance().getConfigFile().getDistribution();
+
+ Snapshot latestSnapshot = DistributionController.getInstance().getLatestSnapshot(distribution);
+ if (latestSnapshot == null) {
+ return null;
+ } else {
+ snapshotPath = DistributionController.getInstance().getLatestSnapshot(distribution).getPath();
+ }
+ } else {}
+
+ packageListURL = PathUtil.addURLPath(url,
+ snapshotPath,
+ getPackageListFileName());
+
+ } else {
+ packageListURL = PathUtil.addURLPath(url, getPackageListFileName());
+ }
+
+ try {
+ return new URL(packageListURL);
+ } catch (MalformedURLException e) {
+ Log.ExceptionLog(e);
+ return null;
+ }
+ }
+ }
+
+
+
+ /**
+ * @return installed packages
+ */
+ public PackageSet getInstalledPackages() {
+ return (PackageSet) installedPackages.clone();
+ }
+
+ /**
+ * Set packages of repository
+ * @param sections
+ */
+ protected void setRepoPackages( Map<String,List<PropertySection>> repoToSectionsMap) {
+ repoPackages = new PackageSet();
+ setPackages(repoPackages, repoToSectionsMap, false);
+ }
+
+ /**
+ * Set packages to <code>destPackages</code>
+ * @param destPackages It is set of packages.
+ * @param repoToSectionsMap It is added to <code>destPackages</code>
+ */
+ private void setPackages(PackageSet destPackages, Map<String,List<PropertySection>> repoToSectionsMap, boolean isExtensionPackage) {
+ if (destPackages == null) {
+ destPackages = new PackageSet();
+ }
+
+ for(String repoBaseUrl : repoToSectionsMap.keySet()) {
+ for(PropertySection sect : repoToSectionsMap.get(repoBaseUrl)) {
+ Package pkg = new Package(sect.getProperties(), repoBaseUrl);
+
+ if (isExtensionPackage) {
+ if (pkg.getAttribute().equalsIgnoreCase("extra")) {
+ pkg.setExtensionServer(repoBaseUrl);
+ destPackages.add(pkg);
+ }
+ } else {
+ destPackages.add(pkg);
+ }
+ }
+ }
+ }
+
+ /**
+ * @return packages of repository
+ */
+ public PackageSet getRepoPackages() {
+ return repoPackages;
+ }
+
+ /**
+ * @return root meta packages of repository
+ */
+ public PackageSet getRootMetaPackagesOfRepository() {
+ return rootMeta(repoPackages);
+ }
+
+ /**
+ * Get install meta packages from repository.
+ * @return
+ */
+ public PackageSet getInstallMetaPackagesOfRepository() {
+ return installMeta(repoPackages);
+ }
+
+ /**
+ * Get root meta package from extension package server()
+ */
+ public PackageSet getRootMetaPackagesOfExtensionServer() {
+ return rootMeta(extensionPackages);
+ }
+
+ /**
+ * @return recent packages. This includes the latest packages among all packages from currently
+ * installed packages and packages of repository if a package has several versions.
+ */
+ public PackageSet getRecentPackages() {
+ if(recentPackages == null) {
+ recentPackages = new PackageSet();
+ for(Package ip : installedPackages) {
+ if(repoPackages != null && repoPackages.contains(ip)) {
+ Package rp = repoPackages.getPackage(ip);
+ if(ip.getVersion().compareTo(rp.getVersion()) > 0) {
+ recentPackages.add(ip);
+ } else {
+ recentPackages.add(rp);
+ }
+ } else if (extensionPackages != null && extensionPackages.contains(ip)) {
+ Package ep = extensionPackages.getPackage(ip);
+ if(ip.getVersion().compareTo(ep.getVersion()) > 0) {
+ recentPackages.add(ip);
+ } else {
+ recentPackages.add(ep);
+ }
+ } else {
+ recentPackages.add(ip);
+ }
+ }
+
+ for(Package rp : repoPackages) {
+ if(!recentPackages.contains(rp)) {
+ recentPackages.add(rp);
+ }
+ }
+ }
+ return recentPackages;
+ }
+
+ private void setExtensionPackagesToRecentPackages() {
+ if (recentPackages == null) {
+ recentPackages = new PackageSet();
+ }
+
+ for(Package ip : installedPackages) {
+ if (extensionPackages != null && extensionPackages.contains(ip)) {
+ Package ep = extensionPackages.getPackage(ip);
+ if(ip.getVersion().compareTo(ep.getVersion()) > 0) {
+ recentPackages.add(ip);
+ } else {
+ recentPackages.add(ep);
+ }
+ } else {
+ recentPackages.add(ip);
+ }
+ }
+ }
+
+
+
+ // Methods for update process
+ /**
+ * except package from installed package list.
+ * @param pkg
+ * @return
+ */
+ public boolean exceptPackageFromInstalledPackages(Package pkg) {
+ return installedPackages.remove(pkg);
+ }
+
+ /**
+ * Add package to installed package list.
+ * @param pkg
+ * @return
+ */
+ public boolean addPackageToInstalledPackages(Package pkg) {
+ installedPackages.remove(pkg);
+ return installedPackages.add(pkg);
+ }
+
+ /**
+ * @return updatable packages among installed packages
+ */
+ public PackageSet getUpdatableInstalledPackages() {
+ PackageSet updatables = new PackageSet();
+ for(Package ip : installedPackages) {
+ if(repoPackages.contains(ip)) {
+ Package rp = repoPackages.getPackage(ip);
+ if(rp.getVersion().compareTo(ip.getVersion()) != 0) {
+ updatables.add(ip);
+ }
+ }
+ }
+ return updatables;
+ }
+
+ /**
+ * if pkg is updatable, return true. else return false.
+ * @param pkg
+ * @return
+ */
+ public boolean isUpdatable(Package pkg) {
+ PackageSet updatables = getUpdatableInstalledPackages();
+
+ if (updatables.contains(pkg)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * If pkg is installed, return true. else return false
+ * @param pkg
+ * @return
+ */
+ public boolean isInstalledVersion(Package pkg) {
+ Package installedPackage = installedPackages.getPackage(pkg);
+ if (installedPackage == null) {
+ return false;
+ } else {
+ Version installedVersion = installedPackage.getVersion();
+ if (installedVersion.compareTo(pkg.getVersion()) == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * @return meta packages among installed packages
+ */
+ public PackageSet getInstalledMetaPackages() {
+ return meta(installedPackages);
+ }
+
+ /**
+ * @return meta packages among all recent packages
+ */
+ public PackageSet getAllMetaPackages() {
+ PackageSet allMeta = new PackageSet();
+
+ PackageSet recentMeta = meta(recentPackages);
+ PackageSet extensionMeta = meta(extensionPackages);
+
+ allMeta.addAll(recentMeta);
+ allMeta.addAll(extensionMeta);
+
+ return allMeta;
+ }
+
+ /**
+ * Get dependency packages of installable package.
+ * @param pkgs installable packages.
+ * @return
+ */
+ public PackageSet getDependsPackagesFromRepository(PackageSet pkgs) {
+ return dep(pkgs, State.INSTALL);
+ }
+
+ /**
+ * @return meta packages that have no updates considering its dependents
+ */
+ public PackageSet getNotUpdatableMetaPackages() {
+ PackageSet noup = new PackageSet();
+ for(Package m : getAllMetaPackages()) {
+ if(!isMetaUpdatable(m)) {
+ noup.add(m);
+ }
+ }
+ return noup;
+ }
+
+ public PackageSet getNotInstallableAndNotUpdatablePackages() {
+ PackageSet notPkg = new PackageSet();
+
+ for (Package m :getAllMetaPackages()) {
+ if (isMetaRemovable(m) && !isMetaUpdatable(m)) {
+ notPkg.add(m);
+ }
+ }
+
+ return notPkg;
+ }
+
+ /**
+ * @return meta packages thar are updatable among installed packages
+ */
+ public PackageSet getUpdatableMetaPackages() {
+ PackageSet allMetas = getAllMetaPackages();
+ PackageSet notUpdatableMetas = getNotUpdatableMetaPackages();
+ return diff(allMetas, notUpdatableMetas);
+ }
+
+ /**
+ * @param selectedMetas
+ * @return packages that will be installed after update/install resulted from the selected meta packages
+ */
+ public PackageSet getResultPackagesAfterUpdate(PackageSet selectedMetas) {
+ PackageSet deps = dep(selectedMetas, State.INSTALL);
+ PackageSet conflicts = conflict(selectedMetas);
+ PackageSet remainedFromConflicts = diff(installedPackages, conflicts);
+ return union(deps, remainedFromConflicts);
+ }
+
+ /**
+ * Get updatable packages in update process except new packages.
+ * @param selectedMetas
+ * @return
+ */
+ public PackageSet getUpdatablepackagesInUpdate(PackageSet selectedMetas) {
+ PackageSet result = dep(selectedMetas, State.INSTALL);
+ PackageSet up = getUpdatableInstalledPackages();
+ return intersect(result, up);
+ }
+
+ /**
+ * Get removable packages in snapshot process except new packages.
+ * @param selectedMetas
+ * @return
+ */
+ public PackageSet getRemovablePackagesInSnapshot(PackageSet selectedMetas) {
+ PackageSet result = dep(selectedMetas, State.UNINSTALL);
+ PackageSet pkgSet = getdifferentVersionFromInstalledPackages(result);
+
+ return pkgSet;
+ }
+
+ /**
+ * check version between sourcePackages and installedPackages, and return different version packages.
+ * @param pkgs
+ * @return Different version packages among installed packages
+ */
+ public PackageSet getdifferentVersionFromInstalledPackages(PackageSet pkgs) {
+ PackageSet depPkgs = dep(pkgs, State.INSTALL);
+ PackageSet otherVersionPackages = new PackageSet();
+ for(Package ip : installedPackages) {
+ if(depPkgs.contains(ip)) {
+ Package rp = depPkgs.getPackage(ip);
+ if(rp.getVersion().compareTo(ip.getVersion()) != 0) {
+ otherVersionPackages.add(ip);
+ }
+ }
+ }
+
+ return otherVersionPackages;
+ }
+
+ /**
+ * @param selectedMetas
+ * @return packages to newly install in update process by the selected meta packages
+ */
+ public PackageSet getInstallablePackages(PackageSet selectedMetas) {
+ PackageSet result = getResultPackagesAfterUpdate(selectedMetas);
+ PackageSet installablePkgs = diffPackageWithVersion(result, installedPackages);
+ return installablePkgs;
+ }
+
+ /**
+ * @param selectedMetas
+ * @return packages to update in update process by the selected meta packages
+ */
+ public PackageSet getToUpdatePackagesInUpdate(PackageSet selectedMetas) {
+ PackageSet result = getResultPackagesAfterUpdate(selectedMetas);
+ PackageSet up = getUpdatableInstalledPackages();
+ return intersect(result, up);
+ }
+
+
+ /**
+ * @param selectedMetas
+ * @return packages to remove in update process by conflicts with the selected meta packages
+ */
+ public PackageSet getConflictPackagesInUpdate(PackageSet selectedMetas) {
+ PackageSet conflicts = conflict(selectedMetas);
+ return intersect(conflicts, installedPackages);
+ }
+
+ // Methods for remove process
+
+ /**
+ * @return packages that can be removed
+ */
+ public PackageSet getRemovableMetaPackages() {
+ return getInstalledMetaPackages();
+ }
+
+ public PackageSet getInstallableMetaPackagesInSnapshot() {
+ PackageSet repoMetas = meta(repoPackages);
+
+ PackageSet installableMeta = new PackageSet();
+ for (Package metaPackage : repoMetas) {
+ if (isMetaInstallable(metaPackage)) {
+ installableMeta.add(metaPackage);
+ }
+ }
+
+ return installableMeta;
+ }
+
+ /**
+ * @param selectedMetas
+ * @return packages to remove in remove process
+ */
+ public PackageSet getToRemovePackagesInRemove(PackageSet selectedMetas) {
+ /*
+ PackageSet dep = dep(selectedMetas);
+ PackageSet mayRemove = intersect(installedPackages, dep);
+ PackageSet remainMetas = diff(getInstalledMetaPackages(), selectedMetas);
+ PackageSet remainPackages = dep(remainMetas);
+ PackageSet toRemove = diff(mayRemove, remainPackages);
+ return reverseSet(toRemove);
+ */
+ PackageSet dep = dep(selectedMetas, State.UNINSTALL);
+ return reverseSet(dep);
+ }
+
+ /**
+ * @param selectedMetas
+ * @return packages that will be remained after remove resulted from the selected meta packages
+ */
+ public PackageSet getResultPackagesAfterRemove(PackageSet selectedMetas) {
+ return diff(getInstalledMetaPackages(), selectedMetas);
+ }
+
+ // set handling methods
+
+ /**
+ * @param pset
+ * @return meta packages in the package set
+ */
+ private PackageSet meta(PackageSet pset) {
+ PackageSet metas = new PackageSet();
+
+ if (pset == null) {
+ return metas;
+ }
+
+ for(Package p : pset) {
+ if(p.isMeta()) {
+ metas.add(p);
+ }
+ }
+ return metas;
+ }
+
+ /**
+ * @param pset
+ * @return meta packages in the package set
+ */
+ private PackageSet rootMeta(PackageSet pset) {
+ PackageSet metas = new PackageSet();
+ for(Package p : pset) {
+ if(p.isRootMeta() || p.isPartnerMeta() || p.isExtraMeta() || p.isPublicMeta()) {
+ metas.add(p);
+ }
+ }
+ return metas;
+ }
+
+ /**
+ * @param pset
+ * @return meta packages in the package set
+ */
+ private PackageSet installMeta(PackageSet pset) {
+ PackageSet metas = new PackageSet();
+ for(Package p : pset) {
+ if(p.isInstallMeta()) {
+ metas.add(p);
+ }
+ }
+ return metas;
+ }
+
+ /**
+ * Get dependency package list from p.
+ * @param p a package
+ * @return all the packages that the given package depends on directly or indirectly
+ */
+ private PackageSet dep(Package p, State state) {
+ // depth first traverse on dependency graph
+ PackageSet dep = new PackageSet();
+ Stack<Package> pkgStack = new Stack<Package>();
+ pkgStack.push(p);
+ while(!pkgStack.isEmpty()) {
+ Package pkg = pkgStack.pop();
+
+ if(!dep.contains(pkg)) {
+ dep.add(pkg);
+ PackageSet depPackageSet = new PackageSet();
+ try {
+ if (state == State.INSTALL) {
+ if (repoPackages.contains(pkg)) {
+ depPackageSet = repoPackages.getPackagesByNames(pkg.getDependentPackageNames());
+ } else if (extensionPackages.contains(pkg)) {
+ depPackageSet = extensionPackages.getPackagesByNames(pkg.getDependentPackageNames());
+ }
+ } else if (state == State.UNINSTALL){
+ depPackageSet = installedPackages.getPackagesByNames(pkg.getDependentPackageNames());
+ } else {
+ Log.err("State class have two state(INSTALL/UNINSTALL) ");
+ throw new IMFatalException(ErrorCode.UNKOWN_ERROR);
+ }
+ } catch (IMPackageNotFound e) {
+ Log.err("Finding dependents: "+p+": Package does not exist: " + e.getPackageName()+ " or "+ pkg.getDependentPackageNames());
+ throw new IMFatalException(ErrorCode.CANNOT_FIND_PACKAGE);
+ }
+
+ for(Package depPkg : depPackageSet) {
+ if(p.equals(depPkg)) {
+ Log.err("Circular dependency found: "+p);
+ throw new IMFatalException(ErrorCode.CIRCULAR_PACKAGE_DEPENDENCY);
+ }
+ pkgStack.push(depPkg);
+ }
+ } else {
+ // already visited.
+ addDependsSet(dep, pkg);
+ }
+ }
+
+ return reverseSet(dep);
+ }
+
+ /**
+ * Need reverse depends when remove.
+ * @param p
+ * @return
+ */
+ private PackageSet reverseDep(Package p) {
+ // depth first traverse on dependency graph
+ PackageSet reverseDep = new PackageSet();
+ Stack<Package> pkgStack = new Stack<Package>();
+ pkgStack.push(p);
+ while(!pkgStack.isEmpty()) {
+ Package pkg = pkgStack.pop();
+
+ if(!reverseDep.contains(pkg)) {
+ reverseDep.add(pkg);
+
+ for (Package recentPkg : recentPackages) {
+ Collection<String> dependsList = recentPkg.getDependentPackageNames();
+ for (String pkgName : dependsList) {
+ if (pkgName.equals(pkg.getPackageName())) {
+ pkgStack.push(recentPkg);
+ break;
+ }
+ }
+
+ }
+ } else {
+ // already visited
+ addDependsSet(reverseDep, pkg);
+ }
+ }
+
+ return reverseDep;
+ }
+
+ /**
+ * Remove saved package and save package at the end of set.
+ * @param dependsSet
+ * @param pkg
+ */
+ private void addDependsSet(PackageSet dependsSet, Package pkg) {
+ if (dependsSet.contains(pkg)) {
+ dependsSet.remove(pkg);
+ }
+
+ dependsSet.add(pkg);
+ }
+
+ /**
+ * reverse package list.
+ * @param pkgSet
+ * @return
+ */
+ public PackageSet reverseSet(PackageSet pkgSet) {
+ if (pkgSet == null) {
+ return null;
+ }
+
+ Stack<Package> stack = new Stack<Package>();
+ for (Package pkg : pkgSet) {
+ stack.push(pkg);
+ }
+
+ PackageSet reverseSet = new PackageSet();
+
+ while(!stack.isEmpty()) {
+ reverseSet.add(stack.pop());
+ }
+
+ return reverseSet;
+ }
+
+ /**
+ * @param pset package set
+ * @return all the packages that the given packages depends on directly or indirectly
+ */
+ private PackageSet dep(PackageSet pset, State state) {
+ PackageSet dep = new PackageSet();
+ for(Package p : pset) {
+ dep.addAll(dep(p, state));
+ }
+ return dep;
+ }
+
+ /**
+ * Get conflict package list from p.
+ * @param p
+ * @return packages that conflict with the given package directly or indirectly
+ */
+ public PackageSet conflict(Package p) {
+ PackageSet conflicts = new PackageSet();
+ PackageSet dep = dep(p, State.INSTALL);
+ for(Package pkg : dep) {
+ Collection<String> conflictPackageNames = pkg.getConflictPackageNames();
+ for(String conflictPackageName : conflictPackageNames) {
+ if(installedPackages.hasPackageByName(conflictPackageName)) {
+ Package conflictPackage = installedPackages.getPackageByName(conflictPackageName);
+ conflicts.addAll(reverseDep(conflictPackage));
+ }
+ }
+ }
+ return conflicts;
+ }
+
+ /**
+ * Get conflict package list.
+ * @param pset
+ * @return packages that conflict with the given packages directly or indirectly
+ */
+ private PackageSet conflict(PackageSet pset) {
+ PackageSet conflicts = new PackageSet();
+ for(Package p : pset) {
+ conflicts.addAll(conflict(p));
+ }
+ return conflicts;
+ }
+
+ /**
+ * Adds packages of pset2 to packages of pset1.
+ * @param pset1
+ * @param pset2
+ * @return new package set has the union of pset1 and pset2.
+ */
+ private PackageSet union(PackageSet pset1, PackageSet pset2) {
+ PackageSet union = (PackageSet) pset1.clone();
+ union.addAll(pset2);
+ return union;
+ }
+
+ /**
+ * Removes packages of pset2 from packages of pset1.
+ * @param pset1
+ * @param pset2
+ * @return new package set that represents (pset1 - pset2).
+ */
+ private PackageSet diff(PackageSet pset1, PackageSet pset2) {
+ PackageSet diff = new PackageSet();
+ for(Package p : pset1) {
+ if(!pset2.contains(p)) {
+ diff.add(p);
+ }
+ }
+ return diff;
+ }
+
+ private PackageSet diffPackageWithVersion(PackageSet pset1, PackageSet pset2) {
+ PackageSet diff = new PackageSet();
+ for(Package p : pset1) {
+ Package pkg = pset2.getPackage(p);
+
+ if (pkg == null) {
+ diff.add(p);
+ } else {
+ if (Version.compareTo(p.getVersion(), pkg.getVersion()) != 0) {
+ diff.add(p);
+ }
+ }
+ }
+ return diff;
+ }
+
+ /**
+ *
+ * @param pset1
+ * @param pset2
+ * @return new set of intersection of pset1 and pset2. It has the order of pset1.
+ */
+ private PackageSet intersect(PackageSet pset1, PackageSet pset2) {
+ PackageSet pset = new PackageSet();
+ for(Package p : pset1) {
+ if(pset2.contains(p)) {
+ pset.add(p);
+ }
+ }
+ return pset;
+ }
+
+ /**
+ * @param m meta package to be checked updatable
+ * @return <code>true</code> if the meta package is updatable.
+ * ie. the meta package is installed and one of its dependents is already installed and is updatable.
+ */
+ private boolean isMetaUpdatable(Package m) {
+ // if one of the meta package's dependents is installed and updatable, the meta package is updatable.
+ PackageSet dep = dep(m, State.INSTALL);
+
+ for(Package p : dep) {
+
+ if(installedPackages.contains(p)) {
+ Package ip = installedPackages.getPackage(p);
+ if (ip == null) {
+ continue;
+ }
+
+ Package rp = null;
+ if (repoPackages != null && repoPackages.hasPackage(p)) {
+ rp = repoPackages.getPackage(p);
+ } else if (extensionPackages != null && extensionPackages.hasPackage(p)) {
+ rp = extensionPackages.getPackage(p);
+ }
+
+ // checks p is updatable
+ if(rp != null && rp.getVersion().compareTo(ip.getVersion()) != 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+
+ /**
+ * @param m meta package to be checked removable
+ * @return <code>true</code> if the meta package is removable
+ * ie. the meta package is installed and one of its dependents is already installed and is removable.
+ */
+ private boolean isMetaRemovable(Package m) {
+ // if the meta package is not installed, it's never updatable
+ if(installedPackages.contains(m)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * check new installation or upgrade or downgrade.
+ * @param meta meta package to be checked installable.
+ * @return <code>true</code> if the meta package is updatable.
+ * ie. the meta package is installed and one of its dependents is already installed and is updatable.
+ */
+ private boolean isMetaInstallable(Package meta) {
+ // if one of the meta package's dependents is installed and updatable, the meta package is updatable.
+ PackageSet dep = dep(meta, State.INSTALL);
+
+ for(Package p : dep) {
+ //Do not check meta package. It is only used by install-type or category.
+ if (p.isMeta()) {
+ continue;
+ }
+
+ if(installedPackages.contains(p)) {
+ Package ip = installedPackages.getPackage(p);
+ if (ip == null) {
+ continue;
+ }
+
+ Package rp = repoPackages.getPackage(p); // rp always exists if ip exists
+
+ // checks p is updatable
+ if(rp.getVersion().compareTo(ip.getVersion()) != 0) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // utility methods
+ /**
+ * Get installed package.
+ * @param pkg
+ * @return If not exist package in installed package list, return empty string.
+ */
+ public Package getInstalledPackageByName(String pkgName) {
+ Package retPkg = installedPackages.getPackageByName(pkgName);
+
+ return retPkg;
+ }
+
+ /**
+ * Get installed packages by package name.
+ * @param pkgName name of packages
+ * @return If not exist package in installed package list, return empty string.
+ */
+ public PackageSet getInstalledPackagesByName(List<String> pkgNames) {
+ PackageSet installedPackages = new PackageSet();
+ for (String pkg : pkgNames) {
+ Package retPkg = getInstalledPackageByName(pkg);
+
+ if (retPkg != null) {
+ installedPackages.add(retPkg);
+ }
+ }
+
+ return installedPackages;
+ }
+
+ /**
+ * Get Package instance from package name.
+ * @param pkgName
+ * @return
+ */
+ public Package getPackageByName(String pkgName) {
+ if(repoPackages.hasPackageByName(pkgName)) {
+ return repoPackages.getPackageByName(pkgName);
+ } else {
+ return null;
+ }
+ }
+ /**
+ * @param packageNames
+ * @return packages collected by the given package names
+ */
+ public PackageSet getPackagesByNames(Collection<String> packageNames) {
+ PackageSet pset = new PackageSet();
+ for(String name : packageNames) {
+ if(repoPackages.hasPackageByName(name)) {
+ Package pkg = repoPackages.getPackageByName(name);
+ pset.add(pkg);
+ } else if (extensionPackages.hasPackageByName(name)) {
+ Package pkg = extensionPackages.getPackageByName(name);
+ pset.add(pkg);
+ } else {
+ throw new IMFatalException(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
+ }
+ }
+ return pset;
+ }
+
+ public PackageSet getMandatoryPackages() {
+ PackageSet pSet = new PackageSet();
+
+ for (Package pkg : repoPackages) {
+ if (pkg.isMandatory()) {
+ pSet.add(pkg);
+ }
+ }
+
+ return pSet;
+ }
+
+ /**
+ * Check installed meta packages
+ * @return if installed package exists, return true. if not return false.
+ */
+ public boolean existInstalledMetaPackages() {
+ if (getInstalledMetaPackages().size() <= 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Check installable meta packages
+ * @return if installable meta package exists, return true. if not return false.
+ */
+ public boolean existInstallableMetaPackages() {
+ if (getInstalledMetaPackages().size() <= 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Check installed packages.
+ * @return if installed package exists, return true. if not return false.
+ */
+ public boolean existInstalledPackages() {
+ if (installedPackages.size() <= 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Check installable or updatable packages.
+ * @return if installable package exists, return true. if not return false.
+ */
+ public boolean existInstallablePackages() {
+ for(Package p : repoPackages) {
+ if(installedPackages.contains(p)) {
+ Package ip = installedPackages.getPackage(p);
+ if (ip == null) {
+ continue;
+ }
+
+ Package rp = recentPackages.getPackage(p); // rp always exists if ip exists
+ // checks p is updatable
+ if(rp.getVersion().compareTo(ip.getVersion()) > 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * get total size to install.
+ * @param pkg
+ * @return
+ */
+ public long getTotalSizeOfInstallablePackages(Package pkg) {
+ PackageSet pkgs = new PackageSet();
+
+ pkgs.add(pkg);
+ PackageSet depPkgSet = getInstallablePackages(pkgs);
+
+ return getTotalSize(depPkgSet);
+ }
+
+ /**
+ * get total size to remove.
+ * @param pkg
+ * @return
+ */
+ public long getTotalSizeOfRemovablePackages(Package pkg) {
+ PackageSet pkgs = new PackageSet();
+
+ pkgs.add(pkg);
+ PackageSet depPkgSet = getToRemovePackagesInRemove(pkgs);
+
+ return getTotalSize(depPkgSet);
+ }
+
+ /**
+ * get total size to install.
+ * @param pkg
+ * @return
+ */
+ public long getTotalSizeOfInstallablePackages(PackageSet pkgs) {
+ PackageSet depPkgSet = getInstallablePackages(pkgs);
+
+ return getTotalSize(depPkgSet);
+ }
+
+ /**
+ * get total size to remove.
+ * @param pkg
+ * @return
+ */
+ public long getTotalSizeOfRemovablePackages(PackageSet pkgs) {
+ PackageSet depPkgSet = getRemovablePackagesInSnapshot(pkgs);
+
+ return getTotalSize(depPkgSet);
+ }
+
+ /**
+ * get total size to install
+ * @param pkgs
+ * @return
+ */
+// public long getInstallablePackageSize(PackageSet pkgs) {
+// return getTotalSize(pkgs);
+// }
+
+ private long getTotalSize(PackageSet pkgs) {
+ long totalSize = 0;
+ for (Package depPkg : pkgs) {
+ totalSize += depPkg.getPackageSize();
+ }
+
+ return totalSize;
+ }
+
+ /**
+ * @return <code>true</code> if installed and repository packages are empty.
+ */
+ public boolean isEmpty() {
+
+ if (installedPackages.size() <= 0 && repoPackages.size() <= 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get Installable packages.
+ * @return packages that can be newly installable.
+ */
+ public PackageSet getInstallableMetaPackages() {
+ return diff(getAllMetaPackages(), getInstalledMetaPackages());
+ }
+
+ /**
+ * @return packages that can be newly installable or updatable.
+ */
+ public PackageSet getInstallableOrUpdatableMetaPackages() {
+ PackageSet installableMetaPackages = new PackageSet();
+ PackageSet allMetaPackages = getAllMetaPackages();
+
+ for (Package metaPackage : allMetaPackages) {
+ if (isMetaInstallable(metaPackage)) {
+ installableMetaPackages.add(metaPackage);
+ }
+ }
+
+ return installableMetaPackages;
+ }
+
+
+ /**
+ * Check missing packages from repository's package list.
+ * @return packages that is missing in repository's package list.
+ */
+ public PackageSet getMissingPackagesFromRepository() {
+ PackageSet missingPackages = new PackageSet();
+
+ if (!repoPackages.isEmpty()) {
+ missingPackages = diff(installedPackages, repoPackages);
+ missingPackages = diff(missingPackages, extensionPackages);
+ }
+
+ return missingPackages;
+ }
+
+ /**
+ * save packages to installedpackage.list
+ * @param filePath
+ */
+ public void saveInstalledList(String filePath) {
+ if (filePath == null) {
+ return;
+ }
+ PropertyParser parser = new PropertyParser();
+ List<PropertySection> pSections = saveProperySectionsFromPackages(installedPackages);
+ parser.writeToFile(pSections, filePath);
+ }
+
+ public List<PropertySection> saveProperySectionsFromPackages(PackageSet packages) {
+ List<PropertySection> pSections = new ArrayList<PropertySection>();
+ PropertySection pSection = null;
+ Properties properties = null;
+
+ for (Package pkg : packages) {
+ properties = (Properties)pkg.getProperties();
+ pSection = new PropertySection();
+ pSection.setProperties(properties);
+ pSections.add(pSection);
+ }
+
+ return pSections;
+ }
+
+ /**
+ * Prints dependency graph of packages in dot format to stdout.
+ * @throws IMExitException
+ */
+ public void printDepGraph() throws IMExitException {
+ StringBuffer buf = new StringBuffer();
+ try {
+ buf.append("digraph G {\n");
+ for(Package p : recentPackages) {
+ PackageSet dep = dep(p, State.INSTALL);
+ for(Package d : dep) {
+ if(!d.equals(p)) {
+ buf.append("\""+p+"\" -> \"" + d + "\";\n");
+ }
+ }
+ }
+ buf.append("}\n");
+ System.out.println(buf);
+ } catch(Exception e) {
+ System.err.println(ErrorController.getErrorMessage()); // print error message to stderr for alert
+ Log.ExceptionLog(e);
+ throw new IMExitException(Config.EXITCODE_DEP_ERROR);
+ }
+ }
+
+ public static void dispose() {
+ if (pm != null) {
+ pm = null;
+ }
+ }
+
+ /**
+ * Get PackageManager singleton instance.
+ * @param installed
+ * @param repoPackagesUrls
+ * @return
+ * @throws IOException
+ */
+ public static PackageManager getInstance(File installed, Collection<String> repoPackagesUrls) throws IOException {
+ if (Options.platForm == null) {
+ if (pm == null) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ pm = new LinuxPackageManager(installed, repoPackagesUrls);
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ pm = new WindowsPackageManager(installed, repoPackagesUrls);
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ pm = new DarwinPackageManager(installed, repoPackagesUrls);
+ } else {
+ return null;
+ }
+ }
+ } else {
+ if (pm == null) {
+ if (Options.platForm.equals("ubuntu")) {
+ pm = new LinuxPackageManager(installed, repoPackagesUrls);
+ } else if (Options.platForm.equals("windows")) {
+ pm = new WindowsPackageManager(installed, repoPackagesUrls);
+ } else {
+ return null;
+ }
+ }
+ }
+ return pm;
+ }
+
+ public static PackageManager getInstance() {
+ return pm;
+ }
+}
sReadData = bReader.readLine();
Log.log(sReadData);
-
+ //end of file.
if (sReadData == null) {
if (pFieldList.size() > 0) {
pSection = new PropertySection();
pSectionReturn.add(pSection);
} else {}
break;
- } else {}
+ } else {
+ sReadData = sReadData.trim();
+ }
if (this.mSectionSeparator.equals(sReadData)) {
//read control
} else {
pField.setValue(pField.getValue()+'\n'+sReadData.trim());
}
+ } else {
+ Log.err("Cannot parse name and value from installmanager.conf. (read line => " + sReadData + ")");
}
}
}
} catch (IOException ie) {
Log.ExceptionLog(ie);
throw new IMFatalException(ErrorCode.CANNOT_PARSING_TEXT);
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(e.getMessage());
} finally {
try {
if(bReader != null) {
}
} catch (IOException ioe) {
throw new IMFatalException(ErrorCode.CANNOT_SAVE_PROPERTY_FILE);
+ } catch (Throwable e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(e.getMessage());
} finally {
try {
/*close*/
if (fWriter != null) {
fWriter.close();
}
- } catch (Exception e) {
+ } catch (Throwable e) {
Log.ExceptionLog(e);
}
}
--- /dev/null
+package org.tizen.installmanager.pkg.lib.darwin;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+
+public class DarwinPackageManager extends PackageManager {
+
+ public DarwinPackageManager(File installed, Collection<String> repoPackagesUrls)
+ throws IOException {
+ super(installed, repoPackagesUrls);
+ }
+
+ @Override
+ public String getPackageListFileName() {
+ return Config.PACKAGE_LIST_FILE_MACOS_64;
+ }
+
+}
--- /dev/null
+package org.tizen.installmanager.pkg.lib.linux;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.Platform;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+
+/**
+ * Package Manager for linux.
+ * <p>
+ * This class provides various methods for managing packages.
+ * Most of the methods handle packages symbolically. Namely, they are identified by its package name not the object if not specially mentioned.
+ * <p>
+ * Some methods are carefully designed to preserve the order of packages because the order of packages is important sometimes.
+ * See the details in the documentation of each methods.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public class LinuxPackageManager extends PackageManager {
+ public LinuxPackageManager(File installed, Collection<String> repoPackagesUrls)
+ throws IOException {
+ super(installed, repoPackagesUrls);
+ }
+
+ @Override
+ public String getPackageListFileName() {
+ if (Options.platFormBit != 0) {
+ if (Options.platFormBit == 32) {
+ return Config.PACKAGE_LIST_FILE_LINUX_32;
+ } else if (Options.platFormBit == 64){
+ return Config.PACKAGE_LIST_FILE_LINUX_64;
+ }
+ }
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32) {
+ return Config.PACKAGE_LIST_FILE_LINUX_32;
+ } else {
+ return Config.PACKAGE_LIST_FILE_LINUX_64;
+ }
+ }
+}
--- /dev/null
+package org.tizen.installmanager.pkg.lib.win;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.Platform;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+
+/**
+ * Package Manager for windows
+ * <p>
+ * This class provides various methods for managing packages.
+ * Most of the methods handle packages symbolically. Namely, they are identified by its package name not the object if not specially mentioned.
+ * <p>
+ * Some methods are carefully designed to preserve the order of packages because the order of packages is important sometimes.
+ * See the details in the documentation of each methods.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public class WindowsPackageManager extends PackageManager {
+
+ public WindowsPackageManager (File installed,
+ Collection<String> repoPackagesUrls) throws IOException {
+ super(installed, repoPackagesUrls);
+ }
+
+ @Override
+ public String getPackageListFileName() {
+ if (Options.platFormBit != 0) {
+ if (Options.platFormBit == 32) {
+ return Config.PACKAGE_LIST_FILE_WINDOWS_32;
+ } else if (Options.platFormBit == 64){
+ return Config.PACKAGE_LIST_FILE_WINDOWS_64;
+ }
+ }
+ if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32) {
+ return Config.PACKAGE_LIST_FILE_WINDOWS_32;
+ } else {
+ return Config.PACKAGE_LIST_FILE_WINDOWS_64;
+ }
+ }
+
+}
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.pkg.model;
import java.io.IOException;
import java.util.List;
-import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.Log;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
import org.tizen.installmanager.pkg.lib.PropertyParser;
-import org.tizen.installmanager.util.PathUtil;
-
/**
* This class describes the installmanager.conf file.
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
public class ConfigFile {
- private static final String FIELD_REPOSITORY = "Repository";
- private static final String FIELD_INSTALLMANAGER_REPOSITORY = "InstallManager-Repository";
- private static final String FIELD_INSTALLMANAGER_VERSION = "InstallManager-Version";
- private static final String FIELD_PROXY_SERVER = "Proxy-server";
- private static final String FIELD_PROXY_PORT = "Proxy-port";
+ private static final String FIELD_REPOSITORY = "Repository";
+ private static final String FIELD_Distribution = "Distribution";
+ private static final String FIELD_PACKAGE_SERVER = "Package-Server";
+ private static final String FIELD_EXTENSION_SERVER = "Extension-Server";
+ private static final String FIELD_BUILT_IN_EXTENSION_SERVER = "Built-in-Extension-Server";
+ private static final String FIELD_INSTALLMANAGER_REPOSITORY = "InstallManager-Repository";
+ private static final String FIELD_INSTALLMANAGER_VERSION = "InstallManager-Version";
+ private static final String FIELD_PROXY_SERVER = "Proxy-server";
+ private static final String FIELD_PROXY_PORT = "Proxy-port";
+ private static final String FIELD_SNAPSHOT_PATH = "Snapshot-Path";
+ private static final String FIELD_RELEASE_NOTE = "Release-note";
- private Properties mProperties;
- private String mConfigFilePath;
+ private Properties mProperties;
+ private String mConfigFilePath;
- public ConfigFile(String confPath) {
- mProperties = new Properties();
+ public ConfigFile(String confPath) {
+ mProperties = new Properties();
if (!loadConfigFile(confPath)) {
Log.err("Fail to load config file in this path : " + confPath);
ErrorController.setError(ErrorCode.CANNOT_FIND_CONFIG_FILE);
} else {
Log.log("Success to load config file in this path : " + confPath);
}
- }
-
- /**
- * @return Repository of package list to install.
- */
- public String getRepository() {
- return getValue(FIELD_REPOSITORY);
- }
-
- /**
- * @return Repository of installmanager to update installmanager's binary
- */
- public String getInstallManagerRepository() {
- return getValue(FIELD_INSTALLMANAGER_REPOSITORY);
- }
-
- /**
- * @return Version of installmanager
- */
- public String getInstallManagerVersion() {
- return getValue(FIELD_INSTALLMANAGER_VERSION);
- }
-
- /**
- * @return proxy-server for connecting to repository.
- */
- public String getProxyServer() {
- return getValue(FIELD_PROXY_SERVER);
- }
-
- /**
- * Set proxy server ip.
- * @param proxyServer
- */
- public void setProxyServer(String proxyServer) {
- Property property = getProperty(ConfigFile.FIELD_PROXY_SERVER);
-
- if (property != null) {
- property.setValue(proxyServer);
- } else {
- property = new Property();
- property.setName(ConfigFile.FIELD_PROXY_SERVER);
- property.setValue(proxyServer);
-
- mProperties.add(property);
- }
- }
-
- /**
- * @return port number for proxy. -1 if not specified.
- */
- public int getProxyPort() {
- String proxyPortStr = getValue(FIELD_PROXY_PORT);
- try {
- if(!proxyPortStr.isEmpty()) {
- return Integer.parseInt(proxyPortStr);
- } else {
- return -1;
- }
- } catch(NumberFormatException e) {
- Log.log("Invalid proxy port");
- return -1;
- }
- }
-
- /**
- * Set proxy port
- * @param proxyPort
- */
- public void setProxyPort(String proxyPort) {
- Property property = getProperty(ConfigFile.FIELD_PROXY_PORT);
-
- if (property != null) {
- property.setValue(proxyPort);
- } else {
- property = new Property();
- property.setName(ConfigFile.FIELD_PROXY_PORT);
- property.setValue(proxyPort);
-
- mProperties.add(property);
- }
- }
-
- /**
- * Get Property instance from configuration key.
- * @param key
- * @return
- */
- private Property getProperty(String key) {
- if (mProperties != null && key != null) {
- for (int i = 0; i < mProperties.size(); i++) {
- if (key.compareTo(mProperties.get(i).getName()) == 0) {
- return mProperties.get(i);
- }
- }
- }
- return null;
- }
-
- /**
- * @param key
- * @return Get value from configuration key.
- */
- public String getValue(String key) {
- Property property = getProperty(key);
-
- if (property != null) {
- return property.getValue();
- } else {
- return "";
- }
- }
-
- /**
- * Get properties instance from this class
- * @return
- */
- public Properties getProperties() {
- return mProperties;
- }
-
- /**
- * Set Properties instance to this class.
- * @param properties
- */
- public void setProperties(Properties properties) {
- this.mProperties = properties;
- }
-
- /**
- * Set installmanager's version
- * @param version
- */
- public void setInstallManagerVersion(String version) {
- Property property = getProperty(ConfigFile.FIELD_INSTALLMANAGER_VERSION);
-
- if (property != null) {
- property.setValue(version);
- } else {
- property = new Property();
- property.setName(ConfigFile.FIELD_INSTALLMANAGER_VERSION);
- property.setValue(version);
-
- mProperties.add(property);
- }
- }
-
- public void setRepository(String repository) {
- Property property = getProperty(ConfigFile.FIELD_REPOSITORY);
-
- if (property != null) {
- property.setValue(repository);
- } else {
- property = new Property();
- property.setName(ConfigFile.FIELD_REPOSITORY);
- property.setValue(repository);
-
- mProperties.add(property);
- }
- }
-
- /**
- * Load config file from configFilePath.
- * @param configFilePath
- * @return
- */
- private boolean loadConfigFile(String configFilePath) {
- List<PropertySection> propertySections = null;
-
- File configFile = new File(configFilePath);
-
- if (!configFile.exists()) {
- configFilePath = PathUtil.getFromInstalledPath(Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_PATH);
- setConfigPath(configFilePath);
- } else {
- setConfigPath(configFilePath);
- }
-
- PropertyParser parser = new PropertyParser();
- propertySections = parser.readFromFile(configFilePath);
-
- return loadFromProperties(propertySections);
- }
-
- /**
- * Read PropertySection and make ConfigFile instance
- * @param propertySections
- * @return
- */
- public boolean loadFromProperties(List<PropertySection> propertySections) {
- if ((propertySections == null) || (propertySections.size() == 0)) {
- Log.log("(propertySections == null) || (propertySections.size() == 0)");
- return false;
- }
-
- this.setProperties(propertySections.get(0).getProperties());
- return true;
- }
-
- /**
- * save config file to configFilePath.
- * @param configFilePath config file path
- */
- public void saveConfig(String configFilePath) {
- Log.log("Config save config start => " + configFilePath);
- if (this == null) {
- Log.err("No config object");
- return;
- } else {}
-
- if (configFilePath == null || configFilePath.equals("")) {
- Log.err("Invalid config file path");
- return;
- }
-
- File configFile = new File(configFilePath);
- if (configFile.exists()) {
- configFile.delete();
- }
-
- File parentDir = configFile.getParentFile();
- if (!parentDir.exists()) {
- parentDir.mkdirs();
- } else {}
-
- try {
+ }
+
+ /**
+ * @return Repository of package list to install.
+ */
+ public String getRepository() {
+ return getValue(FIELD_REPOSITORY);
+ }
+
+ /**
+ * @return Repository of package list to install.
+ */
+ public String getDistribution() {
+ return getValue(FIELD_Distribution);
+ }
+
+ /**
+ * @return Repository of installmanager to update installmanager's binary
+ */
+ public String getInstallManagerRepository() {
+ return getValue(FIELD_INSTALLMANAGER_REPOSITORY);
+ }
+
+ /**
+ * @return Version of installmanager
+ */
+ public String getInstallManagerVersion() {
+ return getValue(FIELD_INSTALLMANAGER_VERSION);
+ }
+
+ /**
+ * @return Version of installmanager
+ */
+ public String getReleaseNoteUrl() {
+ return getValue(FIELD_RELEASE_NOTE);
+ }
+
+ /**
+ * @return proxy-server for connecting to repository.
+ */
+ public String getProxyServer() {
+ return getValue(FIELD_PROXY_SERVER);
+ }
+
+ /**
+ * Set proxy server ip.
+ *
+ * @param proxyServer
+ */
+ public void setProxyServer(String proxyServer) {
+ Property property = getProperty(ConfigFile.FIELD_PROXY_SERVER);
+
+ if (property != null) {
+ property.setValue(proxyServer);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_PROXY_SERVER);
+ property.setValue(proxyServer);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * @return port number for proxy. -1 if not specified.
+ */
+ public int getProxyPort() {
+ String proxyPortStr = getValue(FIELD_PROXY_PORT);
+ try {
+ if (!proxyPortStr.isEmpty()) {
+ return Integer.parseInt(proxyPortStr);
+ } else {
+ return -1;
+ }
+ } catch (NumberFormatException e) {
+ Log.log("Invalid proxy port");
+ return -1;
+ }
+ }
+
+ /**
+ * Set proxy port
+ *
+ * @param proxyPort
+ */
+ public void setProxyPort(String proxyPort) {
+ Property property = getProperty(ConfigFile.FIELD_PROXY_PORT);
+
+ if (property != null) {
+ property.setValue(proxyPort);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_PROXY_PORT);
+ property.setValue(proxyPort);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * @return Package-server for downloading packages.
+ */
+ public String getPackageServer() {
+ return getValue(FIELD_PACKAGE_SERVER);
+ }
+
+ /**
+ * Set package server
+ *
+ * @param packageServer package server address.
+ */
+ public void setPackageServer(String packageServer) {
+ Property property = getProperty(ConfigFile.FIELD_PACKAGE_SERVER);
+
+ if (property != null) {
+ property.setValue(packageServer);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_PACKAGE_SERVER);
+ property.setValue(packageServer);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * @return snapshot path from repository.
+ */
+ public String getSnapshotPath() {
+ return getValue(FIELD_SNAPSHOT_PATH);
+ }
+
+ /**
+ * Set snapshot path from repository
+ *
+ * @param snapshot path.
+ */
+ public void setSnapshotPath(String snapshotPath) {
+ Property property = getProperty(ConfigFile.FIELD_SNAPSHOT_PATH);
+
+ if (property != null) {
+ property.setValue(snapshotPath);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_SNAPSHOT_PATH);
+ property.setValue(snapshotPath);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * @return Built-in Extension-server for downloading packages.
+ */
+ public String getBuiltInExtensionServer() {
+ return getValue(FIELD_BUILT_IN_EXTENSION_SERVER);
+ }
+
+ /**
+ * @return Extension-server for downloading packages.
+ */
+ public String getExtensionServer() {
+ return getValue(FIELD_EXTENSION_SERVER);
+ }
+
+ /**
+ * Set package server
+ *
+ * @param packageServer package server address.
+ */
+ public void setExtensionServer(String extensionServer) {
+ Property property = getProperty(ConfigFile.FIELD_EXTENSION_SERVER);
+
+ if (property != null) {
+ property.setValue(extensionServer);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_EXTENSION_SERVER);
+ property.setValue(extensionServer);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * Get Property instance from configuration key.
+ *
+ * @param key
+ * @return
+ */
+ private Property getProperty(String key) {
+ if (mProperties != null && key != null) {
+ for (int i = 0; i < mProperties.size(); i++) {
+ if (key.compareTo(mProperties.get(i).getName()) == 0) {
+ return mProperties.get(i);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param key
+ * @return Get value from configuration key.
+ */
+ public String getValue(String key) {
+ Property property = getProperty(key);
+
+ if (property != null) {
+ return property.getValue();
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ * Get properties instance from this class
+ *
+ * @return
+ */
+ public Properties getProperties() {
+ return mProperties;
+ }
+
+ /**
+ * Set Properties instance to this class.
+ *
+ * @param properties
+ */
+ public void setProperties(Properties properties) {
+ this.mProperties = properties;
+ }
+
+ /**
+ * Set installmanager's version
+ *
+ * @param version
+ */
+ public void setInstallManagerVersion(String version) {
+ Property property = getProperty(ConfigFile.FIELD_INSTALLMANAGER_VERSION);
+
+ if (property != null) {
+ property.setValue(version);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_INSTALLMANAGER_VERSION);
+ property.setValue(version);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * Get sdk repository.
+ * @param repository
+ */
+ public void setRepository(String repository) {
+ Property property = getProperty(ConfigFile.FIELD_REPOSITORY);
+
+ if (property != null) {
+ property.setValue(repository);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_REPOSITORY);
+ property.setValue(repository);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * Get current distribution in repository.
+ * @param distribution
+ */
+ public void setDistribution(String distribution) {
+ Property property = getProperty(ConfigFile.FIELD_Distribution);
+
+ if (property != null) {
+ property.setValue(distribution);
+ } else {
+ property = new Property();
+ property.setName(ConfigFile.FIELD_Distribution);
+ property.setValue(distribution);
+
+ mProperties.add(property);
+ }
+ }
+
+ /**
+ * Load config file from configFilePath.
+ *
+ * @param configFilePath
+ * @return
+ */
+ private boolean loadConfigFile(String configFilePath) {
+ List<PropertySection> propertySections = null;
+
+ File configFile = new File(configFilePath);
+
+ if (!configFile.exists()) {
+ return false;
+ } else {
+ setConfigPath(configFilePath);
+ }
+
+ PropertyParser parser = new PropertyParser();
+ propertySections = parser.readFromFile(configFilePath);
+
+ return loadFromProperties(propertySections);
+ }
+
+ /**
+ * Read PropertySection and make ConfigFile instance
+ *
+ * @param propertySections
+ * @return
+ */
+ public boolean loadFromProperties(List<PropertySection> propertySections) {
+ if ((propertySections == null) || (propertySections.size() == 0)) {
+ Log.log("(propertySections == null) || (propertySections.size() == 0)");
+ return false;
+ }
+
+ this.setProperties(propertySections.get(0).getProperties());
+ return true;
+ }
+
+ /**
+ * save config file to configFilePath.
+ *
+ * @param configFilePath
+ * config file path
+ */
+ public void saveConfig(String configFilePath) {
+ Log.log("Config save config start => " + configFilePath);
+ if (this == null) {
+ Log.err("No config object");
+ return;
+ } else {
+ }
+
+ if (configFilePath == null || configFilePath.equals("")) {
+ Log.err("Invalid config file path");
+ return;
+ }
+
+ File configFile = new File(configFilePath);
+ if (configFile.exists()) {
+ configFile.delete();
+ }
+
+ File parentDir = configFile.getParentFile();
+ if (!parentDir.exists()) {
+ parentDir.mkdirs();
+ } else {
+ }
+
+ try {
configFile.createNewFile();
} catch (IOException e1) {
Log.err("Cannot create config file => " + configFilePath);
throw new IMFatalException(ErrorCode.CANNOT_SAVE_CONFIG);
}
-
+
BufferedWriter writer = null;
- try {
- writer = new BufferedWriter(new FileWriter(configFile));
-
- Properties repoProperties = this.getProperties();
- for (int i=0; i<repoProperties.size(); i++) {
- writer.write(repoProperties.get(i).getName() + ": " + repoProperties.get(i).getValue() + "\n");
- }
-
- writer.write("\n");
- } catch (IOException e) {
- Log.err("Cannot write config file");
- throw new IMFatalException(ErrorCode.CANNOT_SAVE_CONFIG);
- } finally {
- try {
- if (writer != null) {
- writer.close();
- }
+ try {
+ writer = new BufferedWriter(new FileWriter(configFile));
+
+ Properties repoProperties = this.getProperties();
+ for (int i = 0; i < repoProperties.size(); i++) {
+ writer.write(repoProperties.get(i).getName() + ": "
+ + repoProperties.get(i).getValue() + "\n");
+ }
+
+ writer.write("\n");
+ } catch (IOException e) {
+ Log.err("Cannot write config file");
+ throw new IMFatalException(ErrorCode.CANNOT_SAVE_CONFIG);
+ } finally {
+ try {
+ if (writer != null) {
+ writer.close();
+ }
} catch (IOException e) {
Log.err("close fileoutput fail");
}
- }
- Log.log("Config save config end");
- }
-
- private void setConfigPath(String configPath) {
- mConfigFilePath = configPath;
- }
-
- /**
- * @return Config file path that installer is using config file now.
- */
- public String getConfigPath() {
- return mConfigFilePath;
- }
+ }
+ Log.log("Config save config end");
+ }
+
+ private void setConfigPath(String configPath) {
+ mConfigFilePath = configPath;
+ }
+
+ /**
+ * @return Config file path that installer is using config file now.
+ */
+ public String getConfigPath() {
+ return mConfigFilePath;
+ }
}
--- /dev/null
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.pkg.model;
+
+import java.util.List;
+
+/**
+ * This class describes a distribution.
+ * This class cannot change variable.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public class Distribution {
+ private static final String FIELD_NAME = "name";
+ private static final String FIELD_DATE = "time";
+
+ private String repository = "";
+ private List<Property> mProperties;
+
+ /**
+ * Constructor.
+ *
+ * @param properties
+ * Set <code>properties</code> to member variable.
+ */
+ public Distribution(String repo, List<Property> properties) {
+ this.repository = repo;
+ this.mProperties = properties;
+ }
+
+ /**
+ * Get snapshot name.
+ * @return
+ */
+ public String getName() {
+ return getValue(FIELD_NAME);
+ }
+
+ /**
+ * Get intended date of snapshot
+ * @return
+ */
+ public String getDate() {
+ return getValue(FIELD_DATE);
+ }
+
+ /**
+ * Get Property instance from configuration key.
+ *
+ * @param key
+ * @return
+ */
+ private Property getProperty(String key) {
+ for (Property prop : mProperties) {
+ if (prop.getName().equals(key)) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return List of Property instance.
+ */
+ public List<Property> getProperties() {
+ return mProperties;
+ }
+
+ public String getRepository() {
+ return this.repository;
+ }
+
+ /**
+ * @param key
+ * @return string value of the property name. empty string if there's no
+ * such property name
+ */
+ private String getValue(String key) {
+ Property property = getProperty(key);
+ if (property == null) {
+ return null;
+ } else {
+ return property.getValue();
+ }
+ }
+
+ public String toString() {
+ return getName();
+ }
+}
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Wooyoung Cho <wooyoung1.cho@samsung.com>
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Taeyoung Son <taeyoung2.son@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.pkg.model;
+
+import java.util.LinkedHashSet;
+
+/**
+ * This class describes a snapshot list.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+@SuppressWarnings("serial")
+public class DistributionSet extends LinkedHashSet<Distribution>{
+ public final static DistributionSet EMPTY = new DistributionSet();
+
+ /**
+ * Finds and returns a snapshot in this set with the same name of the given snapshot.
+ * You have to check the existence with <code>contains()</code> method before calling this method.
+ * @param p0
+ * @return a snapshot that has same name with the given snapshot.
+ * <code>null</code> when cannot find the snapshot
+ */
+ public Distribution getDistribution(Distribution dist) {
+ for(Distribution d : this) {
+ if(d.equals(dist)) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param snapshot Name
+ * @return snapshot object that has the snapshot name.
+ * <code>null</code> when cannot find the snapshot
+ */
+ public Distribution getDistributionByName(String distName) {
+ for(Distribution d : this) {
+ String name = d.getName();
+
+ if (name != null) {
+ if(name.equals(distName)) {
+ return d;
+ }
+ }
+ }
+ return null;
+ }
+}
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Wooyoung Cho <wooyoung1.cho@samsung.com>
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Taeyoung Son <taeyoung2.son@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.pkg.model;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.lib.Platform;
+
+/**
+ * This class describes a package.
+ *
+ * @author Wooyoung Cho <wooyoung1.cho@samsung.com>
+ *
+ */
+public class Package {
+
+ // fields of package control
+ // mandatory
+ public static final String FIELD_PACKAGE = "Package";
+ public static final String FIELD_VERSION = "Version";
+ public static final String FIELD_LABEL = "Label";
+ public static final String FIELD_MAINTAINER = "Maintainer";
+ public static final String FIELD_DESCRIPTION = "Description";
+
+ // etc
+ public static final String FIELD_DEPENDS = "Install-dependency"; // list of packages that this package depends on
+ public static final String FIELD_CONFLICTS = "Conflicts";
+ public static final String FIELD_PACKAGE_SIZE = "Size"; // size of zipped package
+ // public static final String FIELD_INSTALLEDSIZE = "Installed-Size"; // TODO implement
+
+ // fields of installed control
+ public static final String FIELD_ATTRIBUTE = "Attribute";
+
+ // fields of repository control
+ public static final String FIELD_SHA256 = "SHA256";
+ public static final String FIELD_FILE_PATH = "Path"; // path from the base url
+
+ // fields of ordering for UI
+ public static final String FIELD_ORDER = "C-Order";
+
+ // field of Partner SDK
+ public static final String FIELD_PARTNER = "C-Partner";
+
+ // fields of script
+ public static final String INSTALL_SCRIPT_LINUX = "install.sh";
+ public static final String REMOVE_SCRIPT_LINUX = "remove.sh";
+ public static final String INSTALL_SCRIPT_WINDOWS = "Install.bat";
+ public static final String REMOVE_SCRIPT_WINDOWS = "Remove.bat";
+
+ // fields of ui control
+ public static final String FIELD_DEFAULT_CHECK = "Default";
+
+ //field of extension server. this field is used by installed list.
+ public static final String FIELD_EXTENSION_SERVER = "Extension-server";
+
+ // attribute value
+ private static final String ATTRIBUTE_ROOT_META = "root";
+ private static final String ATTRIBUTE_EXTRA_META = "extra";
+ private static final String ATTRIBUTE_INSTALL_META = "install";
+ private static final String ATTRIBUTE_MANDATORY = "mandatory";
+ private static final String ATTRIBUTE_PARTNER = "partner";
+ private static final String ATTRIBUTE_PUBLIC = "public";
+
+ //dependency information
+ private final String START_OF_OS_DEPENDENCY = "[";
+
+ private List<Property> mProperties;
+ private URL url; // url to the package zip file
+
+ private final int LOWEST_ORDER = 100;
+
+ public Package(List<Property> properties) {
+ this.mProperties = properties;
+ }
+
+ /**
+ * Make url of package.
+ * @param properties package
+ * @param repoBaseUrl url before snapshot path.
+ */
+ public Package(Properties properties, String repoBaseUrl) {
+ this(properties);
+ try {
+ if (Config.fromWhere == Config.ConfDialog.LOCAL_IMAGE) { // data from file dialog for local installing
+ this.url = new URL(repoBaseUrl + "/" + getValue(FIELD_FILE_PATH));
+ } else { // data from snapshot and normal 'next' case
+ this.url = new URL(repoBaseUrl + "/" + getValue(FIELD_FILE_PATH));
+ }
+ } catch (MalformedURLException e) {
+ Log.err("Invalid package url: "+repoBaseUrl + "/" + getValue(FIELD_FILE_PATH));
+ throw new IMFatalException(ErrorCode.WRONG_PACKAGE_URL);
+ }
+ }
+
+ /**
+ * @return version of this package
+ */
+ public Version getVersion() {
+ return new Version(getValue(FIELD_VERSION));
+ }
+
+ /**
+ * @return package name of this package
+ */
+ public String getPackageName() {
+ return getValue(FIELD_PACKAGE);
+ }
+
+ /**
+ * @return name of package.
+ */
+ public String getLabel() {
+ return getValue(FIELD_LABEL);
+ }
+
+ /**
+ * @return the size of zipped package file
+ */
+ public Long getPackageSize() {
+ long result = 0;
+ try {
+ result = Long.parseLong(getValue(FIELD_PACKAGE_SIZE));
+ } catch(NumberFormatException e) {
+ Log.err(toString() + " size do not exist.");
+ Log.ExceptionLog(e);
+ }
+
+ return result;
+ }
+
+ /**
+ * @return Path of this package File from repository.
+ */
+ public String getFileName() {
+ return getValue(FIELD_FILE_PATH);
+ }
+
+ /**
+ * @return Description of this package.
+ */
+ public String getDescription() {
+ return getValue(FIELD_DESCRIPTION);
+ }
+
+ /**
+ * @return SHA256 digest of this package file.
+ */
+ public String getSHA256() {
+ return getValue(FIELD_SHA256);
+ }
+
+ /**
+ * @return URL to the package file in repository.
+ */
+ public URL getURL() {
+ return url;
+ }
+
+ public String getPartner() {
+ return getValue(FIELD_PARTNER);
+ }
+
+ /**
+ * @return Extension server of this package.
+ */
+ public String getExtensionServer() {
+ return getValue(FIELD_EXTENSION_SERVER);
+ }
+
+ /**
+ * Set extension server to package information.
+ * @param extensionServer extension server of this packge
+ */
+ public void setExtensionServer(String extensionServer) {
+ Property property = getProperty(FIELD_EXTENSION_SERVER);
+
+ if (property != null) {
+ property.setValue(extensionServer);
+ } else {
+ property = new Property();
+ property.setName(FIELD_EXTENSION_SERVER);
+ property.setValue(extensionServer);
+
+ mProperties.add(property);
+ }
+ }
+ /**
+ * Get package order for InstallManager displaying package tree.
+ * @return package order
+ */
+ public int getOrder() {
+ String order = getValue(FIELD_ORDER);
+ if (order.equals("")) {
+ return LOWEST_ORDER;
+ } else {
+ int nOrder = 0;
+ try {
+ nOrder = Integer.parseInt(order);
+ } catch (NumberFormatException e) {
+ Log.err("C-Order field value is not a integer format.");
+ return 100;
+ }
+ return nOrder;
+ }
+ }
+
+ /**
+ * @return Remove Script name of this package.
+ */
+ public String getRemoveScript() {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return REMOVE_SCRIPT_LINUX;
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ return REMOVE_SCRIPT_WINDOWS;
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ return "";
+ } else {}
+ return null;
+ }
+
+ /**
+ * @return Install script name of this package.
+ */
+ public String getInstallScript() {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return INSTALL_SCRIPT_LINUX;
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
+ return INSTALL_SCRIPT_WINDOWS;
+ } else if (Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ return "";
+ } else {}
+ return null;
+ }
+
+ /**
+ * @return List of Property instance.
+ */
+ public List<Property> getProperties() {
+ return mProperties;
+ }
+
+ /**
+ * Get Property instance from key.
+ *
+ * @param key
+ * @return
+ */
+ private Property getProperty(String key) {
+ if (mProperties != null && key != null) {
+ for (int i = 0; i < mProperties.size(); i++) {
+ if (key.compareTo(mProperties.get(i).getName()) == 0) {
+ return mProperties.get(i);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param propertyName
+ * @return string value of the property name. empty string if there's no such property name
+ */
+ private String getValue(String propertyName) {
+ for(Property prop : mProperties) {
+ if(prop.getName().equals(propertyName)) {
+ return prop.getValue();
+ }
+ }
+ return "";
+ }
+
+ /**
+ * @return Attribute value.
+ */
+ public String getAttribute() {
+ return getValue(FIELD_ATTRIBUTE);
+ }
+
+ /**
+ * @return <code>true</code> if this package is a meta package.
+ */
+ public boolean isMeta() {
+ // onlyDownload option, in this case, do not need separate public meta package
+ // to partner meta package because installmanager should download all meta packages.
+ if (Options.onlyDownload) {
+ if (isRootMeta() || isInstallMeta() || isExtraMeta() ||
+ isPublicMeta() || isPartnerMeta() || isMandatory()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ if (!Options.partnerSdk) { // public download case
+ if (isRootMeta() || isInstallMeta() || isExtraMeta() || isMandatory() || isPublicMeta()) {
+ return true;
+ } else {
+ return false;
+ }
+ } else { // partner download case
+ if (isRootMeta() || isInstallMeta() || isExtraMeta() || isMandatory() || isPartnerMeta()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * @return <code>true</code> if this package is a root meta package.
+ */
+ public boolean isRootMeta() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_ROOT_META)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @return <code>true</code> if this package is a extra meta package.
+ */
+ public boolean isExtraMeta() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_EXTRA_META)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check to belong to partner sdk given package
+ * @return <code>true</code> if this package is a partner package.
+ */
+ public boolean isPartnerMeta() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_PARTNER)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check to belong to partner sdk given package
+ * @return <code>true</code> if this package is a partner package.
+ */
+ public boolean isPublicMeta() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_PUBLIC)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @return <code>true</code> if this meta package is a install meta package.
+ */
+ public boolean isInstallMeta() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_INSTALL_META)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @return <code>true</code>, if this package is a mandatory package. This package must install.
+ */
+ public boolean isMandatory() {
+ String attributeValue = getAttribute().trim();
+
+ if (attributeValue.equalsIgnoreCase(ATTRIBUTE_MANDATORY)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isExtensionPackage() {
+ String extensionServer = getExtensionServer();
+
+ if (extensionServer == null || extensionServer.isEmpty()) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * @return package names that this package directly depends on
+ */
+ public Collection<String> getDependentPackageNames() {
+ HashSet<String> depends = new HashSet<String>();
+ String dependsStr = getValue(FIELD_DEPENDS);
+ String deps[] = dependsStr.split(",");
+ for(int i = 0; i < deps.length; i++) {
+ String dep = removeOSInformationOfDepends(deps[i]);
+
+ if(!dep.isEmpty()) {
+ depends.add(dep);
+ }
+ }
+ return depends;
+ }
+
+ private String removeOSInformationOfDepends(String info) {
+ //Log.log("Package.removeOSInformation (info => " + info + ")");
+
+ if (info.contains(START_OF_OS_DEPENDENCY)) {
+ int index = info.indexOf(START_OF_OS_DEPENDENCY);
+ String pkgInfo = info.substring(0, index).trim();
+
+ return pkgInfo;
+ } else {
+ return info.trim();
+ }
+ }
+
+ /**
+ * @return package names that this package directly conflicts to
+ */
+ public Collection<String> getConflictPackageNames() {
+ HashSet<String> conflicts = new HashSet<String>();
+ String conflictsStr = getValue(FIELD_CONFLICTS);
+ String confs[] = conflictsStr.split(",");
+ for(int i = 0; i < confs.length; i++) {
+ conflicts.add(confs[i].trim());
+ }
+ return conflicts;
+ }
+
+ public String toString() {
+ return getPackageName();
+ }
+
+ /**
+ * Checks equality symbolically only using their package names.
+ * @return <code>true</code> if they have the same package name.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Package) {
+ Package pkg2 = (Package)obj;
+ return this.getPackageName().equals(pkg2.getPackageName());
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return getPackageName().hashCode();
+ }
+}
import java.util.Collection;
import java.util.LinkedHashSet;
+
/**
* This class represents a set of packages.
* Even though this is a set, it preserves the order that elements are added. Iteration on this set will be in the order elements are added.
* @author Wooyoung Cho <wooyoung1.cho@samsung.com>
*/
@SuppressWarnings("serial")
-public class PackageSet extends LinkedHashSet<Package2>{
+public class PackageSet extends LinkedHashSet<Package>{
public final static PackageSet EMPTY = new PackageSet();
/**
* @return a package that has same name with the given package.
* <code>null</code> when cannot find the package
*/
- public Package2 getPackage(Package2 p0) {
- for(Package2 p : this) {
+ public Package getPackage(Package p0) {
+ for(Package p : this) {
if(p.equals(p0)) {
return p;
}
* @return package object that has the package name.
* <code>null</code> when cannot find the package
*/
- public Package2 getPackageByName(String packageName) {
- for(Package2 p : this) {
+ public Package getPackageByName(String packageName) {
+ if (packageName == null) {
+ return null;
+ }
+
+ for(Package p : this) {
if(p.getPackageName().equals(packageName)) {
return p;
}
* @return true if there's a package with the package name
*/
public boolean hasPackageByName(String packageName) {
- for(Package2 p : this) {
+ for(Package p : this) {
if(p.getPackageName().equals(packageName)) {
return true;
}
* @param package instance
* @return true if there's a package.
*/
- public boolean hasPackage(Package2 pkg) {
+ public boolean hasPackage(Package pkg) {
if (getPackage(pkg) == null) {
return false;
} else {
public PackageSet getPackagesByNames(Collection<String> names) throws IMPackageNotFound {
PackageSet pset = new PackageSet();
for(String name : names) {
- Package2 pkg = getPackageByName(name);
+ Package pkg = getPackageByName(name);
if(pkg != null) {
pset.add(pkg);
- } else {
- throw new IMPackageNotFound(name);
}
}
return pset;
--- /dev/null
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.pkg.model;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.tizen.installmanager.lib.Log;
+
+/**
+ * This class describes a snapshot.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+public class Snapshot implements Comparable<Snapshot> {
+ private static final String FIELD_TYPE = "type";
+ private static final String FIELD_NAME = "name";
+ private static final String FIELD_PATH = "path";
+ private static final String FIELD_TIME = "time";
+
+ private List<Property> mProperties;
+
+ /**
+ * Constructor.
+ *
+ * @param properties
+ * Set <code>properties</code> to member variable.
+ */
+ public Snapshot(List<Property> properties) {
+ this.mProperties = properties;
+ }
+
+ /**
+ * Get snapshot type.
+ * @return
+ */
+ public String getType() {
+ return getValue(FIELD_TYPE);
+ }
+
+ /**
+ * Get snapshot name.
+ * @return
+ */
+ public String getName() {
+ return getValue(FIELD_NAME);
+ }
+
+ /**
+ * Get snapshot path.
+ * @return
+ */
+ public String getPath() {
+ return getValue(FIELD_PATH);
+ }
+
+ /**
+ * Get intended date of snapshot
+ * @return
+ */
+ public Date getTime() {
+ String strDate = getValue(FIELD_TIME);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date date = null;
+ try {
+ date = sdf.parse(strDate);
+ } catch (ParseException e) {
+ Log.err("Snapshot time attribute is not SimpleDateFormat.");
+ }
+ //Date date = new Date(lDate);
+ return date;
+ }
+
+ /**
+ * Get Property instance from configuration key.
+ *
+ * @param key
+ * @return
+ */
+ private Property getProperty(String key) {
+ for (Property prop : mProperties) {
+ if (prop.getName().equals(key)) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @return List of Property instance.
+ */
+ public List<Property> getProperties() {
+ return mProperties;
+ }
+
+ /**
+ * Set Properties instance to this class.
+ *
+ * @param properties
+ */
+ public void setProperties(List<Property> properties) {
+ this.mProperties = properties;
+ }
+
+ /**
+ * @param key
+ * @return string value of the property name. empty string if there's no
+ * such property name
+ */
+ private String getValue(String key) {
+ Property property = getProperty(key);
+ if (property == null) {
+ return null;
+ } else {
+ return property.getValue();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg != null) {
+ String argName = ((Snapshot)arg).getName();
+
+ if (argName.equals(getName())){
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(Snapshot snapshot) {
+ //Descending sort.
+ Date argTime = ((Snapshot)snapshot).getTime();
+ return argTime.compareTo(getTime());
+ }
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+}
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Wooyoung Cho <wooyoung1.cho@samsung.com>
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Taeyoung Son <taeyoung2.son@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.pkg.model;
+
+import java.util.ArrayList;
+
+/**
+ * This class describes a snapshot list.
+ *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
+ *
+ */
+@SuppressWarnings("serial")
+public class SnapshotList extends ArrayList<Snapshot> {
+ public final static SnapshotList EMPTY = new SnapshotList();
+
+ /**
+ * Finds and returns a snapshot in this list with the same name of the given snapshot.
+ * You have to check the existence with <code>contains()</code> method before calling this method.
+ * @param p0
+ * @return a snapshot that has same name with the given snapshot.
+ * <code>null</code> when cannot find the snapshot
+ */
+ public Snapshot getSnapshot(Snapshot snapshot) {
+ for(Snapshot s : this) {
+ if(s.equals(snapshot)) {
+ return s;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param snapshot Name
+ * @return snapshot object that has the snapshot name.
+ * <code>null</code> when cannot find the snapshot
+ */
+ public Snapshot getSnapshotByName(String snapshotName) {
+ for(Snapshot s : this) {
+ if(s.getName().equals(snapshotName)) {
+ return s;
+ }
+ }
+ return null;
+ }
+
+ public Snapshot getSnapshotByPath(String snapshotPath) {
+ for(Snapshot s : this) {
+ if(s.getPath().equals(snapshotPath)) {
+ return s;
+ }
+ }
+ return null;
+ }
+}
public static final int LT = -1;
public static final int GT = 1;
- private Integer mMajor;
- private Integer mMinor;
- private Integer mRevision;
+ private Integer mMajor = 0;
+ private Integer mMinor = 0;
+ private Integer mRevision = 0;
/**
* @param version full version.
*/
private void parseVersionString(String version) {
+ if (version == null || version.isEmpty()) {
+ return;
+ }
String[] dividedVersion = version.split("\\.");
int length = dividedVersion.length;
mRevision = Integer.parseInt(dividedVersion[2]);
}
} catch (NumberFormatException numException) {
- Log.err("Invalid package version: "+version);
- throw new IMFatalException(ErrorCode.INVALID_PACKAGE_VERSION);
+ Log.err("Invalid package version: "+version);
+ throw new IMFatalException(ErrorCode.INVALID_PACKAGE_VERSION);
}
}
package org.tizen.installmanager.ui;
-import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.widgets.Shell;
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMExitException;
-import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.core.InstallManager;
import org.tizen.installmanager.core.Options;
import org.tizen.installmanager.core.UpdateInstallManager;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.IMError;
import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.lib.OldRegistry;
import org.tizen.installmanager.lib.Platform;
import org.tizen.installmanager.lib.ProgramController;
import org.tizen.installmanager.lib.Registry;
-import org.tizen.installmanager.lib.ErrorController.ErrorCode;
-import org.tizen.installmanager.pkg.lib.PackageManager2;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Package;
import org.tizen.installmanager.pkg.model.PackageSet;
+import org.tizen.installmanager.ui.dialog.AddExtraRepositoryDialog;
import org.tizen.installmanager.ui.dialog.IndeterminateProgressDialog;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
import org.tizen.installmanager.ui.page.SetInstallDirectoryPage;
import org.tizen.installmanager.ui.page.UninstallableListPage;
import org.tizen.installmanager.ui.page.UninstallingPage;
+import org.tizen.installmanager.ui.page.UpdatableListPage;
import org.tizen.installmanager.ui.page.ViewController;
import org.tizen.installmanager.ui.page.WelcomePage;
import org.tizen.installmanager.ui.page.InstallingPage.InstallProgressMonitor;
import org.tizen.installmanager.ui.page.WelcomePage.RADIO_ACTION;
-import org.tizen.installmanager.util.IMShellCommandFail;
import org.tizen.installmanager.util.PathUtil;
-import org.tizen.installmanager.util.ShellUtil;
/**
* @author Taeyoung Son <taeyoung2.son@samsung.com>
*/
public class InstallManagerWindow extends ApplicationWindow {
- public static final RGB RGB_BACKGROUND = new RGB(242, 242,
- 242);
+ public static final RGB RGB_BACKGROUND = new RGB(242, 242, 242);
private static final Point POINT_MAIN_WINDOW = new Point(628, 478);
private static Image IMAGE_WINDOW_ICON;
private static Button btnClose;
private static Button btnBack;
private static Button btnNext;
+ private static Button addExtraButton;
+ private AddExtraRepositoryDialog extraDialog = null;
+
private Composite pageComposite;
private WelcomePage compositeWelcomePage;
private LicensePage compositeLicensePage;
private UninstallingPage compositeUninstallingPage;
private CompletePage compositeCompletePage;
private SetInstallDirectoryPage compositeSetInstallDirectoryPage;
+ public UpdatableListPage compositeUpdatableListPage;
private static ViewController controller;
private SelectionAdapter cancelBtnSelectionAdapter = null;
return IMAGE_WINDOW_ICON;
}
- private void init() {
+ private void init() throws IMExitException{
Log.log("Window init start");
-
- final Runnable initJob = new Runnable() {
-
- @Override
+
+ //make waiting dialog.
+ final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();
+
+ final Shell shell = progressbar.getParent();
+ shell.getDisplay().asyncExec(new Runnable(){
public void run() {
- try {
- checkJavaInstallation();
- controller = new ViewController();
- initController();
- } catch (IMFatalException e) {
- Log.ExceptionLog(e);
- ErrorController.setInstallationSuccess(false);
- } catch (Exception e) {
- Log.ExceptionLog(e);
- ErrorController.setInstallationSuccess(false);
- }
- }
-
- };
-
- try {
- // if GUI environment, show progress bar
- Shell shell = new Shell(Display.getCurrent());
- final IndeterminateProgressDialog progressbar = new IndeterminateProgressDialog(shell,
- SWT.NONE, "Checking Install Manager update...");
- progressbar.updateName("Initialize InstallManager");
- Runnable initWithUI = new Runnable() {
- public void run() {
- try {
- initJob.run();
- } finally {
- progressbar.finish();
+ //checking installmanager update.
+ if (Options.doUpdateInstallManager) {
+ progressbar.updateName("Checking InstallManager update.\nIt may take a minute...");
+ shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (updateInstallManager()) {
+ Log.log("InstallManager is updatable.");
+ System.out.println("## Success to update the InstallManager, and restart now.");
+ ErrorController.isInstallManagerUpdatable = true;
+ return;
+ }
+ }
+ });
+ } else {}
+
+ //initialize installmanager
+ progressbar.updateName("Connecting to package server.\nIt may take a minute...");
+ shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (!initInstallManager()) {
+ Log.err("InstallManager init fail.");
+ ErrorController.setInstallationSuccess(false);
+ }
}
- }
- };
- Thread initThread = new Thread(initWithUI);
- initThread.start();
- progressbar.open();
-
- try {
- initThread.join();
- } catch (InterruptedException e) {
- throw new IMFatalException("Failed to initialize");
+
+ });
+
+ //init end
+ progressbar.finish();
}
- } catch (SWTError e) {
- // if headless environment(especially for testing), just run the init job.
- Log.log("Headless env detected. Init without UI");
- initJob.run();
+ });
+
+ if (!shell.isDisposed()) {
+ progressbar.open();
}
-
- if (!ErrorController.checkInstallationSuccess()) {
- throw new IMFatalException(ErrorController.getErrorCode());
+
+ if (ErrorController.isInstallManagerUpdatable) {
+ throw new IMExitException(Config.EXITCODE_HAS_SELF_UPDATE);
}
Log.log("Window init end");
}
- private void initController() {
- boolean bResult = controller.init();
+ private boolean updateInstallManager() {
+ UpdateInstallManager upInstaller = new UpdateInstallManager();
+
+ return upInstaller.update();
- if (bResult == true) {
- Log.log("Installer is ready for installing - ViewController is " +
- "initialized succecsfully");
- ErrorController.setInstallationSuccess(true);
- } else {
- Log.err("Installer is not ready for installing - ViewController init failed");
- ErrorController.setInstallationSuccess(false);
- }
}
- private void checkJavaInstallation() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- File checkJavaScript = null;
- try {
- checkJavaScript = PathUtil.getTempFileFromResource(
- "/res/desktop_directory/checkJavaInstallation.sh",
- "checkJavaInstallation",
- ".sh");
- checkJavaScript.setExecutable(true);
- } catch (IOException e) {
- Log.ExceptionLog(e);
- throw new IMFatalException("Cannot execute checkJavaScript ");
- }
-
- try {
- int exitCode = ShellUtil.execute(checkJavaScript.getAbsolutePath());
- if (exitCode != 0) {
- throw new IMFatalException(ErrorCode.CANNOT_FIND_JAVA);
- }
- } catch (IMShellCommandFail e) {
- Log.ExceptionLog(e);
- throw new IMFatalException("Cannot execute " + checkJavaScript.getAbsolutePath());
- }
- }
+ /**
+ * init IM's configuation and packages information.
+ * @return
+ */
+ private boolean initInstallManager() {
+ ErrorController.setInstallationSuccess(true);
+
+ controller = new ViewController();
+ boolean bResult = controller.init();
+
+ return bResult;
}
/**
*/
@Override
protected Control createContents(Composite parent) {
+
IMError.setComposite(parent);
Composite container = new Composite(parent, SWT.NONE);
container.setBackground(getBackgroundColor());
result = MessageBoxDlg.showDlg(
e.display.getActiveShell(),
"Tizen SDK Install Manager",
- "Are you sure you want to quit Install Manager?\n\nIf you click \"Yes\", installation will be stopped.",
+ "Are you sure you want to quit Install Manager?\n\nIf you click \"Yes\", the installation is stopped.",
DialogType.WARNING);
if (result == MessageBoxDlg.YES) {
mon.setCanceled(true);
mon.setCancelRequested(false);
}
return;
- } else if (sl_composite.topControl == compositeUninstallingPage)
+ } else if (sl_composite.topControl == compositeUninstallingPage) {
result = MessageBoxDlg.showDlg(
e.display.getActiveShell(),
"Tizen SDK Install Manager",
- "Are you sure you want to quit Install Manager?\n\nIf you click \"Yes\", uninstallation will be stopped.",
+ "Are you sure to quit Install Manager?\n\nIf you click \"Yes\", the uninstallation is stopped.",
DialogType.WARNING);
- else if (sl_composite.topControl == compositeCompletePage) {
+ } else if (sl_composite.topControl == compositeCompletePage) {
if (Documents.isChecked()) {
- Documents.ShowChangeLog(); // show the change log(history)
+ Documents.showChangeLog(); // show the change log(history)
}
result = MessageBoxDlg.YES;
}
else
result = MessageBoxDlg.showDlg(e.display.getActiveShell(),
"Tizen SDK Install Manager",
- "Are you sure you want to quit Install Manager?",
+ "Are you sure to quit Install Manager?",
DialogType.WARNING);
if (result == MessageBoxDlg.YES) {
e.display.close();
@Override
public void widgetSelected(SelectionEvent e) {
if (sl_composite.topControl == compositeWelcomePage) {
+ addExtraButton.setVisible(false);
if (compositeWelcomePage.getSelectedRadioButton() == RADIO_ACTION.INSTALL) {
if (!ErrorController.checkInstallationSuccess())
return;
btnNext.setEnabled(compositeLicensePage.getAcceptButton()
.getSelection());
- if (controller.existRemovablePackage())
+ if (controller.existRemovablePackage()) // Update case
{
boolean hasItem = false;
- hasItem = compositeInstallablePage.loadPage(controller);
+ hasItem = compositeUpdatableListPage.loadPage(controller);
btnBack.setVisible(true);
+ addExtraButton.setVisible(true);
if (hasItem) {
- showComposite(compositeInstallablePage);
- btnNext.setEnabled(hasItem);
+ showComposite(compositeUpdatableListPage);
if (controller.existRemovablePackage()) {
btnNext.setText("Install");
}
btnBack.setVisible(true);
}
} else if (compositeWelcomePage.getSelectedRadioButton() == RADIO_ACTION.UNINSTALL) {
- if (Registry.isOldSDKInstalled()) {
- OldRegistry oreg = new OldRegistry();
- oreg.remove();
- showUninstallOldSDKCompletePage();
+ int resultDialog = MessageBoxDlg.NO;
+ resultDialog = MessageBoxDlg.showDlg(
+ e.display.getActiveShell(),
+ "Tizen SDK Install Manager",
+ "Are you sure you want to remove the Tizen SDK?\n\nIf you click \"Yes\", the Tizen SDK is uninstalled.",
+ DialogType.WARNING);
+ if (resultDialog == MessageBoxDlg.YES) {
+ showComposite(compositeUninstallingPage);
+ btnBack.setVisible(false);
+ btnNext.setVisible(false);
+ btnClose.setEnabled(false);
+ addExtraButton.setVisible(false);
+ List<Item> items = compositeUninstallablePage.getItems();
+ boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,
+ controller,
+ window);
+ if (!result) {
+ showComposite(compositeWelcomePage);
+ btnBack.setVisible(true);
+ btnNext.setVisible(true);
+ btnClose.setEnabled(true);
+ }
} else {
- compositeUninstallablePage.loadPage(controller);
- showComposite(compositeUninstallablePage);
- btnBack.setVisible(true);
- btnNext.setText("Uninstall");
- btnBack.setVisible(true);
+ return;
}
}
} else if (sl_composite.topControl == compositeLicensePage) {
showComposite(compositeInstallablePage);
btnNext.setEnabled(hasItem);
btnBack.setVisible(hasItem);
+ addExtraButton.setVisible(true);
if (controller.existRemovablePackage()) {
btnNext.setText("Install");
}
// DialogType.NOTIFY);
}
} else if (sl_composite.topControl == compositeInstallablePage) {
+ List<Item> items = compositeInstallablePage.getItems();
+ if (getSelectedPackageNames(items).size() <= 0) {
+ return;
+ }
if (controller.existRemovablePackage()) {
btnBack.setVisible(false);
btnNext.setVisible(false);
- List<Item> items = compositeInstallablePage.getItems();
showComposite(compositeInstallingPage);
- boolean result = compositeInstallingPage.loadPage(
- getSelectedPackageNames(items),
+ addExtraButton.setVisible(false);
+ boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items),
controller,
Registry.getInstalledPath(),
window, true);
btnBack.setVisible(true);
btnNext.setVisible(true);
btnClose.setEnabled(true);
+ addExtraButton.setVisible(true);
}
} else {
showComposite(compositeSetInstallDirectoryPage);
controller,
compositeInstallablePage.getCheckedPackageSize());
btnNext.setText("Install");
+ addExtraButton.setVisible(false);
+ }
+ } else if (sl_composite.topControl == compositeUpdatableListPage) {
+ List<Item> items = compositeUpdatableListPage.getItems();
+ if (getSelectedPackageNames(items).size() <= 0) {
+ return;
+ }
+ if (controller.existRemovablePackage()) {
+ btnBack.setVisible(false);
+ btnNext.setVisible(false);
+ addExtraButton.setVisible(false);
+ showComposite(compositeInstallingPage);
+ boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items), controller, Registry.getInstalledPath(), window, true);
+
+ if (!result) {
+ showComposite(compositeUpdatableListPage);
+ btnBack.setVisible(true);
+ btnNext.setVisible(true);
+ btnClose.setEnabled(true);
+ addExtraButton.setVisible(true);
+ }
+ } else {
+ showComposite(compositeSetInstallDirectoryPage);
+ compositeSetInstallDirectoryPage.loadPage(controller, compositeInstallablePage.getCheckedPackageSize());
+ btnNext.setText("Install");
}
} else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {
boolean installable = compositeSetInstallDirectoryPage.isInstallablePath();
MessageBoxDlg.showDlg(
Display.getCurrent().getShells()[0],
"Error",
- "Selected disk's free space is not enough to install. Select another disk path.",
+ "Not enough disk space for the installation. Select a different installation path.",
DialogType.ERROR);
return;
}
btnBack.setVisible(false);
btnNext.setVisible(false);
+ addExtraButton.setVisible(false);
List<Item> items = compositeInstallablePage.getItems();
showComposite(compositeInstallingPage);
boolean result = compositeInstallingPage.loadPage(
btnBack.setVisible(false);
btnNext.setVisible(false);
btnClose.setEnabled(false);
+ addExtraButton.setVisible(false);
List<Item> items = compositeUninstallablePage.getItems();
- boolean result = compositeUninstallingPage.loadPage(
- getSelectedPackageNames(items),
+ boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,
controller,
window);
if (!result) {
btnNext.setEnabled(true);
btnBack.setVisible(false);
btnNext.setFocus();
+ addExtraButton.setVisible(false);
showComposite(compositeWelcomePage);
- } else if (sl_composite.topControl == compositeInstallablePage) {
+ } else if (sl_composite.topControl == compositeInstallablePage || sl_composite.topControl == compositeUpdatableListPage) {
compositeInstallablePage.getItems().clear();
+ addExtraButton.setVisible(false);
if (controller.existRemovablePackage()) {
btnBack.setVisible(false);
showComposite(compositeWelcomePage);
btnNext.setText("Next");
} else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {
showComposite(compositeInstallablePage);
+ addExtraButton.setVisible(true);
btnNext.setText("Next");
btnNext.setEnabled(true);
} else if (sl_composite.topControl == compositeUninstallablePage) {
showComposite(compositeWelcomePage);
+ addExtraButton.setVisible(false);
btnNext.setText("Next");
btnNext.setEnabled(true);
btnBack.setVisible(false);
btnBack.setBounds(363, 10, 78, 29);
btnBack.setText("Back");
btnBack.setVisible(false);
+
+ setAddRepositoryButton(composite_1);
compositeWelcomePage = new WelcomePage(pageComposite, SWT.NONE);
compositeLicensePage = new LicensePage(pageComposite, SWT.NONE);
compositeUninstallingPage = new UninstallingPage(pageComposite, SWT.NONE);
compositeUninstallablePage = new UninstallableListPage(pageComposite, SWT.NONE);
compositeSetInstallDirectoryPage = new SetInstallDirectoryPage(pageComposite, SWT.NONE);
+ compositeUpdatableListPage = new UpdatableListPage(pageComposite, SWT.NONE);
registLicensePageListener();
registCompletePageListener();
- showWelcomePage();
+ initWelcomePage();
return container;
}
- private void showWelcomePage() {
+ /**
+ * Set add Repository button.
+ */
+ private void setAddRepositoryButton(final Composite composite) {
+ if (addExtraButton == null) {
+ addExtraButton = new Button(composite ,SWT.NONE);
+ }
+
+ addExtraButton.setBounds(20, 10, 125, 29);
+ addExtraButton.setText("Add Repository");
+ addExtraButton.setVisible(false);
+
+ addExtraButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ extraDialog = new AddExtraRepositoryDialog(composite.getShell());
+ int ret = extraDialog.open();
+
+ if (ret != 0) {
+ Log.err("Cannot open extra dialog");
+ } else {
+ if (sl_composite.topControl == compositeInstallablePage) {
+ compositeInstallablePage.addExtensionPackagesToExtra(extraDialog.getPackagesFromExtraRepository());
+ } else if (sl_composite.topControl == compositeUpdatableListPage) {
+ compositeUpdatableListPage.addExtensionPackagesToExtra(extraDialog.getPackagesFromExtraRepository());
+ }
+ }
+ }
+ });
+ }
+
+ private void initWelcomePage() {
compositeWelcomePage.setViewController(controller);
if (ErrorController.checkInstallationSuccess()) {
compositeWelcomePage.setTitle(WelcomePage.STRING_TITLE);
+ compositeWelcomePage.setSubTitleBounds(20, 190, 600, 40);
compositeWelcomePage.setSubTitle(WelcomePage.STRING_SUBTITLE);
compositeWelcomePage.setVisibleRadioButton(true);
btnNext.setVisible(false);
compositeWelcomePage.setTitle("Cannot start Tizen SDK Install Manager.");
- compositeWelcomePage.setErrorSubTitle(ErrorController.getErrorMessage());
+
+ String errMsg = ErrorController.getErrorMessage();
+ String repository = Config.getInstance().getConfigFile().getRepository();
+ errMsg = errMsg + "\n(" + repository + ")";
+ compositeWelcomePage.setSubTitleBounds(20, 190, 600, 100);
+ compositeWelcomePage.setErrorSubTitle(errMsg);
btnClose.setText("Close");
* Refresh packages and configuration information.
*/
public void refresh() {
- initController();
- showWelcomePage();
- }
-
-
- /**
- * check and try to update install manager itself
- * @throws IMExitException thrown if there's new version of IM
- */
- private static void checkInstallManagerUpdate() throws IMExitException {
- UpdateInstallManager upInstaller = new UpdateInstallManager();
- upInstaller.update();
+ initInstallManager();
+ initWelcomePage();
}
/**
* Then print "updatable" to stdout.
*/
private static void checkMetaPackageUpdate() {
- InstallManager mInstallManager = InstallManager.getInstance();
- PackageManager2 mPackageManager2 = mInstallManager.getPackageManager2();
- ;
- PackageSet pack = new PackageSet();
- pack = mPackageManager2.getUpdatableMetaPackages();
- if (pack.size() != 0) {
+ if (PackageManager.getInstance().getUpdatableMetaPackages().size() != 0) {
System.out.println("updatable");
}
}
+ /**
+ * There is no UI, just download packages.
+ * @throws IMExitException
+ */
private static void onlyDownloadPackages() throws IMExitException {
- ViewController controller = InstallManagerWindow.controller;
+ ViewController controller = new ViewController();
+ controller.init();
+
+ InstallManager installManager = InstallManager.getInstance();
+ PackageManager packageManager = installManager.getPackageManager();
- List<String> listPackages = new ArrayList<String>();
+ // Get all meta packages list by boundary.(eg. public, partner, all....)
+ PackageSet packageList = installManager.getPackageManager().getAllMetaPackages();
+ PackageSet filteredMeta = filterPackageSet(packageList, packageManager);
+ PackageSet downloadablePkgs = packageManager.getInstallablePackages(filteredMeta);
- String pkgList = Options.packageList;
- if (pkgList.equals("all")) {
- InstallManager installManager = InstallManager.getInstance();
- PackageSet packageList = installManager.getPackageManager2().getAllMetaPackages();
- installManager.install(packageList, PathUtil.getCurrentDir(), null);
+ // Download all meta packages.
+ boolean filteredPackages = installManager.downloadPackages(downloadablePkgs, null);
+
+ if (filteredPackages) {
+ Log.log("Success to download packages from repository");
} else {
- String[] pkgs = Options.packageList.split(",");
- for (String pkg : pkgs) {
- listPackages.add(pkg);
+ Log.err("Fail to download packages from repository");
+ return;
+ }
+ }
+
+ private static PackageSet filterPackageSet(PackageSet packageSet, PackageManager pkgManager) {
+ PackageSet cloneSet = (PackageSet) packageSet.clone();
+ // filtering download packages because of exclusive cases each other.
+ for (Package pkg : cloneSet) {
+ if (pkg.getAttribute().isEmpty()) {
+ continue;
+ } else if (Options.boundary.equalsIgnoreCase("public")) { // public case
+ if (pkg.getAttribute().equalsIgnoreCase("partner")
+ || pkg.getAttribute().equalsIgnoreCase("install")) {
+ String partnerName = pkg.getPackageName();
+ Package partner = pkgManager.getPackageByName(partnerName);
+ packageSet.remove(partner);
+ }
+ } else if (Options.boundary.equalsIgnoreCase("partner")) { // partner case
+ if (pkg.getAttribute().equalsIgnoreCase("public")
+ || pkg.getAttribute().equalsIgnoreCase("install")) {
+ String publicName = pkg.getPackageName();
+ Package publicPkg = pkgManager.getPackageByName(publicName);
+ packageSet.remove(publicPkg);
+ }
+ } else {
+ // Another case.
}
-
- controller.install(listPackages, PathUtil.getCurrentDir(), null);
}
+
+ return packageSet;
+ }
+
+ private static void showInstallManagerVersion() {
+ System.out.println("InstallManager Version : " +
+ Config.getInstance().getInstallManagerVersion().toString());
}
/**
Log.log(Platform.getPlatformInfo());
Log.log("Install Manager Jar Build-Version: " + Config.getJarBuildVersion());
Options.loadCmdArgs(args);
+
+ if (Options.onlyDownload) {
+ onlyDownloadPackages();
+ System.exit(0);
+ } else if (Options.showVersion) {
+ showInstallManagerVersion();
+ System.exit(0);
+ }
window = new InstallManagerWindow();
window.setBlockOnOpen(true);
- checkInstallManagerUpdate();
window.init();
Log.log("after init");
if (Options.checkPackageUpdate) {
checkMetaPackageUpdate();
} else if (Options.printDepGraph) {
- InstallManager.getInstance().getPackageManager2().printDepGraph();
- } else if (Options.onlyDownload) {
- onlyDownloadPackages();
+ InstallManager.getInstance().getPackageManager().printDepGraph();
} else {
window.open();
if (Display.getCurrent() != null
ErrorController.setExitCode(Config.EXITCODE_UNKNOWN_ERROR);
} finally {
- if (Options.doRemoveTempTizenSDK) {
+ if (Platform.isWindows()) {
ProgramController.createProgramController().removeSDKTempDir();
}
-
+
Log.LogTitle("Installmanager finish");
Log.close();
return list;
}
-
- private void showUninstallOldSDKCompletePage() {
- compositeCompletePage.setTitle("Uninstalling old SDK completed!");
- compositeCompletePage.setCustomMessage("Now you can install Tizen SDK.");
- btnBack.setVisible(false);
- btnNext.setVisible(false);
- btnClose.setEnabled(true);
- compositeCompletePage.showCheckButton(false);
- compositeCompletePage.loadPage();
- showComposite(compositeCompletePage);
- }
-
+
/**
* Get install manager window object.
* @return install manager window object.
public void setCancelBtnEnabled(boolean enabled) {
btnClose.setEnabled(enabled);
}
+
+ public ViewController getViewController() {
+ return controller;
+ }
}
--- /dev/null
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.ui.dialog;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
+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.installmanager.core.SDKExtensionInfo;
+import org.tizen.installmanager.lib.Downloader;
+import org.tizen.installmanager.lib.ErrorController;
+import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.util.PathUtil;
+
+/**
+ * This class supports to add extra's repository.
+ *
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>
+ */
+public class AddExtraDialog extends Dialog {
+ private String DIALOG_TITLE = "Add Repository";
+ private AddExtraRepositoryDialog rDialog = null;
+
+ private Text nameText = null;
+ private Text repositoryText = null;
+
+ private Label errLabel = null;
+ private Button okButton;
+
+ private String thirdPartyName = "";
+ private String thirdPartyRepository = "";
+
+ public AddExtraDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(400, 195);
+ }
+
+ /**
+ * Set to enable OK button.
+ *
+ * @param isAvailable
+ */
+ public void okButtonEnable(boolean isAvailable) {
+ okButton = getButton(Window.OK);
+ okButton.setEnabled(isAvailable);
+ }
+
+ /**
+ * Create contents of the dialog.
+ *
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ container.setLayout(null);
+ rDialog = new AddExtraRepositoryDialog(getParentShell());
+
+ setTitle();
+
+ setNameText(container);
+ setRepositoryText(container);
+ setErrorLabel(container);
+ setSeparator(container);
+
+ return container;
+ }
+
+ private void setTitle() {
+ getShell().setText(DIALOG_TITLE);
+ }
+
+ @Override
+ protected void okPressed() {
+ thirdPartyName = nameText.getText();
+ thirdPartyRepository = repositoryText.getText();
+ if (!isValidName()) {
+ errLabel.setText(ErrorController.getErrorMessage());
+ } else if (!isOverlapRepository()) {
+ errLabel.setText(ErrorController.getErrorMessage());
+ } else if (!isValidRepository()) {
+ errLabel.setText(ErrorController.getErrorMessage());
+ } else {
+ this.close();
+ }
+ }
+
+ private void setNameText(Composite composite) {
+ Label nameLabel = new Label(composite, SWT.NONE);
+ if (nameText == null) {
+ nameText = new Text(composite, SWT.BORDER);
+ }
+ nameLabel.setBounds(5, 7, 75, 23);
+ nameLabel.setText("Name :");
+ nameText.setBounds(85, 5, 305, 23);
+ }
+
+ private void setRepositoryText(Composite composite) {
+ Label repositoryLabel = new Label(composite, SWT.NONE);
+ if (repositoryText == null) {
+ repositoryText = new Text(composite, SWT.BORDER);
+ }
+ repositoryLabel.setBounds(5, 34, 75, 23);
+ repositoryLabel.setText("Repository :");
+ repositoryText.setBounds(85, 32, 305, 23);
+ repositoryText.append("http://");
+ }
+
+ private void setErrorLabel(Composite composite) {
+ if (errLabel == null) {
+ errLabel = new Label(composite, SWT.WRAP);
+ }
+
+ errLabel.setBounds(5, 60, 380, 50);
+ errLabel.setForeground(new Color(null, 255, 0, 0));
+ errLabel.setEnabled(true);
+ }
+
+ private void setSeparator(Composite composite) {
+ Label sep = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setBounds(0, 115, 400, 1);
+ }
+
+ private boolean isValidName() {
+ if (!hasSpaceInName()) {
+ return false;
+ } else if (isOnlyEngName()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean isOnlyEngName() {
+ char[] temp = thirdPartyName.toCharArray();
+ int tmp = Character.getType(temp[0]);
+ if (tmp == 5) {
+ ErrorController.setError(ErrorCode.HANGUL_IN_REPOSITORY_NAME);
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private boolean hasSpaceInName() {
+ if (thirdPartyName.length() <= 0) {
+ ErrorController.setError(ErrorCode.SPACE_IN_REPOSITORY_NAME);
+ return false;
+ } else {
+ for (int i = 0; i < thirdPartyName.length(); i++) {
+ if (thirdPartyName.charAt(i) == ' ') {
+ ErrorController.setError(ErrorCode.SPACE_IN_REPOSITORY_NAME);
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private boolean isValidRepository() {
+ URL serverUrl;
+
+ try {
+ serverUrl = new URL(PathUtil.addURLPath(thirdPartyRepository,
+ PackageManager.getInstance().getPackageListFileName()));
+
+ Downloader downloader = new Downloader();
+ boolean conResult = downloader.connect(serverUrl);
+
+ return conResult;
+
+ } catch (MalformedURLException e) {
+ // the URL is not in a valid form
+ ErrorController.setError(ErrorCode.WRONG_URL_FORMAT);
+ return false;
+ }
+ }
+
+ private boolean isOverlapRepository() {
+ removeSeperator();
+ SDKExtensionInfo extensionInfo = rDialog.getSdkExtensionInfo();
+ if (extensionInfo.contains(thirdPartyRepository)) {
+ ErrorController.setError(ErrorCode.OVERLAP_EXTENSION_REPOSITORY);
+ return false;
+ } else if (extensionInfo.containsBuiltIn(thirdPartyRepository)) {
+ ErrorController.setError(ErrorCode.OVERLAP_BUILT_IN_EXTENSION_REPOSITORY);
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private void removeSeperator() {
+ if (thirdPartyRepository.endsWith(PathUtil.URL_SEPERATOR)) {
+ while (thirdPartyRepository.endsWith(PathUtil.URL_SEPERATOR)) {
+ thirdPartyRepository = thirdPartyRepository.substring(0, thirdPartyRepository.length() - 1);
+ }
+ }
+ }
+
+ public String getThirdPartyName() {
+ return thirdPartyName;
+ }
+
+ public String getThirdPartyRepository() {
+ removeSeperator();
+ return thirdPartyRepository;
+ }
+}
--- /dev/null
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.ui.dialog;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.Dialog;
+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.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+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.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.tizen.installmanager.core.SDKExtensionInfo;
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.pkg.model.PackageSet;
+
+/**
+ * This class supports to control(add, reomove) extra's repository.
+ *
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>
+ */
+public class AddExtraRepositoryDialog extends Dialog {
+ private final String STRING_TITLE = "Add Extra Repository";
+
+ private AddExtraDialog addDialog = null;
+ private String thirdPartyName = "";
+ private String thirdPartyRepository = "";
+
+ //Repository table column
+ public static final int TABLE_COLUMN_NAME = 0;
+ public static final int TABLE_COLUMN_REPOSITORY = 1;
+
+ private Table repositoryTable = null;
+ private Button addButton = null;
+ private Button removeButton = null;
+ private Button okButton = null;
+
+ // Set of removable item list.
+ private Set<TableItem> removeRepositorySet;
+
+ private SDKExtensionInfo sdkExtensionInfo = SDKExtensionInfo.getInstance();
+
+ public AddExtraRepositoryDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(500, 400);
+ }
+
+ /**
+ * Create contents of the dialog.
+ *
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ container.setLayout(null);
+
+ sdkExtensionInfo.load();
+ removeRepositorySet = new HashSet<TableItem>();
+
+ setTitle();
+ setRepositoryTable(container);
+ addItemToRepositoryTable(sdkExtensionInfo.getExtensionRepositories());
+
+ setSeparator(container);
+
+ setAddButton(container);
+ setRemoveButton(container);
+
+ return container;
+ }
+
+ /**
+ * Set page title
+ */
+ private void setTitle() {
+ getShell().setText(STRING_TITLE);
+ }
+
+ @Override
+ protected void okPressed() {
+ this.close();
+ }
+
+ /**
+ * Set 3rd party repository table.
+ * @param composite
+ */
+ private void setRepositoryTable(Composite composite) {
+ if (repositoryTable == null) {
+ repositoryTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
+ }
+
+ repositoryTable.forceFocus();
+ repositoryTable.setBounds(5, 5, 380, 305);
+ repositoryTable.setLayout(new FillLayout());
+
+ setTableColumn();
+
+ repositoryTable.setHeaderVisible(true);
+ repositoryTable.setLinesVisible(true);
+
+ repositoryTable.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TableItem selectedItem = (TableItem) e.item;
+ if (selectedItem.getChecked() == true) {
+ removeRepositorySet.add(selectedItem);
+ } else {
+ removeRepositorySet.remove(selectedItem);
+ }
+
+ if (removeRepositorySet.isEmpty()) {
+ removeButton.setEnabled(false);
+ } else {
+ removeButton.setEnabled(true);
+ }
+ }
+ });
+ }
+
+ /**
+ * Set table column.
+ */
+ private void setTableColumn() {
+ TableColumn tcName = new TableColumn(repositoryTable, SWT.CENTER);
+ TableColumn tcRepository = new TableColumn(repositoryTable, SWT.CENTER);
+
+ tcName.setText("Name");
+ tcRepository.setText("Repository");
+
+ tcName.setWidth(100);
+ tcName.setResizable(false);
+ tcRepository.setWidth(270);
+ tcRepository.setResizable(false);
+ }
+
+ /**
+ * Show 3rd party information on table.
+ * @param type
+ */
+ private void showRepositoryTable() {
+ repositoryTable.removeAll();
+ removeRepositorySet.clear();
+ addItemToRepositoryTable(sdkExtensionInfo.getExtensionRepositories());
+ }
+
+ /**
+ * Add 3rd party information to table by row.
+ * @param
+ */
+ private void addItemToRepositoryTable(LinkedHashMap<String, String> repositoryInfo) {
+ Set<String> keys = repositoryInfo.keySet();
+ for (String key : keys) {
+ TableItem item = new TableItem(repositoryTable, SWT.NONE);
+ item.setText(TABLE_COLUMN_NAME, repositoryInfo.get(key));
+ item.setText(TABLE_COLUMN_REPOSITORY, key);
+ }
+ }
+
+ private void setSeparator(Composite composite) {
+ Label sep = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setBounds(0, 320, 500, 1);
+ }
+
+ /**
+ * Set Add repository button.
+ * @param composite
+ */
+ private void setAddButton(Composite composite) {
+ if (addButton == null) {
+ addButton = new Button(composite, SWT.NONE);
+ }
+
+ addButton.setBounds(390, 10, 88, 27);
+ addButton.setText("Add");
+
+ addButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ addDialog = new AddExtraDialog(getShell());
+
+ int ret = addDialog.open();
+
+ if (ret == 0) {
+ thirdPartyName = addDialog.getThirdPartyName(); // 3rd party name via location dialog.
+ thirdPartyRepository = addDialog.getThirdPartyRepository(); // 3rd party repository via location dialog.
+ addRepositoryInformation();
+ showRepositoryTable();
+ } else {
+ Log.err("Cannot open add 3rd party repository dialog.");
+ }
+ }
+ });
+ }
+
+ /**
+ * Set button to remove item which is checked.
+ * @param composite
+ */
+ private void setRemoveButton(Composite composite) {
+ if (removeButton == null) {
+ removeButton = new Button(composite, SWT.NONE);
+ }
+
+ removeButton.setBounds(390, 42, 88, 27);
+ removeButton.setText("Remove");
+ removeButton.setEnabled(false);
+
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ removeRepositoryInformation();
+ showRepositoryTable();
+ }
+ });
+ }
+
+ /**
+ * Write 3rd party information of adding to installmanager.conf
+ */
+ private void addRepositoryInformation() {
+ sdkExtensionInfo.add(thirdPartyName, thirdPartyRepository);
+ sdkExtensionInfo.save();
+ }
+
+ /**
+ * Write 3rd party information of removing to installmanager.conf
+ */
+ private void removeRepositoryInformation() {
+ for (TableItem removeItem : removeRepositorySet) {
+ sdkExtensionInfo.remove(removeItem.getText(1));
+ }
+ sdkExtensionInfo.save();
+ }
+
+ public PackageSet getPackagesFromExtraRepository() {
+ return sdkExtensionInfo.getExtensionPackages();
+ }
+ /**
+ * Set to enable OK button.
+ *
+ * @param isAvailable
+ */
+ public void okButtonEnable(boolean isAvailable) {
+ okButton = getButton(Window.OK);
+ okButton.setEnabled(isAvailable);
+ }
+
+ public SDKExtensionInfo getSdkExtensionInfo() {
+ return sdkExtensionInfo;
+ }
+}
--- /dev/null
+package org.tizen.installmanager.ui.dialog;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+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.installmanager.core.Config;
+import org.tizen.installmanager.lib.Downloader;
+import org.tizen.installmanager.lib.ErrorController;
+import org.tizen.installmanager.util.PathUtil;
+
+public class ChangeServerDialog extends Dialog {
+ private static final String STRING_TITLE = "Change Server";
+ private Label titleLabel = null;
+ private Text serverText = null;
+ private Label errLabel = null;
+
+ private String serverUrl = "";
+
+ public ChangeServerDialog(Shell parentShell) {
+ super(parentShell);
+ setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL);
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(400, 190);
+ }
+
+ /**
+ * Create contents of the dialog.
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ container.setLayout(null);
+
+ setTitle();
+ setTitleLabel(container);
+ setServerUrlText(container);
+ setErrLabel(container);
+
+ return container;
+ }
+
+ @Override
+ protected void okPressed() {
+ String changeServerUrl = serverText.getText();
+
+ if (serverUrl.equals(changeServerUrl)) {
+ this.close();
+ } else {
+ if (isExactFormat(changeServerUrl)) {
+ serverUrl = changeServerUrl;
+ this.close();
+ } else {
+ // do not close configuration dialog because of wrong pkg list path.
+ }
+ }
+ }
+
+ /**
+ * Set page title
+ */
+ private void setTitle() {
+ getShell().setText(STRING_TITLE);
+ }
+
+ private void setTitleLabel(Composite composite) {
+ titleLabel = new Label(composite, SWT.NONE);
+ titleLabel.setText("Input New Server");
+ titleLabel.setBounds(10, 10, 200, 23);
+ }
+
+ private void setServerUrlText(Composite composite) {
+ serverText = new Text(composite, SWT.BORDER);
+ serverText.setBounds(10, 33, 360, 23);
+ serverText.setEnabled(true);
+
+ if (serverUrl.isEmpty()) {
+ serverText.setText("http://");
+ } else {
+ serverText.setText(serverUrl);
+ serverText.selectAll();
+ }
+ }
+
+ private void setErrLabel(Composite composite) {
+ errLabel = new Label(composite, SWT.WRAP);
+ errLabel.setBounds(10, 58, 350, 100);
+ errLabel.setForeground(new Color(null, 255, 0, 0));
+ }
+
+ private boolean isExactFormat(String serverUrl) {
+ boolean result = false;
+ if (!serverUrl.startsWith("http://")) {
+ errLabel.setText("Enter the URL in a correct format.");
+ return false;
+ }
+
+ try {
+ URL distInfoFileURL = new URL(PathUtil.addURLPath(serverUrl, Config.REPOSITORY_DISTRIBUTION_INFO_FILE));
+
+ Downloader downloader = new Downloader();
+ result = downloader.connect(distInfoFileURL);
+
+ if (!result) {
+ errLabel.setText(ErrorController.getErrorMessage());
+ }
+ } catch (MalformedURLException e) {
+ errLabel.setText("Enter the URL in a correct format.");
+ return false;
+ } catch (IllegalArgumentException e) {
+ errLabel.setText("Connection to the input URL failed.");
+ // the connection does not work.(wrong URL address)
+ return false;
+ }
+
+ return result;
+ }
+
+ /**
+ * Set server address to text ui in dialog.
+ * @param url current server address.
+ */
+ public void setCurrentServer(String url) {
+ serverUrl = url;
+ }
+
+ public String getServerUrl() {
+ return serverUrl;
+ }
+}
+/*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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.installmanager.ui.dialog;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
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.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.DistributionController;
+import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.Config.ServerType;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.lib.SDKPackageFormat;
+import org.tizen.installmanager.lib.ErrorController.ErrorCode;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Snapshot;
+import org.tizen.installmanager.pkg.model.SnapshotList;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
+import org.tizen.installmanager.util.PathUtil;
+/**
+ * This class supports snapshot, user package server and local install.
+ *
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>
+ */
public class ConfigurationDialog extends Dialog {
- private Text repositoryText;
+ //return data
+ private String snapshotPath = "";
+ private String currentDistribution = "";
private String repository = "";
- private int POSITION_X = 20;
- private int POSITION_Y = 20;
+ private ServerType serverType = ServerType.SNAPSHOT;
+
+// private ChangeServerDialog changeServerDialog = null;
+
+ private static final String STRING_TITLE = "Advanced Configuration";
+
+ private Button buttonSnapshot = null;
+ private Button buttonLocal = null;
+ private Button buttonSelectImage = null;
+ private Button okBtn;
+ private Button buttonChangeServer;
+ private Combo distributionCombo = null;
+ private Button latestVersionCheckBox = null;
+ private Button buttonSnapshotFilter = null;
+ private Table snapshotTable;
+
+ private Label localErrLabel;
+ private Label textPackageServerUrl;
+ private Label textLocalServerUrl;
+ private File imageFile;
+ private long unzipResult = -1;
+
+ private DistributionController controller = null;
+ private boolean noErr = true; // flag check to verify pkg list file path.
+
+ //snapshot table column
+ public static final int TABLE_STATUS = 0;
+ public static final int TABLE_NAME = 1;
+ public static final int TABLE_DATE = 2;
+
+ //snapshot table status
+ public static final String STATUS_LATEST = "Latest";
+
+ private static final String SDK_IMAGE_ZIP_EXTENSION = ".zip";
+
public ConfigurationDialog(Shell parentShell) {
super(parentShell);
setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL);
+ controller = DistributionController.getInstance();
}
/**
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(null);
-//
- Label repositoryLabel = new Label(container, SWT.NONE);
- repositoryLabel.setAlignment(SWT.RIGHT);
- repositoryLabel.setBounds(POSITION_X, POSITION_Y + 7, 80, 20);
- repositoryLabel.setText("Repository :");
- repositoryText = new Text(container, SWT.BORDER);
- repositoryText.setText(repository);
- repositoryText.setBounds(POSITION_X + 100, POSITION_Y + 4, 250, 28);
+ setTitle();
- repositoryText.addKeyListener(new KeyAdapter() {
- @Override
- public void keyReleased(KeyEvent arg0) {
- repository = repositoryText.getText();
- }
- });
+ setSnapshotButton(container);
+ packageServerLabel(container);
+ setChangeUrlButton(container);
+ setDistributionComboBox(container);
+ setLatestVersionCheckBox(container);
+ setSnapshotFilter(container);
+ makeSnapshotTable(container);
+ showSnapshotTable(currentDistribution);
+ setSelectionBySnapshotPath();
+
+ setSeparator(container);
+
+ setLocalButton(container);
+ setFileDialog(container);
+ setLocalLabel(container);
+ setLocalErrorlabel(container);
return container;
}
+
+ protected Button getOKButton() {
+ Button button = getButton(IDialogConstants.OK_ID);
+ return button;
+ }
@Override
protected void okPressed() {
- if (repository == null || repository.length() < 1) {
- MessageBoxDlg.showDlg(this.getShell(), "Input repository",
- "Please input your repository.", DialogType.NOTIFY);
+
+ if (buttonLocal.getSelection()) {
+ if (unzipSDKImageFile(imageFile) > 0) {
+ this.serverType = ServerType.LOCAL;
+ } else {
+ Log.err("unzip SDK IMAGE FILE fail. => " + imageFile.getName());
+ throw new IMFatalException(ErrorCode.FAIL_TO_EXTRACT_SDK_IMAGE_FILE);
+ }
+
} else {
+ this.serverType = ServerType.SNAPSHOT;
+ }
+
+ if (noErr) {
+ // everything is good. keep going ahead.
this.close();
}
}
*/
@Override
protected Point getInitialSize() {
- return new Point(400, 248);
+ return new Point(580, 485);
+ }
+
+ public void setComboList(List<String> list) {
+
}
/**
- * Set repository to Text.
- *
- * @param repository
+ * Set snapshot path by snapshot name.
+ * @param name snapshot name
*/
- public void setRepository(String repository) {
- this.repository = repository;
+ public void setSnapshotPathByName(String name) {
+ SnapshotList snapshotSet = controller.getSnapshotList(currentDistribution);
+
+ if (snapshotSet == null) {
+ throw new IMFatalException("Selected distribution(" + currentDistribution + ") do not exist in repository");
+ }
+
+ Snapshot currentSnapshot = snapshotSet.getSnapshotByName(name);
+
+ if (currentSnapshot != null) {
+ this.snapshotPath = currentSnapshot.getPath();
+ } else {
+ this.snapshotPath = "";
+ }
+ }
+
+ public void setSnapshotPath(String path) {
+ SnapshotList snapshotSet = controller.getSnapshotList(currentDistribution);
+
+ if (snapshotSet == null) {
+ throw new IMFatalException("Selected distribution(" + currentDistribution + ") do not exist in repository");
+ }
+
+ Snapshot currentSnapshot = snapshotSet.getSnapshotByPath(path);
+
+ if (currentSnapshot != null) {
+ this.snapshotPath = currentSnapshot.getPath();
+ } else {
+ this.snapshotPath = "";
+ }
}
+ public void setRepository(String serverUrl) {
+ if (serverUrl == null || serverUrl.isEmpty()) {
+ return;
+ }
+
+ this.repository = serverUrl;
+ }
+
+ /**
+ * Change package server type by install type(normal, snapshot, local).
+ * @param isConfDialog User push 'OK' button in configuration dialog is true, otherwise is false.
+ */
+ public void setServerType() {
+ if (buttonSnapshot.getSelection()) {
+ serverType = ServerType.SNAPSHOT;
+ } else if (buttonLocal.getSelection()) {
+ serverType = ServerType.PACKAGE;
+ } else {
+ Log.err("Snapshot or package server button is not selection in configuration page.");
+ serverType = ServerType.SNAPSHOT;
+ }
+ }
+
/**
- * Get repository from Text.
+ * Get package server url from Text widget.
* @return
*/
public String getRepository() {
return repository;
}
+
+ /**
+ * Set snapshot type
+ *
+ * @param type
+ * selected snapshot type.
+ */
+ public void setCurrentDistribution(String type) {
+ this.currentDistribution = type;
+ }
+
+ /**
+ * Get snapshot type
+ *
+ * @return
+ */
+ public String getCurrentDistribution() {
+ return currentDistribution.toLowerCase();
+ }
+
+ /**
+ * Get snapshot path
+ *
+ * @return snapshot path
+ */
+ public String getSnapshotPath() {
+ return snapshotPath;
+ }
+
+ /**
+ * Set page title
+ */
+ private void setTitle() {
+ getShell().setText(STRING_TITLE);
+ }
+
+ private void setPackageServerEnv(String packageServerPath) {
+ this.repository = packageServerPath;
+ textPackageServerUrl.setText(packageServerPath);
+
+ //refresh information of distribution
+ refreshDistribution();
+
+ //refresh combobox of distribution
+ distributionCombo.removeAll();
+ List<String> distributions = controller.getDistributionList();
+ addDistributionsToDistributionCombo(distributions);
+ if (distributions.size() > 0) {
+ currentDistribution = distributions.get(0);
+ distributionCombo.select(0);
+ }
+
+ //refresh snapshot list
+ snapshotTable.clearAll();
+ showSnapshotTable(distributionCombo.getText());
+ if (snapshotTable.getItems().length > 0) {
+ snapshotTable.setSelection(0);
+ }
+ }
+
+ private void refreshDistribution() {
+ Config.getInstance().getConfigFile().setRepository(repository);
+ InstallManager.getInstance().initDistribution();
+ this.controller = DistributionController.getInstance();
+ }
+
+ /**
+ * Set snapshot radio button.
+ *
+ * @param composite
+ */
+ private void setSnapshotButton(Composite composite) {
+ if (buttonSnapshot == null) {
+ buttonSnapshot = new Button(composite, SWT.RADIO);
+ }
+
+ buttonSnapshot.setSelection(true);
+ buttonSnapshot.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ distributionCombo.setEnabled(true);
+ buttonSnapshotFilter.setEnabled(true);
+ buttonChangeServer.setEnabled(true);
+ buttonSelectImage.setEnabled(false);
+ textLocalServerUrl.setEnabled(false);
+ textLocalServerUrl.setText("");
+ localErrLabel.setText("");
+ setOkEnable(false);
+ }
+ });
+
+ buttonSnapshot.setBounds(10, 10, 130, 20);
+
+ buttonSnapshot.setText("Package Server : ");
+ }
+
+ /**
+ * Set url label
+ *
+ * @param composite
+ */
+ private void packageServerLabel(Composite composite) {
+ if (textPackageServerUrl == null) {
+ textPackageServerUrl = new Label(composite, SWT.BORDER);
+ }
+
+ textPackageServerUrl.setBounds(150, 10, 300, 20);
+ textPackageServerUrl.setEnabled(false);
+ textPackageServerUrl.setText(this.repository);
+ }
+
+ private void setChangeUrlButton(final Composite composite) {
+ if (buttonChangeServer == null) {
+ buttonChangeServer = new Button(composite, SWT.PUSH);
+ }
+
+ buttonChangeServer.setText("Change Server");
+ buttonChangeServer.setBounds(455, 7, 115, 27);
+ buttonChangeServer.setEnabled(true);
+
+ buttonChangeServer.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ChangeServerDialog changeServerDialog = new ChangeServerDialog(composite.getShell());
+ changeServerDialog.setCurrentServer(repository);
+ int ret = changeServerDialog.open();
+ if (ret == 0) {
+ String changeServerUrl = changeServerDialog.getServerUrl();
+ if (!repository.equals(changeServerUrl)) {
+ setPackageServerEnv(changeServerUrl);
+ }
+ } else {
+ Log.log("ChangeServer dialog is canceled.");
+ }
+ }
+ });
+ }
+
+ /**
+ * Set snapshot type combo box.
+ *
+ * @param composite
+ */
+ private void setDistributionComboBox(Composite composite) {
+ if (distributionCombo == null) {
+ distributionCombo = new Combo(composite, SWT.READ_ONLY);
+ }
+
+ addDistributionsToDistributionCombo(controller.getDistributionList());
+
+ Label distLabel = new Label(composite, SWT.NONE);
+ distLabel.setBounds(10, 45, 100, 20);
+ distLabel.setText("Distribution : ");
+
+ distributionCombo.setText(currentDistribution);
+ distributionCombo.setBounds(104, 40, 90, 20);
+ distributionCombo.setEnabled(true);
+
+ distributionCombo.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String distribution = distributionCombo.getText();
+
+ if (currentDistribution.equals(distribution)) {
+ return;
+ } else {
+ showSnapshotTable(distribution);
+
+ if (snapshotTable.getItemCount() > 0) {
+ if (latestVersionCheckBox.getSelection()) {
+ snapshotTable.deselectAll();
+ } else {
+ snapshotTable.select(0);
+ setSnapshotPathByName(snapshotTable.getSelection()[0].getText(1));
+ }
+
+ currentDistribution = distribution;
+ Config.fromWhere = Config.ConfDialog.SNAPSHOT; // it means data from table.
+ }
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ }
+ });
+ }
+
+ private void setLatestVersionCheckBox(Composite composite) {
+ if (latestVersionCheckBox == null) {
+ latestVersionCheckBox = new Button(composite, SWT.CHECK);
+ }
+
+ latestVersionCheckBox.setText("Auto update");
+ latestVersionCheckBox.setBounds(205, 45, 100, 20);
+ latestVersionCheckBox.setEnabled(true);
+ latestVersionCheckBox.pack();
+
+ if(this.snapshotPath.isEmpty()) {
+ latestVersionCheckBox.setSelection(true);
+ } else {
+ latestVersionCheckBox.setSelection(false);
+ }
+
+ latestVersionCheckBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (latestVersionCheckBox.getSelection()) {
+ snapshotTable.deselectAll();
+ snapshotTable.setEnabled(false);
+ buttonSnapshotFilter.setEnabled(false);
+ snapshotPath = "";
+ } else {
+ snapshotTable.setEnabled(true);
+ buttonSnapshotFilter.setEnabled(true);
+
+ if (snapshotTable.getItemCount() > 0) {
+ snapshotTable.select(0);
+ setSnapshotPathByName(snapshotTable.getSelection()[0].getText(1));
+ } else {}
+ }
+ }
+ });
+ }
+
+ private void addDistributionsToDistributionCombo(Collection<String> distList) {
+ if (distributionCombo == null || distList == null) {
+ return;
+ }
+
+ for (String dist : distList) {
+ if (dist != null) {
+ distributionCombo.add(dist);
+ }
+ }
+ }
+
+ private void setSnapshotFilter(Composite composite) {
+ if (buttonSnapshotFilter == null) {
+ buttonSnapshotFilter = new Button(composite, SWT.CHECK);
+ }
+
+ buttonSnapshotFilter.setText("Show all");
+ buttonSnapshotFilter.setBounds(480, 45, 100, 20);
+ buttonSnapshotFilter.pack();
+
+ if (latestVersionCheckBox.getSelection()) {
+ buttonSnapshotFilter.setEnabled(false);
+ } else {
+ buttonSnapshotFilter.setEnabled(true);
+ }
+
+ buttonSnapshotFilter.setSelection(false);
+ buttonSnapshotFilter.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ showSnapshotTable(currentDistribution);
+ }
+ });
+ }
+
+ /**
+ * Make snapshot table.
+ *
+ * @param composite
+ * @return Snapshot table object.
+ */
+ private Table makeSnapshotTable(Composite composite) {
+ if (snapshotTable == null) {
+ snapshotTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
+ }
+
+ snapshotTable.forceFocus();
+ snapshotTable.setBounds(10, 70, 560, 200);
+ snapshotTable.setLayout(new FillLayout());
+
+ if (latestVersionCheckBox.getSelection()) {
+ snapshotTable.setEnabled(false);
+ } else {
+ snapshotTable.setEnabled(true);
+ }
+
+ TableColumn tcStatus = new TableColumn(snapshotTable, SWT.CENTER);
+ TableColumn tcLabel = new TableColumn(snapshotTable, SWT.CENTER);
+ TableColumn tcDate = new TableColumn(snapshotTable, SWT.CENTER);
+
+ tcStatus.setText("Status");
+ tcLabel.setText("Name");
+ tcDate.setText("Date");
+ tcStatus.setWidth(109);
+ tcLabel.setWidth(193);
+ tcDate.setWidth(214);
+
+ snapshotTable.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ snapshotTable.setEnabled(!latestVersionCheckBox.getSelection());
+ buttonSnapshot.setSelection(true);
+ buttonSnapshotFilter.setEnabled(true);
+ buttonChangeServer.setEnabled(true);
+ distributionCombo.setEnabled(true);
+
+ buttonLocal.setSelection(false);
+ textLocalServerUrl.setEnabled(false);
+ textLocalServerUrl.setText("");
+ localErrLabel.setText("");
+ buttonSelectImage.setEnabled(false);
+
+ setOkEnable(true);
+
+ setSnapshotPathByName(snapshotTable.getSelection()[0].getText(1));
+ Config.fromWhere = Config.ConfDialog.SNAPSHOT; // it means data from table.
+ }
+ });
+
+ return snapshotTable;
+ }
+
+ private void setSelectionBySnapshotPath() {
+ if (latestVersionCheckBox.getSelection()) {
+ snapshotTable.deselectAll();
+ return;
+ }
+
+ String distribution = distributionCombo.getText();
+ SnapshotList snapshotList = DistributionController.getInstance().getSnapshotList(distribution);
+
+ Snapshot snapshot= snapshotList.getSnapshotByPath(snapshotPath);
+
+ if (snapshot == null) {
+ snapshotTable.select(0);
+ } else {
+ String snapshotName = snapshot.getName();
+
+ TableItem[] tItems = snapshotTable.getItems();
+ for (TableItem tItem : tItems) {
+ if (snapshotName.equals(tItem.getText(1))) {
+ snapshotTable.setSelection(tItem);
+ }
+ }
+ }
+ }
+
+ private void addItemToSnapshotTable(Snapshot snapshot) {
+ if (snapshot == null) {
+ return;
+ } else {
+ addItemToSnapshotTable(snapshot.getName(), snapshot.getTime());
+ }
+ }
+
+ private void addLatestItemToSnapshotTable(Snapshot snapshot) {
+ addItemToSnapshotTable(STATUS_LATEST, snapshot.getName(), snapshot.getTime());
+ }
+
+ /**
+ * Add snapshot to snapshot table by row.
+ *
+ * @param snapshots
+ * String[] of snapshot information.
+ */
+ private void addItemToSnapshotTable(String name, Date date) {
+ addItemToSnapshotTable("", name, date);
+ }
+
+ private void addItemToSnapshotTable(String status, String name, Date date) {
+ TableItem item = new TableItem(snapshotTable, SWT.NONE);
+
+ item.setText(TABLE_STATUS, status);
+ item.setText(TABLE_NAME, name);
+ item.setText(TABLE_DATE, date.toString());
+ }
+
+ /**
+ * Show snapshot information by combo box selection.
+ *
+ * @param distribution
+ */
+ private void showSnapshotTable(String distribution) {
+ snapshotTable.removeAll();
+ snapshotTable.setHeaderVisible(true);
+
+ //add latest snapshot to table.
+ Snapshot latestSnapshot = controller.getLatestSnapshot(distribution);
+ if (latestSnapshot != null) {
+ addLatestItemToSnapshotTable(latestSnapshot);
+ }
+
+ if (buttonSnapshotFilter.getSelection()) {
+ SnapshotList allSnapshots = controller.getSnapshotList(distribution);
+
+ if (allSnapshots == null) {
+ Log.log("Selected distribution(" + distribution + ") do not exist in repository");
+ return;
+ }
+
+ for (Snapshot snapshot : allSnapshots) {
+ if (!latestSnapshot.equals(snapshot)) {
+ addItemToSnapshotTable(snapshot);
+ }
+ }
+ } else {
+ //add snapshots to table
+ SnapshotList snapshots = controller.getManualSnapshotList(distribution);
+
+ if (snapshots == null) {
+ Log.log("Selected distribution(" + distribution + ") do not exist in repository");
+ return;
+ }
+
+ for (Snapshot snapshot : snapshots) {
+ if (!latestSnapshot.equals(snapshot)) {
+ addItemToSnapshotTable(snapshot);
+ }
+ }
+ }
+ }
+
+ private void setSeparator(Composite composite) {
+ Label sep = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ sep.setBounds(10, 280, 560, 1);
+ }
+
+ private void setLocalButton(Composite composite) {
+ buttonLocal = new Button(composite, SWT.RADIO);
+ buttonLocal.setSelection(false);
+ buttonLocal.setBounds(10, 290, 350, 18);
+ buttonLocal.setText("SDK Image");
+
+ buttonLocal.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ textLocalServerUrl.setEnabled(true);
+ buttonSelectImage.setEnabled(true);
+ localErrLabel.setEnabled(true);
+
+ distributionCombo.setEnabled(false);
+ buttonChangeServer.setEnabled(false);
+ buttonSnapshotFilter.setEnabled(false);
+
+ snapshotPath = "";
+ }
+ });
+ }
+
+ /**
+ * Set url label
+ *
+ * @param composite
+ */
+ private void setLocalLabel(Composite composite) {
+ textLocalServerUrl = new Label(composite, SWT.BORDER);
+ textLocalServerUrl.setBounds(10, 318, 500, 20);
+ textLocalServerUrl.setEnabled(false);
+ }
+
+ /**
+ * Set file dialog button
+ *
+ * @param composite
+ */
+ private void setFileDialog(Composite composite) {
+ buttonSelectImage = new Button(composite, SWT.NONE);
+ buttonSelectImage.setEnabled(false);
+ buttonSelectImage.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String strDir = showSettingInstallpathDlg();
+ if (strDir != null) {
+ if (strDir.endsWith(SDK_IMAGE_ZIP_EXTENSION)) {
+ imageFile = new File(strDir);
+ if (validation(strDir)) {
+ textLocalServerUrl.setText(strDir);
+ localErrLabel.setText("");
+ setOkEnable(true);
+ Config.fromWhere = Config.ConfDialog.LOCAL_IMAGE; // it means data from file dialog.
+ } else {
+ MessageBoxDlg.showDlg(Display.getCurrent().getShells()[0],
+ "Error",
+ "No package list file is found in the image file. Check the image file.",
+ DialogType.ERROR);
+ return;
+ }
+ } else {
+ MessageBoxDlg.showDlg(Display.getCurrent().getShells()[0],
+ "Error",
+ "Select the correct SDK image file.",
+ DialogType.ERROR);
+ return;
+ }
+ }
+ }
+ });
+
+ buttonSelectImage.setImage(PathUtil.getImageFromResource("/res/icons/icon_directory_open.png"));
+ buttonSelectImage.setBounds(520, 313, 35, 29);
+ }
+
+ @SuppressWarnings("unused")
+ private boolean validation(String strDir) {
+ ZipFile zipFile = null;
+ ZipEntry entry = null;
+
+
+ try {
+ zipFile = new ZipFile(strDir);
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+
+ return false;
+ }
+
+ if (zipFile != null) {
+
+ entry = zipFile.getEntry(PackageManager.getInstance().getPackageListFileName());
+
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+
+ return ( entry != null ) ? true : false;
+ } else {
+ return false;
+ }
+ }
+
+
+ private void setLocalErrorlabel(Composite composite) {
+ localErrLabel = new Label(composite, SWT.WRAP);
+ localErrLabel.setBounds(20, 343, 475, 45);
+ localErrLabel.setForeground(new Color(null, 255, 0, 0));
+ }
+
+ /**
+ * Show file path dialog when file dialog button is pushed.
+ *
+ * @return File path that selected file.
+ */
+ private String showSettingInstallpathDlg() {
+ FileDialog dlg = new FileDialog(Display.getCurrent().getShells()[0]);
+ dlg.setText("Select the package image.");
+ String strDir = dlg.open();
+
+ return strDir;
+ }
+
+ /**
+ * Unzip SDK ImageFile.
+ *
+ * @param imageFile SDK Image File.
+ * @return if success to unzip is 1, not -1 or 0.
+ */
+ private long unzipSDKImageFile(final File imageFile) {
+ Log.log("Start to unzip SDK Image File. => " + imageFile.getName());
+
+ String sdkTempDir = PathUtil.getCurrentDir();
+
+ final File sdkTempDirFile = new File(sdkTempDir);
+ if (!sdkTempDirFile.exists()) {
+ sdkTempDirFile.mkdirs();
+ }
+
+ final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();
+ progressbar.updateName("Extracting the SDK image file...\n It can take few minutes.");
+
+ Shell shell = progressbar.getParent();
+ shell.getDisplay().asyncExec(new Runnable(){
+ public void run() {
+ String imageFilePath = imageFile.getAbsolutePath();
+ SDKPackageFormat format = SDKPackageFormat.createSDKPackageFormat();
+ unzipResult = format.unZip(imageFilePath, sdkTempDirFile.getAbsolutePath(), null);
+ progressbar.finish();
+ }
+ });
+
+ if (!shell.isDisposed()) {
+ progressbar.open();
+ }
+
+ if (unzipResult <= 0) {
+ repository = "";
+ } else {
+ repository = sdkTempDir;
+ }
+
+ return unzipResult;
+ }
+
+ /**
+ * get serverType.
+ *
+ * @return
+ */
+ public ServerType getServerType() {
+ return serverType;
+ }
+
+ /**
+ * Set to enable OK button.
+ *
+ * @param isAvailable
+ */
+ public void setOkEnable(boolean isAvailable) {
+ okBtn = getButton(Window.OK);
+ okBtn.setEnabled(isAvailable);
+ }
+
+ /**
+ * Clear the data.
+ */
+ public void clear() {
+ if (!distributionCombo.isDisposed()) {
+ distributionCombo.dispose();
+ }
+
+ if (!snapshotTable.isDisposed()) {
+ snapshotTable.clearAll();
+ }
+ }
}
ProgressBar mProgressBar = null;
boolean bCancel = false;
+
+ private static IndeterminateProgressDialog progressDialog = null;
- public IndeterminateProgressDialog(Shell parent, int style) {
+ private IndeterminateProgressDialog(Shell parent, int style) {
super(parent, style);
}
- public IndeterminateProgressDialog(Shell parent, int style, String title) {
+ private IndeterminateProgressDialog(Shell parent, int style, String title) {
super(parent, style);
mDisplay = getParent().getDisplay();
setText(title);
public void open() {
createContents();
setCenterOfMonitor();
-
+
mShell.open();
mShell.layout();
*/
private void createContents() {
mShell = new Shell(getParent(), SWT.None | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- mShell.setSize(250, 130);
+ mShell.setSize(300, 130);
mShell.setText("InstallManager");
- mProgressBar = new ProgressBar(mShell, SWT.INDETERMINATE);
- mProgressBar.setBounds(50, 43, 150, 17);
+// mProgressBar = new ProgressBar(mShell, SWT.INDETERMINATE);
+// mProgressBar.setBounds(50, 43, 150, 17);
mNameLabel = new Label(mShell, SWT.NONE | SWT.CENTER);
- mNameLabel.setBounds(45, 17, 160, 17);
+ mNameLabel.setBounds(25, 17, 250, 40);
mNameLabel.setText("file name");
}
* @param fileName is string that wants to show on dialog
*/
public void updateName(final String fileName) {
+// if (!mDisplay.isDisposed()) {
+// mNameLabel.setText(fileName);
+// }
if (!mDisplay.isDisposed()) {
mDisplay.asyncExec(new Runnable() {
public void run() {
if (!mNameLabel.isDisposed()) {
if (fileName.length() > 30) {
- String name = fileName.substring(0, 29);
- name = name + "...";
+ //String name = fileName.substring(0, 29);
+ String name = fileName + "...";
mNameLabel.setText(name);
}
else {
/**
* Finish displaying the indeterminate dialog.
*/
- public void finish() {
- if (mShell.isDisposed()) {
+ public void finish() {
+ if (mShell == null || mShell.isDisposed()) {
return;
}
}
}
- /**
- * Start to display the indeterminate dialog.
- */
- public static void start() {
-
+ public static IndeterminateProgressDialog getInstance() {
+ if (progressDialog == null) {
+ Shell shell = new Shell(Display.getCurrent());
+ progressDialog = new IndeterminateProgressDialog(shell, SWT.NONE, "");
+ }
+
+ return progressDialog;
}
}
import java.util.ArrayList;
import java.util.List;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Package;
+import org.tizen.installmanager.pkg.model.PackageSet;
+
/**
* This class support items for tree view.
* @author Taeyong Son <taeyong2.son@samsung.com>
*/
-public class Item {
+public class Item implements Comparable<Item> {
+ private Package latestPackage;
+ private Package installedPackage;
private Item parent;
- private String name;
- private String latestVersion;
- private String installedVersion;
- private String size;
private ArrayList<Item> children;
- private boolean isChecked = true;
- private State mState = null;
+ private CheckState checkState= CheckState.UNCHECKED;
+ private InstallState installState = InstallState.INSTALL;
/**
* Package item status enumeration.<br>
* UPDATE : This item need to update.<br>
* UNINSTALL : This item need to uninstall.
*/
- public enum State {
+ public enum InstallState {
INSTALL,
UPDATE,
+ SNAPSHOT,
UNINSTALL,
}
+
+ /**
+ * item check status enumeration.<br>
+ * CHECKED : this item's check state is checked.<br>
+ * GRAYED : this item's check state is grayed.<br>
+ * UNCHECKED : this item's check state is unchecked.
+ */
+ public enum CheckState {
+ CHECKED,
+ GRAYED,
+ UNCHECKED
+ }
/**
* Construct Item class.
* @param size is a item size.
* @param state is a item state.
*/
- public Item(
- Item parent, String name, String latestVersion, String installedVersion, long size,
- State state) {
- setParent(parent);
- setName(name);
- setLatestVersion(latestVersion);
- setInstalledVersion(installedVersion);
- setSize(size);
- setState(state);
- children = new ArrayList<Item>();
-
+ public Item(Package latestPackage, Package installedPackage, InstallState state) {
+ setLatestPackage(latestPackage);
+ setInstalledPackage(installedPackage);
+ setInstallState(state);
+
+ this.children = new ArrayList<Item>();
}
/**
- * Get package item name.
+ * Get display name of item.
+ * @return
+ */
+ public String getDisplayName() {
+ if (latestPackage != null) {
+ return latestPackage.getLabel();
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ * Get package name of item.
* @return
*/
- public String getName() {
- return name;
+ public String getPackageName() {
+ if (latestPackage != null) {
+ return latestPackage.getPackageName();
+ } else {
+ return "";
+ }
}
/**
* @return
*/
public String getLatestVersion() {
- return latestVersion;
+ if (latestPackage != null) {
+ return latestPackage.getVersion().toString();
+ } else {
+ return "";
+ }
}
/**
* @return
*/
public String getInstalledVersion() {
- return installedVersion;
+ if (installedPackage != null) {
+ return installedPackage.getVersion().toString();
+ } else {
+ return "";
+ }
}
-
+
/**
- * Get package item size
- * @return
+ * Get total checked items size
+ * @return Checked items size
+ */
+ public Long getSize() {
+ PackageManager pm = PackageManager.getInstance();
+
+ if (pm == null) {
+ return 0l;
+ } else {
+ long size = 0l;
+ PackageSet checkedChildPackages = getCheckedPackages();
+
+ if (installState == InstallState.UNINSTALL) {
+ size = pm.getTotalSizeOfRemovablePackages(checkedChildPackages);
+ } else {
+ size = pm.getTotalSizeOfInstallablePackages(checkedChildPackages);
+ }
+
+ return size;
+ }
+ }
+
+ private ArrayList<Item> getCheckedItems() {
+ ArrayList<Item> checkedItems = getCheckedChildItems();
+
+ if (this.getCheckState() == CheckState.CHECKED) {
+ checkedItems.add(this);
+ }
+
+ return checkedItems;
+ }
+
+ private ArrayList<Item> getCheckedChildItems() {
+ ArrayList<Item> checkedItems = new ArrayList<Item>();
+
+ ArrayList<Item> childItems = getChildren();
+ for (Item childItem : childItems) {
+ if (childItem.getCheckState() == CheckState.CHECKED) {
+ checkedItems.add(childItem);
+ } else if (childItem.getCheckState() == CheckState.GRAYED) {
+ checkedItems.addAll(childItem.getCheckedChildItems());
+ }
+ }
+
+ return checkedItems;
+ }
+
+ private PackageSet getCheckedPackages() {
+ PackageSet checkedPackages = new PackageSet();
+
+ ArrayList<Item> checkedItems = getCheckedItems();
+
+ for (Item checkedItem : checkedItems) {
+ if (installState == InstallState.UNINSTALL) {
+ checkedPackages.add(checkedItem.getInstalledPackage());
+ } else {
+ checkedPackages.add(checkedItem.getLatestPackage());
+ }
+ }
+
+ return checkedPackages;
+ }
+
+ /**
+ * Get package item order
+ * @return item order
*/
- public String getSize() {
- return size;
+ public int getPackageOrder() {
+ if (latestPackage != null) {
+ return latestPackage.getOrder();
+ } else {
+ return 0;
+ }
}
/**
+ * add child item on current item.
+ */
+ public void addChildItem(Item item) {
+ this.children.add(item);
+ }
+
+ /**
+ * Clear children items on current item.
+ */
+ public void clearChildrenItems() {
+ this.children.clear();
+ }
+
+ /**
* Get dependent package item on current item.
* @return
*/
- public Object[] getChildren() {
- return children.toArray();
+ public ArrayList<Item> getChildren() {
+ return children;
}
/**
* Check package is checked.
* @return true is checked, false is unchecked.
*/
- public boolean isChecked() {
- return isChecked;
+ public CheckState getCheckState() {
+ return checkState;
}
/**
* @return If package has children, return true. if not, return false.
*/
public boolean hasChildren() {
- return !children.isEmpty();
+ return !getChildren().isEmpty();
}
-
+
/**
* Get parent package.
* @return parent package.
*/
- public Item getParent() {
+ public Item getParent() {
return parent;
}
-
+
/**
- * Set parent package.
- * @param parent
+ * Get latest package.
+ * @return
*/
- public void setParent(Item parent) {
- this.parent = parent;
+ public Package getLatestPackage() {
+ return latestPackage;
}
-
+
/**
- * Set package name
- * @param name
+ * Get installed package.
+ * @return
*/
- public void setName(String name) {
- this.name = name;
+ public Package getInstalledPackage() {
+ return latestPackage;
}
-
+
/**
- * Set package's lastest version.
- * @param latestVersion
+ * Get package that depends on the state.
+ * @return
*/
- public void setLatestVersion(String latestVersion) {
- this.latestVersion = latestVersion;
+ public Package getPackage() {
+ if (this.installState == InstallState.UNINSTALL) {
+ return installedPackage;
+ } else {
+ return latestPackage;
+ }
}
-
+
/**
- * Set installed package's version
- * @param installedVersion
+ * Set latest package for tree item.
+ * @param pkg
*/
- public void setInstalledVersion(String installedVersion) {
- this.installedVersion = installedVersion;
+ public void setLatestPackage(Package pkg) {
+ this.latestPackage = pkg;
}
-
+
/**
- * Set package's total size
- * @param totalSize(String)
+ * Set installed package for tree item.
+ * @param pkg
*/
- public void setSize(String totalSize) {
- this.size = totalSize;
+ public void setInstalledPackage(Package pkg) {
+ this.installedPackage = pkg;
}
/**
- * Set package's total size
- * @param totalSize(long)
+ * Set parent package.
+ * @param parent
*/
- public void setSize(long totalSize) {
- String size = "0";
- if (totalSize != 0) {
- size = new Long(totalSize).toString();
- }
- setSize(size);
+ public void setParent(Item parentItem) {
+ parent = parentItem;
}
/**
* Set package's checked flag.
- * @param checked is true, this package is selected by tree view.
+ * @param CHECKED is true, this package is selected by tree view.
*/
- public void setChecked(boolean checked) {
- this.isChecked = checked;
+ public void setCheckState(CheckState state) {
+ this.checkState = state;
+ }
+
+ public void setCheckState(boolean state) {
+ if (state) {
+ this.checkState = CheckState.CHECKED;
+ } else {
+ this.checkState = CheckState.UNCHECKED;
+ }
}
/**
* Set item's state.
* @param state
- * @see State
+ * @see InstallState
*/
- public void setState(State state) {
- mState = state;
+ public void setInstallState(InstallState state) {
+ if (state == InstallState.UPDATE) {
+ this.checkState = CheckState.CHECKED;
+ } else if (state == InstallState.UNINSTALL) {
+ this.checkState = CheckState.UNCHECKED;
+ }
+
+ this.installState = state;
}
/**
* Get item's state
* @return state
- * @see State
+ * @see InstallState
*/
- public State getState() {
- return mState;
+ public InstallState getInstallState() {
+ return installState;
}
-
+
+ /**
+ * Get item's display order
+ * @return display order
+ */
+ public int getOrder() {
+ return latestPackage.getOrder();
+ }
+
/**
- * Get parameter's child items.
- * @param itemName
- * @return If current item equals param's item, return this(current item).
- * If param's item has children, return child item. if not, return null.
+ * Set state by children's state
*/
- public Item getDescendant(String itemName) {
- if (getName().equals(itemName)) {
- return this;
+ public void setStateByChildren() {
+ setCheckStateByChildren(this);
+ setInstallStateByChildren(this);
+ }
+
+ private void setCheckStateByChildren(Item parentItem) {
+ if (!parentItem.hasChildren()) {
+ return;
+ } else {
+ for (Item item : parentItem.getChildren()) {
+ setCheckStateByChildren(item);
+ }
+
+ if (parentItem.isChildrenAllChecked()) {
+ parentItem.setCheckState(CheckState.CHECKED);
+ } else if (parentItem.isChildrenAllUnchecked()) {
+ parentItem.setCheckState(CheckState.UNCHECKED);
+ } else {
+ parentItem.setCheckState(CheckState.GRAYED);
+ }
}
-
- if (hasChildren()) {
- Item existItem = null;
- for (int i = 0; i < getChildren().length; i++) {
- existItem = ((Item) getChildren()[i]).getDescendant(itemName);
- if (existItem != null)
- return existItem;
+ }
+
+ private void setInstallStateByChildren(Item parentItem) {
+ if (!parentItem.hasChildren()) {
+ return;
+ } else {
+ for (Item item : parentItem.getChildren()) {
+ setInstallStateByChildren(item);
+ }
+
+ if (parentItem.isChildrenAllUpdate()) {
+ parentItem.setInstallState(InstallState.UPDATE);
+ } else if (parentItem.isChildrenAllUninstall()) {
+ parentItem.setInstallState(InstallState.UNINSTALL);
+ } else {
+ parentItem.setInstallState(InstallState.INSTALL);
+ }
+ }
+ }
+
+
+ /**
+ * check children's checkbox state.
+ * @return if true, children's checkbox state is all checked.
+ */
+ public boolean isChildrenAllChecked() {
+ for (Item item : getChildren()) {
+ if (item.getCheckState() != CheckState.CHECKED) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * check children's checkbox state.
+ * @return if true, children's checkbox state is all unchecked.
+ */
+ public boolean isChildrenAllUnchecked() {
+ for (Item item : getChildren()) {
+ if (item.getCheckState() != CheckState.UNCHECKED) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isChildrenAllUpdate() {
+ for (Item item : getChildren()) {
+ if (item.getInstallState() != InstallState.UPDATE) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean isChildrenAllUninstall() {
+ for (Item item : getChildren()) {
+ if (item.getInstallState() != InstallState.UNINSTALL) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String getStateToString() {
+ if (hasChildren() || getParent() == null) {
+ return "";
+ } else {
+ switch(installState) {
+ case INSTALL:
+ return "Not installed";
+ case UPDATE:
+ return "Updatable";
+ case UNINSTALL:
+ return "Installed";
+ default:
+ return "";
}
}
- return null;
}
/**
* If parent item is checked, child items should be checked.
- * @param checked is true, every child items' checked flag is true. false is the opposite.
+ * @param state is true, every child items' checked flag is true. false is the opposite.
*/
- public void setSubItemChecked(boolean checked) {
- setChecked(checked);
+ public void setSubItemChecked(boolean state) {
+ setCheckState(state);
if (hasChildren()) {
- for (int i = 0; i < getChildren().length; i++) {
- ((Item) getChildren()[i]).setSubItemChecked(checked);
+ for (int i = 0; i < getChildren().size(); i++) {
+ ((Item) getChildren().get(i)).setSubItemChecked(state);
}
}
}
*/
public void getTerminalPackages(List<String> installList, boolean checked) {
if (hasChildren()) {
- for (int i = 0; i < getChildren().length; i++) {
- ((Item) getChildren()[i]).getTerminalPackages(installList, checked);
+ for (Item childItem : getChildren()) {
+ childItem.getTerminalPackages(installList, checked);
}
- } else {
- if (checked == true) {
- if (isChecked())
- installList.add(getName());
- } else {
- if (!isChecked())
- installList.add(getName());
+ }
+
+ if (getChildren().size() <= 0) {
+ if (getCheckState() == CheckState.CHECKED) {
+ installList.add(getPackageName());
}
}
}
List<Item> descendants = new ArrayList<Item>();
descendants.add(this);
if (hasChildren()) {
- for (int i = 0; i < getChildren().length; i++) {
- descendants.addAll(((Item) getChildren()[i]).getDescendants());
+ for (int i = 0; i < getChildren().size(); i++) {
+ descendants.addAll(((Item) getChildren().get(i)).getDescendants());
}
}
return descendants;
}
-
+
public boolean hasGrayedChild(List<Item> grayCheckedItems) {
for (int i = 0; i < grayCheckedItems.size(); i++) {
- for (int j = 0; j < getChildren().length; j++) {
- if (grayCheckedItems.get(i) == getChildren()[j])
+ for (int j = 0; j < getChildren().size(); j++) {
+ if (grayCheckedItems.get(i) == getChildren().get(j))
return true;
}
}
return false;
}
+
+ /**
+ * check children's checkbox state.
+ * @return if true, child item's checkbox state is grayed.
+ */
+ public boolean hasGrayedChild() {
+ for (Item item : getChildren()) {
+ if (item.getCheckState() == CheckState.GRAYED) {
+ return true;
+ }
+ }
+ return false;
+ }
public void checkSuperItemGrayed(
List<Item> grayCheckedItems, List<Item> checkedItems, List<Item> unCheckedItems) {
if (hasChildren()) {
boolean isAllChecked = true;
boolean isAllUnchecked = true;
- for (int i = 0; i < getChildren().length; i++) {
- if (((Item) getChildren()[i]).isChecked() == false)
+ for (int i = 0; i < getChildren().size(); i++) {
+ if (((Item) getChildren().get(i)).getCheckState() == CheckState.UNCHECKED)
isAllChecked = false;
else
isAllUnchecked = false;
}
if (isAllChecked == false && isAllUnchecked == false || hasGrayedChild(grayCheckedItems) == true) {
grayCheckedItems.add(this);
- setChecked(true);
+// setChecked(true);
} else if (isAllChecked == true && isAllUnchecked == false && hasGrayedChild(grayCheckedItems) == false) {
checkedItems.add(this);
- setChecked(true);
+ setCheckState(CheckState.CHECKED);
} else if (isAllChecked == false && isAllUnchecked == true && hasGrayedChild(grayCheckedItems) == false) {
unCheckedItems.add(this);
- setChecked(false);
+ setCheckState(CheckState.UNCHECKED);
}
}
if (getParent() != null) {
getParent().checkSuperItemGrayed(grayCheckedItems, checkedItems, unCheckedItems);
}
}
+
+ public String toString() {
+ return getPackageName();
+ }
+
+ @Override
+ public int compareTo(Item item) {
+ int order = item.getOrder();
+ if (order > getOrder()) {
+ return -1;
+ } else if (order == getOrder()) {
+ return 0;
+ } else if (order < getOrder()) {
+ return 1;
+ }
+ return 0;
+ }
}
package org.tizen.installmanager.ui.model;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.installmanager.ui.model.Item.CheckState;
+import org.tizen.installmanager.ui.model.Item.InstallState;
import org.tizen.installmanager.ui.page.PackageListPage;
* @see PackageListPage
* @author Taeyoung Son <taeyoung2.son@samsung.com>
*/
-public class ItemLabelProvider implements ITableLabelProvider {
+public class ItemLabelProvider extends ColumnLabelProvider {
@Override
public void addListener(ILabelProviderListener listener) {
public void removeListener(ILabelProviderListener listener) {
}
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
+// public String getToolTipText(Object element) {
+// String description = "Tooltip (" + element + ")";
+// if (element instanceof Item && viewController != null) {
+// String pkgName = ((Item) element).getPackageName();
+// description = viewController.getDescription(pkgName);
+// }
+//
+// return description;
+// }
+
+ public Point getToolTipShift(Object object) {
+ return new Point(5, 5);
}
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
+
+ public int getToolTipTimeDisplyed(Object object) {
+ return 5000;
+ }
+
+ public void update(ViewerCell cell) {
+ int columnIndex = cell.getColumnIndex();
+ Object element = cell.getElement();
String result = null;
switch (columnIndex) {
case 0:
- if (element instanceof Item)
- result = ((Item) element).getName();
+ if (element instanceof Item) {
+ result = ((Item) element).getDisplayName();
+ }
break;
case 1:
- if (element instanceof Item)
- result = ((Item) element).getLatestVersion();
+ if (element instanceof Item) {
+ result = ((Item) element).getStateToString();
+ }
break;
case 2:
- if (element instanceof Item)
- result = ((Item) element).getInstalledVersion();
+ if (element instanceof Item) {
+ result = displaySize(element);
+ }
break;
case 3:
- if (element instanceof Item)
- result = sizeToKB(((Item) element).getSize());
+ if (element instanceof Item) {
+ result = ((Item) element).getInstalledVersion();
+ }
break;
}
- return result;
+
+ if (result != null) {
+ cell.setText(result);
+ }
+
+ if (element instanceof Item) {
+ InstallState state = ((Item)element).getInstallState();
+ if (state == InstallState.UPDATE || state == InstallState.UNINSTALL) {
+ cell.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+ }
+ }
+ }
+
+ private String displaySize(Object element) {
+ Item item = (Item) element;
+
+ if (item.getCheckState() == CheckState.UNCHECKED) {
+ return "";
+ } else {
+ return sizeToKB(item.getSize());
+ }
}
- private String sizeToKB(String size) {
- if (size.equals("")) {
+ private String sizeToKB(Long size) {
+ if (size <= 0) {
return "";
}
- double sizeB = Double.parseDouble(size);
+
+ double sizeB = (double)size;
double sizeK = sizeB / 1024.0;
double sizeM = sizeK / 1024.0;
package org.tizen.installmanager.ui.model;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ITreeContentProvider;
@Override
public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
+ ArrayList<Object> retElements = new ArrayList<Object>();
+
+ if (inputElement instanceof List) {
+ List<?> elementList = (List<?>)inputElement;
+
+ for (Object obj : elementList) {
+ if (obj instanceof Item) {
+ Item item = (Item)obj;
+
+ if (item.getParent() == null) {
+ retElements.add(item);
+ }
+ }
+ }
+ }
+
+ return retElements.toArray();
}
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof List)
- return ((List<?>) parentElement).toArray();
- if (parentElement instanceof Item)
- return ((Item) parentElement).getChildren();
- return new Object[0];
+ if (parentElement instanceof Item) {
+ return ((Item) parentElement).getChildren().toArray();
+ } else {
+ return null;
+ }
}
@Override
public Object getParent(Object element) {
- if (element instanceof Item)
+ if (element instanceof Item) {
return ((Item) element).getParent();
- return null;
+ } else {
+ return null;
+ }
}
@Override
public boolean hasChildren(Object element) {
- if (element instanceof List)
- return ((List<?>) element).size() > 0;
- if (element instanceof Item)
+ if (element instanceof Item) {
return ((Item) element).hasChildren();
- return false;
+ } else {
+ return false;
+ }
}
}
\ No newline at end of file
--- /dev/null
+/PageTemplate.java
package org.tizen.installmanager.ui.page;
+import java.io.File;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.lib.Platform;
import org.tizen.installmanager.ui.InstallManagerWindow;
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
+import org.tizen.installmanager.util.PathUtil;
/**
public static final String RSC_PATH_UNINSTALL_IMAGE = RESOURCE_PATH + "/uninstaller_graphicmotif_003.png";
public static final String STRING_TITLE = "Installation Completed";
private Label lblNewLabel;
- public static Button checkBtn;
+ public Button checkBtn;
/**
* Set basic environment of complete page.
* Get check button
* @return check button object
*/
- public static Button getChkBtn() {
+ public Button getChkBtn() {
return checkBtn;
}
public void setCustomMessage(String completeMsg) {
lblNewLabel.setText(completeMsg);
}
+
+ public void removeTargetDir() {
+ String targetDir = Config.getInstance().getTargetDir();
+ if (targetDir == null || targetDir.isEmpty()) {
+ return;
+ }
+
+ File targetDirFile = new File(targetDir);
+ if (!targetDirFile.exists()) {
+ return;
+ } else {
+ if (!Platform.isWindows()) {
+ int confirm = MessageBoxDlg.showDlg(getShell(),
+ "WARNING",
+ "Do you want to remove the SDK directory?\n" +
+ "Your data files in '" +
+ targetDir +
+ "' will be removed too.",
+ DialogType.WARNING);
+
+ if (confirm == MessageBoxDlg.YES) {
+ PathUtil.remove(targetDir);
+ } else {}
+ } else {}//if(Patform.isWindows())
+ }
+ }
/**
* Show error message on complete page.
public class ConfigPathPage extends PageTemplate {
private static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_003.png";
private static final String STRING_TITLE = "Install";
- private static final String STRING_SUBTITLE = "Where do you want to install and update packages?";
+ private static final String STRING_SUBTITLE = "Select the package installation and update location.";
private Table table;
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.ui.page;
+import java.util.ArrayList;
+import java.util.Collection;
+
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Label;
import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.SDKExtensionInfo;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.IMError;
import org.tizen.installmanager.lib.Log;
+import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.ui.model.Item.State;
-
-
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Package;
/**
* This class displays installable package list on page.
- * @author Taeyoung Son <taeyoung2.son@samsung.com>
+ *
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>
*/
public class InstallableListPage extends PackageListPage {
- static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_002.png";
- static final String STRING_TITLE = "Items";
- static final String STRING_SUBTITLE = "Customize the items that you wish to install.";
+ static final String RSC_PATH_IMAGE = RESOURCE_PATH
+ + "/install_manager_graphicmotif_002.png";
+ static final String STRING_TITLE = "Install Type";
+
+ static final String TYPICAL_BUTTON_NAME = "Typical";
+ static final String MINIMAL_BUTTON_NAME = "Minimal";
+ static final String CUSTOM_BUTTON_NAME = "Custom";
+
+ private Composite buttonComposite;
+
+ // Install Type button
+ private Button typicalButton;
+ private Button minimalButton;
+ private Button customButton;
+
+ // Install Type Explain Label
+ private Label typicalLabel;
+ private Label minimalLabel;
/**
* @param parent
public InstallableListPage(Composite parent, int style) {
super(parent, style, Type.INSTALL);
setLeftImageFromResource(RSC_PATH_IMAGE);
+ setTitleBounds(160, 3, 468, 20);
+ disableSubtitleBounds();
setTitle(STRING_TITLE);
- setSubTitle(STRING_SUBTITLE);
+
+ buttonComposite = new Composite(this, SWT.NONE);
+
+ buttonComposite.setSize(468, 60);
+ buttonComposite.setLocation(160, 27);
+ buttonComposite
+ .setBackground(InstallManagerWindow.getBackgroundColor());
+
+ setButtons();
+ }
+
+ /**
+ * Set Install Type radio buttons.
+ */
+ private void setButtons() {
+ setTypicalButton();
+ setMinimalButton();
+ setCustomButton();
+ }
+
+ /**
+ * Set Typical Type radio button.
+ */
+ private void setTypicalButton() {
+ if (typicalButton == null) {
+ typicalButton = new Button(buttonComposite, SWT.RADIO);
+ }
+
+ typicalButton.setSelection(true);
+
+ typicalButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setCheckedByType(TYPICAL_BUTTON_NAME.toUpperCase());
+ checkboxTreeViewer.refresh();
+ checkboxTreeViewer.getTree().setEnabled(false);
+
+ lblRequiredSize.setText("Total space required : "
+ + convertToVolumeSize(getCheckedPackageSize()));
+
+ setNextBtnEnabledAboutCheckedPackageCount();
+ }
+ });
+
+ typicalButton.setBounds(0, 0, 80, 15);
+ typicalButton.setText(TYPICAL_BUTTON_NAME + ":");
+ typicalButton.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ typicalLabel = new Label(buttonComposite, SWT.NONE);
+ typicalLabel.setBounds(81, 0, 410, 15);
+ }
+
+ /**
+ * Set Minimal Type radio button.
+ */
+ private void setMinimalButton() {
+ if (minimalButton == null) {
+ minimalButton = new Button(buttonComposite, SWT.RADIO);
+ }
+
+ minimalButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setCheckedByType(MINIMAL_BUTTON_NAME.toUpperCase());
+ checkboxTreeViewer.refresh();
+ checkboxTreeViewer.getTree().setEnabled(false);
+
+ lblRequiredSize.setText("Total space required : "
+ + convertToVolumeSize(getCheckedPackageSize()));
+
+ setNextBtnEnabledAboutCheckedPackageCount();
+ }
+ });
+
+ minimalButton.setBounds(0, 20, 80, 15);
+ minimalButton.setText(MINIMAL_BUTTON_NAME + ":");
+ minimalButton.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ minimalLabel = new Label(buttonComposite, SWT.NONE);
+ minimalLabel.setBounds(81, 20, 410, 15);
+ }
+
+ /**
+ * Set Custom Type radio button.
+ */
+ private void setCustomButton() {
+ if (customButton == null) {
+ customButton = new Button(buttonComposite, SWT.RADIO);
+ }
+
+ customButton.setBounds(0, 40, 80, 15);
+ customButton.setText(CUSTOM_BUTTON_NAME);
+ customButton.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ customButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ checkboxTreeViewer.getTree().setEnabled(true);
+ }
+ });
+ }
+
+ /**
+ * Check tree item by each install type.
+ */
+ private void setCheckedByType(String installType) {
+ if (installType == null || installType.isEmpty()) {
+ Log.err("Install type is empty. check install type or package server is old.");
+ }
+ Package pkg = InstallManager.getInstance().getPackageManager()
+ .getPackageByName(installType);
+
+ if (pkg == null) {
+ Log.err(installType + " do not exist in package list.");
+ return;
+ }
+
+ Collection<Item> checkedItems = new ArrayList<Item>();
+
+ for (String pkgName : pkg.getDependentPackageNames()) {
+ Item item = findItem(pkgName, items);
+
+ if (item != null) {
+ checkedItems.add(item);
+ }
+ }
+
+ setCheckedItem(checkedItems);
+ }
+
+ private void setCheckedItem(Collection<Item> itemList) {
+ checkboxTreeViewer.setCheckedElements(itemList.toArray());
+
+ // refresh tree item. All of items are unchecked.
+ setAllChecked(false);
+
+ // check selected item.
+ for (Item item : itemList) {
+ setCheckbox(item, true);
+ }
}
/**
this.viewController = controller;
getItems().clear();
+ // back to next on component selection page case.
+ // in this case, page status should be typical selection case.
+ if (customButton.getSelection()) {
+ customButton.setSelection(false);
+ typicalButton.setSelection(true);
+ } else if (minimalButton.getSelection()) {
+ minimalButton.setSelection(false);
+ typicalButton.setSelection(true);
+ }
+
try {
- loadPackagesToTreeViewer(viewController.getInstallableMetaPackageList(), State.INSTALL);
- loadPackagesToTreeViewer(viewController.getUpdatableMetapackageList(), State.UPDATE);
+ loadPackagesToTreeViewer(viewController.getRootMetaPackageListOfRepository());
+
+ SDKExtensionInfo sdkExtensionInfo = SDKExtensionInfo.getInstance();
+ addExtensionPackagesToExtra(sdkExtensionInfo.getExtensionPackages());
} catch (IMFatalException fatalException) {
Log.err(ErrorController.getErrorMessage());
IMError.fatalError(ErrorController.getErrorMessage());
checkboxTreeViewer.refresh();
-
if (getItems().size() <= 0) {
return false;
}
- setAllChecked(true);
+ setCheckedByType(TYPICAL_BUTTON_NAME.toUpperCase());
+ checkboxTreeViewer.getTree().setEnabled(false);
- //font color to gray
- setDisableColor();
+ checkboxTreeViewer.refresh();
setNextBtnEnabledAboutCheckedPackageCount();
- lblRequiredSize.setText("Space required : " + convertToVolumeSize(getCheckedPackageSize()));
+ lblRequiredSize.setText("Total space required : "
+ + convertToVolumeSize(getCheckedPackageSize()));
+
+ initDescriptionToInstallType();
return true;
}
+
+ private void initDescriptionToInstallType() {
+ PackageManager pm = PackageManager.getInstance();
+
+ //set typical description
+ String typicalExplain = "";
+ Package typicalPackage = pm.getPackageByName(TYPICAL_BUTTON_NAME.toUpperCase());
+ if (typicalPackage != null) {
+ typicalExplain = typicalPackage.getDescription();
+ }
+
+ typicalLabel.setText(typicalExplain);
+ typicalLabel.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ //set minimal description
+ String minimalExplain = "";
+ Package minimalPackage = pm.getPackageByName(MINIMAL_BUTTON_NAME.toUpperCase());
+ if (minimalPackage != null) {
+ minimalExplain = minimalPackage.getDescription();
+ }
+
+ minimalLabel.setText(minimalExplain);
+ minimalLabel.setBackground(InstallManagerWindow.getBackgroundColor());
+ }
/**
- * Updatable packages's color is gray.
- * It means that user cannot uncheck.
+ * Find item which should be checked in component tree.
+ *
+ * @param name
+ * the name of item which should be checked.
+ * @param itemList
+ * @return item which should be checked in component tree.
*/
- private void setDisableColor() {
- for (TreeItem tItem : checkboxTreeViewer.getTree().getItems()) {
- Item item = (Item) tItem.getData();
+ private Item findItem(String name, Collection<Item> itemList) {
+ Item retItem = null;
+ for (Item item : itemList) {
+ if (name.equalsIgnoreCase(item.getPackageName())) {
+ return item;
+ } else {
+ Collection<Item> childItemList = item.getChildren();
- if (item.getState() == State.UPDATE) {
- tItem.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
+ if (childItemList.size() > 0) {
+ retItem = findItem(name, childItemList);
+
+ if (retItem != null) {
+ break;
+ }
+ }
}
}
+ return retItem;
}
}
+
+
+
import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
-
/**
* @author Taeyoung Son <taeyoung2.son@samsung.com>
*
static final String RSC_PATH_IMAGE = RESOURCE_PATH
+ "/install_manager_graphicmotif_003.png";
static final String STRING_TITLE = "Installation Progress";
- static final String STRING_SUBTITLE = "Please wait while the Tizen SDK installation is being processed.";
+ static final String STRING_SUBTITLE = "Wait while the Tizen SDK installation is being processed.";
static final double KB_SIZE = 1;
static final double MB_SIZE = KB_SIZE * 1024;
display = customComposite.getDisplay();
if (isUpdate == true) {
- int confirm = MessageBoxDlg.YES;
-
ProgramController controller = ProgramController
.createProgramController();
- if (controller.runningProgramExists())
- confirm = MessageBoxDlg
+
+ if (controller.runningProgramExists()) {
+ int confirm = MessageBoxDlg
.showDlg(
getShell(),
"Warning",
- "SDK is running."
- + " If you want to update SDK, we will kill the process."
- + " Would you like to update SDK?",
+ "SDK is running. If you update the SDK, the running SDK version is stopped. Are you sure you want to update the SDK?",
DialogType.WARNING);
- if (confirm == MessageBoxDlg.YES) {
- controller.terminateRunningProgram();
- new InstallThread(monitor).start();
- } else if (confirm == MessageBoxDlg.NO) {
- return false;
- }
- } else {
- if (!viewController.existRemovablePackage() && viewController.existFilesInTargetDirectory(installPath)) {
- int confirm = MessageBoxDlg.showDlg(
- getShell()
- ,
- "Warning"
- ,
- "Target directory has some files or directories.\nThey will be removed by InstallManager.\n"
- + "Would you like to remove them?"
- , DialogType.WARNING);
-
+
if (confirm == MessageBoxDlg.YES) {
- viewController.removeTargetPath(installPath);
- new InstallThread(monitor).start();
- } else {
- //TODO : complete message?
+ controller.terminateRunningProgram();
+ } else if (confirm == MessageBoxDlg.NO) {
return false;
}
- } else {
- new InstallThread(monitor).start();
}
- }
+ } else {}
+
+ new InstallThread(monitor).start();
+
return true;
}
if (ErrorController.checkInstallationSuccess()) {
completePage.setTitle("Installation Completed");
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
completePage
- .setCustomMessage("Thank you for installing Tizen SDK. \n\n" +
- "To use the SDK program, open the Application menu, " +
- "find the Tizen SDK folder, and click the program icon.");
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ .setCustomMessage("Thank you for installing the Tizen SDK. \n\n" +
+ "To use the SDK, go to Application > Tizen SDK > Tizen IDE.");
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
completePage
- .setCustomMessage("Thank you for installing Tizen SDK. \n\n" +
- "To use the SDK program, open the Desktop menu, " +
- "find the Tizen folder, and click the program icon.");
+ .setCustomMessage("Thank you for installing the Tizen SDK. \n\n" +
+ "To use the SDK, go to Start > All Programs > Tizen SDK > Tizen IDE.");
} else {
- ErrorController
- .setError(ErrorCode.UNSUPPORTED_PLATFORM);
- throw new IMFatalException(ErrorController
- .getErrorMessage());
+ completePage
+ .setCustomMessage("Thank you for installing the Tizen SDK. \n\n");
}
Log.log("installation complete");
} else {
Log.log("(un)installation failed");
completePage.setTitle("(Un)Installation failed");
- completePage.setCustomErrorMessage(ErrorController.getErrorMessage() + "\n" +
- "It's recommended to uninstall all and install again.");
+ completePage.setCustomErrorMessage(ErrorController.getErrorMessage() + "\n");
mainWindow.getCompletePage().showCheckButton(false);
}
/* set remain time */
double remainTime = 0;
if (downloadVelocity == 0)
- remainTimeStr = "unknown";
+ remainTimeStr = "estimating..";
else {
double remainSize = totalWork - mProgressSize;
remainTime = remainSize / downloadVelocity;
statusLabel.setText("Downloading : " + mProgressTitle);
installedNumberLabel.setText(currentSize + "/" + totalSize);
- mSubTitleOfProgress.setText("Remain time : "
+ mSubTitleOfProgress.setText("Remaining time : "
+ remainTimeStr);
mDownloadVelocity.setText(downloadVelocityStr);
progressBar
public class LicensePage extends PageTemplate {
private static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_001.png";
private static final String STRING_TITLE = "License Agreement";
- private static final String STRING_SUBTITLE = "To continue you must accept the terms of this agreement.";
+ private static final String STRING_SUBTITLE = "To continue, accept the terms of this agreement.";
private StyledText txtLicense;
private Button btnAccept;
/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
+ * InstallManager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>
+ * Shihyun Kim <shihyun.kim@samsung.com>
+ * Taeyoung Son <taeyoung2.son@samsung.com>
+ * Yongsung kim <yongsung1.kim@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
-*
-*/
+ * 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.installmanager.ui.page;
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.tizen.installmanager.core.Config;
-import org.tizen.installmanager.pkg.model.Package2;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.Platform;
+import org.tizen.installmanager.pkg.model.Package;
import org.tizen.installmanager.pkg.model.PackageSet;
import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.ui.model.Item;
import org.tizen.installmanager.ui.model.ItemLabelProvider;
import org.tizen.installmanager.ui.model.ItemTreeContentProvider;
-import org.tizen.installmanager.ui.model.Item.State;
-
+import org.tizen.installmanager.ui.model.Item.CheckState;
+import org.tizen.installmanager.ui.model.Item.InstallState;
/**
* Display install or uninstall package lists via tree view.
+ *
* @author Taeyoung Son <taeyoung2.son@samsung.com>
*/
public abstract class PackageListPage extends PageTemplate {
protected Tree tree;
private Label lblSelectPackage;
protected Label lblRequiredSize;
- private List<Item> items;
+ protected List<Item> items;
+ protected Label lblDescriptions;
CheckboxTreeViewer checkboxTreeViewer;
ViewController viewController = null;
- public enum Type {
- INSTALL,
- UNINSTALL
- }
-
Type mType = null;
+ private static final String EXTRAS_OF_TREE_ITEM = "EXTRAS";
+ public enum Type {
+ INSTALL, UNINSTALL, UPDATE
+ }
+
/**
- * Set environments for packagelist page, such as style, adding listener.
+ * Set environments for packagelist page, such as style, adding listener.
+ *
* @param parent
* @param style
*/
mType = type;
items = new ArrayList<Item>();
+
+ setDescriptionText(customComposite);
+
+ lblDescriptions = new Label(getCustomComposite(), SWT.NONE);
+ lblDescriptions.setBounds(0, 235, 124, 17);
+ if (Platform.isUbuntu()) {
+ lblDescriptions.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 11, SWT.BOLD))));
+ } else if (Platform.isWindows()) {
+ lblDescriptions.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 11, SWT.BOLD))));
+ }
+ lblDescriptions.setText("Description");
+ lblDescriptions.setBackground(InstallManagerWindow.getBackgroundColor());
- mDescriptionText = new Text(
- customComposite,
- SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
- mDescriptionText.setForeground(new Color(null, 96, 96, 96));
- mDescriptionText.setText("Position your mouse over a item to see its description.");
- mDescriptionText.setEditable(false);
- mDescriptionText.setEnabled(false);
- mDescriptionText.setBounds(0, 247, 447, 55);
-
- checkboxTreeViewer = new CheckboxTreeViewer(
- customComposite, SWT.BORDER | SWT.H_SCROLL | SWT.LEFT);
+ checkboxTreeViewer = new CheckboxTreeViewer(customComposite, SWT.BORDER | SWT.H_SCROLL | SWT.LEFT);
tree = checkboxTreeViewer.getTree();
- tree.setBounds(0, 0, 447, 210);
+ tree.setBounds(0, 0, 447, 230);
tree.setHeaderVisible(true);
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
tree.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent arg0) {
- mDescriptionText.setText("Position your mouse over a item to see its description.");
+ mDescriptionText.setText("Position your mouse pointer over an item to view its description.");
mDescriptionText.setForeground(new Color(null, 96, 96, 96));
}
-
});
+
tree.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent arg0) {
TreeItem item = tree.getItem(mousePoint);
if (item != null) {
mDescriptionText.setForeground(new Color(null, 0, 0, 0));
- String packageName = item.getText();
+ Item it = (Item)item.getData();
+ String packageName = it.getPackageName();
String description = viewController.getDescription(packageName);
- if (!description.isEmpty() && item.getText(1) != "")
+ if (!description.isEmpty())
mDescriptionText.setText(description);
else
mDescriptionText.setText("\"" + packageName + "\" category.");
} else {
- mDescriptionText.setText("Position your mouse over a item to see its description.");
+ mDescriptionText.setText("Position your mouse pointer over an item to view its description.");
mDescriptionText.setForeground(new Color(null, 96, 96, 96));
}
}
});
TreeColumn trclmnA = new TreeColumn(tree, SWT.LEFT);
- trclmnA.setWidth(187);
+ trclmnA.setWidth(260);
trclmnA.setText("Name");
TreeColumn trclmnB = new TreeColumn(tree, SWT.CENTER);
- trclmnB.setWidth(85);
- trclmnB.setText("Latest");
-
+ trclmnB.setWidth(110);
+ trclmnB.setText("Status");
+
TreeColumn trclmnC = new TreeColumn(tree, SWT.CENTER);
- trclmnC.setWidth(85);
- trclmnC.setText("Installed");
-
- TreeColumn trclmnSize = new TreeColumn(tree, SWT.RIGHT);
- trclmnSize.setWidth(83);
- trclmnSize.setText("Size");
+ trclmnC.setWidth(50);
+ trclmnC.setText("Size");
checkboxTreeViewer = new CheckboxTreeViewer(tree);
- Label lblDescriptions = new Label(getCustomComposite(), SWT.NONE);
- lblDescriptions.setBounds(0, 225, 124, 17);
- lblDescriptions.setFont(new Font(Display.getCurrent(), new FontData("Sans", 10, SWT.BOLD)));
- lblDescriptions.setText("Description");
- lblDescriptions.setBackground(InstallManagerWindow.getBackgroundColor());
-
+ ColumnViewerToolTipSupport.enableFor(checkboxTreeViewer);
lblSelectPackage = new Label(getCustomComposite(), SWT.NONE);
lblSelectPackage.setBounds(0, 225, 402, 17);
lblSelectPackage.setBackground(InstallManagerWindow.getBackgroundColor());
lblSelectPackage.setVisible(false);
- if (type == Type.INSTALL) {
+ if (Config.status == Config.Status.INSTALL) {
lblRequiredSize = new Label(getCustomComposite(), SWT.NONE);
- lblRequiredSize.setBounds(270, 212, 180, 23);
+ lblRequiredSize.setBounds(250, 235, 210, 23);
lblRequiredSize.setBackground(InstallManagerWindow.getBackgroundColor());
}
+
checkboxTreeViewer.setContentProvider(new ItemTreeContentProvider());
checkboxTreeViewer.setLabelProvider(new ItemLabelProvider());
checkboxTreeViewer.setInput(getItems());
+
checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
if (e.getElement() instanceof Item) {
+
Item item = (Item) e.getElement();
- if (item.getName().equals(Config.SDK_NAME)) {
+ if (item.getPackageName().equals(Config.SDK_NAME)) {
checkboxTreeViewer.setSubtreeChecked(item, !e.getChecked());
setCheckbox(item, e.getChecked());
setNextBtnEnabledAboutCheckedPackageCount();
return;
- }
-
- //Updatable packages cannot be unchecked.
- if (item.getState() == State.UPDATE) {
- setCheckbox(item, true);
} else {
setCheckbox(item, e.getChecked());
+ checkboxTreeViewer.refresh();
+
setNextBtnEnabledAboutCheckedPackageCount();
- if (type == Type.INSTALL)
- lblRequiredSize.setText("Space required : " + convertToVolumeSize(getCheckedPackageSize()));
+ if (type == Type.INSTALL || type == Type.UPDATE) {
+ lblRequiredSize.setText("Total space required : "
+ + convertToVolumeSize(getCheckedPackageSize()));
+ }
}
}
}
});
}
+
+ private void setDescriptionText(Composite composite) {
+ mDescriptionText = new Text(
+ composite,
+ SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
+ mDescriptionText.setForeground(new Color(null, 96, 96, 96));
+ mDescriptionText.setText("Position your mouse pointer over an item to view its description.");
+ mDescriptionText.setEditable(false);
+ mDescriptionText.setEnabled(false);
+
+ if (Platform.isUbuntu()) {
+ mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
+ } else if (Platform.isWindows()) {
+ mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.NONE))));
+ }
+
+ if (mType == Type.INSTALL) {
+ mDescriptionText.setBounds(0, 257, 447, 45);
+ } else if (mType == Type.UPDATE) {
+ mDescriptionText.setBounds(0, 287, 447, 45);
+ }
+ }
protected void setNextBtnEnabledAboutCheckedPackageCount() {
if (getCheckedPackageNumber() > 0)
InstallManagerWindow.setNextBtnEnabled(false);
}
- private void setCheckbox(Item item, boolean checked) {
- if (item == null)
+ protected void setCheckbox(Item item, boolean checked) {
+ if (item == null) {
return;
- setChildCheckbox(checkboxTreeViewer, item, checked);
- setParentCheckbox(item);
+ } else {
+ setChildCheckbox(checkboxTreeViewer, item, checked);
+ if (item.getParent() != null) {
+ setParentCheckbox(item.getParent());
+ }
+
+ setCheckbox(items);
+ }
}
- private void setChildCheckbox(
- CheckboxTreeViewer checkboxTreeViewer, Item selectedItem, boolean checked) {
- if (checked) {
- checkboxTreeViewer.setSubtreeChecked(selectedItem, true);
- selectedItem.setSubItemChecked(true);
+ private void setChildCheckbox(CheckboxTreeViewer checkboxTreeViewer,
+ Item selectedItem, boolean checked) {
+ if (!selectedItem.hasChildren()) {
+ setCheckState(selectedItem, checked);
} else {
- checkboxTreeViewer.setSubtreeChecked(selectedItem, false);
- selectedItem.setSubItemChecked(false);
+ for (Item item : selectedItem.getChildren()) {
+ setChildCheckbox(checkboxTreeViewer, item, checked);
+ }
+ setCheckStateByChildren(selectedItem);
}
}
- private void setParentCheckbox(Item selectedItem) {
- List<Item> grayCheckedItems = new ArrayList<Item>();
- List<Item> checkedItems = new ArrayList<Item>();
- List<Item> unCheckedItems = new ArrayList<Item>();
- if (selectedItem.getParent() != null) {
- selectedItem.getParent().checkSuperItemGrayed(
- grayCheckedItems, checkedItems, unCheckedItems);
- for (int i = 0; i < grayCheckedItems.size(); i++) {
- checkboxTreeViewer.setGrayChecked(grayCheckedItems.get(i), true);
- }
- for (int i = 0; i < checkedItems.size(); i++) {
- checkboxTreeViewer.setGrayed(checkedItems.get(i), false);
- checkboxTreeViewer.setChecked(checkedItems.get(i), true);
- }
- for (int i = 0; i < unCheckedItems.size(); i++) {
- checkboxTreeViewer.setGrayed(unCheckedItems.get(i), false);
- checkboxTreeViewer.setChecked(unCheckedItems.get(i), false);
+ private void setCheckState(Item selectedItem, boolean checked) {
+ if (selectedItem.getInstallState() == InstallState.INSTALL) {
+ selectedItem.setCheckState(checked);
+ }
+ }
+
+ private void setParentCheckbox(Item parentItem) {
+ if (parentItem == null) {
+ return;
+ }
+
+ setCheckStateByChildren(parentItem);
+
+ if (parentItem.getParent() != null) {
+ setParentCheckbox(parentItem.getParent());
+ }
+ }
+
+ private void setCheckStateByChildren(Item treeItem) {
+ if (treeItem.isChildrenAllChecked()) {
+ treeItem.setCheckState(true);
+ } else if (treeItem.isChildrenAllUnchecked()) {
+ treeItem.setCheckState(false);
+ } else {
+ treeItem.setCheckState(CheckState.GRAYED);
+ }
+ }
+
+ protected void setCheckbox(List<Item> itemList) {
+ checkboxTreeViewer.setCheckedElements(itemList.toArray());
+
+ for (Item item : itemList) {
+ if (item.getCheckState() == CheckState.CHECKED) {
+ checkboxTreeViewer.setGrayed(item, false);
+ checkboxTreeViewer.setChecked(item, true);
+ } else if (item.getCheckState() == CheckState.UNCHECKED) {
+ checkboxTreeViewer.setGrayed(item, false);
+ checkboxTreeViewer.setChecked(item, false);
+ } else {
+ checkboxTreeViewer.setGrayed(item, true);
}
}
}
/**
* Get items list.
+ *
* @return items list.
*/
public List<Item> getItems() {
abstract public boolean loadPage(ViewController controller);
- protected boolean loadPackagesToTreeViewer(PackageSet packageSet, State state) {
- boolean result = false;
+ protected void loadPackagesToTreeViewer(PackageSet packageSet) {
+ //make tree items from package set.
+ List<Item> treeItems = makeTreeItem(packageSet);
+
+ items.addAll(treeItems);
+
+ // make relation for item tree.
+ makeRelation(items);
+ makeState();
+ }
+
+ public void addExtensionPackagesToExtra(PackageSet packageSet) {
+ Item extraItem = getExtraTreeItem();
+ if (extraItem == null) {
+ return;
+ }
+
+ //Always refresh Extra component whatever add and remove.
+ removeChildrenOfExtra();
+
+ List<Item> extensionItems = makeTreeItem(packageSet);
+
+ makeRelation(extensionItems);
+
+ //Add top items of extension items to extra.
+ for (Item extensionItem : extensionItems) {
+ if (extensionItem.getParent() == null) {
+ extraItem.addChildItem(extensionItem);
+ extensionItem.setParent(extraItem);
+ }
+ }
+
+ for (Item item : items) {
+ if (item.getPackageName().equals(EXTRAS_OF_TREE_ITEM)) {
+ item.setStateByChildren();
+ }
+ }
+ items.addAll(extensionItems);
+ checkboxTreeViewer.refresh();
+ }
+
+ private List<Item> makeTreeItem(PackageSet packageSet) {
+ List<Item> treeItemList = new ArrayList<Item>();
+
if (packageSet == null) {
- return result;
+ return treeItemList;
}
- for (Package2 pkg : packageSet) {
- if (!pkg.isMeta()) {
+ for (Package pkg : packageSet) {
+ if (!pkg.isRootMeta() && !pkg.isPartnerMeta() && !pkg.isExtraMeta() && !pkg.isPublicMeta()) {
continue;
}
-
- if (pkg.getPackageName().equals("TIZEN-SDK")) {
- continue;
+
+ if (!Options.partnerSdk) { // Public SDK case
+ if (pkg.isPartnerMeta()) {
+ continue;
+ }
+ } else { // Partner SDK case
+ if (pkg.isPublicMeta()) {
+ continue;
+ }
}
String packageName = pkg.getPackageName();
- String installedVersion = viewController.getInstalledVersion(pkg);
- Long packageSize = viewController.getTotalSizeWithDepends(pkg);
+ Package installedPackage = viewController.getInstalledPackage(packageName);
- String latestVersion = null;
- if (state == State.UNINSTALL) {
- latestVersion = "";
- } else {
- latestVersion = pkg.getVersion().toString();
+ InstallState itemState = getState(pkg);
+
+ Item newItem = new Item(pkg, installedPackage, itemState);
+ treeItemList.add(newItem);
+ }
+
+ return treeItemList;
+ }
+
+ private Item getExtraTreeItem() {
+ for (Item tItem : items) {
+ if (tItem.getPackageName().equalsIgnoreCase(EXTRAS_OF_TREE_ITEM)) {
+ return tItem;
+ }
+ }
+ return null;
+ }
+
+ private void removeChildrenOfExtra() {
+ Item extraItem = getExtraTreeItem();
+
+ for (Item childItem : extraItem.getChildren()) {
+ removeTreeItem(childItem);
+ }
+
+ extraItem.clearChildrenItems();
+ }
+
+ private void removeTreeItem(Item item) {
+ if (item.hasChildren()) {
+ for (Item childItem : item.getChildren()) {
+ removeTreeItem(childItem);
}
+ }
+
+ items.remove(item);
+ }
+ private InstallState getState(Package pkg) {
+ if (viewController.getInstallableMetaPackageList().contains(pkg)) {
+ return InstallState.INSTALL;
+ } else if (viewController.getUpdatableMetapackageList().contains(pkg)) {
+ return InstallState.UPDATE;
+ } else {
+ return InstallState.UNINSTALL;
+ }
+ }
+ private void makeRelation(List<Item> treeItems) {
+ // set relation of items.
+ for (Item item : treeItems) {
+ setRelationOfItem(item, treeItems);
+ }
- Item newItem = new Item(
- null, packageName, latestVersion, installedVersion, packageSize, state);
- getItems().add(newItem);
+ Collections.sort(treeItems);
+ }
- result = true;
+ private void makeState() {
+ for (Item item : items) {
+ item.setStateByChildren();
}
+ }
- return result;
+ private void setRelationOfItem(Item parentItem, List<Item> compareList) {
+ Package packageOfParentItem = parentItem.getPackage();
+ Collection<String> theChildPackage = packageOfParentItem.getDependentPackageNames();
+
+ for (String childPackage : theChildPackage) {
+ for (Item treeItem : compareList) {
+ String packageNameOfTreeItem = treeItem.getPackageName();
+
+ if (packageNameOfTreeItem.equalsIgnoreCase(childPackage)) {
+ parentItem.addChildItem(treeItem);
+ treeItem.setParent(parentItem);
+ break;
+ }
+ }
+ }
}
protected void setAllChecked(boolean checked) {
List<Item> items = getItems();
- if (items == null)
- return;
- if (items.size() == 1 && items.get(0).getName().equals(Config.SDK_NAME)) {
- checkboxTreeViewer.setSubtreeChecked(items.get(0), true);
+ if (items == null) {
return;
}
-
- for (int i = 0; i < items.size(); i++) {
- setCheckbox(items.get(i), checked);
+
+ for (Item treeItem : items) {
+ setCheckbox(treeItem, checked);
}
-
-
}
protected void setDisableChecked(List<Item> items, boolean checked) {
/**
* Get checked packages count.
+ *
* @return checked packages count.
*/
public int getCheckedPackageNumber() {
/**
* Get checked packages size.
+ *
* @return checked packages size.
*/
public long getCheckedPackageSize() {
if (checkboxTreeViewer != null) {
Object[] items = checkboxTreeViewer.getCheckedElements();
- for (int i = 0; i < items.length; i++) {
- listPkgName.add(((Item) items[i]).getName());
+ for (Object item : items) {
+ Item checkedItem = (Item)item;
+ if (checkedItem.getCheckState() == CheckState.CHECKED) {
+ listPkgName.add(checkedItem.getPackageName());
+ }
}
}
return viewController.getTotalSizeWithDepends(listPkgName);
}
+ public List<String> getCheckedPackageNames() {
+ List<String> listPkgName = new ArrayList<String>();
+
+ if (checkboxTreeViewer != null) {
+ Object[] items = checkboxTreeViewer.getCheckedElements();
+
+ for (int i = 0; i < items.length; i++) {
+ Item item = (Item) items[i];
+ if (item.getParent() != null) {
+ listPkgName.add(item.getPackageName());
+ }
+ }
+ }
+
+ return listPkgName;
+ }
+
/**
* Calculate byte to GB, MB, KB.
+ *
* @param byteSize
* @return Converted byte to GB, MB, KB
*/
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.tizen.installmanager.lib.Platform;
import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.util.PathUtil;
super(parent, style);
setLayout(null);
setBackground(InstallManagerWindow.getBackgroundColor());
-
+
imgLabel = new Label(this, SWT.NONE);
imgLabel.setBounds(0, 0, 160, 398);
imgLabel.setBackground(InstallManagerWindow.getBackgroundColor());
titleLabel = new Label(this, SWT.NONE);
- titleLabel.setFont((new Font(Display.getCurrent(), new FontData("Sans", 11, SWT.BOLD))));
+
+ if (Platform.isUbuntu()) {
+ titleLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 11, SWT.BOLD))));
+ } else if (Platform.isWindows()) {
+ titleLabel.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 11, SWT.BOLD))));
+ }
+
titleLabel.setBounds(160, 17, 468, 20);
titleLabel.setText("New Label");
titleLabel.setBackground(InstallManagerWindow.getBackgroundColor());
public void setSubTitleBounds(int nX, int nY, int nWidth, int nHeight) {
subtitleLabel.setBounds(nX, nY, nWidth, nHeight);
}
+
+ public void setSubTitleFont(FontData fontData) {
+ subtitleLabel.setFont((new Font(Display.getCurrent(), fontData)));
+ }
public void setCustomCompositeBounds(int nX, int nY, int nWidth, int nHeight) {
customComposite.setSize(nWidth, nHeight);
customComposite.setLocation(nX, nY);
}
+
+ public void disableSubtitleBounds() {
+ subtitleLabel.dispose();
+ }
}
private static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_002.png";
private static final String STRING_TITLE = "Location";
- private static final String STRING_SUBTITLE = "Choose a location where you want to install.";
- private static final String WINDOWS_DEFAULT_TARGET_PATH = "C:\\tizen_sdk";
+ private static final String STRING_SUBTITLE = "Select the installation location.";
+ private static final String WINDOWS_DEFAULT_TARGET_PATH = "C:\\tizen-sdk";
private Text installDirectoryText;
private Label installDirectoryLabel;
* Set default install target directory depends on platform.
*/
private void setTargetDirectory() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
installDirectoryText.setText(System.getProperty("user.home") + File.separator + Config.SDK_DIRECTORY);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
installDirectoryText.setText(WINDOWS_DEFAULT_TARGET_PATH);
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
installDirectoryErrLabel.setForeground(new Color(null, 255, 0, 0));
spaceRequiredLabel = new Label(customComposite, SWT.NONE);
- spaceRequiredLabel.setBounds(20, 240, 180, 17);
+ spaceRequiredLabel.setBounds(20, 240, 250, 17);
spaceRequiredLabel.setBackground(InstallManagerWindow.getBackgroundColor());
spaceAvailableLabel = new Label(customComposite, SWT.NONE);
- spaceAvailableLabel.setBounds(20, 265, 180, 17);
+ spaceAvailableLabel.setBounds(20, 265, 250, 17);
spaceAvailableLabel.setBackground(InstallManagerWindow.getBackgroundColor());
installDirectoryText = new Text(customComposite, SWT.BORDER);
MessageBoxDlg.showDlg(
e.display.getShells()[0],
"Error",
- "Selected disk's free space is not enough to install. Select another disk path.",
+ "Not enough disk space for the installation. Select a different installation path.",
DialogType.ERROR);
} else
isAvailablePath = true;
private boolean checkAvailablePath() {
if (installDirectoryText.getText().equals("")) {
- installDirectoryErrLabel.setText("Please set install path.");
+ installDirectoryErrLabel.setText("Set the installation path.");
spaceAvailableLabel.setText("Space available : ");
return false;
}
try {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
if (!installDirectoryText.getText().matches("[^= ]+")) {
- installDirectoryErrLabel.setText("Invalid character is found.\nDo not use '=' character and empty space.");
+ installDirectoryErrLabel.setText("Value cannot contain the '=' character or spaces.");
return false;
} else {
if (!installDirectoryText.getText().startsWith(System.getProperty("user.home"))) {
- installDirectoryErrLabel.setText("You should set install path to home directory.");
+ installDirectoryErrLabel.setText("Set the installation path to the home directory.");
return false;
}
}
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
if (!installDirectoryText.getText().matches("[^`~!@#$%^&*=? ]+")) {
- installDirectoryErrLabel.setText("Invalid character is found.\nDo not use '`~!@#$%^&*=?' character and empty space.");
+ installDirectoryErrLabel.setText("Value cannot contain special characters or spaces.");
return false;
}
}
if (availableSize >= 0)
spaceAvailableLabel.setText("Space available : " + convertToVolumeSize(availableSize));
else {
- installDirectoryErrLabel.setText("Please set install path correctly.");
+ installDirectoryErrLabel.setText("Set the installation path correctly.");
spaceAvailableLabel.setText("Space available : ");
return false;
}
if (requiredSpace > availableSize) {
- installDirectoryErrLabel.setText("Selected disk's free space is not enough to install. Please change install disk path.");
+ installDirectoryErrLabel.setText("Not enough disk space for the installation. Select a different installation path.");
return false;
}
installDirectoryErrLabel.setText("");
InstallManagerWindow.setNextBtnEnabled(checkAvailablePath());
setAvailableSpace(installDirectoryText.getText());
- spaceRequiredLabel.setText("Space required : " + convertToVolumeSize(requiredSize));
+ spaceRequiredLabel.setText("Total space required : " + convertToVolumeSize(requiredSize));
if (selectedDisk != null)
spaceAvailableLabel.setText("Space available : " + convertToVolumeSize(selectedDisk.getUsableSpace()));
else {
MessageBoxDlg.showDlg(
Display.getCurrent().getShells()[0], "Notify",
- "Please select install path for installation.", DialogType.ERROR);
+ "Select the installation path.", DialogType.ERROR);
}
return result;
}
private void setAvailableSpace(String selectedPath) {
IFileSystemInformation fsInfo;
- if (Platform.CURRENT_PLATFORM == Platform.LINUX)
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64)
fsInfo = new LinuxFileSystemInfo();
- else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS)
+ else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64)
fsInfo = new WindowsFileSystemInfo();
else
fsInfo = new IFileSystemInformation() {
private long getAvailableSpaceSize(String selectedPath) {
IFileSystemInformation fsInfo;
- if (Platform.CURRENT_PLATFORM == Platform.LINUX)
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64)
fsInfo = new LinuxFileSystemInfo();
- else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS)
+ else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64)
fsInfo = new WindowsFileSystemInfo();
else
fsInfo = new IFileSystemInformation() {
private String showSettingInstallpathDlg() {
DirectoryDialog dlg = new DirectoryDialog(Display.getCurrent().getShells()[0]);
dlg.setFilterPath(getInstallPath());
- dlg.setText("Install Manager Directory Dialog");
+ dlg.setText("Install Manager Directory");
dlg.setMessage("Select a directory");
String strDir = dlg.open();
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.swt.widgets.Composite;
-import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.ui.model.Item.State;
/**
*/
public class UninstallableListPage extends PackageListPage {
static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/uninstaller_graphicmotif_001.png";
- static final String STRING_TITLE = "Items";
- static final String STRING_SUBTITLE = "Select the items that you wish to uninstall.";
+ static final String STRING_TITLE = "Uninstall Items";
+ static final String STRING_SUBTITLE = "You can see the items to uninstall.";
/**
* Display packages tree structure and add check state listener. a package is selected by check,
this.viewController = controller;
getItems().clear();
- loadPackagesToTreeViewer(viewController.getRemovableMetaPackageList(), State.UNINSTALL);
+ loadPackagesToTreeViewer(viewController.getRemovableMetaPackageList());
if (getItems().size() <= 0) {
setUninstallAll();
setUninstallColumn();
checkboxTreeViewer.refresh();
setAllChecked(true);
-
return true;
}
* Change column in uninstallable list page.
*/
protected void setUninstallColumn() {
- tree.getColumn(1).setWidth(0);
- tree.getColumn(2).setText("Installed version");
- tree.getColumn(3).setWidth(0);
+ tree.getColumn(1).setText("Status");
+// tree.getColumn(1).setWidth(0);
+// tree.getColumn(2).setText("Installed version");
+// tree.getColumn(3).setWidth(0);
}
/**
* When all packages must be removed, Set TIZEN SDK item in uninstallable list page
*/
protected void setUninstallAll() {
- getItems().add(new Item(null, Config.SDK_NAME, "", "unknown", 0, State.UNINSTALL));
+ //TODO impl
+// getItems().add(new Item(null, Config.SDK_NAME, "", "unknown", 0, State.UNINSTALL));
}
}
package org.tizen.installmanager.ui.page;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.InstallManager;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.IIMProgressMonitor;
import org.tizen.installmanager.lib.Log;
import org.tizen.installmanager.lib.ProgramController;
+import org.tizen.installmanager.pkg.model.PackageSet;
import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
-
-
+import org.tizen.installmanager.pkg.model.Package;
/**
* @author Taeyoung Son <taeyoung2.son@samsung.com>
- *
+ * @author Shihyun Kim <shihyun.kim@samsung.com>
*/
public class UninstallingPage extends PageTemplate {
static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/uninstaller_graphicmotif_002.png";
static final String STRING_SUBTITLE = "";
- private List<String> selectedList;
private ProgressBar progressBar;
private Label statusLabel;
private Label uninstalledNumberLabel;
/**
* Display uninstalling page, if sdk is running during uninstalling, page will show warning dialog.
* @param selectedList
- * @param viewController
+ * @param vController
* @param mainWindow
* @return
*/
public boolean loadPage(
- List<String> selectedList, ViewController viewController,
+ List<String> selectedList, ViewController vController,
InstallManagerWindow mainWindow) {
- this.selectedList = selectedList;
- this.viewController = viewController;
+ this.viewController = vController;
this.mainWindow = mainWindow;
monitor = new UninstallProgressMonitor();
display = customComposite.getDisplay();
- int confirm = MessageBoxDlg.YES;
-
+ //kill running process.
ProgramController controller = ProgramController.createProgramController();
- if (controller.runningProgramExists())
- confirm = MessageBoxDlg.showDlg(
+ if (controller.runningProgramExists()) {
+ int confirm = MessageBoxDlg.showDlg(
getShell(),
"Warning",
- "SDK is running." +
- " If you want to uninstall SDK, we will kill the process." +
- " Would you like to uninstall SDK?",
- DialogType.WARNING);
- if (confirm == MessageBoxDlg.YES) {
- controller.terminateRunningProgram();
- new UninstallThread(monitor).start();
- } else if (confirm == MessageBoxDlg.NO) {
- return false;
- }
+ "SDK is running now. If you update the SDK, the running is stopped. Are you sure to uninstall the SDK?",
+ DialogType.WARNING);
+ if (confirm == MessageBoxDlg.YES) {
+ controller.terminateRunningProgram();
+ } else if (confirm == MessageBoxDlg.NO) {
+ return false;
+ }
+ } else {}
+
+ //start uninstall.
+ final UninstallThread uninstallThread = new UninstallThread(monitor);
+ uninstallThread.start();
+
return true;
}
public void run() {
try {
uninstallProcess(monitor);
- ErrorController.setInstallationSuccess(true);
} catch (IMFatalException e) {
Log.err("internal error occurred");
Log.ExceptionLog(e);
public void uninstallProcess(IIMProgressMonitor monitor) {
boolean result = false;
- if (selectedList.size() <= 0) {
+ PackageSet pkgs = InstallManager.getInstance().getPackageManager().getInstalledPackages();
+ List<String> installedList = new ArrayList<String>();
+ for (Package pkg : pkgs) {
+ installedList.add(pkg.getPackageName());
+ }
+
+ if (installedList.size() <= 0) {
return;
} else {
- result = viewController.uninstall(selectedList, monitor);
+ result = viewController.uninstall(installedList, monitor);
}
ErrorController.setInstallationSuccess(result);
- monitor.done();
}
/**
if (ErrorController.checkInstallationSuccess()) {
completePage.setTitle("Uninstallation Completed!");
+ if (!viewController.existRemovablePackage()) {
+ completePage.removeTargetDir();
+ } else {};
+
String msg = "Thank you for using Tizen SDK. ";
- if (!ErrorController.isTargetDirEmpty()) {
- msg = msg
- + "\n\nSome files are not deleted. These can be user configuration. \n";
- if (!viewController.getConfig().getTargetDir().isEmpty()) {
- msg = msg
- + "Please check '"
- + viewController.getConfig().getTargetDir()
- + "' folder.";
- }
- }
+
completePage.setCustomMessage(msg);
} else {
completePage.setTitle("Uninstallation Failed!");
--- /dev/null
+/*
+* InstallManager
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Wooyoung Cho <wooyoung1.cho@samsung.com>
+* Shihyun Kim <shihyun.kim@samsung.com>
+* Taeyoung Son <taeyoung2.son@samsung.com>
+* Yongsung kim <yongsung1.kim@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.installmanager.ui.page;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.SDKExtensionInfo;
+import org.tizen.installmanager.lib.ErrorController;
+import org.tizen.installmanager.lib.IMError;
+import org.tizen.installmanager.lib.Log;
+
+/**
+ * This class displays installable package list on page.
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>
+ */
+public class UpdatableListPage extends PackageListPage {
+
+ static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_002.png";
+ static final String STRING_TITLE = "Update";
+ static final String STRING_SUBTITLE = "Updated components are installed.\n" +
+ "You can select additional components for installation as well.";
+
+ /**
+ * @param parent
+ * @param style
+ */
+ public UpdatableListPage(Composite parent, int style) {
+ super(parent, style, Type.UPDATE);
+ setLeftImageFromResource(RSC_PATH_IMAGE);
+ setTitleBounds(160, 3, 468, 20);
+ setSubTitleBounds(160, 25, 468, 30);
+ setCustomCompositeBounds(160, 60, 468, 334);
+ setTitle(STRING_TITLE);
+ setSubTitle(STRING_SUBTITLE);
+ setSubTitleFont(new FontData("Dejavu Sans", 9, SWT.NONE));
+ tree.setBounds(0, 0, 447, 260);
+ lblRequiredSize.setBounds(250, 265, 210, 23);
+ lblDescriptions.setBounds(0, 265, 124, 17);
+ }
+
+ /**
+ * Display installable package list from view controller.
+ */
+ public boolean loadPage(ViewController controller) {
+ this.viewController = controller;
+ getItems().clear();
+
+ try {
+ loadPackagesToTreeViewer(viewController.getRootMetaPackageListOfRepository());
+
+ SDKExtensionInfo sdkExtensionInfo = SDKExtensionInfo.getInstance();
+ addExtensionPackagesToExtra(sdkExtensionInfo.getExtensionPackages());
+
+ } catch (IMFatalException fatalException) {
+ Log.err(ErrorController.getErrorMessage());
+ IMError.fatalError(ErrorController.getErrorMessage());
+ }
+
+ if (getItems().size() <= 0) {
+ return false;
+ }
+
+ setCheckbox(items);
+
+ checkboxTreeViewer.refresh();
+
+ setNextBtnEnabledAboutCheckedPackageCount();
+ lblRequiredSize.setText("Total space required : " + convertToVolumeSize(getCheckedPackageSize()));
+
+ return true;
+ }
+}
import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMExitException;
+import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.core.Config.ServerType;
import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.IIMProgressMonitor;
import org.tizen.installmanager.lib.Log;
import org.tizen.installmanager.lib.Registry;
import org.tizen.installmanager.lib.ErrorController.ErrorCode;
-import org.tizen.installmanager.pkg.lib.PackageManager2;
-import org.tizen.installmanager.pkg.model.Package2;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.Package;
import org.tizen.installmanager.pkg.model.PackageSet;
import org.tizen.installmanager.ui.page.InstallingPage.InstallProgressMonitor;
import org.tizen.installmanager.util.PathUtil;
*/
public class ViewController {
- private InstallManager mInstallManager;
- private PackageManager2 mPackageManager2;
+ private InstallManager installManager;
+ private PackageManager packageManager;
/**
* Initialize objects which need to install.
*/
public boolean init() {
Log.log("ViewController init");
- mInstallManager = InstallManager.getInstance();
- boolean bResult = mInstallManager.init();
- mPackageManager2 = mInstallManager.getPackageManager2();
-
- bResult = bResult && existInstallableOrRemovablePackages();
-
- return bResult;
+
+ try {
+ installManager = InstallManager.getInstance();
+ installManager.init();
+ packageManager = installManager.getPackageManager();
+
+ if (packageManager == null) {
+ throw new IMFatalException("Cannot read package information.");
+ } else {
+ if (existInstallableOrRemovablePackages()) {
+ return true;
+ } else {
+ ErrorController.setInstallationSuccess(false);
+ return false;
+ }
+ }
+ } catch(IMFatalException e) {
+ Log.ExceptionLog(e);
+ return false;
+ }
}
/**
* @return Meta package set
*/
public PackageSet getInstallableOrUpdatableMetaPackages() {
- if (mPackageManager2 == null) {
+ if (packageManager == null) {
return null;
} else {
- return mPackageManager2.getInstallableOrUpdatableMetaPackages();
+ return packageManager.getInstallableOrUpdatableMetaPackages();
}
}
* @return Meta package set
*/
public PackageSet getInstallableMetaPackageList() {
- if (mPackageManager2 == null) {
+ if (packageManager == null) {
return null;
} else {
- return mPackageManager2.getInstallableMetaPackages();
+ return packageManager.getInstallableMetaPackages();
+ }
+ }
+
+ /**
+ * Get meta packages in repository.
+ * @return Meta package set
+ */
+ public PackageSet getRootMetaPackageListOfRepository() {
+ if (packageManager == null) {
+ return null;
+ } else {
+ return packageManager.getRootMetaPackagesOfRepository();
}
}
* @return Meta package set
*/
public PackageSet getUpdatableMetapackageList() {
- if (mPackageManager2 == null) {
+ if (packageManager == null) {
return null;
} else {
- return mPackageManager2.getUpdatableMetaPackages();
+ return packageManager.getUpdatableMetaPackages();
+ }
+ }
+
+ /**
+ * Get meta packages that are available to update.
+ * @return Meta package set
+ */
+ public PackageSet getNotUpdatableMetapackageList() {
+ if (packageManager == null) {
+ return null;
+ } else {
+ return packageManager.getNotInstallableAndNotUpdatablePackages();
}
}
* @return Meta package set
*/
public PackageSet getRemovableMetaPackageList() {
- if (mPackageManager2 == null) {
+ if (packageManager == null) {
+ return null;
+ } else {
+ return packageManager.getRemovableMetaPackages();
+ }
+ }
+
+ public PackageSet getInstallablePackageListInSnapshot() {
+ if (packageManager == null) {
return null;
} else {
- return mPackageManager2.getRemovableMetaPackages();
+ return packageManager.getInstallableMetaPackagesInSnapshot();
}
}
* @return package set
*/
public PackageSet getRemovablePackageList() {
- return mPackageManager2.getInstalledPackages();
+ if (packageManager == null) {
+ return null;
+ } else {
+ return packageManager.getInstalledPackages();
+ }
}
/**
* @return if installed package exists, return true. if not return false.
*/
public boolean existRemovablePackage() {
- return mPackageManager2.existInstalledPackages();
+ if (packageManager == null) {
+ return false;
+ } else {
+ return packageManager.existInstalledPackages();
+ }
}
/**
Log.log("======== Start Installing ========");
Log.log("ViewController install => Selected package list: " + installList);
- if (mPackageManager2 == null) {
+ if (packageManager == null) {
Log.err("Package list does not exist.");
return false;
}
return true;
}
- PackageSet selectedMetas = mPackageManager2.getPackagesByNames(installList);
+ PackageSet selectedMetas = packageManager.getPackagesByNames(installList);
+
+ //add mandotory packages
+ selectedMetas.addAll(packageManager.getMandatoryPackages());
+
+ //get package set by pusrpose.
+ selectedMetas = getMetaPackagesByPurpose(selectedMetas);
- return mInstallManager.install(selectedMetas, targetPath, monitor);
+ return installManager.install(selectedMetas, targetPath, monitor);
}
+
+ private PackageSet getMetaPackagesByPurpose(PackageSet metaPackages) {
+ for (Package pkg : metaPackages) {
+ String attribute = pkg.getAttribute();
+
+ if (!attribute.equalsIgnoreCase("root") && attribute.equals("extra")) {
+ if (!attribute.equalsIgnoreCase(attribute)) {
+ metaPackages.remove(pkg);
+ }
+ }
+ }
+
+ return metaPackages;
+ }
/**
* Start to uninstall
*/
public boolean uninstall(List<String> uninstallList, IIMProgressMonitor monitor) {
Log.log("ViewController Uninstall Start => " + uninstallList);
- if (mPackageManager2 == null || uninstallList.size() == 0) {
+ if (packageManager == null || uninstallList.size() == 0) {
Log.err("ViewController.uninstall() uninstalllist does not exist. => " + uninstallList);
ErrorController.setError(ErrorCode.ERROR);
return false;
}
- if (uninstallList.size() == 1 && uninstallList.get(0).equals(Config.SDK_NAME)) {
+ if (Options.doRemoveOldSDK || (uninstallList.size() == 1 && uninstallList.get(0).equals(Config.SDK_NAME))) {
uninstallAll(monitor);
+ return true;
+ } else {
+ PackageSet removablePackages = packageManager.getInstalledPackagesByName(uninstallList);
+
+ return uninstallPackages(removablePackages, monitor);
}
-
- PackageSet removablePackages = mPackageManager2.getPackagesByNames(uninstallList);
-
- return uninstallPackages(removablePackages, monitor);
}
/**
* @return If removable packages can success to uninstall, return true. if not return false.
*/
public boolean uninstallPackages(PackageSet removableMetapkgs, IIMProgressMonitor monitor) {
- boolean bRet = mInstallManager.removePackages(removableMetapkgs, monitor);
+ boolean bRet = installManager.removePackages(removableMetapkgs, monitor);
Log.log("ViewController Uninstall End => " + bRet);
return bRet;
*/
public void uninstallAll(IIMProgressMonitor monitor) {
Log.log("ViewController Unintall All");
- mInstallManager.removeAll(monitor);
+ installManager.removeAll(monitor);
Registry.removeRegistry();
}
/**
* Get package version that is installed already.
- * @param pkg is installed packages already.
+ * @param pkgName is installed packages already.
* @return version
*/
- public String getInstalledVersion(Package2 pkg) {
- if (pkg == null) {
- return null;
- }
-
- return mPackageManager2.getInstalledVersion(pkg);
+ public Package getInstalledPackage(String pkgName) {
+ return packageManager.getInstalledPackageByName(pkgName);
}
/**
* @return size
*/
public long getTotalSizeWithDepends(String packageName) {
- Package2 pkg = mPackageManager2.getPackagesByName(packageName);
- return getTotalSizeWithDepends(pkg);
+ Package pkg = packageManager.getPackageByName(packageName);
+ return getInstallablePackagesSize(pkg);
}
/**
* @return size
*/
public long getTotalSizeWithDepends(Collection<String> pkgList) {
- PackageSet pkgSet = mPackageManager2.getPackagesByNames(pkgList);
+ PackageSet pkgSet = packageManager.getPackagesByNames(pkgList);
return getTotalSizeWithDepends(pkgSet);
}
* @param pkg is package format.
* @return size
*/
- public long getTotalSizeWithDepends(Package2 pkg) {
- return mPackageManager2.getTotalSizeWithDepends(pkg);
+ public long getInstallablePackagesSize(Package pkg) {
+ return packageManager.getTotalSizeOfInstallablePackages(pkg);
+ }
+
+ /**
+ * Get total size depends on a package format.
+ * @param pkg is package format.
+ * @return size
+ */
+ public long getRemovablePackagesSize(Package pkg) {
+ return packageManager.getTotalSizeOfRemovablePackages(pkg);
}
/**
* @return size
*/
public long getTotalSizeWithDepends(PackageSet pkgs) {
- return mPackageManager2.getTotalSizeWithDepends(pkgs);
+ return packageManager.getTotalSizeOfInstallablePackages(pkgs);
}
/**
* @return There are packages to install or remove, return true. if not false.
*/
public boolean existInstallableOrUpdatablePackages() {
- return (getInstallableOrUpdatableMetaPackages().size() > 0);
+ if (Options.snapshot || Config.fromWhere == Config.ConfDialog.LOCAL_IMAGE) {
+ return (getInstallablePackageListInSnapshot().size() > 0);
+ } else {
+ return (getInstallableOrUpdatableMetaPackages().size() > 0);
+ }
}
/**
* @return configure object.
*/
public Config getConfig() {
- return mInstallManager.getConfig();
+ return installManager.getConfig();
}
/**
* @return decription of package.
*/
public String getDescription(String pkgName) {
- Package2 pkg = mPackageManager2.getPackagesByName(pkgName);
+ Package pkg = packageManager.getPackageByName(pkgName);
if (pkg == null) {
return "";
public void removeTargetPath(String targetPath) {
PathUtil.remove(targetPath);
}
+
+ /**
+ * save information of server.
+ * @param repository Base-repository of sdk. if repository is null, it do not save repository.
+ * @param type type of repository. if type is null, it do not save type.
+ * @param packageServer package server of sdk. if packageServer is null, it do not save packageServer.
+ * @param packageType set ServerType.snapshot or ServerType.package. if serverType is null, it do not save serverType.
+ */
+ public void saveConfiguration(String repository, String distribution, ServerType packageType, String snapshotPath) {
+ Config.getInstance().saveConfiguration(repository, distribution, packageType, snapshotPath);
+ }
}
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.tizen.installmanager.core.Config;
+import org.tizen.installmanager.core.IMFatalException;
+import org.tizen.installmanager.core.InstallManager;
+import org.tizen.installmanager.core.Options;
+import org.tizen.installmanager.lib.ErrorController;
import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.lib.Registry;
+import org.tizen.installmanager.pkg.lib.PackageManager;
+import org.tizen.installmanager.pkg.model.ConfigFile;
import org.tizen.installmanager.ui.InstallManagerWindow;
import org.tizen.installmanager.ui.dialog.ConfigurationDialog;
-
/**
* This class displays welcome page.
* @author Taeyoung Son <taeyoung2.son@samsung.ncom>
static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_welcome.png";
public static final String STRING_TITLE = "Welcome to Tizen SDK";
public static final String STRING_SUBTITLE = "Tizen SDK will be installed on your computer. " +
- "It is recommended that you close all other applications before starting installation.";
+ "Close all other applications before starting the installation.";
private RADIO_ACTION selectedRadioBtn = RADIO_ACTION.INSTALL;
Button buttonInstall = null;
ViewController viewController = null;
ConfigurationDialog rDialog = null;
-
+
public enum RADIO_ACTION {
INSTALL,
UNINSTALL
* INSTALLED_OLDSDK : There is no compatible old sdk and current sdk<br>
*/
public enum InstalledStatus {
-
INSTALLED_NOTHING,
INSTALLED_SOME_PACKAGES,
INSTALLED_ALL_PACKAGES,
setImageBounds(0, 0, 620, 144);
setTitleBounds(20, 160, 400, 20);
setSubTitleBounds(20, 190, 600, 40);
- setCustomCompositeBounds(0, 220, 620, 150);
+ setCustomCompositeBounds(0, 220, 620, 173);
setLeftImageFromResource(RSC_PATH_IMAGE);
setTitle(STRING_TITLE);
setSubTitle(STRING_SUBTITLE);
private void setButton() {
setInstallButton();
setUninstallButton();
- //setConfigurationButton();
+ setConfigurationButton();
}
private void setInstallButton() {
}
});
buttonInstall.setBounds(26, 40, 500, 15);
- buttonInstall.setText("Install new version of " + Config.SDK_NAME);
+ buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");
buttonInstall.setBackground(InstallManagerWindow.getBackgroundColor());
}
}
});
buttonUninstall.setBounds(26, 85, 500, 22);
- buttonUninstall.setText("Remove " + Config.SDK_NAME);
+ buttonUninstall.setText("Uninstall the " + Config.SDK_NAME);
buttonUninstall.setBackground(InstallManagerWindow.getBackgroundColor());
}
- @SuppressWarnings("unused")
private void setConfigurationButton() {
configurationButton = new Button(customComposite, SWT.PUSH);
- configurationButton.setText("Configuration");
+ configurationButton.setText("Advanced");
configurationButton.setBackground(InstallManagerWindow.getBackgroundColor());
- configurationButton.setBounds(480, 120, 120, 30);
+
+ configurationButton.setBounds(509, 120, 100, 29);
configurationButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rDialog = new ConfigurationDialog(customComposite.getShell());
- String[] repos = viewController.getConfig().getRepositories();
- if (repos != null && repos.length > 0) {
- String fullRepository = "";
- for (String repo : repos) {
- fullRepository += repo + ",";
- }
- fullRepository = fullRepository.substring(0, fullRepository.length()-1);
- rDialog.setRepository(fullRepository);
- }
+ //set information to configuration dialog.
+ ConfigFile confFile = Config.getInstance().getConfigFile();
+ rDialog.setRepository(confFile.getRepository());
+ rDialog.setCurrentDistribution(confFile.getDistribution());
+ rDialog.setSnapshotPath(confFile.getSnapshotPath());
int ret = rDialog.open();
if (ret == 0){
- Config config = viewController.getConfig();
- config.getConfigFile().setRepository(rDialog.getRepository());
- config.saveConfig();
+ viewController.saveConfiguration(rDialog.getRepository(), rDialog.getCurrentDistribution(), rDialog.getServerType(), rDialog.getSnapshotPath());
+ PackageManager.dispose();
InstallManagerWindow.getInstallManagerWindow().refresh();
} else {
Log.log("Configuration dialog is canceled.");
}
+ rDialog.clear();
}
});
}
/**
* Set install status, and set radio button.
* @param status
- * @see InstalledStatus
*/
public void setButtonStatus() {
- if (Registry.isOldSDKInstalled()) {
+ if (Options.doRemoveOldSDK) {
setErrorSubTitle("Old version SDK(Tizen SDK) is installed. " +
- "Tizen SDK can be installed after removing old Tizen SDK.\n Close all running SDK processes before remove.");
+ "Tizen SDK can be installed after removing old Tizen SDK.");
buttonInstall.setSelection(false);
buttonUninstall.setSelection(true);
buttonUninstall.setEnabled(true);
selectedRadioBtn = RADIO_ACTION.UNINSTALL;
+ return;
}
if (viewController == null) {
}
if (!viewController.existRemovablePackage()) {
- buttonInstall.setText("Install new version of " + Config.SDK_NAME);
+ buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");
buttonInstall.setBounds(26, 40, 500, 22);
buttonInstall.setSelection(true);
buttonInstall.setEnabled(true);
buttonUninstall.setEnabled(false);
+
+ selectedRadioBtn = RADIO_ACTION.INSTALL;
+
+ Config.status = Config.Status.INSTALL;
} else if (!viewController.existInstallableOrUpdatablePackages()) {
buttonInstall.setSelection(false);
buttonUninstall.setSelection(true);
buttonUninstall.setEnabled(true);
selectedRadioBtn = RADIO_ACTION.UNINSTALL;
+
+ Config.status = Config.Status.UNINSTALL;
} else {
- buttonInstall.setText("Install or update new version of " + Config.SDK_NAME);
+ buttonInstall.setText("Install or update the " + Config.SDK_NAME);
buttonInstall.setSelection(true);
buttonUninstall.setSelection(false);
buttonInstall.setEnabled(true);
buttonUninstall.setEnabled(true);
+
+ selectedRadioBtn = RADIO_ACTION.INSTALL;
+
+ Config.status = Config.Status.UPDATE;
}
}
* @param controller
*/
public void setViewController(ViewController controller) {
- viewController = controller;
+ if (controller != null) {
+ viewController = controller;
+ } else {
+ Log.err("viewcontroller is null.");
+ ErrorController.setErrorMessage("Cannot initialize controller.");
+ throw new IMFatalException("Can not read package informaion.");
+ }
}
/**
* refresh welcome page.
*/
public void refresh() {
- setButton();
+ InstallManager.getInstance().initPackageList();
+ setButtonStatus();
}
}
private final static String FILE_EXTENSION_SEPERATOR = ".";
private final static String DIRECTORY_SEPERATOR = "/";
+ public final static String URL_SEPERATOR = "/";
private final static int BUF_SIZE = 65536;
/**
Log.log("Copy from " + fromFile + " to " + toFile);
String fromPath = fromFile.getAbsolutePath();
String toPath = toFile.getAbsolutePath();
- String command[] = {"cp", "-rl", fromPath, toPath};
+ String command[] = null;
+
+ command = getCopyShellCommand(fromPath, toPath);
+
try {
ShellUtil.execute(command);
} catch (IMShellCommandFail e) {
return true;
}
+ private static String[] getCopyShellCommand(String fromPath, String toPath) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64) {
+ String command[] = {"cp", "-rl", fromPath, toPath};
+ return command;
+ } else if (Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
+ String command[] = {"cp", "-a", fromPath, toPath};
+ return command;
+ } else {
+ return null;
+ }
+ }
+
//Copy file
/**
* copy file or directory.
if (fInput != null) {
fInput.close();
}
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+
+ try {
if (fOutput != null) {
fOutput.close();
}
*/
public static void writeFileFromInputStream(InputStream is, File to) throws IOException {
Log.log("write file from input stream to : "+to);
+
+ if (is == null) {
+ return;
+ }
if (!to.exists()) {
to.createNewFile();
}
Log.err("Cannot find file "+to);
throw new IMFatalException(ErrorCode.CANNOT_ACCESS_FILE);
} finally {
- if (is != null) {
- is.close();
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
}
- if (os != null) {
- os.close();
+
+ try {
+ if (os != null) {
+ os.close();
+ }
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
}
}
}
* @return <code>true</code> if success
*/
public static boolean remove(File file) {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
return removeForLinux(file);
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
return removeForWindows(file);
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
return filePath.delete() && ret;
}
+ public static File makeNewFile(String filePath) throws IOException{
+ File file = new File(filePath);
+ if (file.exists()) {
+ if (!file.delete()) {
+ return null;
+ }
+ }
+
+ File parentDir = file.getParentFile();
+ if (!parentDir.exists()) {
+ if (!parentDir.mkdirs()) {
+ return null;
+ }
+ }
+
+ if (!file.createNewFile()) {
+ return null;
+ }
+
+ return file;
+ }
+
/**
* Make hidden file.
* @param file
* @return
*/
public static boolean makeHiddenFile(String file) {
- if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ if (Platform.CURRENT_PLATFORM == Platform.WINDOWS_32
+ || Platform.CURRENT_PLATFORM == Platform.WINDOWS_64) {
String[] command = {"c:\\windows\\system32\\attrib.exe",
"+H",
file};
} catch (IMShellCommandFail e) {
return false;
}
- } else if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
+ } else if (Platform.CURRENT_PLATFORM == Platform.LINUX_32
+ || Platform.CURRENT_PLATFORM == Platform.LINUX_64
+ || Platform.CURRENT_PLATFORM == Platform.MACOS_64) {
return true;
} else {
throw new IMFatalException(ErrorCode.UNSUPPORTED_PLATFORM);
}
}
-
+
/**
* Make hidden file.
* @param file
}
/**
+ * @param path_components the path components
+ * @return a path string made by concatenating the path components. empty string if there are no path components.
+ */
+ public static String addURLPath(String... path_components) {
+ if (path_components == null) {
+ return "";
+ }
+
+ String path = "";
+ for(int i = 0; i < path_components.length; i++) {
+ if (path_components[i] == null || path_components[i].isEmpty()) {
+ continue;
+ }
+ if( i == 0 ) {
+ path = path_components[0];
+ } else {
+ path = path + PathUtil.URL_SEPERATOR + path_components[i];
+ }
+ }
+ return path;
+ }
+
+ /**
* @param path_components
* @return a path string made by the path components relative to the home directory
*/
* @return
*/
public static String getLocalAppData() {
- if (Platform.CURRENT_PLATFORM == Platform.LINUX) {
- return "";
- } else if (Platform.CURRENT_PLATFORM == Platform.WINDOWS) {
+ if (Platform.isWindows()) {
return WindowsRegistry.getRegistryValue(
WindowsRegistry.REGISTRY_PATH_OF_SHELL_FOLDER
, WindowsRegistry.REGISTRY_LOCAL_APP_DATA_OF_SHELL_FOLDER);
InputStream is = null;
StringBuffer txt = new StringBuffer();
is = PathUtil.getResourceAsStream(resourcePath);
+ BufferedReader in = null;
+
try {
- BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strLicense;
while((strLicense = in.readLine()) != null) {
txt.append(strLicense);
}
} catch(IOException e) {
throw new IMFatalException("Cannot read resource: "+resourcePath);
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
}
+
return txt.toString();
}
*/
public static String readAllTextFromFile(String filePath) {
StringBuffer txt = new StringBuffer();
+ InputStream is = null;
+ BufferedReader in = null;
try {
- InputStream is = new FileInputStream(filePath);
- BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ is = new FileInputStream(filePath);
+ in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strLicense;
while((strLicense = in.readLine()) != null) {
txt.append(strLicense);
}
} catch(IOException e) {
throw new IMFatalException("Cannot read resource: " + filePath);
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
+
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ Log.ExceptionLog(e);
+ }
}
return txt.toString();
}
public static File getTempFileFromResource(String resourcePath, String prefix, String suffix, boolean deleteOnExit) throws IOException {
File file = File.createTempFile(prefix, suffix);
PathUtil.writeFileFromInputStream(PathUtil.getResourceAsStream(resourcePath), file);
+
if(deleteOnExit) {
file.deleteOnExit();
}
+
return file;
}
throw new IMFatalException("Cannot create file");
}
}
+
+// public static URL addURLPath(URL url, String additionalPath) {
+// return addURLPath(url.toExternalForm(), additionalPath);
+// }
+//
+// public static URL addURLPath(String url, String additionalPath) {
+// if (url == null || url.isEmpty()) {
+// return null;
+// } else {
+// try {
+// return new URL(url + "/" + additionalPath);
+// } catch (MalformedURLException e) {
+// Log.err("Cannot add url path." + url + " + " + additionalPath);
+// return null;
+// }
+// }
+// }
}
return null;
}
}
+
+ /**
+ * Add interpreter from extension.
+ * If extension is ".vbs", add "wscript.exe " in front of command
+ * If extensino is ".bat", add "cmd.exe /C " in front of command
+ * @param command
+ * @return combined command of interpreter.
+ */
+ public static String addInterpreter(String command) {
+ String extension = PathUtil.getFileExtension(command);
+
+ if (extension.equalsIgnoreCase(".vbs")) {
+ command = "wscript.exe " + command;
+ } else if (extension.equalsIgnoreCase(".bat")) {
+ command = "cmd.exe /C " + command;
+ } else {}
+
+ return command;
+ }
}
SHORTCUT_DIR_PATH=${HOME}/.local/share
MENU_DIRECTORY_PATH=${SHORTCUT_DIR_PATH}/desktop-directories
MENU_FILE_PATH=${MENU_DIRECTORY_PATH}/tizen-sdk-menu.directory
-MENU_ICON_FILE_PATH=${INSTALLED_PATH}/InstallManager/tizen-sdk-menu.png
+MENU_ICON_FILE_PATH=${INSTALLED_PATH}/install-manager/tizen-sdk-menu.png
MENU_NAME="Tizen SDK"
MENU_COMMENT="Tizen SDK"
MENU_VERSION=1.0
+PARTNER=${PARTNER_SDK}
##if not exist 'desktop-directories' directory
if [ ! -e ${MENU_DIRECTORY_PATH} ]; then
APPLICATION_DIR_PATH=${SHORTCUT_DIR_PATH}/applications
DESKTOP_FILE_PATH=${APPLICATION_DIR_PATH}/tizen-sdk-installmanager.desktop
-DESKTOP_EXECUTE_FILE_PATH=${INSTALLED_PATH}/InstallManager/InstallManager
-DESKTOP_ICON_FILE_PATH=${INSTALLED_PATH}/InstallManager/tizen-sdk-installmanager.png
+if [ -n "${PARTNER}" ] ; then
+ DESKTOP_EXECUTE_FILE_PATH=${INSTALLED_PATH}/install-manager/InstallManagerP
+else
+ DESKTOP_EXECUTE_FILE_PATH=${INSTALLED_PATH}/install-manager/InstallManager
+fi
+DESKTOP_ICON_FILE_PATH=${INSTALLED_PATH}/install-manager/tizen-sdk-installmanager.png
DESKTOP_NAME="Install Manager"
DESKTOP_COMMENT="Install Manager for Tizen SDK"
Set WshEnv = wshShell.Environment("Process")\r
installedPath = WshEnv("INSTALLED_PATH")\r
makeShortcutPath = WshEnv("MAKESHORTCUT_PATH")\r
-targetPath = installedPath & "\InstallManager\InstManager.exe"\r
-iconPath = installedPath & "\InstallManager\tizen-sdk-installmanager.ico"\r
+partner = WshEnv("PARTNER_SDK")\r
+targetPath = installedPath & "\install-manager\InstManager.exe"\r
+iconPath = installedPath & "\install-manager\tizen-sdk-installmanager.ico"\r
shortcutName = "Install Manager"\r
-wshShell.Run "wscript.exe " & chr(34) & makeShortcutPath & chr(34) & " /target:" & chr(34) & targetPath & chr(34) & " /icon:" & chr(34) & iconPath & chr(34) & " /shortcut:" & chr(34) & shortcutName & chr(34)\r
+\r
+if (partner="") then\r
+ wshShell.Run "wscript.exe " & chr(34) & makeShortcutPath & chr(34) & " /target:" & chr(34) & targetPath & chr(34) & " /icon:" & chr(34) & iconPath & chr(34) & " /shortcut:" & chr(34) & shortcutName & chr(34)\r
+else\r
+ wshShell.Run "wscript.exe " & chr(34) & makeShortcutPath & chr(34) & " /target:" & chr(34) & targetPath & chr(34) & " /icon:" & chr(34) & iconPath & chr(34) & " /shortcut:" & chr(34) & shortcutName & chr(34) & " /partnerSdk:" &chr(34) & partner &chr(34)\r
+end if\r
+\r
\r
\r
set filesys = CreateObject("Scripting.FileSystemObject")\r
filename = Wscript.Arguments.Named("target")\r
+partner = Wscript.Arguments.Named("partnerSdk")\r
set oShellLink = WshShell.CreateShortcut(linkFilePath)\r
oShellLink.TargetPath = filename\r
oShellLink.IconLocation = Wscript.Arguments.Named("icon")\r
oShellLink.WorkingDirectory = filesys.GetParentFolderName(filename)\r
oShellLink.WindowStyle = 1\r
-oShellLink.Save\r
+if (partner="") then\r
+ oShellLink.Save\r
+else\r
+ oShellLink.Arguments = "-partner"\r
+ oShellLink.Save\r
+end if\r
##remove menu directory
MENU_DIRECTORY_PATH=${HOME}/.local/share/desktop-directories/tizen-sdk-menu.directory
-xdg-desktop-menu uninstall ${MENU_DIRECTORY_PATH} *.desktop
+rm ${MENU_DIRECTORY_PATH}
##remove icon file
IM_ICON_FILE_PATH=${INSTALLED_PATH}/InstallManager/tizen-sdk-installmanager.png
if [ -e InstallManager.jar ]
then
java -jar InstallManager.jar $@
-elif [ -e $HOME/.TizenSDK/tizensdkpath ]
+elif [ -e $HOME/tizen-sdk-data/tizensdkpath ]
then
- tizenpath=`grep TIZEN_SDK_INSTALLED_PATH $HOME/.TizenSDK/tizensdkpath`
+ tizenpath=`grep TIZEN_SDK_INSTALLED_PATH $HOME/tizen-sdk-data/tizensdkpath`
SDK_PATH=`echo $tizenpath | cut -f2 -d"="`
if [ "x$SDK_PATH" != "x" ]
then
- cd $SDK_PATH/InstallManager
+ cd $SDK_PATH/install-manager
if [ -e InstallManager.jar ]
then
java -jar InstallManager.jar $@
--- /dev/null
+#/bin/bash
+current_path=`pwd`
+
+if [ -e InstallManager.jar ]
+then
+ java -jar InstallManager.jar -partner
+elif [ -e $HOME/tizen-sdk-data/tizensdkpath ]
+then
+ tizenpath=`grep TIZEN_SDK_INSTALLED_PATH $HOME/tizen-sdk-data/tizensdkpath`
+ SDK_PATH=`echo $tizenpath | cut -f2 -d"="`
+ if [ "x$SDK_PATH" != "x" ]
+ then
+ cd $SDK_PATH/install-manager
+ if [ -e InstallManager.jar ]
+ then
+ java -jar InstallManager.jar -partner
+ fi
+ fi
+fi
+
+exit 0
+
#### Init Environment Variables ####
CUR_DIR=`pwd`
-OUT_PATH="/tmp/tizensdk"
+#OUT_PATH="/tmp/tizensdk"
+OUT_PATH="${HOME}/tizen-sdk-data/install-manager"
# list for pre installation check. Write including 'space'
-INSTALLATION_CHECK="qemu-kvm binutils-multiarch debhelper fakeroot realpath procps libsdl-gfx1.2-4 gettext liblua5.1-0 libdbus-1-3 libcurl3"
+INSTALLATION_CHECK="procps gettext libdbus-1-3 libcurl3 expect gtk2-engines-pixbuf grep zip make libgnome2-0"
pkg_list=""
+# ubuntu version 10.x and 32bit
+if [ "10.04" = ${OS_VERSION} ] || [ "10.10" = ${OS_VERSION} ]; then
+ INSTALLATION_CHECK="$INSTALLATION_CHECK qemu-arm-static"
+elif [ "11.04" = ${OS_VERSION} ] || [ "11.10" = ${OS_VERSION} ]; then
+ INSTALLATION_CHECK="$INSTALLATION_CHECK qemu-user-static"
+fi
+
+# 64bit ubuntu case
+if [ 64 -eq ${OS_BIT} ] ; then
+ INSTALLATION_CHECK="$INSTALLATION_CHECK ia32-libs"
+fi
+
NVIDIA_CHECK=`lspci | grep nVidia`
MESA_CHECK=`dpkg -l | egrep -e libgl1-mesa-glx' '`
####################################
-echo "$CX=== Preparing to install ===$CN"
-
## check the available space ##
if [ $AVAIL_SPACE -lt 5452596 ]; then
echo "${CE} Available blocks: $AVAIL_SPACE($OS_BLOCKSIZE) Needed blocks: about 5.2GB "
exit 1
fi
-## check the kernel bit ##
-if [ "${OS_BIT}" != 32 ] ; then
- echo "${CE}Tizen SDK doesn't support 64bits environment yet.${CN}"
+## check the default java as OpenJDK ##
+CHECK_OPENJDK=`java -version 2>&1 | egrep -e OpenJDK`
+if [ -n "${CHECK_OPENJDK}" ] ; then
+ echo "${CE} OpenJDK is not supported. Try again with Oracle JDK. ${CN}"
exit 1
fi
fi
## check the pre installation packages ##
-for INPUT_PKG_MANE in ${INSTALLATION_CHECK}
+for INPUT_PKG_NAME in ${INSTALLATION_CHECK}
do
- CHECK_FLAG=`dpkg -l | egrep -e ${INPUT_PKG_MANE}' '`
- if [ -z "$CHECK_FLAG" ] ; then
- pkg_list="${pkg_list}\"${INPUT_PKG_MANE}\" "
+ CHECK_FLAG=`dpkg -l ${INPUT_PKG_NAME} 2>/dev/null | grep -e "^ii"`
+ if [ -z "${CHECK_FLAG}" ] ; then
+ pkg_list="${pkg_list}\"${INPUT_PKG_NAME}\" "
fi
done
if [ -n "$pkg_list" ] ; then
exit 1
fi
-echo -n "$CI Unpacking ....... $CN"
-mkdir -p $OUT_PATH
-cd $CUR_DIR
-tail -n +"$ORI_FILE_LEN" "$0" | tee >(md5sum>$OUT_PATH/checksum) | tar xmz -C $OUT_PATH/
-echo "$CI OK $CN"
+mkdir -p ${OUT_PATH}
+cd ${CUR_DIR}
+tail -n +"${ORI_FILE_LEN}" "$0" | tee >(md5sum>${OUT_PATH}/checksum) | tar xmz -C ${OUT_PATH}/
-echo -n "$CI Checksumming ....... $CN"
OUT_FILE_md5sum=`cat "$OUT_PATH/checksum" | awk '{ print $1 }'`
-if [ "$OUT_FILE_md5sum" != "$ORI_FILE_md5sum" ]; then
- echo "$CI Fail $CN"
+if [ "${OUT_FILE_md5sum}" != "${ORI_FILE_md5sum}" ]; then
echo "$CE The download file appears to be corrupted. "
echo " Please do not attempt to install this archive file. $CN"
- echo "$CX============================$CN"
- rm -rf $OUT_PATH
+ rm -rf ${OUT_PATH}
exit 1
fi
-echo "$CI OK $CN"
+##Excute InstallManager
cd $OUT_PATH
./InstallManager $*
-if [ 0 != $? ]; then
- echo "$CI Installing ....... Fail $CN"
-else
- echo "$CI Installing ....... OK $CN"
-fi
-
-echo "$CX Done. $CN"
-echo "$CX============================$CN"
##source bashrc
source ${HOME}/.bashrc
--- /dev/null
+#!/bin/sh
+
+if [ ! -f installmanager.conf ]
+then
+ echo "installmanager.conf file do not exist."
+ exit 1
+fi
+
+if [ $# -ne 1 ]
+then
+ echo "Check your parameter. This script need 1 parameter(binary file name) "
+ echo "ex)./makeImageLinux ImageForUbuntu"
+ exit 1
+fi
+
+##download packages to './binary/*'
+./InstallManager -onlyDownload all linux
+
+mv installmanager.conf installmanager.conf.temp
+echo ${version} >> installmanager.conf
+
+currentDate=`date '+%Y%m%d%H%M'`
+
+zip -r $1_${currentDate} binary/ pkg_list_linux
+
+echo "exitcode="$?
+
+rm installmanager.conf pkg_list_linux
+
+if [ $? -eq 0 ]
+then
+ rm -rf binary
+fi
+
+mv installmanager.conf.temp installmanager.conf
+
--- /dev/null
+#!/bin/sh
+
+if [ ! -f installmanager.conf ]
+then
+ echo "installmanager.conf file do not exist."
+ exit 1
+fi
+
+if [ $# -ne 1 ]
+then
+ echo "Check your parameter. This script need 1 parameter(binary file name) "
+ echo "ex)./makeImageWindows ImageForWindows"
+ exit 1
+fi
+
+##download packages to './binary/*'
+./InstallManager -onlyDownload all windows
+
+mv installmanager.conf installmanager.conf.temp
+echo ${version} >> installmanager.conf
+
+currentDate=`date '+%Y%m%d%H%M'`
+
+zip -r $1_${currentDate} binary/ pkg_list_windows
+
+echo "exitcode="$?
+
+rm installmanager.conf pkg_list_windows
+
+if [ $? -eq 0 ]
+then
+ rm -rf binary
+fi
+
+mv installmanager.conf.temp installmanager.conf
+
-#!/bin/sh
+#!/bin/sh
-#local config file
-cp installmanager.conf.net installmanager.conf
+if [ ! -f installmanager.conf ]
+then
+ echo "installmanager.conf file do not exist."
+ exit 1
+fi
-#download packages to './binary/*'
+if [ $# -ne 1 ]
+then
+ echo "Check your parameter. This script need 1 parameter(binary file name) "
+ echo "ex)./makeLocal tizen_sdk_local"
+ exit 1
+fi
+
+##download packages to './binary/*'
./InstallManager -onlyDownload all
-rm installmanager.conf
-cp installmanager.conf.local installmanager.conf
+##create local config file
+version=`grep "Version" installmanager.conf`
+
+mv installmanager.conf installmanager.conf.temp
+echo ${version} >> installmanager.conf
tar cvfz InstallManager-Local.tar.gz binary/ InstallManager InstallManager.jar installmanager.conf pkg_list_linux
fi
currentDate=`date '+%Y%m%d%H%M'`
-binFile=tizen_sdk_${currentDate}.bin
+binFile=$1_${currentDate}.bin
./makeInstaller InstallManager-Local.tar.gz ${binFile}
rm -rf InstallManager-Local.tar.gz
+mv installmanager.conf.temp installmanager.conf
+
#!/bin/sh
-#local config file
-cp installmanager.conf.net installmanager.conf
-
+if [ ! -f installmanager.conf ]
+then
+ echo "installmanager.conf file do not exist."
+ exit 1
+fi
+
+if [ $# -ne 1 ]
+then
+ echo "Check your parameter. This scrpt need 1 parameter.(binary file name) "
+ echo "ex)./makeNetwork tizen_sdk_network"
+ exit 1
+fi
+
+##zip files
tarGzFile=InstallManager-Network.tar.gz
-tar cvfz ${tarGzFile} InstallManager InstallManager.jar installmanager.conf
-
-rm installmanager.conf
+tar cvfz ${tarGzFile} InstallManager InstallManagerP InstallManager.jar installmanager.conf
+## make binary
currentDate=`date '+%Y%m%d%H%M'`
-binFile=tizen_sdk_${currentDate}.bin
+binFile=$1_${currentDate}.bin
./makeInstaller InstallManager-Network.tar.gz ${binFile}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>InstallManagerUpdater</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Fri Nov 11 13:51:11 KST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+++ /dev/null
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@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.installmanager.updater;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class InstallManagerUpdater {
- private static PrintWriter writer;
-
- private static void initWriter() {
- try {
- writer = new PrintWriter(new File(System.getProperty("user.dir") +
- File.separator +"updater.log"));
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- public boolean moveFile(String from, String to) {
- return moveFile(new File(from), new File(to));
- }
-
- public boolean moveFile(File from, File to) {
- writer.println("Move " + from + " to " + to);
- if (!from.exists()) {
- writer.println("File not found: "+from);
- return false;
- } else {} //nothing
-
- if (to.exists()) {
- writer.println("File exists. try to delete : "+to);
- if(to.delete()) {
- writer.println("deleted");
- } else {
- writer.println("delete fail");
- return false;
- }
- } else {}
-
- return from.renameTo(to);
- }
-
- /**
- * Moves new IM to old IM and run the IM.
- * @param args args[0] is path of new IM. args[1] is path of old IM.
- */
- public static void main(String[] args) {
- initWriter();
-
- if (args.length < 2) {
- return;
- }
-
- try {
- writer.println("sleep 3000");
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- String[] imargs = new String[args.length-2];
- for(int i = 0; i < args.length-2; i++) {
- imargs[i] = args[i+2];
- }
-
- InstallManagerUpdater upInstallManager = new InstallManagerUpdater();
- upInstallManager.update(args[0], args[1], imargs);
- }
-
- private void update(String newIM, String oldIM, String[] imargs) {
- boolean bResult = moveFile(newIM, oldIM);
- String imarg = "";
- for(String a : imargs) {
- imarg = imarg + " " + a;
- }
-
- if (bResult){
- writer.println("move success");
- try {
- File toFile = new File(oldIM);
- toFile.setExecutable(true);
- writer.println("run IM");
- Runtime.getRuntime().exec("java -jar " + toFile.getAbsolutePath() + " -updated " + imarg);
- } catch (IOException e) {
- writer.println("run failed");
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else {
- writer.println("move failed");
- }
- writer.close();
- }
-
-}
+++ /dev/null
-#!/bin/bash -ex
-
-clean()
-{
- rm -rf $SRCDIR/*.zip
- rm -rf $SRCDIR/*.tar.gz
- rm -rf $SRCDIR/InstallManager_java/dist
-}
-
-build()
-{
- version="`cat $SRCDIR/package/pkginfo.manifest | grep "Version:" | head -n 1 | cut -d ':' -f2- | tr -d ' '`"
- $SRCDIR/build.sh $version
-}
-
-install()
-{
- BINDIR=$SRCDIR/package/install-manager.package.$BUILD_TARGET_OS/data
- mkdir -p $BINDIR
- if [ "$BUILD_TARGET_OS" = "linux" ]
- then
- cp -r $SRCDIR/InstallManager_java/dist/linux/InstallManager.jar $BINDIR
- cp -r $SRCDIR/InstallManager_java/src/res/desktop_directory/tizen-sdk-installmanager.png $BINDIR
- cp -r $SRCDIR/InstallManager_java/src/res/desktop_directory/tizen-sdk-menu.png $BINDIR
- cp -r $SRCDIR/InstallManager_java/InstallManager $BINDIR
- cp -r $SRCDIR/InstallManager_java/installmanager.conf.net.linux $BINDIR/installmanager.conf
- else
- cp -r $SRCDIR/InstallManager_java/dist/windows/InstallManager.jar $BINDIR
- cp -r $SRCDIR/InstallManager_java/src/res/desktop_directory/tizen-sdk-installmanager.ico $BINDIR
- cp -r $SRCDIR/InstallManager_java/src/res/desktop_directory/tizen-sdk-menu.ico $BINDIR
- cp -r $SRCDIR/InstallManager_java/installmanager.conf.net.win $BINDIR/installmanager.conf
- fi
-}
-
-$1
-echo "$1 success"
+++ /dev/null
-Package: install-manager
-Version: 1.20.0
-OS: linux
-Build-host-os: linux
-Maintainer: Shihyun Kim<shihyun.kim@samsung.com>, Yongsung Kim<yongsung1.kim@samsung.com>
-Source: install-manager
-Description: InstallManager
-
-Package: install-manager
-Version: 1.20.0
-OS: windows
-Build-host-os: linux
-Maintainer: Shihyun Kim<shihyun.kim@samsung.com>, Yongsung Kim<yongsung1.kim@samsung.com>
-Source: install-manager
-Description: InstallManager
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>unittest</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Nov 30 17:51:35 KST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+++ /dev/null
-package com.samsung.installmanager.tests;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import org.junit.Test;
-
-import com.samsung.installmanager.pkg.lib.PackageManager2;
-import com.samsung.installmanager.pkg.lib.PropertyParser;
-import com.samsung.installmanager.pkg.model.Package2;
-import com.samsung.installmanager.pkg.model.PackageSet;
-import com.samsung.installmanager.pkg.model.PropertySection;
-import com.samsung.installmanager.util.PathUtil;
-
-public class InstallManagerTest {
-
- private List<PropertySection> parse(String resource) {
- File file;
- try {
- file = PathUtil.getTempFileFromResource(resource, "test", ".list");
- PropertyParser parser = new PropertyParser();
- List<PropertySection> propertySections = parser.readFromFile(file);
- return propertySections;
- } catch (IOException e) {
- fail();
- }
- return null;
- }
-
- @Test
- public void testPackageManager() {
- List<PropertySection> installed = parse("/com/samsung/installmanager/tests/installedpackage.list");
- List<PropertySection> repo = parse("/com/samsung/installmanager/tests/Packages_repo.list");
- HashMap<String,List<PropertySection>> repoMap = new HashMap<String,List<PropertySection>>();
- repoMap.put("http://some.where/", repo);
- PackageManager2 pm = new PackageManager2(installed, repoMap);
- PackageSet recent = pm.getRecentPackages();
- //check depends
- for(Package2 p : recent) {
- pm.dep(p);
- }
- //check conflicts
- for(Package2 p : recent) {
- pm.conflict(p);
- }
- System.out.println(recent);
- System.out.println(pm.getUpdatableInstalledPackages());
- System.out.println(pm.getInstalledMetaPackages());
- System.out.println(pm.getAllMetaPackages());
- System.out.println(pm.getNotUpdatableMetaPackages());
- System.out.println(pm.getUpdatableMetaPackages());
- LinkedList<String> Msel = new LinkedList<String>();
- Msel.add("EMULATOR");
- System.out.println(pm.getResultPackagesAfterUpdate(pm.getPackagesByNames(Msel)));
- }
-
-}
+++ /dev/null
-Package : toolchain-gcc-4.5.3
-Version : 0.16.6
-Maintainer : ha taejun <taejun.ha>
-Description : gnu tool chain for SLP SDK
-Depends : slp-base-toolchain, i386-linux-gnueabi-gcc-4.5.3, i386-linux-gnueabi-gdb-7.2, arm-linux-gnueabi-gcc-4.5.3, arm-linux-gnueabi-gdb-7.2
-Category : SDK/build-system/toolchains
-Size: 5068
-Path: /toolchain-gcc-4.5.3_0.16.6_windows.zip
-SHA256: bd77070bb6f2ba35d27929084cc4738c04bd07a89a9ad2826812a22e947fd9aa
-
-Package : GUIBuilder
-Version : 0.3.6
-Maintainer : Changhun Lim <changhun.lim@samsung.com>, Hyunjun Son <hj79.son@samsung.com>
-Description : GUIBuilder
-Category : GUIBuilder
-Depends :
-Install-script : install.sh
-Remove-script : remove.sh
-Size: 7662078
-Path: /GUIBuilder_0.3.6_windows.zip
-SHA256: 63b2264b369f27d4c9d6e553587a67d921b151e87a3ed9cdde2917e6d658dcc0
-
-Package:slp-ide
-Version:1.16.245
-Maintainer:hoon Kang <h245.kang@samsung.com>, taeyoung Son, sihyun Kim
-Description:Samsung Liux Platform IDE
-Category:IDE/SLP IDE/Workbench
-Install-script:install.bat
-Remove-script:remove.bat
-Size: 112081040
-Path: /slp-ide_1.16.245_windows.zip
-SHA256: 93512e98eab1fdbfdf57a86964b201d68a54a57816e131b94db56d5d4e394237
-
-Package : arm-linux-gnueabi-gdb-7.2
-Version : 0.10.0
-Maintainer : ha taejun <taejun.ha>
-Description : gnu debug tool 7.2 for SLP SDK
-Depends :
-Category : SDK/build-system/toolchains
-Size: 10639372
-Path: /arm-linux-gnueabi-gdb-7.2_0.10.0_windows.zip
-SHA256: f797baa924170c6dd66aa0cf52d56313e65749998c8ea61de22a79ce06482e64
-
-Package : smart-build-interface
-Version : 0.13.0
-Maintainer : taejun ha<taejun.ha>
-Description : smart build interface for SLP SDK
-Depends :
-Category : SDK/build-system/base
-Size: 1688171
-Path: /smart-build-interface_0.13.0_windows.zip
-SHA256: 093808411cdd0cb8dccac4bbfc84ada7392c4630052df0b4b50f856ac014a539
-
-Package: slp-emulator-image
-Version: 1.1.91
-Maintainer: Yeong-Kyoon, Lee <yeongkyoon.lee@samsung.com> Dong-Kyun, Yun <dk77.yun@samsung.com>
-Description: Samsung Linux Platform Emulator Image
-Remove-script: remove.bat
-Category: SDK/Emulator
-Size: 221298348
-Path: /emulator-image_1.1.91_windows.zip
-SHA256: f3a480a88ec2ce628d7530e11bfa6697d719fe521ad99874c4c2ad5f43b15387
-
-Package : rootstrap-slp-emulator-1.0
-Version : 0.14.162
-Maintainer : hyoun jiil <jiil.hyoun@samsung.com>
-Description : i386 rootstrap for SLP SDK
-Depends :
-Category : SDK/build-system/rootstraps
-Size: 160261762
-Path: /rootstrap-slp-emulator-1.0_0.14.162_windows.zip
-SHA256: 1acea77cc051ef3d7e1439396979a11ea3d614d054bf0e24e014b378788f28eb
-
-Package : arm-linux-gnueabi-gcc-4.5.3
-Version : 0.10.0
-Maintainer : ha taejun <taejun.ha>
-Description : gnu compiler 4.5.3 for SLP SDK
-Depends :
-Category : SDK/build-system/toolchains
-Size: 114253719
-Path: /arm-linux-gnueabi-gcc-4.5.3_0.10.0_windows.zip
-SHA256: 0f48917ba380137de02415dcece5b816f6ed77f1fe8f8a6153591a7db7d871ce
-
-Package : slp-base-toolchain
-Version : 0.16.2
-Maintainer : ha taejun <taejun.ha>
-Description : base tool chain for SLP SDK
-Depends :
-Install-script:install.bat
-Category : SDK/build-system/toolchains
-Size: 289526856
-Path: /base-toolchain_0.16.2_windows.zip
-SHA256: befcef30c59b6c046c7c8318652140474401b98e0e31a0b43c15723236d4b929
-
-Package : NATIVE_IDE
-Version : 0.16.71
-Maintainer : JongHwan Park <jonghwan2.park@samsung.com>
-Depends : CodeCoverage, rootstrap-slp-device-1.0, arm-linux-gnueabi-gdb-7.2, Profiler, smart-build-interface, UnitTest, arm-linux-gnueabi-gcc-4.5.3, i386-linux-gnueabi-gcc-4.5.3, info, toolchain-gcc-4.5.3, EventInjector, rootstrap-slp-emulator-1.0, slp-base-toolchain, document, i386-linux-gnueabi-gdb-7.2, slp-ide, sdb, GUIBuilder, GUIBuilderPlugins, Efl
-Description : Install NATIVE IDE.
-Attribute : root
-Category : /
-Size: 633
-Path: /NATIVE_IDE_0.16.71_windows.zip
-SHA256: 226a848d5865d40b1175aaee4445e33b0c24b779ae0d390d8cf27af984f61586
-
-Package : i386-linux-gnueabi-gcc-4.5.3
-Version : 0.10.0
-Maintainer : ha taejun <taejun.ha>
-Description : gnu compiler 4.5.3 for SLP SDK
-Depends :
-Category : SDK/build-system/toolchains
-Size: 120422681
-Path: /i386-linux-gnueabi-gcc-4.5.3_0.10.0_windows.zip
-SHA256: ba9601d18a228e83ae8df97adc1007176f65326cbe7dcc40fd4de11312270830
-
-Package : Efl
-Version : 0.3.35
-Maintainer : Changhun Lim <changhun.lim@samsung.com>
-Description : Efl
-Category : Efl
-Depends :
-Size: 46924949
-Path: /Efl_0.3.35_windows.zip
-SHA256: 8e55b402087e192d32942fdab21c91c2e020dfb74f714821ff03b08981b6f739
-
-Package : rootstrap-slp-device-1.0
-Version : 0.14.162
-Maintainer : hyoun jiil <jiil.hyoun@samsung.com>
-Description : arm rootstrap for SLP SDK
-Depends :
-Category : SDK/build-system/rootstraps
-Size: 209315907
-Path: /rootstrap-slp-device-1.0_0.14.162_windows.zip
-SHA256: ff800d4b70153f110383e6842ea9b44fb9e9562e25878342701c549dcf7b077e
-
-Package:sdb
-Version:0.1.35
-Maintainer:Hoon Kang <h245.kang@samsung.com>, Joogwan Kim
-Description:Smart Development Bridge for device management
-Remove-script:remove.bat
-Size: 146872
-Path: /sdb_0.1.35_windows.zip
-SHA256: 1dffb8554c1a15682313dec96039bc1f3eb2177ed276ec1f15061583987217f4
-
-Package : EMULATOR
-Version : 0.16.71
-Maintainer : JongHwan Park <jonghwan2.park@samsung.com>
-Depends : slp-emulator, slp-emulator-image
-Description : Install EMULATOR.
-Attribute : root
-Category : /
-Size: 476
-Path: /EMULATOR_0.16.71_windows.zip
-SHA256: 598e026e437b75837a68f96d5b69d9bada060387ed96a7fc937a70fc5c972d64
-
-Package: slp-emulator
-Version: 1.1.221
-Maintainer: Yeong-Kyoon, Lee <yeongkyoon.lee@samsung.com> Dong-Kyun, Yun <dk77.yun@samsung.com>
-Description: Samsung Linux Platform Emulator
-Install-script: install.bat
-Remove-script: remove.bat
-Category: SDK/Emulator
-Size: 27050568
-Path: /emulator_1.1.221_windows.zip
-SHA256: b35a229ca04ab7b96b733939388dbe2f0a2b4ffc3f63cf4c20f890f7a88a5831
-
-Package : info
-Version : 1.0.224
-Maintainer : JongHwan Park<jonghwan2.park@samsung.com>
-Description : information document for sdk-slp
-Category : SDK
-Size: 42649
-Path: /info_1.0.224_windows.zip
-SHA256: f5c91a5a05f59b0dd03e1a3cfb3022b48ca4146295b09e8b43947b595ee69a32
-
-Package:EventInjector
-Version:1.1
-Architecture:i386
-Maintainer:juyung Kim <j0.kim@samsung.com>, jaewon lim <jaewon81.lim@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
-Description:EventInjector for emulator
-Install-script:
-Remove-script:
-Category:IDE/SLP IDE/Plugins/EventInjector
-Depends:
-Size: 223135
-Path: /eventinjector_1.1.254_windows.zip
-SHA256: 991e094481ce3ef285c0e0a88c3ac0ae882ce778efb2191d9b7c722d39413d92
-
-Package : WAC_IDE
-Version : 0.16.71
-Maintainer : JongHwan Park <jonghwan2.park@samsung.com>
-Depends : wac-ide, EventInjector_Wac, info, sdb
-Description : Install WAC IDE.
-Attribute : root
-Category : /
-Size: 487
-Path: /WAC_IDE_0.16.71_windows.zip
-SHA256: 62f972aef511cf72145823ad8d44b86e7ec5c7490056159ba18e0e72e28b947b
-
-Package:EventInjector_Wac
-Version:1.1
-Architecture:i386
-Maintainer:juyung Kim <j0.kim@samsung.com>, jaewon lim <jaewon81.lim@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
-Description:EventInjector for emulator
-Install-script:
-Remove-script:
-Category:IDE/WAC IDE/Plugins/EventInjector
-Size: 223133
-Path: /eventinjector_wac_1.1.254_windows.zip
-SHA256: 60ff7fa5da778f4997a361a500dc7488c883e7dc529dd559a91efd9674a97499
-
-Package : wac-ide
-Version : 1.16.221
-Maintainer : kangho kim <kh5325.kim@samsung.com> jihoon song<jihoon80.song@samsung.com>
-Description : Samsung Linux Platform WAC IDE
-Category : IDE/WAC IDE/Workbench
-Install-script : install.bat
-Remove-script : remove.bat
-Size: 181060397
-Path: /wac-ide_0.16.221_windows.zip
-SHA256: 3d4169b08a067bb0ffa582a2f96b05e3784249d6a3de4f0ba278952da33ffcec
-
-Package: document
-Version: 1.2.147
-Architecture: i386
-Maintainer: Shingil Kang <shingil.kang@samsung.com>
-Description: Samsung API Document. Provides API document for Samsung SDK developers.
-Category: SDK/Documents
-Size: 27098678
-Path: /document_1.2.147_windows.zip
-SHA256: a2936d618bf6f92e4c68f566c7817920575bb416fec35db3f8f39ec3b1d58001
-
-Package : i386-linux-gnueabi-gdb-7.2
-Version : 0.10.0
-Maintainer : ha taejun <taejun.ha>
-Description : gnu debugger 7.2 for SLP SDK
-Depends :
-Category : SDK/build-system/toolchains
-Size: 8984057
-Path: /i386-linux-gnueabi-gdb-7.2_0.10.0_windows.zip
-SHA256: e6a836794e7697e5d4bf16591b3b08e1b6b434ac9100fd0303538224a63ab260
-
-Package:UnitTest
-Version:1.16.246
-Maintainer:jooyoung Kim <j0.kim@samsung.com>, sanghyun Lee, gun Kim
-Description:Unit test for SLP IDE
-Category:IDE/SLP IDE/Plugins/UnitTest
-Depends:
-Size: 2085403
-Path: /UnitTest_1.16.246_windows.zip
-SHA256: 8176c23c1885cfb1e464030f6bbb0bd8daaf2e1bbd805bd97b49ab05f8660592
-
-Package: Profiler
-Version: 1.0
-Architecture: i386
-Maintainer: Jaewon Lim <jaewon81.lim@samsung.com>, Juyoung Kim
-Description: Samsung Linux Platform IDE
-Category: IDE/SLP IDE/Plugins/Dynamic analysis
-Size: 43006227
-Path: /profiler_1.0.247_windows.zip
-SHA256: d35b8bf41bfe9f3a4662a9e4c184c64d033fc55de97a2108432c0fc94ed84008
-
-Package:CodeCoverage
-Version:1.0
-Maintainer:juyung Kim <j0.kim@samsung.com>, jeonghwan Kim <jeonghwan0613.kim@samsung.com>
-Description:CodeCoverage
-Category:IDE/SLP IDE/Plugins/CodeCoverage
-Depends:
-Size: 326181
-Path: /CodeCoverage_1.0.258_windows.zip
-SHA256: 86e47fc38a1cae8011ab2872db0ac7f772354cb4307c00e28cdb46636ad27a07
-
-Package:GUIBuilderPlugins
-Version:0.3.294
-Maintainer: Changhun Lim <changhun.lim@samsung.com>, Hyunjun Son <hj79.son@samsung.com>, Jaeyeol Lee <jaeyeol148.lee@samsung.com>, Yonghwan Jeon <yonghwan82.jeon@samsung.com>
-Description: GUI Builder PlugIns
-Category: IDE/SLP IDE/Plugins/GUIBuilderPlugins
-Depends: slp-ide , GUIBuilder
-Size: 71394
-Path: /GUIBuilderPlugins_0.3.294_windows.zip
-SHA256: 39f4f687f3664a53885a7a07dfb467f1663154af437d93c09ee23e95ec1119e8
-
-Package: meta1
-Version: 0.1
-Maintainer: cho
-Description: meta1
-Depends: p1
-Conflict:
-Size: 0
-Path: /meta1.zip
-Attribute: root
-
-Package: p1
-Version: 0.1
-Maintainer: cho
-Description: p1
-Depends: p2
-Conflict:
-Size: 0
-Path: /p1.zip
-
-Package: p2
-Version: 0.1
-Maintainer: cho
-Description: p2
-Depends: meta1
-Conflict:
-Size: 0
-Path: /p2.zip
-
-Package: p3
-Version: 0.1
-Maintainer: cho
-Description: p3
-Depends: nopackage
-Conflict:
-Size: 0
-Path: /p3.zip
-
+++ /dev/null
-Package: EventInjector_Wac
-Version: 1.1
-Architecture: i386
-Maintainer: juyung Kim <j0.kim@samsung.com>, jaewon lim <jaewon81.lim@samsung.com>, sungmin Ha <sungmin82.ha@samsung.com>
-Description: EventInjector for emulator
-Install-script:
-Remove-script:
-Category: IDE/WAC IDE/Plugins/EventInjector
-Size: 206116
-Path: ./eventinjector_wac_1.1.245_windows.zip
-SHA256: e50c8b54d46d119468b36850b98ae8e53c81a628668d6f5fbc59493a2704d2f8
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: slp-emulator-image
-Version: 1.1.86
-Maintainer: Yeong-Kyoon, Lee <yeongkyoon.lee@samsung.com> Dong-Kyun, Yun <dk77.yun@samsung.com>
-Description: Samsung Linux Platform Emulator Image
-Remove-script: remove.bat
-Category: SDK/Emulator
-Size: 221007566
-Path: ./emulator-image_1.1.86_windows.zip
-SHA256: 68fcc94883592e1d3b8366ed703165c12ec76e560f2ebab8caba487d55667f53
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: sdb
-Version: 0.1.35
-Maintainer: Hoon Kang <h245.kang@samsung.com>, Joogwan Kim
-Description: Smart Development Bridge for device management
-Remove-script: remove.bat
-Size: 146872
-Path: /sdb_0.1.35_windows.zip
-SHA256: 1dffb8554c1a15682313dec96039bc1f3eb2177ed276ec1f15061583987217f4
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: EMULATOR
-Version: 0.16.63
-Maintainer: JongHwan Park <jonghwan2.park@samsung.com>
-Depends: slp-emulator, slp-emulator-image
-Description: Install EMULATOR.
-Attribute: root
-Category: /
-Size: 476
-Path: ./EMULATOR_0.16.63_windows.zip
-SHA256: cb1914c7d2a0318327cce3f5a398eb289a2361d1def4827d5a1c83108f0f03fd
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: slp-emulator
-Version: 1.1.213
-Maintainer: Yeong-Kyoon, Lee <yeongkyoon.lee@samsung.com> Dong-Kyun, Yun <dk77.yun@samsung.com>
-Description: Samsung Linux Platform Emulator
-Install-script: install.bat
-Remove-script: remove.bat
-Category: SDK/Emulator
-Size: 24493356
-Path: ./emulator_1.1.213_windows.zip
-SHA256: 793ac5e692faecc7e8749392fc93883078954c058a298171ad9da2909591c458
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: info
-Version: 1.0.224
-Maintainer: JongHwan Park<jonghwan2.park@samsung.com>
-Description: information document for sdk-slp
-Category: SDK
-Size: 42649
-Path: /info_1.0.224_windows.zip
-SHA256: f5c91a5a05f59b0dd03e1a3cfb3022b48ca4146295b09e8b43947b595ee69a32
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: WAC_IDE
-Version: 0.16.71
-Maintainer: JongHwan Park <jonghwan2.park@samsung.com>
-Depends: wac-ide, EventInjector_Wac, info, sdb
-Description: Install WAC IDE.
-Attribute: root
-Category: /
-Size: 487
-Path: /WAC_IDE_0.16.71_windows.zip
-SHA256: 62f972aef511cf72145823ad8d44b86e7ec5c7490056159ba18e0e72e28b947b
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-
-Package: wac-ide
-Version: 1.16.221
-Maintainer: kangho kim <kh5325.kim@samsung.com> jihoon song<jihoon80.song@samsung.com>
-Description: Samsung Linux Platform WAC IDE
-Category: IDE/WAC IDE/Workbench
-Install-script: install.bat
-Remove-script: remove.bat
-Size: 181060397
-Path: /wac-ide_0.16.221_windows.zip
-SHA256: 3d4169b08a067bb0ffa582a2f96b05e3784249d6a3de4f0ba278952da33ffcec
-Status: INSTALLED_OK
-Installed-directory: c:/samsung-sdk
-