On Sat, 14 Jun 2008 16:12:17 +0200 Francesco Poli wrote: [...] > The attached patch modifies /usr/share/apt-listbugs/aptcleanup in order > to let it behave as I previously explained.
The attached patch is an updated version. I added a little check, since I found out that a pinned package could be removed from the branch (say, testing) the user is using. In that case, the unpinned_candidate_version is "/(none)" and hence not usable: this would produce a shell error, if not handled properly. The attached version copes with this case, by dropping version specification entirely for package with no usable unpinned_candidate_version. I also added some debug messages. > 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... This still applies to the updated aptcleanup version. > > 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. And this also still holds for the updated aptcleanup 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... The important notice is still important, as well. -- 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 g/aptcleanup
--- c/aptcleanup 2008-05-13 00:00:19.000000000 +0200
+++ g/aptcleanup 2008-09-01 23:41:15.000000000 +0200
@@ -1,29 +1,74 @@
#!/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; }'`
+ unpinned_candidate_version.chomp!
+ if unpinned_candidate_version == "/(none)"
+ unpinned_candidate_version = ""
+ $stderr.puts "Warning: no candidate version for #{pinned_package}" if $DEBUG
+ end
+ buf = pinned_package + unpinned_candidate_version + ' '
+
+ # 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 ?
+ $stderr.puts "Examining #{buf}" if $DEBUG
+ 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 )
pgpE1TkxQFDj3.pgp
Description: PGP signature

