tag 473175 patch
thanks

On Sun, 20 Apr 2008 18:55:12 +0200 Francesco Poli wrote:

> On Sun, 20 Apr 2008 16:27:58 +0900 Junichi Uekawa wrote:
[...]
> > Your logic sounds reasonable, patch is welcome. It's going to be a
> > major rewrite since aptcleanup currently is a very simple script.
> 
> I have to learn Ruby before I can implement my redesign.

OK, Ruby basics learnt, patch prepared.
I think I successfully implemented my aptcleanup redesign!

The attached patch modifies /usr/share/apt-listbugs/aptcleanup in order
to let it behave as I previously explained.
It also adds a copyright and permission notice: please *check* if I
correctly guessed years and copyright holders!!!  The rationale is:
since there was no copyright or permission notice, I think the general
permission notice found in debian/copyright applies to aptcleanup, but
it's better to include it explicitly...

BTW, legal details:
I hereby release my patch under the same terms of
/usr/share/apt-listbugs/aptcleanup, that is to say, under the terms of
the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.

Please review my aptcleanup rewrite and, if it looks OK to you, please
apply my patch and update debian/copyright accordingly.


Important notice
================
My aptcleanup rewrite *depends* on the apt-listbugs query command,
hence please apply my aptcleanup patch *after* you applied or at the
*same time* you apply the patch I sent for bug #476988 !!
Of course, you could also consider fixing bug #485109, while you are at
it...


Thank you for your attention and for maintaining apt-listbugs!


-- 
 http://frx.netsons.org/doc/index.html#nanodocs
 The nano-document series is here!
..................................................... Francesco Poli .
 GnuPG key fpr == C979 F34B 27CE 5CD8 DC12  31B5 78F4 279B DD6D FCF4
diff -ruN c/aptcleanup d/aptcleanup
--- c/aptcleanup	2008-05-13 00:00:19.000000000 +0200
+++ d/aptcleanup	2008-06-14 15:45:31.000000000 +0200
@@ -1,29 +1,68 @@
 #!/usr/bin/ruby -I/usr/share/apt-listbugs
+#
+# aptcleanup: filters /etc/apt/preferences to unpin packages when bugs are fixed
+#
+# Copyright (C) 2004-2005  Masato Taruishi <[EMAIL PROTECTED]>
+# Copyright (C) 2006-2008  Junichi Uekawa <[EMAIL PROTECTED]>
+# Copyright (C) 2008  Francesco Poli <[EMAIL PROTECTED]>
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License with
+#  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
+#  if not, write to the Free Software Foundation, Inc., 51 Franklin St,
+#  Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# 
 
 require 'debian/apt_preferences'
+APTCACHE = "/usr/bin/apt-cache"
+AWK = "/usr/bin/awk"
+LISTBUGS = "/usr/sbin/apt-listbugs"
 
 p = Debian::AptPreferences.new
-buf = ""
-p.pins.each do |pin|
-  buf << " " + pin["Package"] if pin.listbugs?
-end
-pinnedpkgs = buf.split(' ')
-$stderr.puts "Pinned: #{pinnedpkgs.sort.join(' ')}" if $DEBUG
+pinnedpkgs = []
 bugpkgs = []
-open("|/usr/sbin/apt-listbugs -y -q list #{buf}") { |io|
-  array = io.readlines()
-  if array.size != 0
-    buf = array[array.size-1].delete(' ').gsub(/\([^\)]+\)/,'').chomp
-    bugpkgs = buf.split(',')
+p.pins.each do |pin|
+  if pin.listbugs?
+    pinned_package = pin["Package"]
+    pinnedpkgs << pinned_package
+
+    # which version would get installed, if the pinning were removed ?
+    unpinned_candidate_version = `#{APTCACHE} -o Dir::Etc::Preferences=/dev/null policy #{pinned_package} | #{AWK} '/Candidate:/ { printf "/%s", $2; }'`
+    buf = pinned_package + unpinned_candidate_version.chomp + ' '
+
+    # read which bugs caused the pinning ("bugs that the user fears")
+    feared_bugs = pin["Explanation"].scan /#(\d+):/
+    buf << feared_bugs.join(' ')
+
+    # are bugs that the user fears still affecting unpinned_candidate_version ?
+    open("|#{LISTBUGS} -y -q query #{buf}") { |io|
+      array = io.readlines()
+      bugpkgs << pinned_package if array.size != 0
+    }
+    if $?.exitstatus != 0
+      $stderr.puts "Error... exiting!" if $DEBUG
+      exit 1
+    end
   end
-}
-if $?.exitstatus != 0
-  $stderr.puts "Error... exiting!" if $DEBUG
-  exit 1
 end
+
+$stderr.puts "Pinned: #{pinnedpkgs.sort.join(' ')}" if $DEBUG
 $stderr.puts "Bugs: #{bugpkgs.sort.join(' ')}" if $DEBUG
+
 if (pinnedpkgs - bugpkgs).size > 0
   $stderr.puts "#{(pinnedpkgs - bugpkgs).join(', ')} has been fixed"
 end
+
+# write out filtered preferences file
 p.filter( bugpkgs )
 

Attachment: pgpS7JQZztymN.pgp
Description: PGP signature

Reply via email to