From 61db1b1a07e295684f7cf523038b8c2250ef8db1 Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Fri, 22 Feb 2013 20:46:45 +0900 Subject: [PATCH] [Title] Fixed bug for displaying new version on installed version field --- .../nativeplatform/pkgmgr/RPMPackageCommander.java | 29 ++++++++++++++-------- .../pkgmgr/RPMPackageCommands.properties | 4 +-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java index ab7169a..41e4175 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommander.java @@ -449,10 +449,13 @@ public class RPMPackageCommander { // get installed packages using rpm cmd = String.format("%s;%s", getResetDbCmd(), getInstalledPkgListCmd()); command = getChrootedCommand(path, cmd); - result = CommandLauncher.executeSudoOutput(command); - splitStr = result.split("\n"); - for (String s : splitStr) { - s = s.replaceAll(" ", "").trim(); + result = CommandLauncher.executeSudoOutput(command); + int firstIndex = result.indexOf(""); + int lastIndex = result.lastIndexOf(""); + result = result.substring(firstIndex, lastIndex); + splitStr = result.split(""); + for (String s : splitStr) { + s = s.replaceAll(" ", "").replaceAll("", ""); String[] part = s.split(","); if (part.length == 3) { String name = part[0]; @@ -486,8 +489,9 @@ public class RPMPackageCommander { // get list using zypper String command = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(), getRemotePkgListCmd()); - //rec.cleanLog(); + rec.cleanLog(); executeDeviceShellCommand(device, command, rec); + for (String s : rec.getLog()) { s = s.replaceAll(" ", ""); String[] part = s.split("\\|"); @@ -517,10 +521,16 @@ public class RPMPackageCommander { // get installed packages using rpm command = String.format("%s;%s", getResetDbCmd(), getInstalledPkgListCmdDevice()); - //rec.cleanLog(); + rec.cleanLog(); executeDeviceShellCommand(device, command, rec); - for (String s : rec.getLog()) { - s = s.replaceAll(" ", "").trim(); + String result = rec.getLog()[0]; + int firstIndex = result.indexOf(""); + int lastIndex = result.lastIndexOf(""); + result = result.substring(firstIndex, lastIndex); + String[] splitStr = result.split(""); + + for (String s : splitStr) { + s = s.replaceAll(" ", "").replaceAll("", ""); String[] part = s.split(","); if (part.length == 3) { String name = part[0]; @@ -528,8 +538,7 @@ public class RPMPackageCommander { String arch = part[2]; Package pkg = packageHash.get(name); if (pkg == null) { - packageHash.put(name, new Package(name, version, "", - arch)); + packageHash.put(name, new Package(name, version, "", arch)); } else { pkg.setInstalledVersion(version); } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties index 55498e1..2c9ba35 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/RPMPackageCommands.properties @@ -11,8 +11,8 @@ Command.Refresh.Repo = zypper --non-interactive refresh Command.List.Repo = zypper lr -u Command.Reset.Repo = rm -rf /etc/zypp/repos.d/* Command.List.Remote.Pkg = zypper --non-interactive pa -Command.List.Installed.Pkg = rpm -qa --qf \\\"%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\n\\\" -Command.List.Installed.Pkg.Device = rpm -qa --qf \"%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\n\" +Command.List.Installed.Pkg = rpm -qa --qf \\\\%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\\\<\\\\/pkg\\\\> +Command.List.Installed.Pkg.Device = rpm -qa --qf \\%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\<\\/pkg\\> Command.Show.Pkg = rpm -qa %s Command.Show.Info.Pkg = rpm -qi %s Command.Info.Pkg.File = rpm -qp --qf "%%{%s}\n" %s -- 2.7.4