From 1de1eff5d27b62226f27193683bec05f5af6e98f Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Mon, 3 Feb 2014 18:06:55 +0200 Subject: [PATCH] Cleanup disklabel.py Remove --print-last-linux and change some other argument names --- snf-image-helper/common.sh.in | 2 +- snf-image-helper/disklabel.py | 15 +++------------ snf-image-helper/tasks/20FilesystemResizeUnmounted.in | 16 +++++++++++----- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/snf-image-helper/common.sh.in b/snf-image-helper/common.sh.in index 3a5c2ec..dafcf55 100644 --- a/snf-image-helper/common.sh.in +++ b/snf-image-helper/common.sh.in @@ -551,7 +551,7 @@ mount_all() { if [[ "$osfamily" =~ ^(open|net)bsd$ ]]; then # OpenBSD DUIDs device naming if [[ "${entry[1]}" =~ ^[a-f0-9]{16}\.[a-p]$ ]]; then - duid="$(@scriptsdir@/disklabel.py --print-duid "$device")" + duid="$(@scriptsdir@/disklabel.py --get-duid "$device")" if [[ ! "${entry[1]}" =~ ^$duid ]]; then warn "fstab refers to unknown DUID: \`$duid'" diff --git a/snf-image-helper/disklabel.py b/snf-image-helper/disklabel.py index b5d566b..b0c4b5e 100755 --- a/snf-image-helper/disklabel.py +++ b/snf-image-helper/disklabel.py @@ -515,13 +515,10 @@ if __name__ == '__main__': parser.add_option("-l", "--list", action="store_true", dest="list", default=False, help="list the disklabel on the specified media") - parser.add_option("--print-last", action="store_true", dest="last_part", - default=False, + parser.add_option("--get-last-partition", action="store_true", + dest="last_part", default=False, help="print the label of the last partition") - parser.add_option("--print-last-linux", action="store_true", - dest="last_linux", default=False, - help="print the linux number for the last partition") - parser.add_option("--print-duid", action="store_true", dest="duid", + parser.add_option("--get-duid", action="store_true", dest="duid", default=False, help="print the disklabel unique identifier") parser.add_option("-d", "--enlarge-disk", type="int", dest="disk_size", @@ -550,12 +547,6 @@ if __name__ == '__main__': if options.last_part: print "%c" % chr(ord('a') + disklabel.get_last_partition_id()) - if options.last_linux: - part_id = disklabel.get_last_partition_id() - # The linux kernel does not assign a partition for label 'c' that - # describes the whole disk - print part_id + (4 if part_id > 2 else 5) - if options.disk_size is not None: disklabel.enlarge_disk(options.disk_size) diff --git a/snf-image-helper/tasks/20FilesystemResizeUnmounted.in b/snf-image-helper/tasks/20FilesystemResizeUnmounted.in index 7cbc5e4..65c584c 100644 --- a/snf-image-helper/tasks/20FilesystemResizeUnmounted.in +++ b/snf-image-helper/tasks/20FilesystemResizeUnmounted.in @@ -37,13 +37,19 @@ if [ ! -b "$SNF_IMAGE_DEV" ]; then fi if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = openbsd ]; then - part="${SNF_IMAGE_DEV}$(@scriptsdir@/disklabel.py --print-last-linux "$SNF_IMAGE_DEV")" + bsd_part="$(@scriptsdir@/disklabel.py --get-last-partition "$SNF_IMAGE_DEV")" + if [ "$bsd_part" = "b" ]; then + warn "Last partition is swap space. Resizing ommited" + exit 0 + fi + + part="${SNF_IMAGE_DEV}$(disklabel2linux "$bsd_part")" - # If this fails the script will stop - $DUMPFS_OPENBSD "$part" > /dev/null + $DUMPFS_OPENBSD "$part" > /dev/null || + { warn "Filesystem is not UFS. Resizing ommited"; exit 0; } - $GROWFS_OPENBSD -y "$part" - exit 0 + $GROWFS_OPENBSD -y "$part" + exit 0 fi if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = netbsd ]; then -- 1.7.10.4