Blame SOURCES/0082-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch

0cb0b9
From 0e70861c9f72fb2e06f9a121e6dac0e542ee1230 Mon Sep 17 00:00:00 2001
0cb0b9
From: "Brian C. Lane" <bcl@redhat.com>
0cb0b9
Date: Wed, 27 Jun 2018 13:45:09 -0700
0cb0b9
Subject: [PATCH 82/86] Modify gpt-header-move and msdos-overlap to work with
0cb0b9
 py2 or py3
0cb0b9
0cb0b9
Distributions are starting to remove python2 and only use python3.
0cb0b9
Modify these test scripts so that they will work with either python 2.7
0cb0b9
or python 3.X
0cb0b9
---
0cb0b9
 tests/gpt-header-move | 15 ++++++++-------
0cb0b9
 tests/msdos-overlap   |  5 ++---
0cb0b9
 2 files changed, 10 insertions(+), 10 deletions(-)
0cb0b9
0cb0b9
diff --git a/tests/gpt-header-move b/tests/gpt-header-move
0cb0b9
index 05cdc65..3dda5cb 100755
0cb0b9
--- a/tests/gpt-header-move
0cb0b9
+++ b/tests/gpt-header-move
0cb0b9
@@ -3,20 +3,21 @@
0cb0b9
 # open img file, subtract 33 from altlba address, and move the last 33 sectors
0cb0b9
 # back by 33 sectors
0cb0b9
 
0cb0b9
-from struct import *
0cb0b9
+from struct import unpack_from, pack_into
0cb0b9
 from zipfile import crc32
0cb0b9
 import array
0cb0b9
 import sys
0cb0b9
+
0cb0b9
 file = open(sys.argv[1],'rb+')
0cb0b9
 file.seek(512)
0cb0b9
 gptheader = file.read(512)
0cb0b9
-altlba = unpack_from('
0cb0b9
-gptheader = array.array('c',gptheader)
0cb0b9
+altlba = unpack_from('
0cb0b9
+gptheader = array.array('B', gptheader)
0cb0b9
 pack_into('
0cb0b9
 #zero header crc
0cb0b9
 pack_into('
0cb0b9
 #compute new crc
0cb0b9
-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
0cb0b9
+newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF)
0cb0b9
 pack_into('
0cb0b9
 file.seek(512)
0cb0b9
 file.write(gptheader)
0cb0b9
@@ -25,7 +26,7 @@ gptheader = file.read(512)
0cb0b9
 file.seek(512*(altlba-32))
0cb0b9
 backup = file.read(512*32)
0cb0b9
 altlba -= 33
0cb0b9
-gptheader = array.array('c',gptheader)
0cb0b9
+gptheader = array.array('B',gptheader)
0cb0b9
 #update mylba
0cb0b9
 pack_into('
0cb0b9
 #update table lba
0cb0b9
@@ -33,9 +34,9 @@ pack_into('
0cb0b9
 #zero header crc
0cb0b9
 pack_into('
0cb0b9
 #compute new crc
0cb0b9
-newcrc = ((crc32(buffer(gptheader,0,92))) & 0xFFFFFFFF)
0cb0b9
+newcrc = ((crc32(gptheader[:92])) & 0xFFFFFFFF)
0cb0b9
 pack_into('
0cb0b9
 file.seek(512*(altlba-32))
0cb0b9
 file.write(backup)
0cb0b9
 file.write(gptheader)
0cb0b9
-file.write("\0" * (512 * 33))
0cb0b9
+file.write(b"\0" * (512 * 33))
0cb0b9
diff --git a/tests/msdos-overlap b/tests/msdos-overlap
0cb0b9
index 5bddfb0..d6ae8d6 100755
0cb0b9
--- a/tests/msdos-overlap
0cb0b9
+++ b/tests/msdos-overlap
0cb0b9
@@ -14,12 +14,11 @@ BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0cb0b9
 OFFSET = 0x1b8
0cb0b9
 
0cb0b9
 if len(sys.argv) < 2:
0cb0b9
-    print "%s: <image or device>"
0cb0b9
+    print("%s: <image or device>" % sys.argv[0])
0cb0b9
     sys.exit(1)
0cb0b9
 
0cb0b9
-data = "".join(chr(c) for c in BAD_ENTRY)
0cb0b9
 with open(sys.argv[1], "rb+") as f:
0cb0b9
     f.seek(OFFSET, 0)
0cb0b9
-    f.write(data)
0cb0b9
+    f.write(bytes(bytearray(BAD_ENTRY)))
0cb0b9
 
0cb0b9
 sys.exit(0)
0cb0b9
-- 
0cb0b9
2.17.1
0cb0b9