]> git.pld-linux.org Git - packages/parted.git/blame - 0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch
- release 6 (by relup.sh)
[packages/parted.git] / 0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch
CommitLineData
74a816df
MK
1From 073c24b5d2361857b8ce8b5dcd81a3e26fc05b96 Mon Sep 17 00:00:00 2001
2From: "Brian C. Lane" <bcl@redhat.com>
3Date: Wed, 27 Jun 2018 13:45:09 -0700
4Subject: [PATCH 91/92] Modify gpt-header-move and msdos-overlap to work with
5 py2 or py3
6
7Distributions are starting to remove python2 and only use python3.
8Modify these test scripts so that they will work with either python 2.7
9or python 3.X
10---
11 tests/gpt-header-move | 15 ++++++++-------
12 tests/msdos-overlap | 5 ++---
13 2 files changed, 10 insertions(+), 10 deletions(-)
14
15diff --git a/tests/gpt-header-move b/tests/gpt-header-move
16index 05cdc65..3dda5cb 100755
17--- a/tests/gpt-header-move
18+++ b/tests/gpt-header-move
19@@ -3,20 +3,21 @@
20 # open img file, subtract 33 from altlba address, and move the last 33 sectors
21 # back by 33 sectors
22
23-from struct import *
24+from struct import unpack_from, pack_into
25 from zipfile import crc32
26 import array
27 import sys
28+
29 file = open(sys.argv[1],'rb+')
30 file.seek(512)
31 gptheader = file.read(512)
32-altlba = unpack_from('<q', gptheader,offset=32)[0]
33-gptheader = array.array('c',gptheader)
34+altlba = unpack_from('<q', gptheader, offset=32)[0]
35+gptheader = array.array('B', gptheader)
36 pack_into('<Q', gptheader, 32, altlba-33)
37 #zero header crc
38 pack_into('<L', gptheader, 16, 0)
39 #compute new crc
40-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
41+newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF)
42 pack_into('<L', gptheader, 16, newcrc)
43 file.seek(512)
44 file.write(gptheader)
45@@ -25,7 +26,7 @@ gptheader = file.read(512)
46 file.seek(512*(altlba-32))
47 backup = file.read(512*32)
48 altlba -= 33
49-gptheader = array.array('c',gptheader)
50+gptheader = array.array('B',gptheader)
51 #update mylba
52 pack_into('<Q', gptheader, 24, altlba)
53 #update table lba
54@@ -33,9 +34,9 @@ pack_into('<Q', gptheader, 72, altlba-32)
55 #zero header crc
56 pack_into('<L', gptheader, 16, 0)
57 #compute new crc
58-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
59+newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF)
60 pack_into('<L', gptheader, 16, newcrc)
61 file.seek(512*(altlba-32))
62 file.write(backup)
63 file.write(gptheader)
64-file.write("\0" * (512 * 33))
65+file.write(b"\0" * (512 * 33))
66diff --git a/tests/msdos-overlap b/tests/msdos-overlap
67index 5bddfb0..d6ae8d6 100755
68--- a/tests/msdos-overlap
69+++ b/tests/msdos-overlap
70@@ -14,12 +14,11 @@ BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 OFFSET = 0x1b8
72
73 if len(sys.argv) < 2:
74- print "%s: <image or device>"
75+ print("%s: <image or device>" % sys.argv[0])
76 sys.exit(1)
77
78-data = "".join(chr(c) for c in BAD_ENTRY)
79 with open(sys.argv[1], "rb+") as f:
80 f.seek(OFFSET, 0)
81- f.write(data)
82+ f.write(bytes(bytearray(BAD_ENTRY)))
83
84 sys.exit(0)
85--
862.17.1
87
This page took 0.08676 seconds and 4 git commands to generate.