]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: Downgrade required python version to 3.9
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 19 Jan 2023 12:14:29 +0000 (13:14 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 20 Jan 2023 12:55:11 +0000 (13:55 +0100)
meson.build
src/ukify/ukify.py

index 965b237d23af8f4ffd13b3e3eb9b06314eef9a7a..d37f47d48b7a1e4866d654d279b6cacd72f86dba 100644 (file)
@@ -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)',
-                         check : false).returncode() == 0
+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
index 6f177bc5b78fe080e0b3ecc788ac84ea6a9afd7e..b00b9fd9001596eae570150aa19c2ea74449a287 100755 (executable)
@@ -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,21 +426,18 @@ def call_systemd_measure(uki, linux, opts):
 
 
 def join_initrds(initrds):
-    match initrds:
-        case []:
-            return None
-        case [initrd]:
-            return initrd
-        case multiple:
-            seq = []
-            for file in multiple:
-                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
+    if len(initrds) == 0:
+        return None
+    elif len(initrds) == 1:
+        return initrds[0]
+
+    seq = []
+    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)
 
 
 def pe_validate(filename):