1Description: Port simg_dump to Python 3.
2Author: Antonio Russo <antonio.e.russo@gmail.com>
3Forwarded: no
4Last-Update: 2019-01-05
5Origin: https://bugs.debian.org/945646
6
7---
8Index: android-platform-system-core/libsparse/simg_dump.py
9===================================================================
10--- android-platform-system-core.orig/libsparse/simg_dump.py
11+++ android-platform-system-core/libsparse/simg_dump.py
12@@ -1,4 +1,4 @@
13-#! /usr/bin/env python
14+#! /usr/bin/env python3
15
16 # Copyright (C) 2012 The Android Open Source Project
17 #
18@@ -14,7 +14,7 @@
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
21
22-from __future__ import print_function
23+
24 import csv
25 import getopt
26 import hashlib
27@@ -47,7 +47,7 @@ def main():
28     opts, args = getopt.getopt(sys.argv[1:],
29                                "vsc:",
30                                ["verbose", "showhash", "csvfile"])
31-  except getopt.GetoptError, e:
32+  except getopt.GetoptError as e:
33     print(e)
34     usage(me)
35   for o, a in opts:
36@@ -66,7 +66,7 @@ def main():
37     usage(me)
38
39   if csvfilename:
40-    csvfile = open(csvfilename, "wb")
41+    csvfile = open(csvfilename, "w", newline='')
42     csvwriter = csv.writer(csvfile)
43
44   output = verbose or csvfilename or showhash
45@@ -121,7 +121,7 @@ def main():
46                           "output offset", "output blocks", "type", "hash"])
47
48     offset = 0
49-    for i in xrange(1, total_chunks + 1):
50+    for i in range(1, total_chunks + 1):
51       header_bin = FH.read(12)
52       header = struct.unpack("<2H2I", header_bin)
53       chunk_type = header[0]
54@@ -160,7 +160,7 @@ def main():
55           if showhash:
56             h = hashlib.sha1()
57             data = fill_bin * (blk_sz / 4);
58-            for block in xrange(chunk_sz):
59+            for block in range(chunk_sz):
60               h.update(data)
61             curhash = h.hexdigest()
62       elif chunk_type == 0xCAC3:
63