list-discoverable-partitions: apply "ruff format"
This commit is contained in:
@@ -30,16 +30,15 @@ ARCHITECTURES = {
|
|||||||
'TILEGX': 'TILE-Gx',
|
'TILEGX': 'TILE-Gx',
|
||||||
'X86': 'x86',
|
'X86': 'x86',
|
||||||
'X86_64': 'amd64/x86_64',
|
'X86_64': 'amd64/x86_64',
|
||||||
}
|
} # fmt: skip
|
||||||
|
|
||||||
TYPES = {
|
TYPES = {
|
||||||
'ROOT' : 'Root Partition',
|
'ROOT': 'Root Partition',
|
||||||
'ROOT_VERITY' : 'Root Verity Partition',
|
'ROOT_VERITY': 'Root Verity Partition',
|
||||||
'ROOT_VERITY_SIG' : 'Root Verity Signature Partition',
|
'ROOT_VERITY_SIG': 'Root Verity Signature Partition',
|
||||||
'USR' : '`/usr/` Partition',
|
'USR': '`/usr/` Partition',
|
||||||
'USR_VERITY' : '`/usr/` Verity Partition',
|
'USR_VERITY': '`/usr/` Verity Partition',
|
||||||
'USR_VERITY_SIG' : '`/usr/` Verity Signature Partition',
|
'USR_VERITY_SIG': '`/usr/` Verity Signature Partition',
|
||||||
|
|
||||||
'ESP': 'EFI System Partition',
|
'ESP': 'EFI System Partition',
|
||||||
'SRV': 'Server Data Partition',
|
'SRV': 'Server Data Partition',
|
||||||
'VAR': 'Variable Data Partition',
|
'VAR': 'Variable Data Partition',
|
||||||
@@ -49,7 +48,7 @@ TYPES = {
|
|||||||
'USER_HOME': 'Per-user Home Partition',
|
'USER_HOME': 'Per-user Home Partition',
|
||||||
'LINUX_GENERIC': 'Generic Linux Data Partition',
|
'LINUX_GENERIC': 'Generic Linux Data Partition',
|
||||||
'XBOOTLDR': 'Extended Boot Loader Partition',
|
'XBOOTLDR': 'Extended Boot Loader Partition',
|
||||||
}
|
} # fmt: skip
|
||||||
|
|
||||||
DESCRIPTIONS = {
|
DESCRIPTIONS = {
|
||||||
'ROOT': (
|
'ROOT': (
|
||||||
@@ -57,56 +56,66 @@ DESCRIPTIONS = {
|
|||||||
'On systems with matching architecture, the first partition with this type UUID on the disk '
|
'On systems with matching architecture, the first partition with this type UUID on the disk '
|
||||||
'containing the active EFI ESP is automatically mounted to the root directory `/`. '
|
'containing the active EFI ESP is automatically mounted to the root directory `/`. '
|
||||||
'If the partition is encrypted with LUKS or has dm-verity integrity data (see below), the '
|
'If the partition is encrypted with LUKS or has dm-verity integrity data (see below), the '
|
||||||
'device mapper file will be named `/dev/mapper/root`.'),
|
'device mapper file will be named `/dev/mapper/root`.',
|
||||||
|
),
|
||||||
'USR': (
|
'USR': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'Similar semantics to root partition, but just the `/usr/` partition.'),
|
'Similar semantics to root partition, but just the `/usr/` partition.',
|
||||||
|
),
|
||||||
'ROOT_VERITY': (
|
'ROOT_VERITY': (
|
||||||
'A dm-verity superblock followed by hash data',
|
'A dm-verity superblock followed by hash data',
|
||||||
'Contains dm-verity integrity hash data for the matching root partition. If this feature is '
|
'Contains dm-verity integrity hash data for the matching root partition. If this feature is '
|
||||||
'used the partition UUID of the root partition should be the first 128 bits of the root hash '
|
'used the partition UUID of the root partition should be the first 128 bits of the root hash '
|
||||||
'of the dm-verity hash data, and the partition UUID of this dm-verity partition should be the '
|
'of the dm-verity hash data, and the partition UUID of this dm-verity partition should be the '
|
||||||
'final 128 bits of it, so that the root partition and its Verity partition can be discovered '
|
'final 128 bits of it, so that the root partition and its Verity partition can be discovered '
|
||||||
'easily, simply by specifying the root hash.'),
|
'easily, simply by specifying the root hash.',
|
||||||
|
),
|
||||||
'USR_VERITY': (
|
'USR_VERITY': (
|
||||||
'A dm-verity superblock followed by hash data',
|
'A dm-verity superblock followed by hash data',
|
||||||
'Similar semantics to root Verity partition, but just for the `/usr/` partition.'),
|
'Similar semantics to root Verity partition, but just for the `/usr/` partition.',
|
||||||
|
),
|
||||||
'ROOT_VERITY_SIG': (
|
'ROOT_VERITY_SIG': (
|
||||||
'A serialized JSON object, see below',
|
'A serialized JSON object, see below',
|
||||||
'Contains a root hash and a PKCS#7 signature for it, permitting signed dm-verity GPT images.'),
|
'Contains a root hash and a PKCS#7 signature for it, permitting signed dm-verity GPT images.',
|
||||||
|
),
|
||||||
'USR_VERITY_SIG': (
|
'USR_VERITY_SIG': (
|
||||||
'A serialized JSON object, see below',
|
'A serialized JSON object, see below',
|
||||||
'Similar semantics to root Verity signature partition, but just for the `/usr/` partition.'),
|
'Similar semantics to root Verity signature partition, but just for the `/usr/` partition.',
|
||||||
|
),
|
||||||
'ESP': (
|
'ESP': (
|
||||||
'VFAT',
|
'VFAT',
|
||||||
'The ESP used for the current boot is automatically mounted to `/efi/` (or `/boot/` as '
|
'The ESP used for the current boot is automatically mounted to `/efi/` (or `/boot/` as '
|
||||||
'fallback), unless a different partition is mounted there (possibly via `/etc/fstab`, or '
|
'fallback), unless a different partition is mounted there (possibly via `/etc/fstab`, or '
|
||||||
'because the Extended Boot Loader Partition — see below — exists) or the directory is '
|
'because the Extended Boot Loader Partition — see below — exists) or the directory is '
|
||||||
'non-empty on the root disk. This partition type is defined by the '
|
'non-empty on the root disk. This partition type is defined by the '
|
||||||
'[UEFI Specification](http://www.uefi.org/specifications).'),
|
'[UEFI Specification](http://www.uefi.org/specifications).',
|
||||||
|
),
|
||||||
'XBOOTLDR': (
|
'XBOOTLDR': (
|
||||||
'Typically VFAT',
|
'Typically VFAT',
|
||||||
'The Extended Boot Loader Partition (XBOOTLDR) used for the current boot is automatically '
|
'The Extended Boot Loader Partition (XBOOTLDR) used for the current boot is automatically '
|
||||||
'mounted to `/boot/`, unless a different partition is mounted there (possibly via '
|
'mounted to `/boot/`, unless a different partition is mounted there (possibly via '
|
||||||
'`/etc/fstab`) or the directory is non-empty on the root disk. This partition type '
|
'`/etc/fstab`) or the directory is non-empty on the root disk. This partition type '
|
||||||
'is defined by the [Boot Loader '
|
'is defined by the [Boot Loader '
|
||||||
'Specification](https://uapi-group.org/specifications/specs/boot_loader_specification).'),
|
'Specification](https://uapi-group.org/specifications/specs/boot_loader_specification).',
|
||||||
|
),
|
||||||
'SWAP': (
|
'SWAP': (
|
||||||
'Swap, optionally in LUKS',
|
'Swap, optionally in LUKS',
|
||||||
'All swap partitions on the disk containing the root partition are automatically enabled. '
|
'All swap partitions on the disk containing the root partition are automatically enabled. '
|
||||||
'If the partition is encrypted with LUKS, the device mapper file will be named '
|
'If the partition is encrypted with LUKS, the device mapper file will be named '
|
||||||
'`/dev/mapper/swap`. This partition type predates the Discoverable Partitions Specification.'),
|
'`/dev/mapper/swap`. This partition type predates the Discoverable Partitions Specification.',
|
||||||
|
),
|
||||||
'HOME': (
|
'HOME': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'The first partition with this type UUID on the disk containing the root partition is '
|
'The first partition with this type UUID on the disk containing the root partition is '
|
||||||
'automatically mounted to `/home/`. If the partition is encrypted with LUKS, the device '
|
'automatically mounted to `/home/`. If the partition is encrypted with LUKS, the device '
|
||||||
'mapper file will be named `/dev/mapper/home`.'),
|
'mapper file will be named `/dev/mapper/home`.',
|
||||||
|
),
|
||||||
'SRV': (
|
'SRV': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'The first partition with this type UUID on the disk containing the root partition is '
|
'The first partition with this type UUID on the disk containing the root partition is '
|
||||||
'automatically mounted to `/srv/`. If the partition is encrypted with LUKS, the device '
|
'automatically mounted to `/srv/`. If the partition is encrypted with LUKS, the device '
|
||||||
'mapper file will be named `/dev/mapper/srv`.'),
|
'mapper file will be named `/dev/mapper/srv`.',
|
||||||
|
),
|
||||||
'VAR': (
|
'VAR': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'The first partition with this type UUID on the disk containing the root partition is '
|
'The first partition with this type UUID on the disk containing the root partition is '
|
||||||
@@ -118,7 +127,8 @@ DESCRIPTIONS = {
|
|||||||
'listed here) is inherently private to a specific installation and cannot possibly be '
|
'listed here) is inherently private to a specific installation and cannot possibly be '
|
||||||
'shared between multiple OS installations on the same disk, and thus should be bound to '
|
'shared between multiple OS installations on the same disk, and thus should be bound to '
|
||||||
'a specific instance of the OS, identified by its machine ID. If the partition is '
|
'a specific instance of the OS, identified by its machine ID. If the partition is '
|
||||||
'encrypted with LUKS, the device mapper file will be named `/dev/mapper/var`.'),
|
'encrypted with LUKS, the device mapper file will be named `/dev/mapper/var`.',
|
||||||
|
),
|
||||||
'TMP': (
|
'TMP': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'The first partition with this type UUID on the disk containing the root partition is '
|
'The first partition with this type UUID on the disk containing the root partition is '
|
||||||
@@ -127,19 +137,23 @@ DESCRIPTIONS = {
|
|||||||
'is indeed `/var/tmp/`, not `/tmp/`. The latter is typically maintained in memory via '
|
'is indeed `/var/tmp/`, not `/tmp/`. The latter is typically maintained in memory via '
|
||||||
'`tmpfs` and does not require a partition on disk. In some cases it might be '
|
'`tmpfs` and does not require a partition on disk. In some cases it might be '
|
||||||
'desirable to make `/tmp/` persistent too, in which case it is recommended to make it '
|
'desirable to make `/tmp/` persistent too, in which case it is recommended to make it '
|
||||||
'a symlink or bind mount to `/var/tmp/`, thus not requiring its own partition type UUID.'),
|
'a symlink or bind mount to `/var/tmp/`, thus not requiring its own partition type UUID.',
|
||||||
|
),
|
||||||
'USER_HOME': (
|
'USER_HOME': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'A home partition of a user, managed by '
|
'A home partition of a user, managed by '
|
||||||
'[`systemd-homed`](https://www.freedesktop.org/software/systemd/man/systemd-homed.html).'),
|
'[`systemd-homed`](https://www.freedesktop.org/software/systemd/man/systemd-homed.html).',
|
||||||
|
),
|
||||||
'LINUX_GENERIC': (
|
'LINUX_GENERIC': (
|
||||||
'Any native, optionally in LUKS',
|
'Any native, optionally in LUKS',
|
||||||
'No automatic mounting takes place for other Linux data partitions. This partition type '
|
'No automatic mounting takes place for other Linux data partitions. This partition type '
|
||||||
'should be used for all partitions that carry Linux file systems. The installer needs '
|
'should be used for all partitions that carry Linux file systems. The installer needs '
|
||||||
'to mount them explicitly via entries in `/etc/fstab`. Optionally, these partitions may '
|
'to mount them explicitly via entries in `/etc/fstab`. Optionally, these partitions may '
|
||||||
'be encrypted with LUKS. This partition type predates the Discoverable Partitions Specification.'),
|
'be encrypted with LUKS. This partition type predates the Discoverable Partitions Specification.',
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def extract(file):
|
def extract(file):
|
||||||
for line in file:
|
for line in file:
|
||||||
# print(line)
|
# print(line)
|
||||||
@@ -148,7 +162,10 @@ def extract(file):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
name = line.split()[1]
|
name = line.split()[1]
|
||||||
if m2 := re.match(r'^(ROOT|USR)_([A-Z0-9]+|X86_64|PPC64_LE|MIPS_LE|MIPS64_LE)(|_VERITY|_VERITY_SIG)\s+SD_ID128_MAKE\((.*)\)', m.group(1)):
|
if m2 := re.match(
|
||||||
|
r'^(ROOT|USR)_([A-Z0-9]+|X86_64|PPC64_LE|MIPS_LE|MIPS64_LE)(|_VERITY|_VERITY_SIG)\s+SD_ID128_MAKE\((.*)\)',
|
||||||
|
m.group(1),
|
||||||
|
):
|
||||||
ptype, arch, suffix, u = m2.groups()
|
ptype, arch, suffix, u = m2.groups()
|
||||||
u = uuid.UUID(u.replace(',', ''))
|
u = uuid.UUID(u.replace(',', ''))
|
||||||
assert arch in ARCHITECTURES, f'{arch} not in f{ARCHITECTURES}'
|
assert arch in ARCHITECTURES, f'{arch} not in f{ARCHITECTURES}'
|
||||||
@@ -165,6 +182,7 @@ def extract(file):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(f'Failed to match: {m.group(1)}')
|
raise ValueError(f'Failed to match: {m.group(1)}')
|
||||||
|
|
||||||
|
|
||||||
def generate(defines):
|
def generate(defines):
|
||||||
prevtype = None
|
prevtype = None
|
||||||
|
|
||||||
@@ -188,6 +206,7 @@ def generate(defines):
|
|||||||
|
|
||||||
print(f'| _{tdesc}{adesc}_ | `{puuid}` `{name}` | {morea} | {moreb} |')
|
print(f'| _{tdesc}{adesc}_ | `{puuid}` `{name}` | {morea} | {moreb} |')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
known = extract(sys.stdin)
|
known = extract(sys.stdin)
|
||||||
generate(known)
|
generate(known)
|
||||||
|
|||||||
Reference in New Issue
Block a user