[yum-langpacks/f19] Fix issue of yum-langpacks commands that slows down yum runs (rh#1011670)

pnemade pnemade at fedoraproject.org
Wed Sep 25 08:23:16 UTC 2013


commit 9f52e44e5e8eeb7a077fcb8d5f3f9e654db7358c
Author: Parag Nemade <pnemade at redhat.com>
Date:   Wed Sep 25 13:52:57 2013 +0530

    Fix issue of yum-langpacks commands that slows down yum runs (rh#1011670)

 ...langtable-unless-we-need-it-it-takes-ages.patch |   38 +++++++++++++++++++
 ...oad-groups-and-setup-conditional_pkgs-unl.patch |   40 ++++++++++++++++++++
 yum-langpacks.spec                                 |   30 +++++++++-----
 3 files changed, 97 insertions(+), 11 deletions(-)
---
diff --git a/0001-Don-t-load-langtable-unless-we-need-it-it-takes-ages.patch b/0001-Don-t-load-langtable-unless-we-need-it-it-takes-ages.patch
new file mode 100644
index 0000000..0b2eb09
--- /dev/null
+++ b/0001-Don-t-load-langtable-unless-we-need-it-it-takes-ages.patch
@@ -0,0 +1,38 @@
+From c716e9c15762945817c487c2f43ec319760dd8b1 Mon Sep 17 00:00:00 2001
+From: James Antill <james at and.org>
+Date: Tue, 24 Sep 2013 15:02:07 -0400
+Subject: [PATCH 1/2] Don't load langtable unless we need it, it takes ages to
+ load.
+
+---
+ langpacks.py |   14 +++++++++++++-
+ 1 files changed, 13 insertions(+), 1 deletions(-)
+
+diff --git a/langpacks.py b/langpacks.py
+index 82fff57..7ca6ad8 100644
+--- a/langpacks.py
++++ b/langpacks.py
+@@ -30,7 +30,19 @@ import rpm
+ 
+ import yum.Errors
+ import yum.misc, sys
+-import langtable
++
++class _lazy_import_langtable:
++
++    def __init__(self):
++        self.mod = None
++
++    def __getattr__(self, name):
++        if self.mod is None:
++            import langtable
++            self.mod = langtable
++        return getattr(self.mod, name)
++
++langtable = _lazy_import_langtable()
+ 
+ def iterparse(filename):
+     try:
+-- 
+1.7.7.6
+
diff --git a/0002-Don-t-download-groups-and-setup-conditional_pkgs-unl.patch b/0002-Don-t-download-groups-and-setup-conditional_pkgs-unl.patch
new file mode 100644
index 0000000..7fc4af0
--- /dev/null
+++ b/0002-Don-t-download-groups-and-setup-conditional_pkgs-unl.patch
@@ -0,0 +1,40 @@
+From 7babcc4f89afbf4234325d2da84d4b37be560661 Mon Sep 17 00:00:00 2001
+From: James Antill <james at and.org>
+Date: Tue, 24 Sep 2013 15:02:33 -0400
+Subject: [PATCH 2/2] Don't download groups and setup conditional_pkgs unless
+ we need to.
+
+---
+ langpacks.py |    9 ++++++++-
+ 1 files changed, 8 insertions(+), 1 deletions(-)
+
+diff --git a/langpacks.py b/langpacks.py
+index 7ca6ad8..7212238 100644
+--- a/langpacks.py
++++ b/langpacks.py
+@@ -238,7 +238,10 @@ def init_hook(conduit):
+             conduit.info(3, "Adding %s to language list" % (lang,))
+             langs.append(lang)
+ 
+-def postreposetup_hook(conduit):
++# This takes ~0.2 seconds to init, so don't do it for non-transaction commands.
++# This does mean we might end up downloading the groups file in postresolve,
++# but meh.
++def my_postreposetup_hook(conduit):
+     global conditional_pkgs
+ 
+     for repo in conduit.getRepos().listEnabled():
+@@ -422,6 +425,10 @@ def remove_matches_from_ts(conduit, lang, base = None):
+             continue
+ 
+ def postresolve_hook(conduit):
++    # This takes ~0.2 seconds to init, so only do it if we need to
++    if not conditional_pkgs:
++        my_postreposetup_hook(conduit)
++
+     yb = conduit._base
+     groups_added = []
+     groups_removed = []
+-- 
+1.7.7.6
+
diff --git a/yum-langpacks.spec b/yum-langpacks.spec
index 2897619..11384cf 100644
--- a/yum-langpacks.spec
+++ b/yum-langpacks.spec
@@ -1,16 +1,19 @@
-Summary: Langpacks plugin for yum
-Name: yum-langpacks
-Version: 0.4.1
-Release: 1%{?dist}
-License: GPLv2+
-Group: Development/Tools
-Source0: https://fedorahosted.org/releases/y/u/%{name}/%{name}-%{version}.tar.gz
-URL: https://fedorahosted.org/yum-langpacks/
-BuildArch: noarch
+Summary:       Langpacks plugin for yum
+Name:          yum-langpacks
+Version:       0.4.1
+Release:       2%{?dist}
+License:       GPLv2+
+Group:         Development/Tools
+Source0:       https://fedorahosted.org/releases/y/u/%{name}/%{name}-%{version}.tar.gz
+# following both patches are from rh#1011670
+Patch0:        0001-Don-t-load-langtable-unless-we-need-it-it-takes-ages.patch
+Patch1:        0002-Don-t-download-groups-and-setup-conditional_pkgs-unl.patch
+URL:           https://fedorahosted.org/yum-langpacks/
+BuildArch:     noarch
 BuildRequires: python-setuptools
 BuildRequires: python2-devel
-Requires: yum >= 3.0
-Requires: langtable-python
+Requires:      yum >= 3.0
+Requires:      langtable-python
 
 %description
 Yum-langpacks is a plugin for YUM that looks for langpacks for your native
@@ -18,6 +21,8 @@ language for packages you install.
 
 %prep
 %setup -q
+%patch0 -p1
+%patch1 -p1
 
 %build
 
@@ -35,6 +40,9 @@ install -p -m 644 yum-langpacks.8.gz %{buildroot}%{_mandir}/man8/yum-langpacks.8
 %{_mandir}/man8/yum-langpacks.8.gz
 
 %changelog
+* Wed Sep 25 2013 Parag Nemade <pnemade AT redhat DOT com> - 0.4.1-2
+- Fix issue of yum-langpacks commands that slows down yum runs (rh#1011670)
+
 * Thu Sep 12 2013 Parag Nemade <pnemade AT redhat DOT com> - 0.4.1-1
 - Fix yum langavailable command output (rh#1006695)
 


More information about the scm-commits mailing list