Bug#800115: debsecan: support python3 backend

2019-09-22 Thread Marc Haber
Hi Michael,

thanks for the bug report. Without being the debsecan maintainer, I'd
like to know whether this is really such a straightforward thing without
having to mess around with on-disk structure of local files. Would that
patch, assuming that it still applies, be suitable for a package in
Debian?

Florian, are there reasons for not applying this nearly four year old
patch other than lack of time? Would you want me to go ahead with this?
Do you want me to do an NMU, add myself to Uploaders or would you prefer
a PR on gitlab? Or, Michael, would you be willing to do this if Florian
agrees? You have much more python skills than I have.

Greetings
Marc


On Sat, Sep 26, 2015 at 08:41:53PM -0400, Michael Gilbert wrote:
> package: debsecan
> severity: wishlist
> tags: patch
> 
> I'm trying to migrate my systems to python3 only, so I've worked on a
> python3 backend patch for debsecan.
> 
> The 2to3 script got most of the way automatically, although there was
> some trickiness with the removal of __cmp__ and compressed data
> strings, but otherwise it was rather straightforward.
> 
> I also made sure to maintain backwards compatibility with python2 via
> try/except in a few places.
> 
> I've done some modest testing, getting the same output with either
> python2 or python3 as backend.
> 
> Please see attached.
> 
> Best wishes,
> Mike



Bug#800115: debsecan: support python3 backend

2015-09-26 Thread Michael Gilbert
package: debsecan
severity: wishlist
tags: patch

I'm trying to migrate my systems to python3 only, so I've worked on a
python3 backend patch for debsecan.

The 2to3 script got most of the way automatically, although there was
some trickiness with the removal of __cmp__ and compressed data
strings, but otherwise it was rather straightforward.

I also made sure to maintain backwards compatibility with python2 via
try/except in a few places.

I've done some modest testing, getting the same output with either
python2 or python3 as backend.

Please see attached.

Best wishes,
Mike
diff -Nru debsecan-0.4.18/debian/changelog debsecan-0.4.18+nmu1/debian/changelog
--- debsecan-0.4.18/debian/changelog	2015-02-22 19:13:07.0 +
+++ debsecan-0.4.18+nmu1/debian/changelog	2015-09-27 00:16:24.0 +
@@ -1,3 +1,10 @@
+debsecan (0.4.18+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add support for python3.
+
+ -- Michael Gilbert   Sat, 26 Sep 2015 21:50:21 +
+
 debsecan (0.4.18) unstable; urgency=low
 
   * Increase compatibility with Python 2.6 in squeeze.  The
diff -Nru debsecan-0.4.18/debian/control debsecan-0.4.18+nmu1/debian/control
--- debsecan-0.4.18/debian/control	2015-02-22 19:06:12.0 +
+++ debsecan-0.4.18+nmu1/debian/control	2015-09-27 00:01:52.0 +
@@ -9,7 +9,7 @@
 
 Package: debsecan
 Architecture: all
-Depends: debconf | debconf-2.0, python (>= 2.3), python-apt, ${misc:Depends},
+Depends: debconf | debconf-2.0, python-apt | python3-apt, ${misc:Depends},
  ca-certificates
 Recommends: cron, exim4 | mail-transport-agent
 Description: Debian Security Analyzer
diff -Nru debsecan-0.4.18/debian/rules debsecan-0.4.18+nmu1/debian/rules
--- debsecan-0.4.18/debian/rules	2010-03-07 16:57:27.0 +
+++ debsecan-0.4.18+nmu1/debian/rules	2015-09-27 00:02:36.0 +
@@ -30,8 +30,10 @@
 
 	# Add here commands to install the package into debian/.
 	install -d debian/`dh_listpackages`/var/lib/debsecan
-	install -D -m 0755 src/debsecan \
+	install -D -m 0755 debsecan \
 		debian/`dh_listpackages`/usr/bin/debsecan
+	install -D -m 0755 src/debsecan \
+		debian/`dh_listpackages`/usr/share/debsecan/debsecan
 	install -D -m 0755 src/debsecan-create-cron \
 		debian/`dh_listpackages`/usr/sbin/debsecan-create-cron
 	install -D -m 0755 doc/debsecan.1 \
diff -Nru debsecan-0.4.18/debsecan debsecan-0.4.18+nmu1/debsecan
--- debsecan-0.4.18/debsecan	1970-01-01 00:00:00.0 +
+++ debsecan-0.4.18+nmu1/debsecan	2015-09-27 00:23:39.0 +
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+if [ -e /usr/share/doc/python3-apt/copyright ]; then
+/usr/bin/python3 /usr/share/debsecan/debsecan $@
+elif [ -e /usr/share/doc/python-apt/copyright ]; then
+/usr/bin/python /usr/share/debsecan/debsecan $@
+else
+echo "error: python-apt package not found"
+exit 1
+fi
diff -Nru debsecan-0.4.18/src/debsecan debsecan-0.4.18+nmu1/src/debsecan
--- debsecan-0.4.18/src/debsecan	2014-03-29 21:09:58.0 +
+++ debsecan-0.4.18+nmu1/src/debsecan	2015-09-27 00:08:36.0 +
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 # debsecan - Debian Security Analyzer
 # Copyright (C) 2005, 2006, 2007 Florian Weimer
+# Copyright (C) 2015 Michael Gilbert 
 #
 # 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
@@ -19,7 +20,6 @@
 VERSION = "0.4"
 
 import copy
-from cStringIO import StringIO
 from optparse import OptionParser
 import os
 import os.path
@@ -28,10 +28,23 @@
 import sys
 import time
 import types
-import urllib2
 import zlib
 import apt_pkg
 
+try:
+from cStringIO import StringIO
+except ImportError:
+from io import StringIO
+
+try:
+from urllib2 import urlopen
+from urllib2 import Request
+from urllib2 import HTTPError
+except ImportError:
+from urllib.error import HTTPError
+from urllib.request import urlopen
+from urllib.request import Request
+
 apt_pkg.init()
 try:
 version_compare = apt_pkg.version_compare
@@ -56,7 +69,7 @@
 """
 
 def __init__(self, filename, lineno, msg):
-assert type(lineno) == types.IntType
+assert type(lineno) == int
 self.filename = filename
 self.lineno = lineno
 self.msg = msg
@@ -65,9 +78,9 @@
 return self.msg
 
 def __repr__(self):
-return "ParseError(%s, %d, %s)" % (`self.filename`,
+return "ParseError(%s, %d, %s)" % (repr(self.filename),
self.lineno,
-   `self.msg`)
+   repr(self.msg))
 
 def printOut(self, file):
 """Writes a machine-parsable error message to file."""
@@ -78,17 +91,35 @@
 """Version class which uses the original APT comparison algorithm."""
 def __init__(self, version):
 """Creates a new Version object."""
-assert