Author: locilka Date: Fri Jun 6 16:03:35 2008 New Revision: 48115 URL: http://svn.opensuse.org/viewcvs/yast?rev=48115&view=rev Log: - Using 'rpmqpack' in PackageSystem::PackageInstalled because it is a way faster than 'rpm' itself. Modified: trunk/yast2/library/packages/src/PackageSystem.ycp trunk/yast2/package/yast2.changes Modified: trunk/yast2/library/packages/src/PackageSystem.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/library/packages/src/PackageSystem.ycp?rev=48115&r1=48114&r2=48115&view=diff ============================================================================== --- trunk/yast2/library/packages/src/PackageSystem.ycp (original) +++ trunk/yast2/library/packages/src/PackageSystem.ycp Fri Jun 6 16:03:35 2008 @@ -253,6 +253,23 @@ return Pkg::IsAvailable(package); } +boolean _rpm_query_binary_initialized = false; +string _rpm_query_binary = "rpm"; + +void InitRPMQueryBinary () { + if (_rpm_query_binary_initialized) return; + + // rpmqpack is a way faster + if (SCR::Read (.target.size, "/usr/bin/rpmqpack") > -1) { + _rpm_query_binary = "/usr/bin/rpmqpack "; + // than rpm itself + } else if (SCR::Read (.target.size, "/bin/rpm") > -1) { + _rpm_query_binary = "/bin/rpm -q "; + } + + _rpm_query_binary_initialized = true; +} + /** * Is a package provided in the system? Is there any installed package providing 'package'? * @return true if yes @@ -273,12 +290,12 @@ * @return true if yes */ global boolean PackageInstalled(string package) { + InitRPMQueryBinary(); + // This is commonly called function and so it's // important that it's fast, especially in the common // case, where all dependencies are satisfied. - // Unfortunately, initializing Pkg reads the RPM database... - // so we must avoid it. - return 0 == (integer) SCR::Execute(.target.bash, "rpm -q " + package); + return 0 == (integer) SCR::Execute (.target.bash, _rpm_query_binary + package); } /** Modified: trunk/yast2/package/yast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/yast2/package/yast2.changes?rev=48115&r1=48114&r2=48115&view=diff ============================================================================== --- trunk/yast2/package/yast2.changes (original) +++ trunk/yast2/package/yast2.changes Fri Jun 6 16:03:35 2008 @@ -3,6 +3,8 @@ - Fixed Progress stages layout, stage-mark has a reseved space now (bnc #395752). +- Using 'rpmqpack' in PackageSystem::PackageInstalled because it is + a way faster than 'rpm' itself. ------------------------------------------------------------------- Wed Jun 4 16:32:13 CEST 2008 - lslezak@suse.cz -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org