On Sun, Jul 19, 2015 at 15:58:47 +0200, Francesco Poli wrote:
> Thank you very much, your helpfulness is really appreciated!
> 
> I am looking forward to seeing your updated patch.
> Please send it as soon as it's ready.

Here it is.

-- Michael
diff --git a/bin/apt-listbugs b/bin/apt-listbugs
index 4c5628f97c04..cf73e5de3242 100755
--- a/bin/apt-listbugs
+++ b/bin/apt-listbugs
@@ -46,7 +46,7 @@ installation/upgrade is safe.
 
 == USAGE
 
-apt-listbugs [-h] [-v] [-s <severities>] [-T <tags>] [-S <states>] [-B <bug#>] [-D] [-H <hostname>] [-p <port>] [-P <priority>] [-E <title>] [-q] [-C <apt.conf>] [-F] [-y] [-n] [-d] <command> [arguments]
+apt-listbugs [-h] [-v] [-s <severities>] [-T <tags>] [-S <states>] [-B <bug#>] [-D] [-u <url>] [-P <priority>] [-E <title>] [-q] [-C <apt.conf>] [-F] [-y] [-n] [-d] <command> [arguments]
 
 == OPTIONS
 
@@ -104,14 +104,21 @@ apt-listbugs [-h] [-v] [-s <severities>] [-T <tags>] [-S <states>] [-B <bug#>] [
 
   Show bugs of downgraded packages. (apt mode only)
 
+* -u <url>, --url <url>
+
+  Specifies the SOAP URL for the Debian Bug Tracking System
+  [https://bugs.debian.org:443/cgi-bin/soap.cgi]. The default URL may be
+  changed by setting the AptListbugs::URL configuration option.
+
 * -H <hostname>, --hostname <hostname>
 
-  Specifies the hostname of the Debian Bug Tracking System [bugs.debian.org].
+  Specifies the hostname of the Debian Bug Tracking System
+  (deprecated, and disables https; use --url instead).
 
 * -p <port>, --port <port>
 
   Specifies the port number of the web interface of the Debian Bug
-  Tracking System [80].
+  Tracking System (deprecated, and disables https; use --url instead).
 
 * -P <priority>, --pin-priority <priority>
 
@@ -221,6 +228,10 @@ notable configuration options are
   Useful for setting HTTP proxy for apt-listbugs.
   The special keyword 'DIRECT' will disable proxy.
 
+: AptListbugs::URL
+
+  Default SOAP URL for the Debian Bug Tracking System.
+
 : AptListbugs::Severities
 
   Default (comma-separated) list of bug severities to be shown. When
diff --git a/lib/aptlistbugs/debian/bts.rb b/lib/aptlistbugs/debian/bts.rb
index 5b31d1bffb8f..3a310819cb46 100644
--- a/lib/aptlistbugs/debian/bts.rb
+++ b/lib/aptlistbugs/debian/bts.rb
@@ -31,23 +31,21 @@ module Debian
   module BTS
     class Parser
 
-      def initialize(host, port)
-        @host = host
-        @port = port
+      def initialize(url)
+        @soapurl = url
       end
 
       # use SOAP interface to obtain the index.
       class SoapIndex < Parser
-        def initialize(host, port)
-          @host = host
-          @port = port
+        def initialize(url)
+          @soapurl = url
           @indexes = {}
           @buf = nil
         end
 
         def parse_bug(bugnum)
           require 'aptlistbugs/debian/btssoap'
-          soap = Debian::BTSSOAP::Soap.new(@host, @port)
+          soap = Debian::BTSSOAP::Soap.new(@soapurl)
           sa = Debian::BTSSOAP::StringArray.new
 
           # query the BTS about the given bug number
@@ -58,7 +56,7 @@ module Debian
 
         def parse(ma_copies, parsestep, severities = ["critical", "grave"])
           require 'aptlistbugs/debian/btssoap'
-          soap = Debian::BTSSOAP::Soap.new(@host, @port)
+          soap = Debian::BTSSOAP::Soap.new(@soapurl)
           sa = Debian::BTSSOAP::StringArray.new
           bugs = Debian::Bugs.new
 
diff --git a/lib/aptlistbugs/debian/btssoap.rb b/lib/aptlistbugs/debian/btssoap.rb
index 759ab7ff01ae..500e2f6d3260 100644
--- a/lib/aptlistbugs/debian/btssoap.rb
+++ b/lib/aptlistbugs/debian/btssoap.rb
@@ -23,8 +23,8 @@ module Debian
   module BTSSOAP
     class StringArray < Array; end
     class Soap
-      def initialize(host = "bugs.debian.org", port = 80)
-        @server="http://#{host}:#{port}/cgi-bin/soap.cgi";
+      def initialize(soapurl)
+        @server=soapurl
         @ns = 'Debbugs/SOAP/'
         @drv = SOAP::RPC::Driver.new(@server, @ns)
         @drv.wiredump_dev = STDOUT if $DEBUG
diff --git a/lib/aptlistbugs/logic.rb b/lib/aptlistbugs/logic.rb
index 1e4289180866..b8923d6f8030 100644
--- a/lib/aptlistbugs/logic.rb
+++ b/lib/aptlistbugs/logic.rb
@@ -42,8 +42,15 @@ class AppConfig
   QUERYBTS = "/usr/bin/querybts"
   WWW_BROWSER = "/usr/bin/www-browser"
   SENSIBLE_BROWSER = "/usr/bin/sensible-browser"
+  DEFAULT_URL = "https://bugs.debian.org:443/cgi-bin/soap.cgi";
+  # The default hostname and port are for backwards compatibility,
+  # and won't be used if neither --hostname nor --port is specified.
+  # These options disable https, so --url is preferred.
+  DEFAULT_HOSTNAME = "bugs.debian.org"
+  DEFAULT_PORT = 80
 
   def usage
+    derive_settings
     $stderr.print _("Usage: "), File.basename($0),
       _(" [options] <command> [arguments]"),
       "\n",
@@ -57,8 +64,7 @@ class AppConfig
       sprintf(_(" -S <states>      : Filter bugs by pending-state categories you want to see\n                    [%s].\n"), @stats.join(',')),
       _(" -B <bug#>        : Filter bugs by number, showing only the specified bugs.\n"),
       _(" -D               : Show downgraded packages, too.\n"),
-      sprintf(_(" -H <hostname>    : Hostname of Debian Bug Tracking System [%s].\n"), @hostname),
-      sprintf(_(" -p <port>        : Port number of the server [%s].\n"), @port),
+      sprintf(_(" -u <url>         : SOAP URL for Debian Bug Tracking System [%s].\n"), @soapurl),
       sprintf(_(" -P <priority>    : Pin-Priority value [%s].\n"), @pin_priority),
       _(" -E <title>       : Title of RSS output.\n"),
       _(" -q               : Don't display progress bar.\n"),
@@ -74,6 +80,30 @@ class AppConfig
       _("See the manual page for the long options.\n")
   end
 
+  def derive_settings
+    if @soapurl == nil
+      if @hostname == nil && @port == nil
+        if /soapurl='(.*)'/ =~ `apt-config #{@apt_conf} shell soapurl AptListbugs::URL`
+          @soapurl = $1
+        else
+          @soapurl = DEFAULT_URL
+        end
+      else
+        if @hostname == nil
+          @hostname = DEFAULT_HOSTNAME
+        end
+        if @port == nil
+          @port = DEFAULT_PORT
+        end
+        @soapurl="http://#{@hostname}:#{@port}/cgi-bin/soap.cgi";
+      end
+    else
+      if @hostname != nil || @port != nil
+        $stderr.puts _("W: ") + _("hostname and port options were overridden by a URL option.")
+      end
+    end
+  end
+
   def initialize
     @severity = ["critical", "grave", "serious"]
     @tag = nil
@@ -87,8 +117,9 @@ class AppConfig
                 ["done", _("Resolved in some Version")]]
     @fbugs = nil
     @show_downgrade = false
-    @hostname = "bugs.debian.org"
-    @port = 80
+    @soapurl = nil
+    @hostname = nil
+    @port = nil
     @parsestep = 200
     @quiet = false
     @command = nil
@@ -148,6 +179,7 @@ class AppConfig
                            ['--stats', '-S', GetoptLong::REQUIRED_ARGUMENT],
                            ['--bugs', '-B', GetoptLong::REQUIRED_ARGUMENT],
                            ['--show-downgrade', '-D', GetoptLong::NO_ARGUMENT],
+                           ['--url', '-u', GetoptLong::REQUIRED_ARGUMENT],
                            ['--hostname', '-H', GetoptLong::REQUIRED_ARGUMENT],
                            ['--port', '-p', GetoptLong::REQUIRED_ARGUMENT],
                            ['--pin-priority', '-P', GetoptLong::REQUIRED_ARGUMENT],
@@ -184,6 +216,8 @@ class AppConfig
           @fbugs = optargs.split(',')
         when '--show-downgrade'
           @show_downgrade = true
+        when '--url'
+          @soapurl = optargs
         when '--hostname'
           @hostname = optargs
         when '--port'
@@ -211,6 +245,7 @@ class AppConfig
       usage
       exit 1
     end
+    derive_settings
 
     if ! $stdout.isatty
       @quiet = true
@@ -295,7 +330,7 @@ class AppConfig
     end
 
     @parser =
-      Debian::BTS::Parser::SoapIndex.new(@hostname, @port)
+      Debian::BTS::Parser::SoapIndex.new(@soapurl)
 
     if FileTest.executable?("#{QUERYBTS}")
       @querybts = QUERYBTS

Attachment: signature.asc
Description: Digital signature

Reply via email to