parent
3d901637d1
commit
66002f375c
@ -25,6 +25,9 @@ that the distribution configuration files follow the current schema.
|
||||
|
||||
Pre-release versions:
|
||||
- 3.3.0-alpha1 (2022-06-27)
|
||||
Initial 3.3.0 release to check the release scripts &c.
|
||||
- 3.3.0-alpha2 (unreleased)
|
||||
Incompatible module-configuration changes, see #1438.
|
||||
|
||||
## Project ##
|
||||
- The C++ code in the project is now formatted with clang-format 12 or 13,
|
||||
@ -49,6 +52,8 @@ Pre-release versions:
|
||||
## Modules ##
|
||||
- *bootloader* now supports more options when building the kernel
|
||||
command-line. (Thanks Evan)
|
||||
- *bootloader* no longer supports `@@`-style suffixes for unique-EFI-id
|
||||
generation. Use `${}` instead.
|
||||
- *displaymanager* no longer supports the discontinued *kdm* display manager.
|
||||
- *fstab* configuration has been completely re-done. Many configuration
|
||||
options have moved to the *mount* module. See #1993
|
||||
|
@ -53,10 +53,10 @@ efiBootMgr: "efibootmgr"
|
||||
# (problematic characters, see above, are replaced).
|
||||
#
|
||||
# There are some special words possible at the end of *efiBootloaderId*:
|
||||
# @@SERIAL@@ can be used to obtain a uniquely-numbered suffix
|
||||
# ${SERIAL} can be used to obtain a uniquely-numbered suffix
|
||||
# that is added to the Id (yielding, e.g., `dirname1` or `dirname72`)
|
||||
# @@RANDOM@@ can be used to obtain a unique 4-digit hex suffix
|
||||
# @@PHRASE@@ can be used to obtain a unique 1-to-3-word suffix
|
||||
# ${RANDOM} can be used to obtain a unique 4-digit hex suffix
|
||||
# ${PHRASE} can be used to obtain a unique 1-to-3-word suffix
|
||||
# from a dictionary of space-themed words
|
||||
# These words must be at the **end** of the *efiBootloaderId* value.
|
||||
# There must also be at most one of them. If there is none, no suffix-
|
||||
|
@ -393,28 +393,28 @@ class phraseEfi(object):
|
||||
|
||||
def get_efi_suffix_generator(name):
|
||||
"""
|
||||
Handle EFI bootloader Ids with @@<something>@@ for suffix-processing.
|
||||
Handle EFI bootloader Ids with ${<something>} for suffix-processing.
|
||||
"""
|
||||
if "@@" not in name:
|
||||
raise ValueError("Misplaced call to get_efi_suffix_generator, no @@")
|
||||
parts = name.split("@@")
|
||||
if len(parts) != 3:
|
||||
raise ValueError("EFI Id {!r} is malformed".format(name))
|
||||
if parts[2]:
|
||||
# Supposed to be empty because the string ends with "@@"
|
||||
raise ValueError("EFI Id {!r} is malformed".format(name))
|
||||
if parts[1] not in ("SERIAL", "RANDOM", "PHRASE"):
|
||||
raise ValueError("EFI suffix {!r} is unknown".format(parts[1]))
|
||||
if "${" not in name:
|
||||
raise ValueError("Misplaced call to get_efi_suffix_generator, no ${}")
|
||||
if not name.endswith("}"):
|
||||
raise ValueError("Misplaced call to get_efi_suffix_generator, no trailing ${}")
|
||||
if name.count("${") > 1:
|
||||
raise ValueError("EFI ID {!r} contains multiple generators".format(name))
|
||||
import re
|
||||
prefix, generator_name = re.match("(.*)\${([^}]*)}$", name).groups()
|
||||
if generator_name not in ("SERIAL", "RANDOM", "PHRASE"):
|
||||
raise ValueError("EFI suffix {!r} is unknown".format(generator_name))
|
||||
|
||||
generator = None
|
||||
if parts[1] == "SERIAL":
|
||||
generator = serialEfi(parts[0])
|
||||
elif parts[1] == "RANDOM":
|
||||
generator = randomEfi(parts[0])
|
||||
elif parts[1] == "PHRASE":
|
||||
generator = phraseEfi(parts[0])
|
||||
if generator_name == "SERIAL":
|
||||
generator = serialEfi(prefix)
|
||||
elif generator_name == "RANDOM":
|
||||
generator = randomEfi(prefix)
|
||||
elif generator_name == "PHRASE":
|
||||
generator = phraseEfi(prefix)
|
||||
if generator is None:
|
||||
raise ValueError("EFI suffix {!r} is unsupported".format(parts[1]))
|
||||
raise ValueError("EFI suffix {!r} is unsupported".format(generator_name))
|
||||
|
||||
return generator
|
||||
|
||||
@ -422,10 +422,10 @@ def get_efi_suffix_generator(name):
|
||||
def change_efi_suffix(efi_directory, bootloader_id):
|
||||
"""
|
||||
Returns a label based on @p bootloader_id that is usable within
|
||||
@p efi_directory. If there is a @@<something>@@ suffix marker
|
||||
@p efi_directory. If there is a ${<something>} suffix marker
|
||||
in the given id, tries to generate a unique label.
|
||||
"""
|
||||
if bootloader_id.endswith("@@"):
|
||||
if bootloader_id.endswith("}") and "${" in bootloader_id:
|
||||
# Do 10 attempts with any suffix generator
|
||||
g = suffix_iterator(10, get_efi_suffix_generator(bootloader_id))
|
||||
else:
|
||||
|
@ -10,7 +10,7 @@ libcalamares.globalstorage.insert("testing", True)
|
||||
from src.modules.bootloader import main
|
||||
|
||||
# Specific Bootloader test
|
||||
g = main.get_efi_suffix_generator("derp@@SERIAL@@")
|
||||
g = main.get_efi_suffix_generator("derp${SERIAL}")
|
||||
assert g is not None
|
||||
assert g.next() == "derp" # First time, no suffix
|
||||
for n in range(9):
|
||||
@ -18,13 +18,13 @@ for n in range(9):
|
||||
# We called next() 10 times in total, starting from 0
|
||||
assert g.next() == "derp10"
|
||||
|
||||
g = main.get_efi_suffix_generator("derp@@RANDOM@@")
|
||||
g = main.get_efi_suffix_generator("derp${RANDOM}")
|
||||
assert g is not None
|
||||
for n in range(10):
|
||||
print(g.next())
|
||||
# it's random, nothing to assert
|
||||
|
||||
g = main.get_efi_suffix_generator("derp@@PHRASE@@")
|
||||
g = main.get_efi_suffix_generator("derp${PHRASE}")
|
||||
assert g is not None
|
||||
for n in range(10):
|
||||
print(g.next())
|
||||
@ -38,19 +38,19 @@ except ValueError as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
g = main.get_efi_suffix_generator("derp@@HEX@@")
|
||||
g = main.get_efi_suffix_generator("derp${HEX}")
|
||||
raise TypeError("Shouldn't get generator (unknown indicator)")
|
||||
except ValueError as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
g = main.get_efi_suffix_generator("derp@@SERIAL@@x")
|
||||
g = main.get_efi_suffix_generator("derp${SERIAL}x")
|
||||
raise TypeError("Shouldn't get generator (trailing garbage)")
|
||||
except ValueError as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
g = main.get_efi_suffix_generator("derp@@SERIAL@@@@RANDOM@@")
|
||||
g = main.get_efi_suffix_generator("derp${SERIAL}${RANDOM}")
|
||||
raise TypeError("Shouldn't get generator (multiple indicators)")
|
||||
except ValueError as e:
|
||||
pass
|
||||
@ -59,9 +59,9 @@ except ValueError as e:
|
||||
# Try the generator (assuming no calamares- test files exist in /tmp)
|
||||
import os
|
||||
assert "calamares-single" == main.change_efi_suffix("/tmp", "calamares-single")
|
||||
assert "calamares-serial" == main.change_efi_suffix("/tmp", "calamares-serial@@SERIAL@@")
|
||||
assert "calamares-serial" == main.change_efi_suffix("/tmp", "calamares-serial${SERIAL}")
|
||||
try:
|
||||
os.makedirs("/tmp/calamares-serial", exist_ok=True)
|
||||
assert "calamares-serial1" == main.change_efi_suffix("/tmp", "calamares-serial@@SERIAL@@")
|
||||
assert "calamares-serial1" == main.change_efi_suffix("/tmp", "calamares-serial${SERIAL}")
|
||||
finally:
|
||||
os.rmdir("/tmp/calamares-serial")
|
||||
|
Loading…
Reference in New Issue
Block a user