Hi, first of all: I know, I'm very late. But I have some changes to make mini-dinstall running well with python 2.6
I've attached my changes. Could someone of the Release Team have a look at my changes and make a decision to insert these changes into Squeeze? If so, I'll upload a new version of mini-dinstall into unstable very shortly. Cheers, Christoph
>From e4640c86461ba77eb653349a7bd085bde60a527e Mon Sep 17 00:00:00 2001 From: Christoph Goehre <ch...@sigxcpu.org> Date: Sun, 22 Aug 2010 11:02:22 +0200 Subject: [PATCH 1/4] replace deprecated md5 and sha module with hashlib --- minidinstall/misc.py | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/minidinstall/misc.py b/minidinstall/misc.py index 2a3467c..b8f323a 100644 --- a/minidinstall/misc.py +++ b/minidinstall/misc.py @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import os, errno, time, string, re, popen2 +import os, errno, time, string, re, popen2, hashlib def dup2(fd,fd2): # dup2 with EBUSY retries (cf. dup2(2) and Debian bug #265513) @@ -56,11 +56,9 @@ def get_file_sum(self, type, filename): def _get_internal_file_sum(self ,type, filename): """ generate hash sums for file with python modules """ if type == 'md5': - import md5 - sum = md5.new() + sum = hashlib.md5() elif type == 'sha1': - import sha - sum = sha.new() + sum = hashlib.sha1() elif type == 'sha256': from Crypto.Hash import SHA256 sum = SHA256.new() -- 1.7.1
>From 6072e9cf6c76c39c81d47e8cc3ad2c1c068af471 Mon Sep 17 00:00:00 2001 From: Christoph Goehre <ch...@sigxcpu.org> Date: Sun, 22 Aug 2010 11:04:12 +0200 Subject: [PATCH 2/4] hashlib can handle sha256, so we didn't need python-crypto anymore --- debian/control | 2 +- minidinstall/misc.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index c861498..6bdd848 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,7 @@ Vcs-Browser: http://git.debian.org/?p=mini-dinstall/mini-dinstall.git Package: mini-dinstall Architecture: all -Depends: ${python:Depends}, python-apt (>= 0.7.93), apt-utils, python-crypto, ${misc:Depends} +Depends: ${python:Depends}, python-apt (>= 0.7.93), apt-utils, ${misc:Depends} Recommends: gpgv Suggests: debian-keyring Description: daemon for updating Debian packages in a repository diff --git a/minidinstall/misc.py b/minidinstall/misc.py index b8f323a..7efd426 100644 --- a/minidinstall/misc.py +++ b/minidinstall/misc.py @@ -60,8 +60,7 @@ def _get_internal_file_sum(self ,type, filename): elif type == 'sha1': sum = hashlib.sha1() elif type == 'sha256': - from Crypto.Hash import SHA256 - sum = SHA256.new() + sum = hashlib.sha256() self._logger.debug("Generate %s (python-internal) for %s" % (type, filename)) f = open(filename) buf = f.read(8192) -- 1.7.1
>From 4c216a26afd5321b4316f82aa3a61cfaa65193e2 Mon Sep 17 00:00:00 2001 From: Christoph Goehre <ch...@sigxcpu.org> Date: Sun, 10 Oct 2010 11:11:01 +0200 Subject: [PATCH 3/4] hashlib needs python >= 2.5 --- debian/pycompat | 1 - debian/pyversions | 1 + 2 files changed, 1 insertions(+), 1 deletions(-) delete mode 100644 debian/pycompat create mode 100644 debian/pyversions diff --git a/debian/pycompat b/debian/pycompat deleted file mode 100644 index 0cfbf08..0000000 --- a/debian/pycompat +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/debian/pyversions b/debian/pyversions new file mode 100644 index 0000000..b3dc41e --- /dev/null +++ b/debian/pyversions @@ -0,0 +1 @@ +2.5- -- 1.7.1
>From 9e2e87a094c4f725c20789ca003a72e9a775f01b Mon Sep 17 00:00:00 2001 From: Christoph Goehre <ch...@sigxcpu.org> Date: Sun, 10 Oct 2010 11:14:16 +0200 Subject: [PATCH 4/4] popen2 is deprecated in python 2.6 So now we only use the internal hash algorithm provided by hashlib. --- minidinstall/misc.py | 41 +---------------------------------------- 1 files changed, 1 insertions(+), 40 deletions(-) diff --git a/minidinstall/misc.py b/minidinstall/misc.py index 7efd426..94fe291 100644 --- a/minidinstall/misc.py +++ b/minidinstall/misc.py @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import os, errno, time, string, re, popen2, hashlib +import os, errno, time, string, re, hashlib def dup2(fd,fd2): # dup2 with EBUSY retries (cf. dup2(2) and Debian bug #265513) @@ -48,13 +48,6 @@ def format_changes(L): def get_file_sum(self, type, filename): """ generate hash sums for file """ - ret = _get_external_file_sum(self, type, filename) - if not ret: - ret = _get_internal_file_sum(self, type, filename) - return ret - -def _get_internal_file_sum(self ,type, filename): - """ generate hash sums for file with python modules """ if type == 'md5': sum = hashlib.md5() elif type == 'sha1': @@ -68,35 +61,3 @@ def _get_internal_file_sum(self ,type, filename): sum.update(buf) buf = f.read(8192) return sum.hexdigest() - -def _get_external_file_sum(self, type, filename): - """ generate hash sums for file with external programs """ - ret = None - if os.access('/usr/bin/%ssum' % (type,), os.X_OK): - cmd = '/usr/bin/%ssum %s' % (type, filename,) - self._logger.debug("Running: %s" % (cmd,)) - child = popen2.Popen3(cmd, 1) - child.tochild.close() - erroutput = child.childerr.read() - child.childerr.close() - if erroutput != '': - child.fromchild.close() - raise DinstallException("%ssum returned error output \"%s\"" % (type, erroutput,)) - (sum, filename) = string.split(child.fromchild.read(), None, 1) - child.fromchild.close() - try: - status = child.wait() - except OSError, (errnum, err): - if errnum == 10: - self._logger.warn("Ignoring missing child proccess") - status = 0 - if not (status is None or (os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0)): - if os.WIFEXITED(status): - msg = "%ssum exited with error code %d" % (type, os.WEXITSTATUS(status),) - elif os.WIFSTOPPED(status): - msg = "%ssum stopped unexpectedly with signal %d" % (type, os.WSTOPSIG(status),) - elif os.WIFSIGNALED(status): - msg = "%ssum died with signal %d" % (type, os.WTERMSIG(status),) - raise DinstallException(msg) - ret = sum.strip() - return ret -- 1.7.1