unzipSDKImage();
}
- if (Registry.getInstalledPath() != "") {
+ if (!Registry.getInstalledPath().equals("")) {
List<String> all = new ArrayList<String>();
all.add("all");
if (cliUninstall(all)) {
}
public static boolean cliNetworkInstall(List<String> packageNames) throws IMExitException {
- if (Registry.getInstalledPath() != "") {
+ if (!Registry.getInstalledPath().equals("")) {
String installRepo = Config.getInstance().getConfigFile().getRepository();
String installDist = Config.getInstance().getConfigFile().getDistribution();
String remoteRepo = Options.repository;
}
public static boolean cliUninstall(List<String> packageNames) throws IMExitException {
- if (Registry.getInstalledPath() == "") {
+ if (Registry.getInstalledPath().equals("")) {
System.out.println("Tizen SDK was not installed.");
return false;
} else {
*/
private void checkOldSDK() {
Log.log("Check old SDK.");
- if (Registry.getOldInstalledPath() != "") { // Old SDK is installed.
+ if (!Registry.getOldInstalledPath().equals("")) { // Old SDK is installed.
if (Registry.getInstalledPath() != null && !Registry.getInstalledPath().isEmpty()) {
// Old SDK is installed but new SDK is also installed, so environment does not need to
// set new SDK environment.
}
static String getSDKDataPath() {
- if (Config.getInstance().getSdkDataDir() == "") {
+ if (Config.getInstance().getSdkDataDir().equals("")) {
if (Platform.isLinux() || Platform.isMacOS()) {
return PathUtil.getFromHome(SDK_DATA_DIR_NAME);
} else if (Platform.isWindows()) {
if(iter.hasNext()) {
snapshot = true;
snapshotPath = iter.next();
- Log.log("User-provided repository: " + repository);
+ Log.log("User-provided snapshot path: " + snapshotPath);
} else {
Log.err("-snapShot requires repository description");
throw new IMFatalException(ErrorCode.USESNAPSHOT_REPOSITORY_NOT_PROVIDED);
}
}
}
- if (suPass == "") {
+ if (suPass.equals("")) {
throw new IMFatalException(ErrorCode.WRONG_OPTION);
}
} else if (Platform.isWindows()) {
boolean bRet = false;
String proxyType = Config.getInstance().getConfigFile().getProxyType();
- if (proxyType == "") { // InstallManager uses a system proxy as default.
+ if (proxyType.equals("")) { // InstallManager uses a system proxy as default.
proxyType = ProxyType.AUTOMATIC.toString();
}
List<RegistryInfo> oldRegistryInfo = new ArrayList<RegistryInfo>();
RegistryInfo mCurrentRegistry = null;
- private class RegistryInfo {
+ private static class RegistryInfo {
String mRegistryPath = "";
String mPathKey = "";
String mTargetPath = "";
}
}
- packageListURL = PathUtil.addURLPath(url,
+ if (snapshotPath != null) {
+ packageListURL = PathUtil.addURLPath(url,
snapshotPath,
getPackageListFileName());
+ }
} else {
packageListURL = PathUtil.addURLPath(url, getPackageListFileName());
}
*/
private long getTotalSize(PackageSet pkgs, boolean isUncompressed) {
long totalSize = 0;
- for (Package depPkg : pkgs) {
- if (isUncompressed) {
- totalSize += depPkg.getUncompressedPackageSize();
- } else {
- totalSize += depPkg.getPackageSize();
- }
+ if (pkgs != null) {
+ for (Package depPkg : pkgs) {
+ if (isUncompressed) {
+ totalSize += depPkg.getUncompressedPackageSize();
+ } else {
+ totalSize += depPkg.getPackageSize();
+ }
+ }
+ } else {
+ Log.log("Cannot caculate packages' total size because of empty or null packages.");
}
return totalSize;
public static PackageManager getInstance(File installed, Collection<String> repoPackagesUrls) throws IOException {
if (Options.platForm == null) {
if (Config.isSupportMultiSDK) {
- if (Registry.targetPath != "") {
+ if (!Registry.targetPath.equals("")) {
pm = null;
if (Platform.isLinux()) {
pm = new LinuxPackageManager(installed, repoPackagesUrls);
pFieldList.add(tempProperty);
pField = tempProperty;
} else {
- pField.setValue(pField.getValue()+'\n'+sReadData.trim());
+ if (pField != null) {
+ pField.setValue(pField.getValue()+'\n'+sReadData.trim());
+ }
}
} else {
Log.err("Cannot parse name and value from installmanager.conf. (read line => " + sReadData + ")");
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));
- }
+ this.url = new URL(repoBaseUrl + "/" + getValue(FIELD_FILE_PATH));
+// 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);
log = snapshotLog.getSnapshotLog(item.getText(TABLE_NAME));
}
- if (log == null) {
+ if (log == null && item != null) {
MessageBoxDlg.showDlg(
getShell(),
"Notice",
boolean bResult = false;
while(true) {
try {
- bResult = installManager.install(installablePackages, targetPath, monitor);
+ if (installablePackages != null) {
+ bResult = installManager.install(installablePackages, targetPath, monitor);
+ } else {
+ Log.err("Fail to install because installable packages are null.");
+ throw new IMFatalException("Fail to install because installable packages are null.");
+ }
break;
} catch (IMNetworkException e) {
Log.ExceptionLog(e);
* @return There are packages to install or remove, return true. if not false.
*/
public boolean existInstallableOrRemovablePackages() {
- PackageSet rmPkgs = getRemovablePackageList();
+ PackageSet rmPkgs = new PackageSet();
+ rmPkgs = getRemovablePackageList();
PackageSet insPkgs = getInstallableOrUpdatableMetaPackages();
if (!rmPkgs.isEmpty() || !insPkgs.isEmpty()) {
private String downloadInstallManager() {
Package pkg = packageManager.getPackageByName(InstallManagerConstants.INSTALLMANAGER_PACKAGE_NAME);
- Downloader downloader = new Downloader();
-
- String packagePath = pkg.getFileName();
- String installManagerTempPath = PathUtil.get(PathUtil.getTempDir(), PathUtil.getFileName(packagePath));
- File tempInstaller = new File(installManagerTempPath);
-
- if (tempInstaller.exists()) {
- if (!PathUtil.remove(installManagerTempPath)) {
- Log.err("Cannot remove installmanager. => " + tempInstaller);
+ if (pkg != null) {
+ Downloader downloader = new Downloader();
+
+ String packagePath = pkg.getFileName();
+ String installManagerTempPath = PathUtil.get(PathUtil.getTempDir(), PathUtil.getFileName(packagePath));
+ File tempInstaller = new File(installManagerTempPath);
+
+ if (tempInstaller.exists()) {
+ if (!PathUtil.remove(installManagerTempPath)) {
+ Log.err("Cannot remove installmanager. => " + tempInstaller);
+ }
}
- }
-
- try {
- long size = downloader.download(pkg.getURL(), installManagerTempPath, null);
- if (size > 0) {
- return installManagerTempPath;
- } else {
+ try {
+ long size = downloader.download(pkg.getURL(), installManagerTempPath, null);
+
+ if (size > 0) {
+ return installManagerTempPath;
+ } else {
+ return null;
+ }
+ } catch (IMNetworkConnectException e) {
+ Log.ExceptionLog(e);
return null;
- }
- } catch (IMNetworkConnectException e) {
- Log.ExceptionLog(e);
- return null;
- } catch (IMNetworkDownloadException e) {
- Log.ExceptionLog(e);
+ } catch (IMNetworkDownloadException e) {
+ Log.ExceptionLog(e);
+ return null;
+ }
+ } else {
+ Log.err("Cannot download installmanager package.");
return null;
}
}
}
String dist = Config.getInstance().getConfigFile().getDistribution();
- if (repo != null && !repo.isEmpty()) {
+ if (dist != null && !dist.isEmpty()) {
commands.add("-distribution");
commands.add(dist);
}
}
}
- Config.getInstance().getConfigFile().setInstallManagerVersion(packageManager.getPackageByName("install-manager").getVersion().toString());
- Config.getInstance().getConfigFile().saveConfig(PathUtil.get(tempIMJarFile.getParent(), "installmanager.conf"));
+ if (packageManager.getPackageByName("install-manager") != null) {
+ Config.getInstance().getConfigFile().setInstallManagerVersion(packageManager.getPackageByName("install-manager").getVersion().toString());
+ Config.getInstance().getConfigFile().saveConfig(PathUtil.get(tempIMJarFile.getParent(), "installmanager.conf"));
+ }
Log.log("Updatable commands => " + commands);
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
-import org.tizen.installmanager.core.Config;
import org.tizen.installmanager.core.IMFatalException;
import org.tizen.installmanager.core.Options;
import org.tizen.installmanager.lib.Log;
if (path != null) {
for (int i = parentDepth; i > 0; i--) {
parentPath = PathUtil.getParentDirectory(parentPath);
+ if (parentPath == null) {
+ break;
+ }
}
}
return exitCode;
} catch (IOException e) {
Log.err("Command exec error => " + Arrays.toString(cmd));
+ Log.ExceptionLog(e);
throw new IMShellCommandFail();
} catch (InterruptedException e) {
Log.err("Command exec error => " + Arrays.toString(cmd));
+ Log.ExceptionLog(e);
throw new IMShellCommandFail();
}
}