Douglas Anderson has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
qualcomm: qgpt: Fixes for python3
* Binary strings should be joined with a binary string * Binary files should be opened in binary mode. * Division that wants truncation should make it explicit.
I have tested that these changes let me compile.
Change-Id: I7c41b80688a9c6bdb3c66561ff531311cc7ebb13 Signed-off-by: Douglas Anderson dianders@chromium.org --- M util/qualcomm/qgpt.py 1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/37024/1
diff --git a/util/qualcomm/qgpt.py b/util/qualcomm/qgpt.py index 5101836..476ca5c 100755 --- a/util/qualcomm/qgpt.py +++ b/util/qualcomm/qgpt.py @@ -167,7 +167,7 @@ # CRC of Partition Entry
PartEntry = GPTBlobBuffer[options.sector_size*2:options.sector_size*2 + 128] - CalcEntryCRC = crc32(''.join(struct.pack("B", x) for x in PartEntry)) + CalcEntryCRC = crc32(b''.join(struct.pack("B", x) for x in PartEntry))
GPTBlobBuffer[i] = CalcEntryCRC & 0xFF GPTBlobBuffer[i+1] = (CalcEntryCRC>>8) & 0xFF @@ -177,7 +177,7 @@
# CRC of Partition Table Header GPTHeader = GPTBlobBuffer[options.sector_size:options.sector_size + 92] - CalcEntryCRC = crc32(''.join(struct.pack("B", x) for x in GPTHeader)) + CalcEntryCRC = crc32(b''.join(struct.pack("B", x) for x in GPTHeader)) i = options.sector_size + 16
GPTBlobBuffer[i] = CalcEntryCRC & 0xFF @@ -209,11 +209,11 @@ options.inputfile = args[0] options.outputfile = args[1]
- with open(options.inputfile, 'r+') as fin: + with open(options.inputfile, 'rb+') as fin: bb_buffer = fin.read()
# Round up to next sector if bootblock size not evenly divisible - options.end_lba = ((len(bb_buffer) + options.sector_size - 1) / + options.end_lba = ((len(bb_buffer) + options.sector_size - 1) // options.sector_size) # Add 3 sectors for MBR, GPT header and GPT partition entry options.end_lba += 3
Douglas Anderson has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
Patch Set 1:
I've only compile-tested these but in my chroot they were required to make compile work (since this script doesn't explicitly request python2 and "python" is transitioning to python3.
Another option would be to explicitly say "python2" but this seems better?
Douglas Anderson has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
Patch Set 1:
What's the plan for this patch. Should we just land this directly and then Mike's future patches can build atop it? Even if we switch to hardcoding python2, these are all still good/correct fixes. They are "more correct" for python2 code and happen to give you a jump for when you decide to move to python3.
Julius Werner has removed a vote from this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
Removed Verified-1 by build bot (Jenkins) no-reply@coreboot.org
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
Patch Set 2: Code-Review+2
I'm okay with landing this since like you said it's just "more correct". (Not sure what went wrong with the CI there, let's just try again...)
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/37024 )
Change subject: qualcomm: qgpt: Fixes for python3 ......................................................................
qualcomm: qgpt: Fixes for python3
* Binary strings should be joined with a binary string * Binary files should be opened in binary mode. * Division that wants truncation should make it explicit.
I have tested that these changes let me compile.
Change-Id: I7c41b80688a9c6bdb3c66561ff531311cc7ebb13 Signed-off-by: Douglas Anderson dianders@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/37024 Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Patrick Georgi pgeorgi@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M util/qualcomm/qgpt.py 1 file changed, 4 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Julius Werner: Looks good to me, approved
diff --git a/util/qualcomm/qgpt.py b/util/qualcomm/qgpt.py index 5101836..476ca5c 100755 --- a/util/qualcomm/qgpt.py +++ b/util/qualcomm/qgpt.py @@ -167,7 +167,7 @@ # CRC of Partition Entry
PartEntry = GPTBlobBuffer[options.sector_size*2:options.sector_size*2 + 128] - CalcEntryCRC = crc32(''.join(struct.pack("B", x) for x in PartEntry)) + CalcEntryCRC = crc32(b''.join(struct.pack("B", x) for x in PartEntry))
GPTBlobBuffer[i] = CalcEntryCRC & 0xFF GPTBlobBuffer[i+1] = (CalcEntryCRC>>8) & 0xFF @@ -177,7 +177,7 @@
# CRC of Partition Table Header GPTHeader = GPTBlobBuffer[options.sector_size:options.sector_size + 92] - CalcEntryCRC = crc32(''.join(struct.pack("B", x) for x in GPTHeader)) + CalcEntryCRC = crc32(b''.join(struct.pack("B", x) for x in GPTHeader)) i = options.sector_size + 16
GPTBlobBuffer[i] = CalcEntryCRC & 0xFF @@ -209,11 +209,11 @@ options.inputfile = args[0] options.outputfile = args[1]
- with open(options.inputfile, 'r+') as fin: + with open(options.inputfile, 'rb+') as fin: bb_buffer = fin.read()
# Round up to next sector if bootblock size not evenly divisible - options.end_lba = ((len(bb_buffer) + options.sector_size - 1) / + options.end_lba = ((len(bb_buffer) + options.sector_size - 1) // options.sector_size) # Add 3 sectors for MBR, GPT header and GPT partition entry options.end_lba += 3