From 3525e2ed2736744ffcae1afd68dfb27c8d01d406 Mon Sep 17 00:00:00 2001 From: "yongsung1.kim" Date: Fri, 19 Jul 2013 10:48:34 +0900 Subject: [PATCH] [Title] -skip option is added. [Desc.] InstallManager can skip specific package installation using -skip option. [Issue] redmine #9998 Change-Id: Idbc1354beb663ab1359b9929c5209cf1a7b2be87 --- .../src/org/tizen/installmanager/cli/CliInstall.java | 6 ++++++ .../src/org/tizen/installmanager/cli/CliUninstall.java | 12 +++++------- .../org/tizen/installmanager/core/InstallManager.java | 1 + .../src/org/tizen/installmanager/core/Installer.java | 4 +++- .../src/org/tizen/installmanager/core/Options.java | 18 ++++++++++++++++++ .../tizen/installmanager/pkg/lib/PackageManager.java | 12 +++++++++++- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/InstallManager_java/src/org/tizen/installmanager/cli/CliInstall.java b/InstallManager_java/src/org/tizen/installmanager/cli/CliInstall.java index 5b01810..989fce2 100644 --- a/InstallManager_java/src/org/tizen/installmanager/cli/CliInstall.java +++ b/InstallManager_java/src/org/tizen/installmanager/cli/CliInstall.java @@ -106,6 +106,12 @@ public class CliInstall { List installableMetaNames = getInstallableMetas(pm, packageNames); PackageSet installableMetas = pm.getPackagesByNames(installableMetaNames); PackageSet installablePackages = pm.getDependsPackagesFromRepository(installableMetas); + PackageSet skipPackages = pm.getPackagesByNames(Options.skipPackages); + + if (!skipPackages.isEmpty()) { + Log.log("Installation skip packages : " + skipPackages); + installablePackages = pm.diff(installablePackages, skipPackages); + } if (checkAvailableSize(installablePackages, targetDir)) { return installPackages(installablePackages, targetDir); diff --git a/InstallManager_java/src/org/tizen/installmanager/cli/CliUninstall.java b/InstallManager_java/src/org/tizen/installmanager/cli/CliUninstall.java index 827400e..724f031 100644 --- a/InstallManager_java/src/org/tizen/installmanager/cli/CliUninstall.java +++ b/InstallManager_java/src/org/tizen/installmanager/cli/CliUninstall.java @@ -64,7 +64,7 @@ public class CliUninstall { controller.init(); PackageManager pm = PackageManager.getInstance(); - + // Uninstall whole SDK. if (packageNames.contains("all")) { if (controller.uninstall(pm.getInstalledMetaNames(), null)) { @@ -73,12 +73,10 @@ public class CliUninstall { } else { return false; } - } - - // Uninstall specific installed packages. - if (!vailidateRemovePkgs(pm, packageNames)) { + } else if (!vailidateRemoveMetaPkgs(pm, packageNames)) { + // Uninstall specific installed packages. return false; - } + } if (controller.uninstall(packageNames, null)) { // After uninstall packages, if installed meta package is "ESSENTIAL-COMPONENT", @@ -117,7 +115,7 @@ public class CliUninstall { * @return If Installmanager can find input package in installed package list, return true. * otherwise, return false. */ - private static boolean vailidateRemovePkgs(PackageManager pm, Collection pkgNames) { + private static boolean vailidateRemoveMetaPkgs(PackageManager pm, Collection pkgNames) { List installedMetaNames = pm.getInstalledMetaNames(); for (String name : pkgNames) { diff --git a/InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java b/InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java index 26afd0b..68e9565 100644 --- a/InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java +++ b/InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java @@ -1310,6 +1310,7 @@ public class InstallManager { } PackageSet pkgsToRemove = packageManager.getToRemovePackagesInRemove(metasToRemove); + Log.log("Remove packages: " + pkgsToRemove); if (monitor != null) { diff --git a/InstallManager_java/src/org/tizen/installmanager/core/Installer.java b/InstallManager_java/src/org/tizen/installmanager/core/Installer.java index c94e8de..1f9a19b 100644 --- a/InstallManager_java/src/org/tizen/installmanager/core/Installer.java +++ b/InstallManager_java/src/org/tizen/installmanager/core/Installer.java @@ -548,7 +548,9 @@ public class Installer { String command = ShellUtil.addInterpreter(scriptFile.getAbsolutePath()); - int exitCode = ShellUtil.execute(command, env, null, + String current = PathUtil.getCurrentDir(); + Log.log("Current working directory. => " + current); + int exitCode = ShellUtil.execute(command, env, new File(current), new LoggerShellParser()); // check exit code diff --git a/InstallManager_java/src/org/tizen/installmanager/core/Options.java b/InstallManager_java/src/org/tizen/installmanager/core/Options.java index e76779c..27d0dc6 100644 --- a/InstallManager_java/src/org/tizen/installmanager/core/Options.java +++ b/InstallManager_java/src/org/tizen/installmanager/core/Options.java @@ -135,6 +135,7 @@ public class Options { public static boolean isNetwork = true; public static List packages = new ArrayList(); + public static List skipPackages = new ArrayList(); /** * Use only download for making SDK image. @@ -470,6 +471,23 @@ public class Options { } } + // set skip packages + argIter = argArray.iterator(); + while (argIter.hasNext()) { + if (argIter.next().equalsIgnoreCase("-skip")) { + argIter.remove(); + while (argIter.hasNext()) { + String pkg = argIter.next(); + if (!pkg.startsWith("-")) { + skipPackages.add(pkg); + argIter.remove(); + } else { + break; + } + } + } + } + // set proxy argIter = argArray.iterator(); while (argIter.hasNext()) { diff --git a/InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java b/InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java index 5216c0c..458c6e2 100644 --- a/InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java +++ b/InstallManager_java/src/org/tizen/installmanager/pkg/lib/PackageManager.java @@ -661,6 +661,16 @@ public abstract class PackageManager { return installedMetaNames; } + public List getInstalledPkgNames() { + ArrayList installedPkgNames = new ArrayList(); + + for (Package pkg : getInstalledPackages()) { + installedPkgNames.add(pkg.getPackageName()); + } + + return installedPkgNames; + } + /** * @return meta packages among all recent packages */ @@ -1283,7 +1293,7 @@ public abstract class PackageManager { * @param pset2 * @return new package set that represents (pset1 - pset2). */ - private PackageSet diff(PackageSet pset1, PackageSet pset2) { + public PackageSet diff(PackageSet pset1, PackageSet pset2) { PackageSet diff = new PackageSet(); for(Package p : pset1) { if(!pset2.contains(p)) { -- 2.7.4