Package: wajig
Version: 2.7.3
Severity: important
Tags: patch

Hi,

The wajig update command (after apt-get update is finished) calls 'join
-v 1 | wc -l' command to get the number of newly available packages.
Just after that it uses very inefficient python code to actually save 
the list of new packages into .wajig/*/New file. 

On my system the first part, i.e. `join | wc pipe', takes less then
second, but the second part, namely double for loop in python, takes
a minute or more.

I'm attaching a patch that fixes the issue.

Regards,
Robert

-- System Information:
Debian Release: 7.0
  APT prefers unstable
  APT policy: (990, 'unstable'), (200, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.5-trunk-686-pae (SMP w/1 CPU core)
Locale: LANG=pl_PL, LC_CTYPE=pl_PL (charmap=ISO-8859-2)
Shell: /bin/sh linked to /bin/dash

Versions of packages wajig depends on:
ii  apt          0.9.7.8
ii  aptitude     0.6.8.2-1
ii  dpkg         1.16.10
ii  python3      3.2.3-6
ii  python3-apt  0.8.8.2

wajig recommends no packages.

Versions of packages wajig suggests:
ii  alien              8.88
ii  apt-file           2.5.1
pn  apt-move           <none>
ii  apt-show-versions  0.20
ii  dctrl-tools        2.22.2
ii  debconf            1.5.49
ii  deborphan          1.7.28.8
ii  debsums            2.0.52
ii  dpkg-dev           1.16.10
ii  dpkg-repack        1.37
ii  fakeroot           1.18.4-2
ii  locales            2.17-0experimental2
ii  netselect-apt      0.3.ds1-25
ii  reportbug          6.4.4
ii  sudo               1.8.5p2-1+nmu1
ii  vrms               1.16

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/wajig/util.py (from wajig package)
--- util.py.old	2013-04-11 21:14:09.911740385 +0200
+++ util.py	2013-04-11 21:15:59.367737810 +0200
@@ -123,12 +123,18 @@
     previous_packages = open(previous_file).readlines()
     diff = len(available_packages) - len(previous_packages)
 
+    temporary_file = tempfile.mkstemp()[1]
     # 090425 Use langC=True to work with change from coreutils 6.10 to 7.2
-    command = "join -v 1 -t' '  {0} {1} | wc -l"
-    command = command.format(available_file, previous_file)
+    command = "join -v 1 -t' '  {0} {1} | cut -d' ' -f 1 | tee {2} | wc -l"
+    command = command.format(available_file, previous_file, temporary_file)
     newest = perform.execute(command, pipe=True, langC=True)
     newest = newest.readlines()[0].strip()
 
+    if newest != "0":
+      os.rename(temporary_file, new_file)
+    else:
+      os.remove(temporary_file)
+
     if not noreport:
         if diff < 0:
             direction = str(0 - diff) + " down on"
@@ -143,17 +149,6 @@
         else:
             print("packages.")
 
-    packages = [package.split()[0] for package in available_packages]
-    old_packages = [package.split()[0] for package in previous_packages]
-    new_packages = list()
-    for package in packages:
-        if package not in old_packages:
-            new_packages.append(package)
-    if new_packages:
-        with open(new_file, 'w') as f:
-            [f.write(package + '\n') for package in new_packages]
-
-
 def gen_installed_command_str():
     """Generate command to list installed packages and their status."""
     # Use sort --unique. See comment in update_available().

Reply via email to