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
This commit is contained in:
Kurt Garloff 2021-05-18 09:03:33 +00:00 committed by Git OBS Bridge
parent 213fae1d4c
commit 5316da5877
3 changed files with 83 additions and 2 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon May 17 09:47:33 UTC 2021 - Matej Cepl <mcepl@suse.com>
- 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

View File

@ -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')

71
no-python2.patch Normal file
View File

@ -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))