mirror of
https://github.com/ipxe/ipxe
synced 2026-05-22 00:03:42 +03:00
[cloud] Fix architecture detection for partitioned disk images
Allow the UEFI CPU architecture to be detected for the partitioned
disk images generated by genfsimg as of commit 2c84b68 ("[build] Use a
partition table in generated USB disk images").
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -8,6 +8,7 @@ from hashlib import sha256
|
||||
from itertools import count
|
||||
import os.path
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import boto3
|
||||
|
||||
@@ -17,8 +18,15 @@ EMPTY_CHECKSUM = b64encode(sha256(b'\0' * BLOCKSIZE).digest()).decode()
|
||||
|
||||
def detect_architecture(image):
|
||||
"""Detect CPU architecture"""
|
||||
mdir = subprocess.run(['mdir', '-b', '-i', image, '::/EFI/BOOT'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
with tempfile.NamedTemporaryFile(mode='w+t') as mtoolsrc:
|
||||
mtoolsrc.writelines([
|
||||
'drive D:', f'file="{image}"',
|
||||
'drive P:', f'file="{image}"', 'partition=4',
|
||||
])
|
||||
mtoolsrc.flush()
|
||||
mdir = subprocess.run(['mdir', '-b', 'D:/EFI/BOOT', 'P:/EFI/BOOT'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
check=False, env={'MTOOLSRC': mtoolsrc.name})
|
||||
if any(b'BOOTAA64.EFI' in x for x in mdir.stdout.splitlines()):
|
||||
return 'arm64'
|
||||
return 'x86_64'
|
||||
|
||||
Reference in New Issue
Block a user