diff --git a/RECIPE.md b/RECIPE.md index 71a54b39..1cae8307 100644 --- a/RECIPE.md +++ b/RECIPE.md @@ -66,6 +66,7 @@ Format an existing partition to a specified filesystem. This operation will dest **Accepts**: - *PartNum* (`int`): The partition number on disk (e.g. `/dev/sda3` is partition 3). - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. +- *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. ### luks-format @@ -75,6 +76,7 @@ Same as `format` but encrypts the partition with LUKS2. - *PartNum* (`int`): The partition number on disk (e.g. `/dev/sda3` is partition 3). - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. - *Password* (`string`): The password used to encrypt the partition. +- *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. ### pvcreate diff --git a/core/recipe.go b/core/recipe.go index b6284ed7..779b409c 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -234,6 +234,7 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { * **Accepts**: * - *PartNum* (`int`): The partition number on disk (e.g. `/dev/sda3` is partition 3). * - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. + * - *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. */ case "format": partNum, err := strconv.Atoi(args[0].(string)) @@ -246,6 +247,13 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { if err != nil { return fmt.Errorf("failed to execute operation %s: %s", operation, err) } + if len(args) == 3 { + label := args[2].(string) + err := disk.Partitions[partNum-1].SetLabel(label) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + } /* !! ### luks-format * * Same as `format` but encrypts the partition with LUKS2. @@ -254,6 +262,7 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { * - *PartNum* (`int`): The partition number on disk (e.g. `/dev/sda3` is partition 3). * - *FsType* (`string`): The filesystem for the partition. Can be either `btrfs`, `ext[2,3,4]`, `linux-swap`, `ntfs`\*, `reiserfs`\*, `udf`\*, or `xfs`\*. * - *Password* (`string`): The password used to encrypt the partition. + * - *Label* (optional `string`): An optional filesystem label. If not given, no label will be set. */ case "luks-format": partNum, err := strconv.Atoi(args[0].(string)) @@ -282,6 +291,13 @@ func runSetupOperation(diskLabel, operation string, args []interface{}) error { if err != nil { return fmt.Errorf("failed to execute operation %s: %s", operation, err) } + if len(args) == 4 { + label := args[3].(string) + err := LUKSSetLabel(&part, label) + if err != nil { + return fmt.Errorf("failed to execute operation %s: %s", operation, err) + } + } /* !! ### pvcreate * * Creates a new LVM physical volume from a partition. diff --git a/debian/changelog b/debian/changelog index 8c1e719b..ed42e864 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ albius (0.3.2) unstable; urgency=critical * Fix luks-format command crash + * Add optional "label" parameter in format and luks-format -- Mateus Melchiades Sat, 10 Nov 2023 20:20:00 -0300