aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/simg_dump-python3.patch
blob: e6933ef145733b922ee10513c865ccee0a146076 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Description: Port simg_dump to Python 3.
Author: Antonio Russo <antonio.e.russo@gmail.com>
Forwarded: not-needed
Last-Update: 2019-01-05
Origin: https://bugs.debian.org/945646

---
Index: android-platform-tools/system/core/libsparse/simg_dump.py
===================================================================
--- android-platform-tools.orig/system/core/libsparse/simg_dump.py
+++ android-platform-tools/system/core/libsparse/simg_dump.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 
 # Copyright (C) 2012 The Android Open Source Project
 #
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from __future__ import print_function
+
 import csv
 import getopt
 import hashlib
@@ -47,7 +47,7 @@ def main():
     opts, args = getopt.getopt(sys.argv[1:],
                                "vsc:",
                                ["verbose", "showhash", "csvfile"])
-  except getopt.GetoptError, e:
+  except getopt.GetoptError as e:
     print(e)
     usage(me)
   for o, a in opts:
@@ -66,7 +66,7 @@ def main():
     usage(me)
 
   if csvfilename:
-    csvfile = open(csvfilename, "wb")
+    csvfile = open(csvfilename, "w", newline='')
     csvwriter = csv.writer(csvfile)
 
   output = verbose or csvfilename or showhash
@@ -121,7 +121,7 @@ def main():
                           "output offset", "output blocks", "type", "hash"])
 
     offset = 0
-    for i in xrange(1, total_chunks + 1):
+    for i in range(1, total_chunks + 1):
       header_bin = FH.read(12)
       header = struct.unpack("<2H2I", header_bin)
       chunk_type = header[0]
@@ -160,7 +160,7 @@ def main():
           if showhash:
             h = hashlib.sha1()
             data = fill_bin * (blk_sz / 4);
-            for block in xrange(chunk_sz):
+            for block in range(chunk_sz):
               h.update(data)
             curhash = h.hexdigest()
       elif chunk_type == 0xCAC3: