From 5316da58776869cc22ae68d4cfcc178a16e8b70432c4a40bb63f734c8752e4c7 Mon Sep 17 00:00:00 2001 From: Kurt Garloff Date: Tue, 18 May 2021 09:03:33 +0000 Subject: [PATCH] Accepting request 893674 from home:mcepl:branches:Base:System - Add no-python2.patch to remove the dependency on Python 2 (sf#ddrescue#4). OBS-URL: https://build.opensuse.org/request/show/893674 OBS-URL: https://build.opensuse.org/package/show/Base:System/dd_rescue?expand=0&rev=62 --- dd_rescue.changes | 6 ++++ dd_rescue.spec | 8 ++++-- no-python2.patch | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 no-python2.patch diff --git a/dd_rescue.changes b/dd_rescue.changes index 691d757..3d73b83 100644 --- a/dd_rescue.changes +++ b/dd_rescue.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 17 09:47:33 UTC 2021 - Matej Cepl + +- Add no-python2.patch to remove the dependency on Python 2 + (sf#ddrescue#4). + ------------------------------------------------------------------- Thu Apr 29 21:15:14 CEST 2021 - kurt@garloff.de diff --git a/dd_rescue.spec b/dd_rescue.spec index 28b9a9e..4850cc6 100644 --- a/dd_rescue.spec +++ b/dd_rescue.spec @@ -31,13 +31,16 @@ Source0: http://garloff.de/kurt/linux/ddrescue/%{name}-%{version}.tar.bz2 Source1: http://garloff.de/kurt/linux/ddrescue/%{name}-%{version}.tar.bz2.asc Source2: %{name}.keyring Source99: %{name}.changes +# PATCH-FIX-UPSTREAM no-python2.patch sf#ddrescue#4 mcepl@suse.com +# Remove dependency on python2 +Patch0: no-python2.patch BuildRequires: autoconf BuildRequires: libattr-devel BuildRequires: libopenssl-devel BuildRequires: lzo-devel BuildRequires: lzop BuildRequires: pkgconfig -BuildRequires: python +BuildRequires: python3-base Requires: bc Recommends: dd_rescue-crypt Recommends: dd_rescue-lzo @@ -108,7 +111,8 @@ though more will have to be done to feel confident about feeding untrusted data to the decompressor; the plugin is still young and might expose bugs. %prep -%setup -q +%autosetup -p1 + # Remove build time references so build-compare can do its work FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{SOURCE99} '+%%H:%%M') FAKE_BUILDDATE=$(LC_ALL=C date -u -r %{SOURCE99} '+%%b %%e %%Y') diff --git a/no-python2.patch b/no-python2.patch new file mode 100644 index 0000000..ed8936c --- /dev/null +++ b/no-python2.patch @@ -0,0 +1,71 @@ +--- + calchmac.py | 46 +++++++++++++++++++++------------------------- + 1 file changed, 21 insertions(+), 25 deletions(-) + +--- a/calchmac.py ++++ b/calchmac.py +@@ -1,43 +1,39 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + import hashlib + import hmac + import sys + + if len(sys.argv) < 4: +- print >>sys.stderr, "Usage: calchmac.py ALG PASS FILE [FILE [..]]" +- sys.exit(1) ++ print("Usage: calchmac.py ALG PASS FILE [FILE [..]]", file=sys.stderr) ++ sys.exit(1) + + algtbl = (("md5", hashlib.md5), +- ("sha1", hashlib.sha1), +- ("sha256", hashlib.sha256), +- ("sha224", hashlib.sha224), +- ("sha512", hashlib.sha512), +- ("sha384", hashlib.sha384)) ++ ("sha1", hashlib.sha1), ++ ("sha256", hashlib.sha256), ++ ("sha224", hashlib.sha224), ++ ("sha512", hashlib.sha512), ++ ("sha384", hashlib.sha384)) + + + alg = sys.argv[1] + pwd = sys.argv[2] +-#salt1 = salt + "\0\0\0\x01" ++# salt1 = salt + "\0\0\0\x01" + algo = None + + for (anm, aob) in algtbl: +- if alg == anm: +- algo = aob +- break ++ if alg == anm: ++ algo = aob ++ break + + if not algo: +- print >>sys.stderr, "Hash algorithm %s not found!" % alg +- sys.exit(2) ++ print("Hash algorithm {} not found!".format(alg), file=sys.stderr) ++ sys.exit(2) + +-#hmf = open("HMACS.%s" % alg, "w") ++# hmf = open("HMACS.%s" % alg, "w") + for fnm in sys.argv[3:]: +- f = file(fnm, "rb") +- if not f: +- print >>sys.stderr, "Could not open %s" % fnm +- sys.exit(3) +- #print fnm +- fcont = f.read() +- hm = hmac.HMAC(pwd, fcont, algo) +- #print >>hmf, "%s *%s" % (hm.hexdigest(), fnm) +- print "%s *%s" %(hm.hexdigest(), fnm) +- ++ with open(fnm, "rb") as f: ++ # print fnm ++ fcont = f.read() ++ hm = hmac.HMAC(pwd, fcont, algo) ++ # print >>hmf, "%s *%s" % (hm.hexdigest(), fnm) ++ print("{} *{}".format(hm.hexdigest(), fnm))