mirror of
https://github.com/systemd/systemd
synced 2024-09-06 08:46:19 +00:00
ukify: Downgrade required python version to 3.9
This commit is contained in:
parent
a6a9ee4b36
commit
09595fd5f2
10
meson.build
10
meson.build
|
@ -1976,13 +1976,13 @@ if run_command(python, '-c', 'import jinja2', check : false).returncode() != 0
|
|||
error('python3 jinja2 missing')
|
||||
endif
|
||||
|
||||
python_310 = run_command(python, '-c',
|
||||
'import sys; sys.exit(0 if sys.version_info >= (3,10) else 1)',
|
||||
python_39 = run_command(python, '-c',
|
||||
'import sys; sys.exit(0 if sys.version_info >= (3,9) else 1)',
|
||||
check : false).returncode() == 0
|
||||
if get_option('ukify') == 'auto'
|
||||
want_ukify = python_310 and conf.get('HAVE_GNU_EFI') == 1
|
||||
elif get_option('ukify') == 'true' and (not python310 or conf.get('HAVE_GNU_EFI') != 1)
|
||||
error('ukify requires Python >= 3.10 and GNU EFI')
|
||||
want_ukify = python_39 and conf.get('HAVE_GNU_EFI') == 1
|
||||
elif get_option('ukify') == 'true' and (not python_39 or conf.get('HAVE_GNU_EFI') != 1)
|
||||
error('ukify requires Python >= 3.9 and GNU EFI')
|
||||
else
|
||||
want_ukify = get_option('ukify') == 'true'
|
||||
endif
|
||||
|
|
|
@ -65,7 +65,7 @@ def shell_join(cmd):
|
|||
return ' '.join(shlex.quote(str(x)) for x in cmd)
|
||||
|
||||
|
||||
def path_is_readable(s: str | None) -> pathlib.Path | None:
|
||||
def path_is_readable(s: typing.Optional[str]) -> typing.Optional[pathlib.Path]:
|
||||
"""Convert a filename string to a Path and verify access."""
|
||||
if s is None:
|
||||
return None
|
||||
|
@ -215,14 +215,14 @@ class Uname:
|
|||
class Section:
|
||||
name: str
|
||||
content: pathlib.Path
|
||||
tmpfile: typing.IO | None = None
|
||||
tmpfile: typing.Optional[typing.IO] = None
|
||||
flags: list[str] = dataclasses.field(default_factory=lambda: ['data', 'readonly'])
|
||||
offset: int | None = None
|
||||
offset: typing.Optional[int] = None
|
||||
measure: bool = False
|
||||
|
||||
@classmethod
|
||||
def create(cls, name, contents, **kwargs):
|
||||
if isinstance(contents, str | bytes):
|
||||
if isinstance(contents, (str, bytes)):
|
||||
mode = 'wt' if isinstance(contents, str) else 'wb'
|
||||
tmp = tempfile.NamedTemporaryFile(mode=mode, prefix=f'tmp{name}')
|
||||
tmp.write(contents)
|
||||
|
@ -261,9 +261,9 @@ class Section:
|
|||
|
||||
@dataclasses.dataclass
|
||||
class UKI:
|
||||
executable: list[pathlib.Path|str]
|
||||
executable: list[typing.Union[pathlib.Path, str]]
|
||||
sections: list[Section] = dataclasses.field(default_factory=list, init=False)
|
||||
offset: int | None = dataclasses.field(default=None, init=False)
|
||||
offset: typing.Optional[int] = dataclasses.field(default=None, init=False)
|
||||
|
||||
def __post_init__(self):
|
||||
self.offset = round_up(pe_next_section_offset(self.executable))
|
||||
|
@ -426,22 +426,19 @@ def call_systemd_measure(uki, linux, opts):
|
|||
|
||||
|
||||
def join_initrds(initrds):
|
||||
match initrds:
|
||||
case []:
|
||||
if len(initrds) == 0:
|
||||
return None
|
||||
case [initrd]:
|
||||
return initrd
|
||||
case multiple:
|
||||
elif len(initrds) == 1:
|
||||
return initrds[0]
|
||||
|
||||
seq = []
|
||||
for file in multiple:
|
||||
for file in initrds:
|
||||
initrd = file.read_bytes()
|
||||
padding = b'\0' * round_up(len(initrd), 4) # pad to 32 bit alignment
|
||||
seq += [initrd, padding]
|
||||
|
||||
return b''.join(seq)
|
||||
|
||||
assert False
|
||||
|
||||
|
||||
def pe_validate(filename):
|
||||
import pefile
|
||||
|
|
Loading…
Reference in a new issue