<copy file="${basedir}/lib/org.eclipse.jface_3.6.2.M20110210-1200.jar" todir="${distlib.dir}" />
<copy file="${basedir}/lib/org.eclipse.core.commands_3.6.0.I20100512-1500.jar" todir="${distlib.dir}" />
<copy file="${basedir}/lib/${swtjar}" todir="${distlib.dir}" />
- <copy file="${basedir}/lib/proxy-vole_20111102.jar" todir="${distlib.dir}" />
<jar jarfile="${dist.dir}/${PLATFORM}/InstallManager.jar">
<fileset dir="${build.dir}" />
<attribute name="Rsrc-Class-Path" value="./ org.eclipse.equinox.common_3.6.0.v20100503.jar
org.eclipse.core.commands_3.6.0.I20100512-1500.jar
org.eclipse.jface_3.6.2.M20110210-1200.jar
- proxy-vole_20111102.jar
${swtjar}"/>
<attribute name="Class-Path" value="."/>
- <attribute name="Rsrc-Main-Class" value="com.samsung.installmanager.ui.InstallManagerWindow"/>
+ <attribute name="Rsrc-Main-Class" value="org.tizen.installmanager.ui.InstallManagerWindow"/>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
</manifest>
</jar>
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;
private String getSaveConfigFilePath() {
if (Options.userConfPath == null) {
- return PathUtil.get(this.getTargetDir(), Config.INSTALL_MANAGER_DEFAULT_CONFIG_FILE_PATH);
+ 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;
}
public IMFatalException(String msg) {
Log.err(msg);
this.msg = msg;
+ ErrorController.setErrorMessage(msg);
}
public IMFatalException(ErrorCode e) {
- ErrorController.setError(e);
this.msg = ErrorController.getMessage(e);
+ Log.err(msg);
+
+ ErrorController.setError(e);
}
public String getMessage() {
} else {
mConfig = new Config();
+ if (Options.doRepository) {
+ 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 (packageToDownload == null || fileDownloadTargetPath == null
|| fileDownloadTargetPath.isEmpty()) {
Log.err("InstallManager.downloadPackage(): Invalid package: " + packageToDownload + ": This might be a bug of IM");
- throw new IMFatalException(ErrorCode.PACKAGES_NOT_EXIST_TO_INSTALL_OR_UNINSTALL);
+ throw new IMFatalException(ErrorCode.PACKAGE_NOT_EXIST_TO_INSTALL_OR_UNINSTALL);
}
// Check cache foler
Log.log("Validate package");
if (!checkPackageSize(packageToDownload, size)) {
Log.err("Package size error. downloaded size => " + size);
- throw new IMFatalException(ErrorCode.WRONG_SIZE);
+ throw new IMFatalException(ErrorCode.PACKAGE_WRONG_SIZE);
}
//TODO :
if (!checkFileChecksum(packageToDownload,
mDownloader.getFileChecksum())) {
Log.err("Package checksum error downloaded checksum => " + mDownloader.getFileChecksum());
- throw new IMFatalException(ErrorCode.WRONG_CHECKSUM);
+ throw new IMFatalException(ErrorCode.PACKAGE_WRONG_CHECKSUM);
}
}
}
if (!moveToTargetDirectoryFromTempDirectory(tempDir, targetDir)) {
- PathUtil.remove(tempDir);
+ 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);
}
if (removeScriptTo.exists()) {
removeScriptTo.delete();
}
- if (PathUtil.moveFile(removeScriptFrom, removeScriptTo)) {
- return true;
- } else {
- Log.err("Cannot move remove script to local => " + pack.getPackageName());
+ if (!PathUtil.moveFile(removeScriptFrom, removeScriptTo)) {
+ Log.err("Cannot move removeScript to targetDir => " + pack.getPackageName());
return false;
}
}
- } else {
- return true;
- }
+ }
+ PathUtil.remove(tempDir);
+ return true;
}
Log.log("Move temp to target");
File fromFile = new File(tempDir + File.separator + Config.DATA_DIRECTORY);
if (!fromFile.exists()) {
- return false;
+ Log.err("Data directory is not exist in package.");
+ return true;
}
File toFile = new File(targetDir);
return false;
}
}
-
return true;
}
*/
public boolean uninstall(Package2 pkg, IIMProgressMonitor monitor) {
Log.log("Installer uninstall start");
+ int resultRemoveScript = executeRemoveScript(pkg, monitor);
- if (executeRemoveScript(pkg, monitor)) {
+ if (resultRemoveScript == 0) {
Log.log("Execute remove script success.");
- } else {
+ } 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));
}
- private boolean executeRemoveScript(Package2 pkg, IIMProgressMonitor monitor) {
+ private int executeRemoveScript(Package2 pkg, IIMProgressMonitor monitor) {
Log.log("executeRemoveScript => " + pkg.getRemoveScript());
//execute remove script
- if (!pkg.getRemoveScript().isEmpty()) {
- String script = PathUtil.get(getRemoveScriptLocalPath(pkg));
- File scriptFile = new File(script);
-
- if (scriptFile.exists()) {
-
- if (monitor != null) {
- monitor.setFileName(scriptFile.getName());
- monitor.workedFileName();
- }
-
- try {
- return executeScript(scriptFile);
- } catch (IMShellCommandFail e) {
- Log.ExceptionLog(e);
- throw new IMFatalException(ErrorCode.REMOVE_SCRIPT_FATAL_ERROR);
- }
- }
- } else {
- return true;
- }
- return false;
+ String script = PathUtil.get(getRemoveScriptLocalPath(pkg));
+ File scriptFile = new File(script);
+
+ if (scriptFile.exists()) {
+
+ if (monitor != null) {
+ monitor.setFileName(scriptFile.getName());
+ monitor.workedFileName();
+ }
+
+ try {
+ if (executeScript(scriptFile)) {
+ return 0; // succeed to execute remove script.
+ } else {
+ return 1; // fail to execute remove script.
+ }
+ } catch (IMShellCommandFail e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.REMOVE_SCRIPT_FATAL_ERROR);
+ }
+ }
+ return 2; // package does not need remove script.
}
/**
public static String userConfPath = null;
/**
+ * Do replace repository.
+ * If <code>doRepository</code> is true, change repository address to <code>repo</code> variable.
+ */
+ public static boolean doRepository = false;
+
+ /**
* Do remove packages after installation
*/
public static boolean doRemovePackages = true;
*/
public static boolean useSnapShot = false;
- public static String repository = null;
+ public static String repo = null;
public static String packageList = null;
public static void loadCmdArgs(String[] args) {
Options.args = args;
Iterator<String> iter = Arrays.asList(args).iterator();
- while(iter.hasNext()) {
- String arg = iter.next();
- Log.log(arg+" option is specified");
-
- if(arg.equals("-noPackageValidation")) {
- doPackageValidation = false;
- } else if(arg.equals("-doAutoInstall")) {
- doAutoInstall = true;
- } else if(arg.equals("-conf")) {
- if(iter.hasNext()) {
- userConfPath = iter.next();
- Log.log("User conf path: "+userConfPath);
- File userConf = new File(userConfPath);
- if (!userConf.exists()) {
- Log.err("There is no user config file in this path : " + userConfPath);
+ try {
+ while(iter.hasNext()) {
+ String arg = iter.next();
+ Log.log(arg+" option is specified");
+
+ if(arg.equals("-noPackageValidation")) {
+ doPackageValidation = false;
+ } else if(arg.equals("-doAutoInstall")) {
+ doAutoInstall = true;
+ } else if(arg.equals("-conf")) {
+ if(iter.hasNext()) {
+ userConfPath = iter.next();
+ Log.log("User conf path: "+userConfPath);
+ File userConf = new File(userConfPath);
+ if (!userConf.exists()) {
+ Log.err("There is no user config file in this path : " + userConfPath);
+ throw new IMFatalException(ErrorCode.CANNOT_FIND_USER_CONFIG_FILE);
+ } else {
+ Log.log("Found user config file in this path : " + userConfPath);
+ }
+ } else {
+ Log.err("-conf requires absolute path to the user conf file");
throw new IMFatalException(ErrorCode.CANNOT_FIND_USER_CONFIG_FILE);
+ }
+ } 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("-checkPackageUpdate")) {
+ checkPackageUpdate = true;
+ } else if(arg.equals("-printDepGraph")) {
+ printDepGraph = true;
+ } else if(arg.equals("-proxy")) {
+ if(iter.hasNext()) {
+ proxy = iter.next();
+ Log.log("User-provided proxy: "+proxy);
} else {
- Log.log("Found user config file in this path : " + userConfPath);
+ Log.err("-proxy requires proxy description");
+ throw new IMFatalException(ErrorCode.PROXY_NOT_PROVIDED);
+ }
+ } else if (arg.equals("-useSnapShot")) {
+ if(iter.hasNext()) {
+ useSnapShot = true;
+ repo = iter.next();
+ Log.log("User-provided repository: "+repo);
+ } else {
+ Log.err("-useSnapShot requires repository description");
+ throw new IMFatalException(ErrorCode.USESNAPSHOT_REPOSITORY_NOT_PROVIDED);
+ }
+ } else if (arg.equals("-onlyDownload")) {
+ if(iter.hasNext()) {
+ onlyDownload = true;
+ packageList = iter.next();
+ Log.log("User-provided package list: "+packageList);
+ } else {
+ Log.err("-onlyDownload requires packageList description");
+ throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
}
- } else {
- Log.err("-conf requires absolute path to the user conf file");
- throw new IMFatalException(ErrorCode.CANNOT_FIND_USER_CONFIG_FILE);
- }
- } 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("-checkPackageUpdate")) {
- checkPackageUpdate = true;
- } else if(arg.equals("-printDepGraph")) {
- printDepGraph = true;
- } else if(arg.equals("-proxy")) {
- if(iter.hasNext()) {
- proxy = iter.next();
- Log.log("User-provided proxy: "+proxy);
- } else {
- Log.err("-proxy requires proxy description");
- throw new IMFatalException(ErrorCode.PROXY_NOT_PROVIDED);
- }
- } else if (arg.equals("-useSnapShot")) {
- if(iter.hasNext()) {
- useSnapShot = true;
- repository = iter.next();
- Log.log("User-provided repository: "+repository);
- } else {
- Log.err("-useSnapShot requires repository description");
- throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
- }
- } else if (arg.equals("-onlyDownload")) {
- if(iter.hasNext()) {
onlyDownload = true;
- packageList = iter.next();
- Log.log("User-provided package list: "+packageList);
- } else {
- Log.err("-onlyDownload requires repository description");
- throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
+ } else if (arg.equals("-noRemoveTempTizenSDK")) {
+ doRemoveTempTizenSDK = false;
+ } else if (arg.equals("-repository")) {
+ if(iter.hasNext()) {
+ doRepository = true;
+ repo = iter.next();
+ Log.log("replace repository : "+repo);
+ } else {
+ Log.err("-replaceRepository requires repository description");
+ throw new IMFatalException(ErrorCode.REPOSITORY_NOT_PROVIDED);
+ }
}
- onlyDownload = true;
- } else if (arg.equals("-noRemoveTempTizenSDK")) {
- doRemoveTempTizenSDK = false;
}
+ } catch(Throwable e) {
+ Log.err("Check your options. => " + Arrays.toString(args));
+ System.err.println("Check your options. => " + Arrays.toString(args));
+ System.exit(1);
}
}
/*
-* 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 java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.ConnectException;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.NoRouteToHostException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+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;
-
/**
* Manages downloading from url.
- *
+ *
* @author Shihyun Kim <shihyun.kim@samsung.com>
- *
+ *
*/
public class Downloader {
private static final String PROTOCOL_SEPARATOR = "://";
private MessageDigest mDigest;
private URLConnection mConnection = null;
- private int mConnectTimeout = 1000; // connection timeout: 1 sec
+ private int connectTimeout = 1000; // connection timeout: 1 sec
private String mUser = "";
private String mPassword = "";
/**
* Downloads the url to the local path
- * @param sUrl url to download
- * @param localPath local path to save the file from the url
+ *
+ * @param sUrl
+ * url to download
+ * @param localPath
+ * local path to save the file from the url
* @param monitor
* @return download size in bytes if success. -1 if fail.
*/
public long download(URL sUrl, String localPath, IIMProgressMonitor monitor) {
- Log.log("Downloading: "+sUrl+" -> "+localPath);
+ Log.log("Downloading: " + sUrl + " -> " + localPath);
if (localPath == null || localPath.equals("")) {
return ERROR;
InputStream input = null;
try {
input = mConnection.getInputStream();
- } catch(FileNotFoundException e) {
+ } catch (FileNotFoundException e) {
ErrorController.setError(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
Log.err("Cannot find file => " + sUrl.toExternalForm());
return ERROR;
- } catch(SocketTimeoutException timeoutException) {
+ } catch (SocketTimeoutException timeoutException) {
ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
Log.err(ErrorController.getErrorMessage());
return ERROR;
ErrorController.setError(ErrorCode.NO_ROUTE_TO_HOST);
Log.err(ErrorController.getErrorMessage());
return ERROR;
- } catch (SocketException e) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
- Log.err(ErrorController.getErrorMessage());
- return ERROR;
+ } catch (SocketException e) {
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ Log.err(ErrorController.getErrorMessage());
+ return ERROR;
} catch (IOException e) {
- if (e.getClass().toString().indexOf("FtpLoginException")>=0) {
+ if (e.getClass().toString().indexOf("FtpLoginException") >= 0) {
ErrorController.setError(ErrorCode.NOT_LOGGED_IN);
Log.err(ErrorController.getErrorMessage());
return ERROR;
long beginMS = System.currentTimeMillis();
try {
mDigest.reset();
- while(totalWriteSize < totalFileSize) {
+ while (totalWriteSize < totalFileSize) {
if (input.available() > 0) {
int inputReadSize = input.read(buf);
totalWriteSize += inputReadSize;
writeSizePerSecond += inputReadSize;
- if(mDigest != null) {
+ if (mDigest != null) {
mDigest.update(buf, 0, inputReadSize);
}
long endMS = System.currentTimeMillis();
if (endMS > (beginMS + 100)) {
if (monitor != null) {
- if(monitor.isCanceled()) {
+ if (monitor.isCanceled()) {
ErrorController.setError(ErrorCode.CANCEL);
return ERROR;
}
long endMS = System.currentTimeMillis();
if (endMS > (beginMS + 5000)) {
- ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
+ ErrorController
+ .setError(ErrorCode.INTERNET_CONNECTION_ERROR);
return ERROR;
}
}
- } catch(SocketTimeoutException timeoutException) {
+ } catch (SocketTimeoutException timeoutException) {
ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
return ERROR;
} catch (IOException e) {
// ignore
}
}
- Log.log("Downloaded size: "+totalWriteSize);
+ Log.log("Downloaded size: " + totalWriteSize);
return totalWriteSize;
}
/**
* Set user name.
+ *
* @param user
*/
public void setUser(String user) {
/**
* Set password
+ *
* @param password
*/
public void setPassword(String password) {
/**
* Get MessageDigest instance from downloading file.
+ *
* @return
*/
public MessageDigest getFileChecksum() {
/**
* Connect to aUrl and ready to download.
+ *
* @param aUrl
* @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();
+ String fullUrl = aUrl.getProtocol() + PROTOCOL_SEPARATOR
+ + mUser + USER_PASSWORD_SEPARATOR + mPassword
+ + ID_SEPARATOR + aUrl.getHost() + aUrl.getPath();
url = new URL(fullUrl);
} else {
bRet = connection(url);
- //set connetion timeout
- if (mConnection != null) {
- mConnection.setConnectTimeout(mConnectTimeout);
- }
-
} catch (MalformedURLException e) {
- Log.err("malformed url: "+url);
- return bRet;
+ Log.ExceptionLog(e);
+ return false;
+ } catch (Exception e) {
+ Log.ExceptionLog(e);
+ return false;
}
return bRet;
}
+ private boolean isAvailableURL(URL url) {
+ if (url.getProtocol().equalsIgnoreCase("file")) {
+ return true;
+ }
+ SocketAddress socketAddress = null;
+ try {
+ int port = url.getPort();
+ if (port < 0) {
+ port = url.getDefaultPort();
+ }
+ socketAddress = getSocketAddress(url.getHost(), port);
+
+ } catch (IMFatalException e) {
+ throw new IMFatalException(e.getMessage() + "\n(Repository: " + url
+ + ").");
+ }
+
+ if (socketAddress == null) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
private boolean connection(final URL url) {
+ Log.log("Connect to " + url);
+
+ String protocol = url.getProtocol();
+ Config conf = InstallManager.getInstance().getConfig();
+
+ boolean bRet = false;
+
+ // connect with proxy.
+ if (protocol.startsWith("file")) { // local url
+ Log.log("Connect to local path.");
+ return connectToURL(url, Proxy.NO_PROXY);
+
+ } else if (Options.proxy != null) {
+ Log.log("Connect to repository with '-proxy' option.");
+ bRet = connectToURL(url, getOptionalProxy());
+
+ } else if (conf.hasProxy()) {
+ Log.log("Connect to repository with config proxy.");
+ bRet = connectToURL(url, getConfigProxy());
+
+ } else { // system proxy
+ Log.log("Connect to repository with system proxy.");
+ List<Proxy> proxyList = 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 connectToURL(URL url, Proxy proxy) {
try {
- Proxy proxy = getProxy(url);
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);
+ }
+
+ return false;
+
+ } catch (SocketException 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 (FileNotFoundException e) {
+ Log.ExceptionLog(e);
+ ErrorController.setError(ErrorCode.CANNOT_FIND_PACKAGE_LIST_FILE_IN_REPOSITORY);
+ return false;
} catch (IOException e) {
Log.ExceptionLog(e);
+ return false;
+ }
+ if (mConnection.getContentLength() < 0) {
+ Log.err("Cannot connect to repository(url=>" + url + ", proxy=>" + proxy);
+ ErrorController.setError(ErrorCode.INTERNET_CONNECTION_ERROR);
return false;
+ } else {
+ return true;
}
- 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.
+ * 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 Proxy getProxy(URL url) {
- String protocol = url.getProtocol();
- if(protocol.startsWith("file")) {
- return Proxy.NO_PROXY;
+ 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);
+ } else {
+ Log.log("Proxy list => " + proxyList);
+ return proxyList;
}
+ }
+
+ private Proxy getOptionalProxy() {
Config conf = InstallManager.getInstance().getConfig();
- if(Options.proxy != null) {
- String[] arr = Options.proxy.split(":");
- try {
- Log.log("Use user-provided proxy: "+Options.proxy);
- SocketAddress addr = new InetSocketAddress(arr[0], Integer.parseInt(arr[1]));
-
- //set proxy server and port
- conf.getConfigFile().setProxyServer(arr[0]);
- conf.getConfigFile().setProxyPort(arr[1]);
-
- return new Proxy(Proxy.Type.HTTP, addr);
- } catch(IllegalArgumentException e) {
- throw new IMFatalException(ErrorCode.PROXY_INVALID);
- }
- } else if(conf.hasProxy()) {
- Log.log("Use proxy specified in .conf file: "+conf.getConfigFile().getProxyServer() +":"+ conf.getConfigFile().getProxyPort());
- SocketAddress addr = new InetSocketAddress(conf.getConfigFile().getProxyServer(), conf.getConfigFile().getProxyPort());
+
+ String[] arr = Options.proxy.split(":");
+ try {
+ Log.log("Use user-provided proxy: " + Options.proxy);
+
+ SocketAddress addr = getSocketAddress(arr[0], arr[1]);
+
+ // save proxy server and port
+ conf.getConfigFile().setProxyServer(arr[0]);
+ conf.getConfigFile().setProxyPort(arr[1]);
+
return new Proxy(Proxy.Type.HTTP, addr);
- } else {
- return Proxy.NO_PROXY;
+ } catch (IllegalArgumentException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.PROXY_SERVER_IS_WRONG);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.PROXY_SERVER_IS_WRONG);
+ } catch (IMFatalException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(e.getMessage() + "\n(proxy: " + arr[0]
+ + ":" + arr[1] + ").");
}
}
+ private Proxy getConfigProxy() {
+ Config conf = InstallManager.getInstance().getConfig();
+
+ Log.log("Use proxy specified in .conf file: "
+ + conf.getConfigFile().getProxyServer() + ":"
+ + conf.getConfigFile().getProxyPort());
+
+ SocketAddress addr = null;
+ try {
+ addr = getSocketAddress(conf.getConfigFile().getProxyServer(), conf
+ .getConfigFile().getProxyPort());
+ } catch (IMFatalException e) {
+ throw new IMFatalException(e.getMessage() + "\n(proxy:"
+ + conf.getConfigFile().getProxyServer() + ":"
+ + conf.getConfigFile().getProxyPort() + ").");
+ }
+
+ return new Proxy(Proxy.Type.HTTP, addr);
+ }
+
+ private SocketAddress getSocketAddress(String address, String port)
+ throws IMFatalException {
+ try {
+ return getSocketAddress(address, Integer.parseInt(port));
+ } catch (NumberFormatException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.URL_PORT_IS_WRONG);
+ }
+ }
+
+ private SocketAddress getSocketAddress(String address, int port)
+ throws IMFatalException {
+ SocketAddress addr = null;
+ try {
+ addr = new InetSocketAddress(InetAddress.getByName(address), port);
+ } catch (UnknownHostException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.URL_ADDRESS_IS_WRONG);
+
+ } catch (IllegalArgumentException e) {
+ Log.ExceptionLog(e);
+ throw new IMFatalException(ErrorCode.URL_PORT_IS_WRONG);
+
+ } catch (SecurityException e) {
+ Log.ExceptionLog(e);
+
+ ErrorController.setErrorMessage(e.getMessage());
+ throw new IMFatalException(ErrorCode.URL_SECURITY_EXCEPTION);
+ }
+
+ return addr;
+ }
+
/**
* Get file size to download.
+ *
* @return
*/
public int getDownloadFileSize() {
*
*/
public enum ErrorCode {
- NOT_LOGGED_IN("Cannot login."),
- INTERNET_CONNECTION_ERROR("Cannot connect to server. Please check your network status or use command line option '-proxy <address>:<port>' for using proxy."),
- NO_ROUTE_TO_HOST("Cannot find server. Please check url."),
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_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."),
- WRONG_SIZE("Downloaded file's size is wrong."),
- WRONG_CHECKSUM("Downloaded file's checksum is wrong."),
- PACKAGES_NOT_EXIST_TO_INSTALL_OR_UNINSTALL("Packages do not exist to install or uninstall."),
CANCEL("Download is canceled."),
ERROR("Error occurred from unknown cause."),
UNKNOWN_PACKAGE_EXTENSION("not supported pakckage extension"),
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"),
- INSTALL_SCRIPT_NOT_EXISTS("Install script not exists."),
- INSTALL_SCRIPT_FATAL_ERROR("Fatal error occurred while installing Tizen SDK."),
REMOVE_SCRIPT_NOT_EXISTS("Remove script not exists."),
REMOVE_SCRIPT_FATAL_ERROR("Fatal error occurred while uninstalling Tizen SDK."),
INSTALLATION_FAIL("Installation is Failed."),
CANNOT_CREATE_FILE("Cannot create file"),
THREAD_INTERRUPTED("Execution is interrupted"),
CIRCULAR_PACKAGE_DEPENDENCY("Circular package dependency is detected"),
- PROXY_SERVER_IS_WRONG("Cannot connect to proxy server. Please, check your proxy server."),
+ //Package error
+ PACKAGE_WRONG_SIZE("Size of package is wrong."),
+ 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."),
+
+ // 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."),
+
+ //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."),
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"),
- PROXY_NOT_PROVIDED("Proxy setting is not provided. Use command line option '-proxy <proxy-address>:<port>'"),
- REPOSITORY_NOT_PROVIDED("Repository setting is not provided. Use command line option '-useSnapShot <repository>'"),
+ 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>'"),
- PROXY_INVALID("Package list are not provided. Use command line '-onlyDownload <package list seperated by \",\">'"),
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 getErrorMessage() {
return errorMessage;
}
+
+ public void setErrorMessage(String msg) {
+ errorMessage = msg;
+ }
}
*/
static public String getErrorMessage() {
if (mErrorCode != null) {
- return mErrorCode.getErrorMessage();
+ String errorMsg = mErrorCode.getErrorMessage();
+
+ return errorMsg;
} else {
if (checkInstallationSuccess()) {
return "No Error";
}
}
}
+
+ static public void setErrorMessage(String msg) {
+ mErrorCode.setErrorMessage(msg);
+ }
/**
* @return Latest error code.
--- /dev/null
+package org.tizen.installmanager.lib;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+
+/**
+ *
+ * Get network proxy address from ProxySelector class.
+ * If you create NetworkProxy instance without ProxySelector instance,
+ * you can get system proxy from select function.
+ * @author Shihyun Kim<shihyun.kim@samsung.com>
+ *
+ */
+public class NetworkProxy {
+ private static NetworkProxy netProxy = null;
+
+ private static final String PROXY_PROPERTY = "java.net.useSystemProxies";
+
+ //member variable
+ private ProxySelector proxySelector = null;
+
+ private NetworkProxy(ProxySelector selector) {
+ 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 list of proxy from ProxySelector.
+ */
+ public List<Proxy> select(URL url) {
+
+ try {
+ return select(url.toURI());
+ } catch (URISyntaxException e) {
+ Log.err("Cannot get proxy => " + url);
+ return null;
+ }
+ }
+
+ /**
+ * Get proxy list from <code>uri</code> parameter.
+ * @param uri
+ * @return list of proxy from ProxySelector.
+ */
+ public List<Proxy> select(URI uri) {
+ if (uri == null) {
+ Log.err("uri is null");
+ return null;
+ }
+
+ Log.log("proxy select uri => " + uri.toString());
+
+ try {
+ return proxySelector.select(uri);
+
+ } catch (IllegalArgumentException e) {
+ Log.ExceptionLog(e);
+ return null;
+ } catch (Exception e) {
+ Log.ExceptionLog(e);
+ return null;
+ }
+ }
+
+ /**
+ * Get direct Proxy instance.
+ * @param url is connected by proxy.
+ * @return Direct proxy instance.
+ */
+ public Proxy getHttpDirectProxy(URL url) {
+ String host = url.getHost();
+ int port = url.getPort();
+ if (port < 0) {
+ port = url.getDefaultPort();
+ }
+
+ Proxy directProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
+ return directProxy;
+ }
+
+ public static NetworkProxy getInstance() {
+ if (netProxy == null) {
+ netProxy = new NetworkProxy();
+ }
+
+ return netProxy;
+ }
+
+ public static NetworkProxy getInstance(ProxySelector selector) {
+ if (netProxy == null) {
+ netProxy = new NetworkProxy(selector);
+ }
+
+ return netProxy;
+ }
+}
+
+
+
+
String repoBaseDirUrl = PathUtil.getParentDirectory(repoBaseUrl);
if (Options.useSnapShot) {
- repoBaseDirUrl = PathUtil.getParentDirectory(Options.repository, 3);
+ repoBaseDirUrl = PathUtil.getParentDirectory(Options.repo, 3);
}
repoPackages.add(new Package2(sect.getProperties(), repoBaseDirUrl));
compositeWelcomePage.setButtonStatus();
} else {
+ compositeWelcomePage.setVisibleRadioButton(false);
+ btnNext.setVisible(false);
+
compositeWelcomePage.setTitle("Cannot start Tizen SDK Install Manager.");
compositeWelcomePage.setErrorSubTitle(ErrorController.getErrorMessage());
- compositeWelcomePage.setVisibleRadioButton(false);
- btnNext.setVisible(false);
btnClose.setText("Close");
btnClose.removeSelectionListener(closeBtnSelectionAdapter);
} catch (Throwable e) {
Log.err("Unexpected error occurred");
Log.ExceptionLog(e);
+
// show error message
- window.open();
- if (Display.getCurrent() != null
- && !Display.getCurrent().isDisposed()) {
- Display.getCurrent().dispose();
+ if (window != null) {
+ window.open();
+
+ if (Display.getCurrent() != null
+ && !Display.getCurrent().isDisposed()) {
+ Display.getCurrent().dispose();
+ }
}
+
ErrorController.setExitCode(Config.EXITCODE_UNKNOWN_ERROR);
} finally {
if (Options.doRemoveTempTizenSDK) {
--- /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.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.installmanager.ui.InstallManagerWindow;
+import org.tizen.installmanager.util.PathUtil;
+
+
+/**
+ * This class is a parent class of all composite classes.
+ */
+public class PageTemplate extends Composite {
+
+ public static final String RESOURCE_PATH = "/res/images";
+
+ private Label imgLabel;
+ private Label titleLabel;
+ private Label subtitleLabel;
+ public Composite customComposite;
+
+ /**
+ * Set basic environment of child pages.
+ * @param parent
+ * @param style
+ */
+ public PageTemplate(Composite parent, int style) {
+ 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))));
+ titleLabel.setBounds(160, 17, 468, 20);
+ titleLabel.setText("New Label");
+ titleLabel.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ subtitleLabel = new Label(this, SWT.WRAP);
+ subtitleLabel.setBounds(160, 43, 451, 40);
+ subtitleLabel.setText("");
+ subtitleLabel.setBackground(InstallManagerWindow.getBackgroundColor());
+
+ customComposite = new Composite(this, SWT.NONE);
+
+ customComposite.setSize(468, 304);
+ customComposite.setLocation(160, 90);
+ customComposite.setBackground(InstallManagerWindow.getBackgroundColor());
+ }
+
+ /**
+ * Set the left image in resource.
+ * @param Image path
+ */
+ public void setLeftImageFromResource(String imgRscPath) {
+ imgLabel.setImage(PathUtil.getImageFromResource(imgRscPath));
+ }
+
+ /**
+ * Set page's title.
+ * @param Title string
+ */
+ public void setTitle(String strTitle) {
+ titleLabel.setText(strTitle);
+ }
+
+ /**
+ * Set page's sub title
+ * @param Sub title string
+ */
+ public void setSubTitle(String strSubTitle) {
+ subtitleLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
+ subtitleLabel.setText(strSubTitle);
+ }
+
+ public void setErrorSubTitle(String strSubTitle) {
+ subtitleLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
+ subtitleLabel.setText(strSubTitle);
+ }
+
+ /**
+ * Return custom composite
+ * @return custom composite object
+ */
+ public Composite getCustomComposite() {
+ return customComposite;
+ }
+
+ public void setImageBounds(int nX, int nY, int nWidth, int nHeight) {
+ imgLabel.setBounds(nX, nY, nWidth, nHeight);
+ }
+
+ public void setTitleBounds(int nX, int nY, int nWidth, int nHeight) {
+ titleLabel.setBounds(nX, nY, nWidth, nHeight);
+ }
+
+ public void setSubTitleBounds(int nX, int nY, int nWidth, int nHeight) {
+ subtitleLabel.setBounds(nX, nY, nWidth, nHeight);
+ }
+
+ public void setCustomCompositeBounds(int nX, int nY, int nWidth, int nHeight) {
+ customComposite.setSize(nWidth, nHeight);
+ customComposite.setLocation(nX, nY);
+ }
+}
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.lib.ErrorController;
import org.tizen.installmanager.lib.IIMProgressMonitor;
mPackageManager2 = mInstallManager.getPackageManager2();
bResult = bResult && existInstallableOrRemovablePackages();
-
- if (bResult == false) {
- throw new IMFatalException(ErrorCode.CANNOT_FIND_FILE_IN_REPOSITROY);
- }
return bResult;
}
* @see InstalledStatus
*/
public void setButtonStatus() {
-
+
if (Registry.isOldSDKInstalled()) {
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.");
selectedRadioBtn = RADIO_ACTION.UNINSTALL;
}
+
+ if (viewController == null) {
+ return;
+ }
+
if (!viewController.existRemovablePackage()) {
buttonInstall.setText("Install new version of " + Config.SDK_NAME);
buttonInstall.setBounds(26, 40, 500, 22);
} else {}//filePath is file.
+ System.gc(); // delete() method does not work exactly sometimes. so, there is gc() before delete().
return filePath.delete() && ret;
}
echo "$CX Done. $CN"
echo "$CX============================$CN"
+
+##source bashrc
+source ${HOME}/.bashrc
+
exit 0
--- /dev/null
+Repository: http://172.21.17.55/dibs/unstable
+InstallManager-Repository: http://172.21.17.55/InstallManager/Linux
+InstallManager-Version: 1.20.10
+
+
+
+
--- /dev/null
+Repository: http://172.21.17.55/dibs/unstable_internal
+InstallManager-Repository: http://172.21.17.55/InstallManager/Linux
+InstallManager-Version: 1.20.10
+
+
+
+
--- /dev/null
+Repository: http://172.21.17.55/dibs/unstable_public
+InstallManager-Repository: http://172.21.17.55/InstallManager/Linux
+InstallManager-Version: 1.20.10
+
+
+
+
fi
currentDate=`date '+%Y%m%d%H%M'`
-binFile=InstallManager-Local-${currentDate}.bin
+binFile=tizen_sdk_${currentDate}.bin
./makeInstaller InstallManager-Local.tar.gz ${binFile}
rm installmanager.conf
currentDate=`date '+%Y%m%d%H%M'`
-binFile=InstallManager-Network-${currentDate}.bin
+binFile=tizen_sdk_${currentDate}.bin
./makeInstaller InstallManager-Network.tar.gz ${binFile}