parted: proper fix for change of partition label case (#594) (#986)

* parted: proper fix for change of partition label case
calling mkpart even when partition existed before mklabel call, fixes #522

* changelog fragment for parted fix #522

* Update changelogs/fragments/522-parted_change_label.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* typo in comment

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 4931fb2681)

Co-authored-by: Robert Osowiecki <robert.osowiecki@gmail.com>
This commit is contained in:
patchback[bot] 2020-09-29 06:08:33 +02:00 committed by GitHub
parent 0d459e5662
commit d7c4849473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -634,11 +634,12 @@ def main():
if state == 'present':
# Assign label if required
if current_device['generic'].get('table', None) != label:
mklabel_needed = current_device['generic'].get('table', None) != label
if mklabel_needed:
script += "mklabel %s " % label
# Create partition if required
if part_type and not part_exists(current_parts, 'num', number):
if part_type and (mklabel_needed or not part_exists(current_parts, 'num', number)):
script += "mkpart %s %s%s %s " % (
part_type,
'%s ' % fs_type if fs_type is not None else '',