[Apt-listbugs-commits] [apt-listbugs] 01/01: improve detection of previous pins

Francesco Poli frx-guest at moszumanska.debian.org
Wed Jul 2 21:09:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

frx-guest pushed a commit to branch master
in repository apt-listbugs.

commit 12bcf7fb03aca6c914e258c1c8cc0dcfed4f71cd
Author: Francesco Poli (wintermute) <invernomuto at paranoici.org>
Date:   Wed Jul 2 23:04:02 2014 +0200

    improve detection of previous pins
    
    When pinning buggy packages (with the 'p' menu command),
    /etc/apt/preferences is parsed in order to avoid pinning already
    pinned packages. The AptPreferences class is now used to
    parse preferences correctly.
---
 debian/changelog          |  1 +
 lib/apt-listbugs/logic.rb | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index deb197e..2af8f51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,7 @@ apt-listbugs (0.1.14) UNRELEASED; urgency=medium
        does not exist or is not readable
      - clarified one debug message
      - internationalized non-debug messages 
+  * improved detection of previous pins when pinning buggy packages
 
  -- Francesco Poli (wintermute) <invernomuto at paranoici.org>  Sun, 11 May 2014 16:45:18 +0200
 
diff --git a/lib/apt-listbugs/logic.rb b/lib/apt-listbugs/logic.rb
index df7085c..64bc7a5 100644
--- a/lib/apt-listbugs/logic.rb
+++ b/lib/apt-listbugs/logic.rb
@@ -33,6 +33,7 @@ require 'thread'
 require 'tempfile'
 require 'gettext'
 require 'rss/maker'
+require 'debian/apt_preferences'
 
 include GetText
 
@@ -481,9 +482,17 @@ class Viewer
           end
           pkgs = {}
           if cmd == "p"
+            prev_pinned_pkgs = {}
+            begin
+              p = Debian::AptPreferences.new
+              p.pins.each { |pin|
+                prev_pinned_pkgs[pin["Package"]] = 1
+              }
+            rescue
+              # something went wrong while parsing preferences: assume no pins
+            end
             bugs.each { |bug|
-              # TODO: need to parse preferences correctly?
-              if ! system("grep -q \"^Package: #{bug.pkg_key} *$\" /etc/apt/preferences 2> /dev/null")
+              if ! prev_pinned_pkgs.has_key?(bug.pkg_key)
                 pkgs[bug.pkg_key] = 1
               end
             }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/apt-listbugs/apt-listbugs.git



More information about the Apt-listbugs-commits mailing list