parted/0091-Modify-gpt-header-move-and-msdos-overlap-to-work-wit.patch
Brian C. Lane d6652ea632 - Use python3 in buildroot
- Add make to BuildRequires
- Switch gpt-header-move and msdos-overlap to python3 (bcl)
- Modify gpt-header-move and msdos-overlap to work with py2 or py3 (bcl)
- Fix atari label false positives (psusi)
- Lift 512 byte restriction on fat resize (psusi)
- build: Remove unused traces of dynamic loading (cjwatson)
- Fix resizepart iec unit end sector (psusi)
- mkpart: Allow negative start value when FS-TYPE is not given (mail)
- Fix set and disk_set to not crash when no flags are supported (psusi)
- tests: fix t6100-mdraid-partitions (psusi)
- Fix make check (psusi)
- linux: Include <sys/sysmacros.h> for major() macro. (rjones)
2018-06-27 14:44:42 -07:00

88 lines
2.6 KiB
Diff

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