[Apt-listbugs-commits] [apt-listbugs] 03/06: become MultiArch aware (Closes: #688506)
Francesco Poli
frx-guest at alioth.debian.org
Fri Oct 4 17:19:14 UTC 2013
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 327a8942388e5f53731b00dece548fa1dd28ffe9
Author: Francesco Poli (wintermute) <invernomuto at paranoici.org>
Date: Wed Oct 2 23:25:01 2013 +0200
become MultiArch aware (Closes: #688506)
On MultiArch-enabled systems, copies of the same package for different
architectures are now treated as distinct packages and may be acted upon
independently.
For instance: during the installation of <pkg>:<arch1> and <pkg>:<arch2>,
the user may choose to pin the latter, but not the former; during an
APT session in which <pkg>:<arch1> is being upgraded and <pkg>:<arch2>
is being installed, the relevant bugs for the two copies of <pkg> may be
different; and so forth...
In apt mode, package copies are now shown as <pkg>:<arch>, unless <arch>
is "all" or the native architecture (in these cases the bare package
name <pkg> is used).
---
apt-listbugs | 72 ++++++++++-----
aptcleanup | 28 +++---
debian/TODO | 1 -
debian/changelog | 4 +
lib/apt-listbugs/logic.rb | 205 +++++++++++++++++++++--------------------
lib/debian/apt_preferences.rb | 18 ++--
lib/debian/bts.rb | 18 ++--
lib/debian/btssoap.rb | 39 ++++----
lib/debian/bug.rb | 19 ++--
test_logic.rb | 24 +++++
10 files changed, 249 insertions(+), 179 deletions(-)
diff --git a/apt-listbugs b/apt-listbugs
index a2d8339..d687d07 100755
--- a/apt-listbugs
+++ b/apt-listbugs
@@ -150,16 +150,20 @@ apt-listbugs [-h] [-v] [-s <severities>] [-T <tags>] [-S <states>] [-B <bug#>] [
or other compatible package manager; Pre-Install-Pkgs hook info
protocol version 3 is expected - see apt.conf(5) for more details).
-: list [<package1[/version]> <package2[/version]>...]
+: list [<package1[:arch][/version]> <package2[:arch][/version]>...]
Reads package names from the arguments and simply lists bugs of
these packages. Package versions may be specified with a slash, as in
- apt/1.0 for example.
+ apt/1.0 for example. Package architectures may be specified with a colon,
+ as in apt:amd64 or apt:amd64/1.0 (but please note that the Debian Bug
+ Tracking System does not distinguish the architectures, hence the
+ same bugs will be listed, regardless of the specified architecture).
-: rss [<package1[/version]> <package2[/version]>...]
+: rss [<package1[:arch][/version]> <package2[:arch][/version]>...]
Reads package names from the arguments and lists bugs of these packages
- in RSS format. Again, package versions may be specified with a slash.
+ in RSS format. Again, package versions may be specified with a slash
+ and architectures with a colon.
== ENVIRONMENT VARIABLES
@@ -308,7 +312,7 @@ Factory.config = config
# handle arguments
new_pkgs = {}
cur_pkgs = {}
-holdpkgs = {}
+native_arch = nil
case config.command
when "apt"
# parse apt VERSION 3 input.
@@ -351,6 +355,11 @@ when "apt"
when ""
puts "#{pkg}" if $DEBUG
state=3
+ when /^APT::Architecture=(.*)/
+ if $1
+ puts "#{pkg}" if $DEBUG
+ native_arch=$1
+ end
when /^quiet=(.*)/
if $1.to_i > 0
puts "#{pkg}" if $DEBUG
@@ -360,7 +369,7 @@ when "apt"
when 3
# package action lines
puts "#{pkg}" if $DEBUG
- pkgname, old_ver, old_arch, old_ma, direction, new_ver, new_arch, new_ma, filename = pkg.split(" ")
+ pkg_name, old_ver, old_arch, old_ma, direction, new_ver, new_arch, new_ma, filename = pkg.split(" ")
case filename
when "**CONFIGURE**"
# none
@@ -377,16 +386,23 @@ when "apt"
when ">", "<"
# ">" means downgrade, "<" means upgrade
if ( config.show_downgrade or direction == "<" )
- if ( pkgname != nil and new_ver != "-" )
+ if ( pkg_name != nil and new_ver != "-" )
f = {}
- f["package"] = pkgname
+ f["package"] = pkg_name
f["version"] = new_ver
- new_pkgs[f["package"]] = f
+ # pkg_key is the package full name (<pkg_name> for native and
+ # "all" architecture packages, <pkg_name>:<arch> for foreign
+ # architecture packages)
+ pkg_key = pkg_name
+ if ( new_arch != nil and new_arch != "all" and new_arch != native_arch )
+ pkg_key = pkg_name + ":" + new_arch
+ end
+ new_pkgs[pkg_key] = f
if ( old_ver != "-" )
f = {}
- f["package"] = pkgname
+ f["package"] = pkg_name
f["version"] = old_ver
- cur_pkgs[f["package"]] = f
+ cur_pkgs[pkg_key] = f
end
end
end
@@ -400,18 +416,20 @@ when "apt"
apt_hook_stream.close
puts if $DEBUG
when "list", "rss"
- ARGV.each { |pkg|
- # parse 'apt-listbugs list pkgname/version .... ' combination
- if ( pkg != nil )
+ ARGV.each { |pkg_key|
+ # parse 'apt-listbugs list pkg_name:arch/version ... ' combination
+ if ( pkg_key != nil )
f = {}
- case pkg
- when /^(.*)\/(.*)$/
- f["package"] = $1
+ if /^(.*)\/(.*)$/ =~ pkg_key
+ pkg_key = $1
f["version"] = $2
+ end
+ if /^(.*):(.*)$/ =~ pkg_key
+ f["package"] = $1
else
- f["package"] = pkg
+ f["package"] = pkg_key
end
- new_pkgs[f["package"]] = f
+ new_pkgs[pkg_key] = f
end
}
end
@@ -419,12 +437,22 @@ end
exit 0 if new_pkgs.size == 0
Factory::BugsFactory.delete_ignore_pkgs(new_pkgs) if config.command == "apt"
-# exitting if no new packages is found
+
exit 0 if new_pkgs.size == 0
-# reading bug reports
+# build the multiarch map: for each pkg_name, list the corresponding pkg_keys
+ma_copies = {}
+new_pkgs.each_pair { |pkg_key, pkg|
+ pkg_name = pkg["package"]
+ if ( pkg_name != nil )
+ ma_copies[pkg_name] = [] if ma_copies[pkg_name] == nil
+ ma_copies[pkg_name] << pkg_key
+ end
+}
+
+# read bug reports
begin
- bugs = Factory::BugsFactory.create(new_pkgs, cur_pkgs) { |msg, val|
+ bugs = Factory::BugsFactory.create(ma_copies) { |msg, val|
config.frontend.progress(msg, val) if config.quiet == false
}
rescue
diff --git a/aptcleanup b/aptcleanup
index 2f2d13b..6e736b6 100755
--- a/aptcleanup
+++ b/aptcleanup
@@ -4,7 +4,7 @@
#
# Copyright (C) 2004 Masato Taruishi <taru at debian.org>
# Copyright (C) 2007 Jean Lepropre <jlepropre at gmail.com>
-# Copyright (C) 2008-2012 Francesco Poli <invernomuto at paranoici.org>
+# Copyright (C) 2008-2013 Francesco Poli <invernomuto at paranoici.org>
# Copyright (C) 2009 Ryan Niebur <ryan at debian.org>
#
# This program is free software; you can redistribute it and/or modify
@@ -38,19 +38,19 @@ LISTBUGS = "/usr/sbin/apt-listbugs"
# read apt preferences
p = Debian::AptPreferences.new
-pinnedpkgs = []
-bugpkgs = []
+pinned_pkg_keys = []
+buggy_pkg_keys = []
# store apt preferences with no apt-listbugs pins in a temporary file
unpinned_pref_file = Tempfile.new('apt_preferences_')
-p.filter( bugpkgs, unpinned_pref_file )
+p.filter( buggy_pkg_keys, unpinned_pref_file )
unpinned_pref_file.flush
unpinned_preferences = unpinned_pref_file.path
p.pins.each do |pin|
if pin.listbugs?
pinned_package = pin["Package"]
- pinnedpkgs << pinned_package
+ pinned_pkg_keys << pinned_package
# which version would get installed, if the pinning were removed ?
unpinned_candidate_version = nil
@@ -65,21 +65,21 @@ p.pins.each do |pin|
unpinned_candidate_version = ""
$stderr.puts "Warning: no candidate version for #{pinned_package}" if $DEBUG
end
- pack_with_vers = pinned_package + unpinned_candidate_version
+ pkg_key_with_vers = pinned_package + unpinned_candidate_version
# read which bugs caused the pinning ("bugs that the user fears")
feared_bugs = pin["Explanation"].scan(/#(\d+):/)
feared_list = feared_bugs.join(',')
# are bugs that the user fears still affecting unpinned_candidate_version ?
- $stderr.puts "Checking bug(s) #{feared_list} for #{pack_with_vers}" if $DEBUG
+ $stderr.puts "Checking bug(s) #{feared_list} for #{pkg_key_with_vers}" if $DEBUG
optionB = nil
if feared_list != "" and feared_list != nil
optionB = "-B #{feared_list}"
end
- open("|#{LISTBUGS} -y -q #{optionB} list #{pack_with_vers}") { |io|
+ open("|#{LISTBUGS} -y -q #{optionB} list #{pkg_key_with_vers}") { |io|
array = io.readlines()
- bugpkgs << pinned_package if array.size != 0
+ buggy_pkg_keys << pinned_package if array.size != 0
}
if $?.exitstatus != 0
$stderr.puts "Error... exiting!" if $DEBUG
@@ -91,13 +91,13 @@ end
# get rid of the temporary file
unpinned_pref_file.close!
-$stderr.puts "Pinned packages: #{pinnedpkgs.sort.join(' ')}" if $DEBUG
-$stderr.puts "Buggy packages : #{bugpkgs.sort.join(' ')}" if $DEBUG
+$stderr.puts "Pinned packages: #{pinned_pkg_keys.sort.join(' ')}" if $DEBUG
+$stderr.puts "Buggy packages : #{buggy_pkg_keys.sort.join(' ')}" if $DEBUG
-if (pinnedpkgs - bugpkgs).size > 0
- $stderr.puts "Fixed packages : #{(pinnedpkgs - bugpkgs).sort.join(' ')}"
+if (pinned_pkg_keys - buggy_pkg_keys).size > 0
+ $stderr.puts "Fixed packages : #{(pinned_pkg_keys - buggy_pkg_keys).sort.join(' ')}"
end
# write out filtered preferences file
-p.filter( bugpkgs )
+p.filter( buggy_pkg_keys )
diff --git a/debian/TODO b/debian/TODO
index aab846b..e75e22c 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -7,7 +7,6 @@ Release goals for version 0.2.0
Release goals for version 0.3.0
-------------------------------
-* close #688506 - apt-listbugs: should show package arch when listing bugs
* close #532678 - apt-listbugs: faster method to select bugs
* close #257873 - apt-listbugs: can check not only designated packages but also its source packages
* close #484423 - manually ignored bugs should have a comment, too
diff --git a/debian/changelog b/debian/changelog
index e05139a..b61fda3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,10 @@ apt-listbugs (0.1.10) UNRELEASED; urgency=low
list of severities the user is interested in
* fixed "support ruby 1.9", thanks to Antonio Terceiro for packaging
ruby-soap4r and for providing the initial patch (Closes: #432200)
+ * fixed "should show package arch when listing bugs" by reading version
+ 3 hook information and treating copies of the same package for different
+ architectures as distinct packages that may be acted upon independently
+ (Closes: #688506)
-- Francesco Poli (wintermute) <invernomuto at paranoici.org> Sat, 29 Jun 2013 17:18:26 +0200
diff --git a/lib/apt-listbugs/logic.rb b/lib/apt-listbugs/logic.rb
index af7cca6..9f5f927 100644
--- a/lib/apt-listbugs/logic.rb
+++ b/lib/apt-listbugs/logic.rb
@@ -369,11 +369,11 @@ class Viewer
end
answer = "n"
- hold_pkgs = []
+ hold_pkg_keys = []
while true
ask_str = _("Are you sure you want to install/upgrade the above packages?").dup
if @config.querybts != nil || @config.browser != nil
- if hold_pkgs.empty?
+ if hold_pkg_keys.empty?
ask_str << " [Y/n/?/...]"
else
ask_str << " [N/?/...]"
@@ -388,7 +388,7 @@ class Viewer
a = "n" if ! @config.yes
end
if a == ""
- if hold_pkgs.empty?
+ if hold_pkg_keys.empty?
answer = "y"
else
answer = "n"
@@ -397,10 +397,12 @@ class Viewer
answer = a.downcase
end
case answer
+
when "y"
return true
+
when "a"
- if hold_pkgs.empty?
+ if hold_pkg_keys.empty?
bugs.each { |bug|
if ! @config.system_ignore_bugs.include?(bug.bug_number)
@config.system_ignore_bugs.add(bug)
@@ -409,14 +411,17 @@ class Viewer
}
return true
end
+
when "n"
return false
+
when /^#?(\d+)$/
if @config.querybts != nil
system("#{@config.querybts} -u text #{$1}")
else
@config.frontend.puts sprintf(_("You must install the reportbug package to be able to do this"))
end
+
when /^i\s+(\d+)$/
if ! @config.system_ignore_bugs.include?($1)
@config.system_ignore_bugs.add($1)
@@ -425,46 +430,47 @@ class Viewer
else
@config.frontend.puts sprintf(_("%s already ignored"), $1)
end
+
when "r"
- display_bugs(bugs, new_pkgs.keys - hold_pkgs, cur_pkgs, new_pkgs)
+ display_bugs(bugs, new_pkgs.keys - hold_pkg_keys, cur_pkgs, new_pkgs)
when /^(h|p)\s+(.+)$/
- key = $1
- if key == "h"
+ cmd = $1
+ if cmd == "h"
@config.frontend.puts DeprecatedWarningHeader
@config.frontend.puts DeprecatedWarning
@config.frontend.puts DeprecatedWarningHeader
end
- pkgs = $2.split(/\s+/)
- if key == "h"
- h = on_hold(pkgs)
+ pkg_keys = $2.split(/\s+/)
+ if cmd == "h"
+ h = on_hold(pkg_keys)
else
- h = pinned(pkgs, cur_pkgs, bugs)
+ h = pinned(pkg_keys, cur_pkgs, bugs)
end
- hold_pkgs.concat(h) if h != nil
+ hold_pkg_keys.concat(h) if h != nil
when "w"
puts bugs if $DEBUG
- display_bugs_as_html(bugs, cur_pkgs.keys - hold_pkgs, cur_pkgs, new_pkgs) if @config.browser != nil
+ display_bugs_as_html(bugs, cur_pkgs, new_pkgs) if @config.browser != nil
when /(h|p)/
- key = $1
- if key == "h"
+ cmd = $1
+ if cmd == "h"
@config.frontend.puts DeprecatedWarningHeader
@config.frontend.puts DeprecatedWarning
@config.frontend.puts DeprecatedWarningHeader
end
pkgs = {}
- if key == "p"
+ if cmd == "p"
bugs.each { |bug|
# TODO: need to parse preferences correctly?
- if ! system("grep -q \"Package: #{bug.pkg_name}\" /etc/apt/preferences 2> /dev/null")
- pkgs[bug.pkg_name] = 1
+ if ! system("grep -q \"Package: #{bug.pkg_key}\" /etc/apt/preferences 2> /dev/null")
+ pkgs[bug.pkg_key] = 1
end
}
else
bugs.each { |bug|
- pkgs[bug.pkg_name] = 1
+ pkgs[bug.pkg_key] = 1
}
end
if pkgs.size != 0
@@ -474,18 +480,19 @@ class Viewer
"The following %{npkgs} packages will be pinned or on hold:\n %{plist}\nAre you sure?",
pkgs.size) % {:npkgs => pkgs.size,
:plist => pkgs.keys.join(', ')}
- if key == "h"
+ if cmd == "h"
h = on_hold(pkgs.keys)
else
h = pinned(pkgs.keys, cur_pkgs, bugs)
end
end
- hold_pkgs.concat(h) if h != nil
+ hold_pkg_keys.concat(h) if h != nil
else
- @config.frontend.puts sprintf(_("All selected packages are already pinned or on hold. Ignoring %s command."), key)
+ @config.frontend.puts sprintf(_("All selected packages are already pinned or on hold. Ignoring %s command."), cmd)
end
+
else
- if hold_pkgs.empty?
+ if hold_pkg_keys.empty?
@config.frontend.puts "" +
# TRANSLATORS: the dashes (-) in the following strings are vertically aligned, please keep their alignment consistent
_(" y - continue the apt installation, but do not mark the bugs\n as ignored.\n") +
@@ -507,75 +514,75 @@ class Viewer
end
end
- def bugs_of_pkg( bugs, pkg )
+ def bugs_of_pkg( bugs, pkg_key )
b = []
bugs.each { |bug|
- b << bug if bug.pkg_name == pkg
+ b << bug if bug.pkg_key == pkg_key
}
b
end
- def pinned(pkgs, cur_pkgs, bugs)
+ def pinned(pkg_keys, cur_pkgs, bugs)
holdstr = ""
- pkgs.each { |pkg|
+ pkg_keys.each { |pkg_key|
pin_ver = "0.no.version"
pin_pri = @config.pin_priority
- if cur_pkgs[pkg] != nil
- pin_ver = cur_pkgs[pkg]['version']
+ if cur_pkgs[pkg_key] != nil
+ pin_ver = cur_pkgs[pkg_key]['version']
else
pin_ver = "*"
pin_pri = "-30000"
end
holdstr << "\nExplanation: Pinned by apt-listbugs at #{Time.now}"
- bugs_of_pkg( bugs, pkg ).each { |bug|
+ bugs_of_pkg( bugs, pkg_key ).each { |bug|
holdstr << "\nExplanation: ##{bug.bug_number}: #{bug.desc}"
}
- holdstr << "\nPackage: #{pkg}\nPin: version #{pin_ver}"
+ holdstr << "\nPackage: #{pkg_key}\nPin: version #{pin_ver}"
holdstr << "\nPin-Priority: #{pin_pri}\n"
}
$stderr.puts holdstr if $DEBUG
if holdstr != ""
File.open("/etc/apt/preferences", "a") { |io|
io.puts holdstr
- @config.frontend.puts sprintf(_("%s pinned by adding Pin preferences in /etc/apt/preferences. Restart APT session to enable"), pkgs.join(' '))
- return pkgs
+ @config.frontend.puts sprintf(_("%s pinned by adding Pin preferences in /etc/apt/preferences. Restart APT session to enable"), pkg_keys.join(' '))
+ return pkg_keys
}
end
return nil
end
- def on_hold (pkgs)
+ def on_hold (pkg_keys)
holdstr = ""
- pkgs.each { |pkg|
- holdstr << "#{pkg} hold\n"
+ pkg_keys.each { |pkg_key|
+ holdstr << "#{pkg_key} hold\n"
}
if system("echo '#{holdstr}' | dpkg --set-selections")
- @config.frontend.puts sprintf(_("%s held. Restart APT session to enable"), pkgs.join(' '))
- return pkgs
+ @config.frontend.puts sprintf(_("%s held. Restart APT session to enable"), pkg_keys.join(' '))
+ return pkg_keys
end
return nil
end
- def display_bugs(bugs, pkgs, cur_pkgs, new_pkgs)
+ def display_bugs(bugs, pkg_keys, cur_pkgs, new_pkgs)
# routine to display every bug that is available and relevant
- p_bug_numbers = []
bugs_statistics = {}
@config.stats.each { |stat|
@config.severity.each { |severity|
- pkgs.each { |pkg|
+ pkg_keys.each { |pkg_key|
+ p_bug_numbers = []
bug_exist = 0
- bugs_statistics[pkg] = 0 unless bugs_statistics[pkg]
- bugs.each_by_category(pkg, severity, stat) { |bug|
+ bugs_statistics[pkg_key] = 0 unless bugs_statistics[pkg_key]
+ bugs.each_by_category(pkg_key, severity, stat) { |bug|
next if p_bug_numbers.include?(bug.bug_number)
- bugs_statistics[pkg] += 1
+ bugs_statistics[pkg_key] += 1
p_bug_numbers << bug.bug_number
if bug_exist == 0
# TRANSLATORS: %{sevty} is the severity of some of the bugs found for package %{packg}.
buf = _("%{sevty} bugs of %{packg} (") % {:sevty => severity,
- :packg => pkg}
- buf += "#{cur_pkgs[pkg]['version']} " if cur_pkgs[pkg] != nil
- buf += "#{@config.arrow} #{new_pkgs[pkg]['version']}) <#{@config.statmap(bug.stat)}>"
+ :packg => pkg_key}
+ buf += "#{cur_pkgs[pkg_key]['version']} " if cur_pkgs[pkg_key] != nil
+ buf += "#{@config.arrow} #{new_pkgs[pkg_key]['version']}) <#{@config.statmap(bug.stat)}>"
@config.frontend.puts buf
bug_exist = 1
end
@@ -599,11 +606,11 @@ class Viewer
}
}
stat_str_ary = []
- bugs_statistics.each { |pkg, num|
+ bugs_statistics.each_pair { |pkg_key, num|
if num > 0
# TRANSLATORS: %{nbugs} is the number of bugs found for package %{packg}.
buf = ngettext("%{packg}(%{nbugs} bug)",
- "%{packg}(%{nbugs} bugs)", num) % {:packg => pkg,
+ "%{packg}(%{nbugs} bugs)", num) % {:packg => pkg_key,
:nbugs => num}
stat_str_ary << buf
end
@@ -639,11 +646,7 @@ class Viewer
}
end
- def display_bugs_as_html(bugs, pkgs, cur_pkgs, new_pkgs)
- bug_exist_for_stat = 0
- bug_exist_for_pkg = 0
- bug_exist = 0
-
+ def display_bugs_as_html(bugs, cur_pkgs, new_pkgs)
tmp = Tempfile.new(["apt-listbugs", ".html"])
tmp.chmod(0644)
tmp.puts "<?xml version=\"1.0\" encoding=\"#{Locale.charset}\"?>"
@@ -661,12 +664,12 @@ class Viewer
each_state_table(tmp, bugs, @config.stats) { |bugs|
bugs.each { |bug|
- pkg = bug.pkg_name
+ pkg_key = bug.pkg_key
tmp.puts "\n <tr class=\"#{bug.severity}\">"
- tmp.puts " <td class=\"pkg\">#{pkg}</td>"
+ tmp.puts " <td class=\"pkg\">#{pkg_key}</td>"
tmp.print "\n <td>"
- tmp.print "#{cur_pkgs[pkg]['version']} " if cur_pkgs[pkg] != nil
- tmp.print "#{@config.xarrow} #{new_pkgs[pkg]['version']}" if new_pkgs[pkg] != nil
+ tmp.print "#{cur_pkgs[pkg_key]['version']} " if cur_pkgs[pkg_key] != nil
+ tmp.print "#{@config.xarrow} #{new_pkgs[pkg_key]['version']}" if new_pkgs[pkg_key] != nil
tmp.puts "</td>\n\n <td>#{bug.severity}</td>"
tmp.puts "\n <td><a href=\"http://bugs.debian.org/#{bug.bug_number}\">##{bug.bug_number}</a></td>"
tmp.puts "\n <td class=\"desc\">#{bug.desc}</td>\n </tr>"
@@ -737,7 +740,7 @@ class Viewer
buf << "<ul>\n"
buf << "<li>Bug##{bug.bug_number}</li>\n"
- buf << "<li>Package: #{bug.pkg_name}</li>\n"
+ buf << "<li>Package: #{bug.pkg_key}</li>\n"
buf << "<li>Severity: #{bug.severity}</li>\n"
buf << "<li>Status: #{bug.stat}</li>\n"
buf << "<li>Tags: #{bug.tags.join(',')}</li>\n" if bug.tags != nil
@@ -793,29 +796,22 @@ module Factory
extend Factory
def delete_ignore_pkgs(new_pkgs)
- new_pkgs.delete_if { |name, pkg|
- config.system_ignore_bugs.include?(name)
+ new_pkgs.delete_if { |pkg_key, pkg|
+ config.system_ignore_bugs.include?(pkg_key)
}
end
- def create(new_pkgs, *args, &progress)
- cur_pkgs = args[0]
+ def create(ma_copies)
bugs = Debian::Bugs.new
- pkg_step = 100 / new_pkgs.size.to_f
retrycount = 10 # retry 10 times
- size = new_pkgs.size
mutex = Mutex.new
threads = []
# TRANSLATORS: this sentence, followed by the translation of "Done" (see above) should fit in less than 79 columns to work well with default width terminals
yield _("Retrieving bug reports..."), "0%"
begin
- # obtain a list of package names
- tmppkgs = []
- new_pkgs.each_key { |k| tmppkgs << k }
-
- # send the list of package names and severity to be parsed.
- bugs = config.parser.parse(tmppkgs, config.severity) { |pct|
+ # obtain the array of bugs
+ bugs = config.parser.parse(ma_copies, config.severity) { |pct|
yield _("Retrieving bug reports..."), pct
}
rescue SOAP::HTTPStreamError => exception
@@ -872,20 +868,20 @@ module Factory
bugs.delete_if { |bug| !config.fbugs.include?(bug.bug_number)}
end
- def iterate_fixed_found_version(bts_versions, pkg_name)
+ def iterate_fixed_found_version(bts_versions, src_name)
# iterate relevant versions, used to parsing Fixed and Found tags of BTS
if bts_versions.nil?
return;
end
bts_versions.split(" ").each { |version|
- # check each fixed_version
+ # check each version
case version
when /^(.*)\/(.*)$/
- if $1 == pkg_name # TODO: actually, this need to be source_name
+ if $1 == src_name
yield $2
else
- # TODO: ignore this until I figure out how to get source_name instead of pkg_name
- #fixed_ver=nil
+ # TODO: ignore this until src_name is really the source package name
+ # yield nil
yield $2
end
else
@@ -894,39 +890,39 @@ module Factory
}
end
- def find_max_version_below_ver(bts_versions, new_ver, pkg_name)
+ def find_max_version_below_ver(bts_versions, new_ver, src_name)
# find the max version from found/fixed that is below or equal to new_ver
# data format of bts_versions:
- # space-delimited sequence of PACKAGE/VERSION or VERSION items.
+ # space-delimited sequence of SRC_PACKAGE/VERSION or VERSION items.
maxver=nil
- iterate_fixed_found_version(bts_versions, pkg_name) { |each_ver|
- # check each fixed_ver
- if Debian::Dpkg.compare_versions(each_ver, "le", new_ver) &&
- ( maxver == nil || Debian::Dpkg.compare_versions(maxver, "le", each_ver) )
- maxver = each_ver
+ iterate_fixed_found_version(bts_versions, src_name) { |ver|
+ # check each ver
+ if Debian::Dpkg.compare_versions(ver, "le", new_ver) &&
+ ( maxver == nil || Debian::Dpkg.compare_versions(maxver, "le", ver) )
+ maxver = ver
end
}
maxver
end
- def find_min_version_above_ver(bts_versions, new_ver, pkg_name)
+ def find_min_version_above_ver(bts_versions, new_ver, src_name)
# find the min version from found/fixed that is strictly above new_ver
# data format of bts_versions:
- # space-delimited sequence of PACKAGE/VERSION or VERSION items.
+ # space-delimited sequence of SRC_PACKAGE/VERSION or VERSION items.
minver=nil
- iterate_fixed_found_version(bts_versions, pkg_name) { |each_ver|
- # check each each_ver
- if Debian::Dpkg.compare_versions(each_ver, "gt", new_ver) &&
- ( minver == nil || Debian::Dpkg.compare_versions(minver, "ge", each_ver) )
- minver = each_ver
+ iterate_fixed_found_version(bts_versions, src_name) { |ver|
+ # check each ver
+ if Debian::Dpkg.compare_versions(ver, "gt", new_ver) &&
+ ( minver == nil || Debian::Dpkg.compare_versions(minver, "ge", ver) )
+ minver = ver
end
}
minver
end
- def am_i_buggy(ver, fixed, found)
+ def am_i_buggy(src_name, ver, fixed, found)
# find out if this version is buggy or not depending on the
# fixed / found arrays.
@@ -938,11 +934,11 @@ module Factory
fixed_min_above = nil
found_min_above = nil
- fixed_max_below = find_max_version_below_ver(fixed, ver, name) if ! fixed.nil?
- found_max_below = find_max_version_below_ver(found, ver, name) if ! found.nil?
+ fixed_max_below = find_max_version_below_ver(fixed, ver, src_name) if ! fixed.nil?
+ found_max_below = find_max_version_below_ver(found, ver, src_name) if ! found.nil?
- fixed_min_above = find_min_version_above_ver(fixed, ver, name) if ! fixed.nil?
- found_min_above = find_min_version_above_ver(found, ver, name) if ! found.nil?
+ fixed_min_above = find_min_version_above_ver(fixed, ver, src_name) if ! fixed.nil?
+ found_min_above = find_min_version_above_ver(found, ver, src_name) if ! found.nil?
val=true
@@ -991,7 +987,7 @@ module Factory
val
end
- def bug_is_irrelevant(name, cur_ver, new_ver, bug_number, fixed, found, bug_stat="")
+ def bug_is_irrelevant(src_name, cur_ver, new_ver, bug_number, fixed, found, bug_stat="")
# find out if the bug number is irrelevant for this specific upgrade, from fixed/found information.
# @return false: bug is relevant, true: bug is irrelevant, should be removed.
val = false
@@ -1008,10 +1004,10 @@ module Factory
val = false
else if cur_ver.nil?
# no known installed version, which means that we want to check the new version
- val = true if ! am_i_buggy(new_ver, fixed, found)
+ val = true if ! am_i_buggy(src_name, new_ver, fixed, found)
else
# both versions are known, which means that we want to check whether the upgrade may introduce this bug into the system
- val = true if am_i_buggy(cur_ver, fixed, found) || ( ! am_i_buggy(new_ver, fixed, found))
+ val = true if am_i_buggy(src_name, cur_ver, fixed, found) || ( ! am_i_buggy(src_name, new_ver, fixed, found))
end
end
end
@@ -1031,18 +1027,23 @@ module Factory
bugs.delete_if { |bug|
val = false
- name = bug.pkg_name
+ pkg_key = bug.pkg_key
new_ver = nil
cur_ver = nil
- new_ver = new_pkgs[name]["version"] if new_pkgs[name] != nil
- cur_ver = cur_pkgs[name]["version"] if cur_pkgs[name] != nil
+ new_ver = new_pkgs[pkg_key]["version"] if new_pkgs[pkg_key] != nil
+ cur_ver = cur_pkgs[pkg_key]["version"] if cur_pkgs[pkg_key] != nil
# show progress
yield _("Parsing Found/Fixed information..."),
"#{(i.to_f/max.to_f*100).to_i}%" if (i % step) == 0
i += 1
- val = true if bug_is_irrelevant(name, cur_ver, new_ver,
+ # TODO: this should actually be the source package name...
+ # use the binary package name, until there is a better strategy
+ src_name = new_pkgs[pkg_key]
+ src_name = src_name["package"] if src_name != nil
+
+ val = true if bug_is_irrelevant(src_name, cur_ver, new_ver,
bug.bug_number, bug.fixed, bug.found, bug.stat)
val
}
diff --git a/lib/debian/apt_preferences.rb b/lib/debian/apt_preferences.rb
index 576cba0..d246f8e 100644
--- a/lib/debian/apt_preferences.rb
+++ b/lib/debian/apt_preferences.rb
@@ -1,7 +1,7 @@
#
# apt_preferences.rb - ruby interface for apt preferences
-# Copyright (c) 2004 Masato Taruishi <taru at debian.org>
-# Copyright (c) 2009 Francesco Poli <invernomuto at paranoici.org>
+# Copyright (C) 2004 Masato Taruishi <taru at debian.org>
+# Copyright (C) 2009-2013 Francesco Poli <invernomuto at paranoici.org>
#
# 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
@@ -74,10 +74,10 @@ module Debian
attr_reader :pins
- def filter( pkgs = [], out = $stdout )
+ def filter( pkg_keys = [], out = $stdout )
_each_pin do |pin|
p = Pin.new(pin)
- if ! p.listbugs? || pkgs.include?( p["Package"] )
+ if ! p.listbugs? || pkg_keys.include?( p["Package"] )
out.puts pin
out.puts ""
end
@@ -94,12 +94,12 @@ if __FILE__ == $0
p.pins.each do |pin|
buf << " " + pin["Package"] if pin.listbugs?
end
- pinnedpkgs = buf.split(' ')
- bugpkgs = []
+ pinned_pkg_keys = buf.split(' ')
+ buggy_pkg_keys = []
open("|/usr/sbin/apt-listbugs -q list #{buf} | tail -n 1 ") { |io|
buf = io.read.delete!(' ').gsub!(/\([^\)]+\)/,'')
- bugpkgs = buf.split(',')
+ buggy_pkg_keys = buf.split(',')
}
- $stderr.puts "#{(pinnedpkgs - bugpkgs).join(', ')} has been fixed"
- p.filter( bugpkgs )
+ $stderr.puts "#{(pinned_pkg_keys - buggy_pkg_keys).join(', ')} has been fixed"
+ p.filter( buggy_pkg_keys )
end
diff --git a/lib/debian/bts.rb b/lib/debian/bts.rb
index 1fd5692..c6454aa 100644
--- a/lib/debian/bts.rb
+++ b/lib/debian/bts.rb
@@ -1,7 +1,8 @@
#
# bts.rb - ruby interface for debian bts
-# Copyright (c) 2002 Masato Taruishi <taru at debian.org>
-# Copyright (c) 2006-2007 Junichi Uekawa <dancer at debian.org>
+# Copyright (C) 2002 Masato Taruishi <taru at debian.org>
+# Copyright (C) 2006-2007 Junichi Uekawa <dancer at debian.org>
+# Copyright (C) 2013 Francesco Poli <invernomuto at paranoici.org>
#
# 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
@@ -46,13 +47,18 @@ module Debian
ParseStep = 200
- def parse(pkgs, severities = ["critical", "grave"])
+ def parse(ma_copies, severities = ["critical", "grave"])
require 'debian/btssoap'
soap = Debian::BTSSOAP::Soap.new(@host, @port)
sa = Debian::BTSSOAP::StringArray.new
bugs = Debian::Bugs.new
- reqbugs = soap.get_bugs('severity', severities, 'package', pkgs)
+ # obtain a list of package names
+ names = ma_copies.keys
+
+ # query the BTS: ask for a list of bug numbers of given severities
+ # affecting the given package names
+ reqbugs = soap.get_bugs('severity', severities, 'package', names)
# the total number of bugs
max = reqbugs.length
@@ -64,13 +70,13 @@ module Debian
reqbugs.each { |bug|
sa << bug
if sa.length > ParseStep
- soap.get_status(sa).each { |b| bugs << b }
+ soap.get_status(sa, ma_copies).each { |b| bugs << b }
offset_i += sa.length
sa = Debian::BTSSOAP::StringArray.new
yield "#{((offset_i).to_f*100/max.to_f).to_i}%"
end
}
- soap.get_status(sa).each { |b| bugs << b }
+ soap.get_status(sa, ma_copies).each { |b| bugs << b }
bugs
end
end
diff --git a/lib/debian/btssoap.rb b/lib/debian/btssoap.rb
index 0b54cc3..8b7e78f 100644
--- a/lib/debian/btssoap.rb
+++ b/lib/debian/btssoap.rb
@@ -1,6 +1,6 @@
# btssoap.rb - ruby interface for Debian BTS SOAP engine
-# Copyright (c) 2006-2008 Junichi Uekawa <dancer at debian.org>
-# Copyright (c) 2009 Francesco Poli <invernomuto at paranoici.org>
+# Copyright (C) 2006-2008 Junichi Uekawa <dancer at debian.org>
+# Copyright (C) 2009-2013 Francesco Poli <invernomuto at paranoici.org>
#
# 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
@@ -49,8 +49,8 @@ module Debian
@drv.get_bugs(param)
end
- def get_status(sa)
- ### soap interface to get bug status matching the bug number(s). sa is a array of strings.
+ def get_status(sa, ma_copies)
+ ### soap interface to get bug status matching the bug number(s). sa is an array of strings. ma_copies is the multiarch map.
get_status = Debian::Bugs.new
if sa.size == 0
puts "No bugs to fetch" if $DEBUG
@@ -60,18 +60,25 @@ module Debian
@drv.get_status(sa).each { |bugnum, res|
# parse the received information, given from the server
p res if $DEBUG
- res.package.split(/[ \t?,()]+/).each { |package|
- newbug=Debian::Bug.new(package,
- bugnum.to_s,
- res.severity,
- res.pending,
- res.subject.gsub(/\r/,''),
- res.tags.split(" "),
- res.mergedwith.to_s.split(" "),
- Time::at(res.date.to_i))
- newbug.found=res.found.keys.join(" ") if res.found.kind_of?(Hash)
- newbug.fixed=res.fixed.keys.join(" ") if res.fixed.kind_of?(Hash)
- get_status << newbug
+ res.package.split(/[ \t?,()]+/).each { |pkg_name|
+ keys = ma_copies[pkg_name]
+ if ( keys != nil )
+ keys.each { |pkg_key|
+ newbug = Debian::Bug.new(pkg_key,
+ bugnum.to_s,
+ res.severity,
+ res.pending,
+ res.subject.gsub(/\r/,''),
+ res.tags.split(" "),
+ res.mergedwith.to_s.split(" "),
+ Time::at(res.date.to_i))
+ newbug.found =
+ res.found.keys.join(" ") if res.found.kind_of?(Hash)
+ newbug.fixed =
+ res.fixed.keys.join(" ") if res.fixed.kind_of?(Hash)
+ get_status << newbug
+ }
+ end
}
}
end
diff --git a/lib/debian/bug.rb b/lib/debian/bug.rb
index 58e9d35..fc27a32 100644
--- a/lib/debian/bug.rb
+++ b/lib/debian/bug.rb
@@ -1,7 +1,8 @@
#
# bug.rb - ruby interface for debian bug
-# Copyright (c) 2002 Masato Taruishi <taru at debian.org>
-# Copyright (c) 2006-2007 Junichi Uekawa <dancer at debian.org>
+# Copyright (C) 2002 Masato Taruishi <taru at debian.org>
+# Copyright (C) 2006-2007 Junichi Uekawa <dancer at debian.org>
+# Copyright (C) 2013 Francesco Poli <invernomuto at paranoici.org>
#
# 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
@@ -22,9 +23,9 @@
module Debian
class Bug
- def initialize (pkg_name, bug_number, severity,
+ def initialize (pkg_key, bug_number, severity,
stat, desc, tags = [], mergeids = [], time = Time.now )
- @pkg_name = pkg_name
+ @pkg_key = pkg_key
@bug_number = bug_number
@severity = severity
@stat = stat
@@ -38,12 +39,12 @@ module Debian
end
def to_s
- "#" + @bug_number + ":" + @pkg_name + ":" + @desc
+ "#" + @bug_number + ":" + @pkg_key + ":" + @desc
end
def inspect
@bug_number + " - " +
- @pkg_name + " - " +
+ @pkg_key + " - " +
@severity + " - " +
@stat + " - " +
@tags.to_s + " - " +
@@ -53,16 +54,16 @@ module Debian
@time.to_s
end
- attr_accessor :pkg_name, :bug_number, :severity,
+ attr_accessor :pkg_key, :bug_number, :severity,
:stat, :desc, :tags, :mergeids, :log, :time, :found, :fixed
end
class Bugs < Array
- def each_by_category (pkg, sev, stat)
+ def each_by_category (pkg_key, sev, stat)
each { |bug|
- yield bug if bug.pkg_name == pkg &&
+ yield bug if bug.pkg_key == pkg_key &&
bug.severity == sev &&
bug.stat == stat
}
diff --git a/test_logic.rb b/test_logic.rb
index b37adfe..784d5f5 100755
--- a/test_logic.rb
+++ b/test_logic.rb
@@ -133,6 +133,7 @@ class TC_BugsFactory < Test::Unit::TestCase
end
# am_i_buggy() arguments:
+ # * source package name
# * version under consideration
# * space-delimited sequence of fixed versions
# * space-delimited sequence of found versions
@@ -163,6 +164,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
[""].join(" "), # fixed
[""].join(" ") # found
@@ -171,6 +173,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["4"].join(" "), # fixed
[""].join(" ") # found
@@ -179,6 +182,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
[""].join(" "), # fixed
["4"].join(" ") # found
@@ -187,6 +191,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["5"].join(" "), # fixed
["4"].join(" ") # found
@@ -196,6 +201,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["4"].join(" "), # fixed
["5"].join(" ") # found
@@ -204,6 +210,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["4"].join(" "), # fixed
["4"].join(" ") # found
@@ -212,6 +219,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
[""].join(" "), # fixed
["2"].join(" ") # found
@@ -220,6 +228,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
[""].join(" "), # fixed
["3"].join(" ") # found
@@ -228,6 +237,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["2","4"].join(" "), # fixed
["5"].join(" ") # found
@@ -236,6 +246,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["3","4"].join(" "), # fixed
["4"].join(" ") # found
@@ -244,6 +255,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["2","5"].join(" "), # fixed
["1","4"].join(" ") # found
@@ -252,6 +264,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["3","4"].join(" "), # fixed
["1","5"].join(" ") # found
@@ -260,6 +273,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["1","5"].join(" "), # fixed
["2","4"].join(" ") # found
@@ -268,6 +282,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["1","5"].join(" "), # fixed
["3","5"].join(" ") # found
@@ -276,6 +291,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["2","4"].join(" "), # fixed
["2","5"].join(" ") # found
@@ -284,6 +300,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3",
["3","4"].join(" "), # fixed
["3"].join(" ") # found
@@ -292,6 +309,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"1.5",
["apt-test/2.0", "apt-test/3.5"].join(" "), # fixed
["apt-test/1.5", "apt-test/3.0"].join(" ") # found
@@ -300,6 +318,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"2.0",
["apt-test/2.0", "apt-test/3.5"].join(" "), # fixed
["apt-test/1.5", "apt-test/3.0"].join(" ") # found
@@ -308,6 +327,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"1.0",
["apt-test/2.0", "apt-test/3.5"].join(" "), # fixed
["apt-test/1.5", "apt-test/3.0"].join(" ") # found
@@ -316,6 +336,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"1.0",
"apt-test/2.0", # fixed
nil # found
@@ -324,6 +345,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3.0",
"apt-test/2.0", # fixed
nil # found
@@ -332,6 +354,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(true,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3.0",
nil, # fixed
"apt-test/1.0" # found
@@ -340,6 +363,7 @@ class TC_BugsFactory < Test::Unit::TestCase
assert_equal(false,
Factory::BugsFactory.am_i_buggy(
+ "apt-test",
"3.0",
"4.0", # fixed
"3.5" # found
--
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