*/
public void initConfig() {
if (mConfig != null) {
+ Registry.saveRepoInfo(mConfig.getConfigFile().getRepository());
if (Config.isSupportMultiSDK()) {
if (!Registry.getInstalledPath().isEmpty()) {
mConfig.setTargetDir(Registry.getInstalledPath());
}
} else {
mConfig = Config.getInstance();
-
+ Registry.saveRepoInfo(mConfig.getConfigFile().getRepository());
if (Options.doReplaceRepository) {
Log.log("Replace repository => " + Options.repository);
mConfig.getConfigFile().setRepository(Options.repository);
private void initPackageManager(Collection<String> repositoryURLs) {
File installedPackageListFile = null;
- if (Registry.targetPath != "") {
+ if (!Registry.targetPath.equalsIgnoreCase("")) {
installedPackageListFile = new File(PathUtil.get(
PathUtil.get(Registry.targetPath, Config.INFO_DIRECTORY),
Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
private void checkOldSDK() {
Log.log("Check old SDK.");
if (Registry.getOldInstalledPath() != "") { // 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
+ 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.
Log.log("Old SDK is installed but new SDK is also installed. => "
+ Registry.getInstalledPath());
public boolean install(PackageSet installablePackages,
final String targetDir, InstallProgressMonitor monitor)
throws IMExitException, IMNetworkException {
- Log.log("InstallManager.install() installable packages : " + installablePackages);
+ Log.log("InstallManager.install() installable packages : "
+ + installablePackages);
// performance measurement
- Performance.sdkPackageSize = packageManager.getTotalSizeOfInstallablePackages(installablePackages, true);
+ Performance.sdkPackageSize = packageManager
+ .getTotalSizeOfInstallablePackages(installablePackages, true);
- if (installablePackages == null || targetDir == null || targetDir.isEmpty()) {
+ if (installablePackages == null || targetDir == null
+ || targetDir.isEmpty()) {
Log.err("packaegs => " + installablePackages + ", targetDir => "
+ targetDir);
return false;
initializeTargetDir(targetDir);
makeShortcutMenu();
- // make start menu
- // if you cannot get installmanager from repository, install from local.
- if (!packageManager
- .existsPackage(InstallManagerConstants.INSTALLMANAGER_PACKAGE_NAME)) {
- Log.log("Cannot find install-manager from repository.");
-
- if (!installInstallManagerFromLocal(targetDir)) {
- Log.err("Cannot install install-manager from local directory.");
- }
+ // TODO : refactoring.
+ long size = 0;
+ if (Options.onlyDownload) {
+ System.out.print("Downloading package => " + packageToDownload + " .......");
}
-
- // wait if cancel confirm dialog is showing. wait until user press
- // button(cancel or not).
- // TODO :
+ Log.log("start download package: " + packageToDownload);
+ URL packageUrl = packageToDownload.getURL();
+
if (monitor != null) {
- while (monitor.checkCancelAndDisableCancelButton() == false) {
- if (monitor.isCanceled()) {
- throw new IMInstallCancelException();
- }
- }
+ monitor.workedDownload(packageToDownload.getPackageName());
}
-
- // remove missing packages in repository.
- removeMissingPackages(monitor);
-
- for (Package pkg : installablePackages) {
- if (!install(pkg, targetDir, monitor)) {
- return false;
+ size = mDownloader.download(packageUrl, fileDownloadTargetPath,
+ monitor);
+
+ if (size >= 0) {
+ if (Options.onlyDownload) {
+ System.out.println(" done.");
}
+ Log.log("finish download");
+ } else {
+ Log.err("download failed => " + packageToDownload.getURL());
+
+ PathUtil.remove(fileDownloadTargetPath);
+
+ String errMsg = "";
+ if (monitor.isCanceled()) {
+ errMsg = ErrorController.getErrorMessage();
+ } else {
+ errMsg = "Fail to get '" +
+ packageToDownload.getPackageName() + "'." +
+ "\n(" + ErrorController.getErrorMessage() + ")";
+ }
+ throw new IMFatalException(errMsg);
}
// download complete.
}
// download package from repository.
- result = downloadPackage(pkg, null, monitor);
+ result = downloadPackage(pkg, monitor);
if (Options.doTest) {
Performance.setDownloadEndTime();
return result;
}
- public boolean downloadPackages(PackageSet packageSet,
- InstallProgressMonitor monitor) throws IMNetworkException {
- if (packageSet == null) {
+ /**
+ * Packages Installation management.
+ * Download and install packages.
+ *
+ * @param packagesToInstall
+ * @param targetDir
+ * @param monitor
+ * @return
+ * @throws IMExitException
+ */
+ public boolean install(PackageSet installablePackages, final String targetDir,
+ InstallProgressMonitor monitor) throws IMExitException, IMNetworkException{
+ Log.log("InstallManager.install() installable packages : " + installablePackages);
+
+ //performance measurement
+ Performance.sdkPackageSize = packageManager.getTotalSizeOfInstallablePackages(installablePackages, true);
+
+ if (installablePackages == null || targetDir == null || targetDir.isEmpty()) {
+ Log.err("packaegs => " + installablePackages + ", targetDir => "
+ + targetDir);
return false;
}
-
- for (Package pkg : packageSet) {
- if (!downloadPackage(pkg, null, monitor)) {
- return false;
+
+ mConfig.setTargetDir(targetDir);
+ mConfig.setSdkDatatDir(Registry.sdkDataPath);
+
+ Performance.setDownloadStartTime();
+
+ // download packages from repository
+ if (downloadPackages(installablePackages, monitor)) {
+ Log.log("Success to download packages from repository.");
+ } else {
+ Log.err("Fail to download packages from repository.");
+ if (!Options.doResumeDownloading) {
+ removePackagesDir();
}
- }
- return true;
- }
-
- public boolean downloadPackage(Package pkg, String fileDownloadTargetPath, InstallProgressMonitor monitor)
- throws IMNetworkException {
- Log.log("Download package => " + pkg);
-
- // check the parameter
- if (pkg == null) {
- Log.err("Cannot find package.");
+
return false;
}
monitor.workedDownloadProgress(pkg.getPackageName(), 1);
}
}
-
- URL downloadFileURL = pkg.getURL();
- if (fileDownloadTargetPath == null) {
- fileDownloadTargetPath = getDownloadTargetPath(pkg);
- }
+ URL downloadFileURL = pkg.getURL();
+ String downloadTargetPath = getDownloadTargetPath(pkg);
- // check the package in cache folder
- if (existInCacheFolder(pkg, fileDownloadTargetPath, monitor)) {
- Log.log("Found the package in cache");
-
- if (monitor != null) {
- monitor.workedDownloadSize(pkg.getPackageSize());
- }
-
- return true;
- }
+ Performance.setInstallationStartTime();
+ // save target directory
+ initializeTargetDir(targetDir);
- // check the option.
- if (Options.doInstallNoUI) {
- System.out.println(pkg.getPackageName() + " is downloading...");
- } else if (Options.onlyDownload || Options.downloadPackage) {
- System.out.print("Downloading package => " + pkg + " .......");
- }
+ //if distribution is changed, remove all packages and install.
+ if (packageManager.isReInstallable()) {
+ removeAllPackages(monitor);
+ } else {
+ // remove missing packages
+ if (!packageManager.isRepoPackagesEmpty()) {
+ // Remove missing packages only network installation.
+ if (Config.fromWhere == Config.ConfDialog.SNAPSHOT) {
+ removeMissingPackages(monitor);
+ }
+ }
// download package from repository
- long size = mDownloader.download(downloadFileURL, fileDownloadTargetPath, monitor);
+ long size = mDownloader.download(downloadFileURL, downloadTargetPath,
+ monitor);
if (size >= 0) {
- if (Options.onlyDownload || Options.downloadPackage) {
- System.out.println(" done.");
+ if (Options.onlyDownload) {
+ System.out.println("Download success. => " + pkg);
}
Log.log("finish download => " + pkg);
} else { // fail
Log.err("download failed => " + downloadFileURL);
- PathUtil.remove(fileDownloadTargetPath);
+ PathUtil.remove(downloadTargetPath);
String errMsg = "";
if (monitor.isCanceled()) {
+ pkg.getPackageSize());
Log.err("Package size error. downloaded size => " + size);
- PathUtil.remove(fileDownloadTargetPath);
+ PathUtil.remove(downloadTargetPath);
throw new IMFatalException(ErrorCode.PACKAGE_WRONG_SIZE);
}
Log.err("Package checksum error downloaded checksum => "
+ mDownloader.getFileChecksum());
- PathUtil.remove(fileDownloadTargetPath);
+ PathUtil.remove(downloadTargetPath);
throw new IMFatalException(ErrorCode.PACKAGE_WRONG_CHECKSUM);
}
}
- return true;
- }
+ int i = 0;
+ for (Package pkg : installablePackages) {
+ if (monitor != null) {
+ monitor.workedProcess(pkg.getPackageName());
+ monitor.worked(++i);
+ }
private boolean installPackage(Package pkg, String targetDir,
InstallProgressMonitor monitor) {
initializeTargetDir(targetDir);
// remove packages to update.
- if (packageManager.isInstalledPackage(pkg) && (packageManager.isReInstallable() || packageManager.isUpdatable(pkg))) {
+ if (packageManager.isInstalledPackage(pkg) && (packageManager.isReInstall() || packageManager.isUpdatable(pkg))) {
if (monitor != null) {
monitor.workedInstallProgress("Remove the previous version", 0);
}
if (bResult) {// save installed package list
packageManager.addPackageToInstalledPackages(pkg);
- packageManager.saveInstalledList(PathUtil.get(
- PathUtil.getFromInstalledPath(Config.INFO_DIRECTORY),
- Config.INSTALLED_PACKAGE_LIST_FILE_NAME));
+ packageManager.saveInstalledList();
} else {
Log.log("Installation failed => " + pkg);
}
boolean bResult = false;
- Installer installer = new Installer();
- bResult = installer.uninstall(pkg, monitor);
+ if (packageManager.isInstalledPackage(pkg)) {
+ Installer installer = new Installer();
+
+ bResult = installer.uninstall(pkg, monitor);
+ } else {
+ bResult = true;
+ }
// 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));
+ packageManager.saveInstalledList();
Log.log(pkg + " remove end => " + bResult);
return bResult;
downloadStartTime = new Date();
}
- public static boolean existDownloadStartTime() {
- if (downloadStartTime != null) {
- return true;
- } else {
- return false;
- }
- }
public static void setDownloadEndTime() {
downloadEndTime = new Date();
}
installationStartTime = new Date();
}
+ public static Date getInstallationStartTime() {
+ return installationStartTime;
+ }
+
public static void setInstallationEndTime() {
installationEndTime = new Date();
}
out.write("Sdk package size\t: " + sdkPackageSize);
out.newLine();
out.write("The initialization time\t: " + getInitializeTime() + "sec");
- out.write("(" + getBitPerSecond(sdkPackageSize / 8, getInitializeTime())+ "byte/sec)");
+ out.write("(" + getBitPerSecond(sdkPackageSize, getInitializeTime())+ "b/s)");
out.newLine();
out.write("The download time\t: " + getDownloadTime() + "sec");
- out.write("(" + getBitPerSecond(sdkPackageSize / 8, getDownloadTime())+ "byte/sec)");
+ out.write("(" + getBitPerSecond(sdkPackageSize, getDownloadTime())+ "b/s)");
out.newLine();
out.write("The installation time\t: " + getInstallationTime() + "sec");
- out.write("(" + getBitPerSecond(sdkPackageSize / 8, getInstallationTime())+ "byte/sec)");
+ out.write("(" + getBitPerSecond(sdkPackageSize, getInstallationTime())+ "b/s)");
out.newLine();
out.write("The removal time\t: " + getRemovalTime() + "sec");
- out.write("(" + getBitPerSecond(sdkPackageSize / 8, getRemovalTime())+ "byte/sec)");
+ out.write("(" + getBitPerSecond(sdkPackageSize, getRemovalTime())+ "b/s)");
out.newLine();
out.write("The install-manager start time\t: " + imStartTime);
out.newLine();
}
}
- public static void printTestResultXmlFormat(boolean isForAutomation) {
+ public static void printTestResultXmlFormat() {
//get file name of test result
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String testFileName = formatter.format(imStartTime) + ".xml";
- String testResultFilePath = "";
-
- if (isForAutomation) {
- testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath()
- , "result", testFileName);
- } else {
- testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
- }
-
+ String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
File testResultFile = new File(testResultFilePath);
if (!testResultFile.getParentFile().exists()) {
}
}
- public static void printTestResultXmlFormat2(boolean isForAutomation) {
+ public static void printTestResultXmlFormat2() {
if (installationStartTime != null) {
printInstallTestResultXmlFormat(isForAutomation);
} else {
out.newLine();
out.write(getTestCaseXml("InstallTest", "The installation time", getInstallationTime()));
out.newLine();
+ out.write(getTestCaseXml("TotalInstallationTest", "Total installation time", getTotalInstallationTime()));
out.write("</testsuite>");
} catch (IOException e) {
Log.ExceptionLog(e);
return interval;
}
- public static Date getDownloadStartTime() {
- return downloadStartTime;
- }
-
- public static Date getInstallationStartTime() {
- return installationStartTime;
- }
-
private static long getDownloadTime() {
if (downloadStartTime == null || downloadEndTime == null) {
return 0;
return interval;
}
+ private static long getTotalInstallationTime() {
+ if (downloadStartTime == null || installationEndTime == null) {
+ return 0;
+ }
+
+ long interval = (installationEndTime.getTime() - downloadStartTime.getTime())/1000;
+ return interval;
+ }
+
private static long getRemovalTime() {
if (removalStartTime == null || removalEndTime == null) {
return 0;
return interval;
}
- private static long getBitPerSecond(long size, long seconds) {
+ private static long getKBPerSecond(long size, long seconds) {
if (seconds == 0) {
return 0;
} else {
- return size/seconds;
+ return (size/1024/seconds);
}
}
}