From 27e3ed99f7e5af7e841b6cae94555bc4d9cabc8d Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 25 Jun 2014 19:18:28 +0200 Subject: [PATCH] installer: support for separate /boot partition (which is required for LVM support) --- installer/installer.kmdr | 1108 ++++++++++++++++++++++++-------------- installer/installer.sh | 67 ++- 2 files changed, 759 insertions(+), 416 deletions(-) diff --git a/installer/installer.kmdr b/installer/installer.kmdr index 3a78cce..9acb12a 100755 --- a/installer/installer.kmdr +++ b/installer/installer.kmdr @@ -1599,7 +1599,7 @@ dcop @dcopid KommanderIf setText swapsizelabel "@i18n("In order to install openm for d in $devices; do # lvm device? - lvm_vgname=`sudo pvdisplay $d 2>/dev/null | grep "VG Name" | sed "s|.*VG Name[[:space:]]*||"` + lvm_vgname=`sudo pvdisplay $d 2>/dev/null | grep "VG Name" | sed "s|.*VG Name[[:space:]]*||"` if [ "$lvm_vgname" ]; then diskdevice=$lvm_vgname native_path="/dev/$lvm_vgname" @@ -1997,27 +1997,6 @@ dcop @dcopid KommanderIf setText installhint "$insthint" WordBreak|AlignTop - - - devicesbox - - - - 10 - 90 - 540 - 130 - - - - - - - - - - - Layout4 @@ -2113,6 +2092,27 @@ dcop @dcopid KommanderIf setText installhint "$insthint" + + + devicesbox + + + + 10 + 90 + 540 + 130 + + + + + + + + + + + @@ -2275,224 +2275,6 @@ function get_udisks_key_last() { Home partition choice - - - PartitionBox_2 - - - true - - - - 10 - 70 - 560 - 260 - - - - - 3 - 7 - 0 - 0 - - - - Where do you want to have openmamba home folder? - - - - - - - - - Layout2_2 - - - - 10 - 220 - 540 - 19 - - - - - unnamed - - - 0 - - - 6 - - - - Label3_2 - - - - 1 - 5 - 0 - 0 - - - - - 1 - - - - Mount home from: - - - AlignVCenter|AlignLeft - - - - - showdevice_2 - - - - 7 - 5 - 0 - 0 - - - - - - - - - - - - - - - - Layout6_2 - - - - 10 - 240 - 540 - 17 - - - - - unnamed - - - 0 - - - 6 - - - - Label22_2_2 - - - - 3 - 5 - 0 - 0 - - - - Format (all current data will be lost) - - - - - format_home_box - - - false - - - - 3 - 0 - 0 - 0 - - - - - - - true - - - - - - - devicesbox_2 - - - - 10 - 90 - 540 - 130 - - - - -1 - - - Single - - - - - - - - - - - - - Label24_2 - - - - 10 - 20 - 540 - 60 - - - - - 1 - - - - Please, select the disk partition that will contain user data. -<br>This is an optional choice, just go to the next step if you don't want a separate home partition. - - - RichText - - - WordBreak|AlignTop - - - PixmapLabel4_2 @@ -2668,6 +2450,45 @@ function get_udisks_key_last() { AlignCenter + + + setlabel_2 + + + + 550 + 50 + 32 + 32 + + + + + + + + @execBegin +@format_home_box.setEnabled(false) +@if (@devicesbox_2.currentItem >= 0) + currdev=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0) + if [ "$currdev" != "none" -a "$currdev" != "nessuna" ]; then + dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "@devicesbox_2.item(@devicesbox_2.currentItem)" + dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box true + dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group @format_home_box.checked() + else + dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "" + dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box false + dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group false + fi + @dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true) + @BackBox.setChecked(true) + dcop @dcopid KommanderIf "setCurrentItem(int)" 0 +@endif +@execEnd +@setBootableCheckbox.execute() + + + scanDevices_2 @@ -2741,44 +2562,223 @@ done - + - setlabel_2 + PartitionBox_2 + + + true - 550 - 50 - 32 - 32 + 10 + 70 + 560 + 260 - - + + + 3 + 7 + 0 + 0 + + + + Where do you want to have openmamba home folder? - @execBegin -@format_home_box.setEnabled(false) -@if (@devicesbox_2.currentItem >= 0) - currdev=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0) - if [ "$currdev" != "none" -a "$currdev" != "nessuna" ]; then - dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "@devicesbox_2.item(@devicesbox_2.currentItem)" - dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box true - dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group @format_home_box.checked() - else - dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_2 "" - dcop @dcopid KommanderIf "setEnabled(QString,bool)" format_home_box false - dcop @dcopid KommanderIf "setEnabled(QString,bool)" formathome_group false - fi - @dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true) - @BackBox.setChecked(true) - dcop @dcopid KommanderIf "setCurrentItem(int)" 0 -@endif -@execEnd -@setBootableCheckbox.execute() + + + + Layout6_2 + + + + 10 + 240 + 540 + 17 + + + + + unnamed + + + 0 + + + 6 + + + + Label22_2_2 + + + + 3 + 5 + 0 + 0 + + + + Format (all current data will be lost) + + + + + format_home_box + + + false + + + + 3 + 0 + 0 + 0 + + + + + + + true + + + + + + + Label24_2 + + + + 10 + 20 + 540 + 60 + + + + + 1 + + + + Please, select the disk partition that will contain user data. +<br>This is an optional choice, just go to the next step if you don't want a separate home partition. + + + RichText + + + WordBreak|AlignTop + + + + + devicesbox_2 + + + + 10 + 90 + 540 + 130 + + + + -1 + + + Single + + + + + + + + + + + + + Layout2_2 + + + + 10 + 220 + 540 + 19 + + + + + unnamed + + + 0 + + + 6 + + + + Label3_2 + + + + 1 + 5 + 0 + 0 + + + + + 1 + + + + Mount home from: + + + AlignVCenter|AlignLeft + + + + + showdevice_2 + + + + 7 + 5 + 0 + 0 + + + + + + + + + + + + + @@ -2828,53 +2828,21 @@ done AlignCenter - + - BootloaderBox + GroupBox16 10 - 70 + 340 560 - 360 + 90 - - - 3 - 4 - 0 - 0 - - Bootloader configuration - - - Label29_2 - - - - 10 - 20 - 531 - 40 - - - - - 1 - - - - Please select where you want to install the boot manager. - - - WordBreak|AlignVCenter - - Layout5_2 @@ -2882,7 +2850,7 @@ done 10 - 60 + 50 530 26 @@ -2899,7 +2867,7 @@ done - Label3_2_3 + Label3_2_3_2 @@ -2954,6 +2922,30 @@ done + + + Label29_2 + + + + 10 + 20 + 531 + 30 + + + + + 1 + + + + Please select where you want to install the boot manager. + + + WordBreak|AlignVCenter + + setBootableCheckbox @@ -2991,6 +2983,288 @@ fi + + + scanDevices_3 + + + + 550 + 0 + 32 + 32 + + + + + @devicesbox_3.clear +@execBegin +function get_udisks_key() { + LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|" +} +devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r` +partlabel= +installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0) +homedevice=@String.section(@devicesbox_3.item(@devicesbox_3.currentItem)," ",0) +dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_3 "@i18n("none (just use a single partition for system and boot)")" 0 +for device in $devices; do + [ "${device:5}" = "$installdevice" -o "${device:5}" = "$homedevice" ] && continue + if [ "${device:5:3}" != "dm-" ]; then + native_path=`get_udisks_key $device native-path` + [ -e $native_path/partition ] || continue + fi + is_system_internal=`get_udisks_key $device "system internal"` + volsize=`get_udisks_key $device size` + volsize=`expr $volsize / 1024 / 1024` + if [ "${device:5:3}" = "dm-" ]; then + volname=`sudo dmsetup info $device | grep "^Name:" | sed "s|.*[[:space:]]||"` + else + volname=`get_udisks_key $device label` + fi + [ $volsize -ge 512 ] || continue + [ "$volname" ] || volname="unnamed" + parttype=`get_udisks_key $device usage` + [ "$parttype" ] || parttype="unknown" + partscheme=`get_udisks_key $device scheme` + [ "$partscheme" ] || partscheme="unknown" + fstype=`get_udisks_key $device type` + [ "$fstype" ] || fstype="unformatted" + add_info="" + [ "$is_system_internal" = "1" ] || { + add_info=",removable" + [ @removablebox.checked == 1 ] || continue + } + if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then + partlabel="$partlabel<br>${device:5} $fstype $volname $volsize MB" + case "$fstype" in + ext2|ext3|ext4|reiserfs|reiser4|unformatted) + dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_3 "${device:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;; + *) ;; + esac + elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then + case "$fstype" in + swap|iso9660) ;; + ext2|ext3|ext4|reiserfs|reiser4|unformatted) + dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_3 "${device:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;; + *) ;; + esac + fi +done +@execEnd + + + + + + + setlabel_3 + + + + 550 + 40 + 32 + 32 + + + + + + + + @execBegin +@if (@devicesbox_3.currentItem >= 0) + currdev=@String.section(@devicesbox_3.item(@devicesbox_3.currentItem)," ",0) + if [ "$currdev" != "none" -a "$currdev" != "nessuna" ]; then + dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_3 "@devicesbox_3.item(@devicesbox_3.currentItem)" + else + dcop @dcopid KommanderIf "setText(QString,QString)" showdevice_3 "" + fi + @dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true) + @BackBox.setChecked(true) + dcop @dcopid KommanderIf "setCurrentItem(int)" 0 +@endif +@execEnd +@setBootableCheckbox.execute() + + + + + + BootloaderBox + + + + 10 + 70 + 560 + 260 + + + + + 3 + 4 + 0 + 0 + + + + Do you want a separate boot partition? + + + + Layout2_2_2 + + + + 10 + 210 + 540 + 19 + + + + + unnamed + + + 0 + + + 6 + + + + Label3_2_2 + + + + 1 + 5 + 0 + 0 + + + + + 1 + + + + Mount /boot from: + + + AlignVCenter|AlignLeft + + + + + showdevice_3 + + + + 7 + 5 + 0 + 0 + + + + + + + + + + + + + + + + Label22_2_2_3 + + + + 10 + 240 + 530 + 16 + + + + + 3 + 5 + 0 + 0 + + + + + 1 + + + + Warning: selected partition will be formatted and all current data will be lost. + + + + + Label24_2_4 + + + + 10 + 20 + 540 + 40 + + + + + 1 + + + + Please, select the boot partition. This is an optional feature for advanced users, in most cases it is safe to skip this choice. + + + RichText + + + WordBreak|AlignTop + + + + + devicesbox_3 + + + + 10 + 70 + 540 + 140 + + + + -1 + + + Single + + + + + + + + + + + @@ -3232,6 +3506,9 @@ fi installhomedevice=@String.section(@devicesbox_2.item(@devicesbox_2.currentItem)," ",0) [ "$installhomedevice" = "none" ] && installhomedevice= +installbootdevice=@String.section(@devicesbox_3.item(@devicesbox_3.currentItem)," ",0) +[ "$installbootdevice" = "none" ] && installbootdevice= + cat >>$conffile << _EOF INSTALL_DEVICE='/dev/$installdevice' INSTALL_DRIVER='@driverlabel.text' @@ -3252,6 +3529,13 @@ INSTALL_HOME_FSTYPE='@fstypebox_2.item(@fstypebox_2.currentItem)' _EOF fi +if [ "$installbootdevice" -a "${installbootdevice:0:1}" != "n" ]; then +cat >>$conffile << _EOF +INSTALL_BOOT_DEVICE='/dev/$installbootdevice' +INSTALL_BOOT_FORMAT='1' +INSTALL_BOOT_FSTYPE='@fstypebox.item(@fstypebox.currentItem)' +_EOF +fi @execEnd @if (@Message.question(@i18n("Selected partition") (@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)) @i18n("will be formatted; all data will be lost. OK to format?"), @i18n("Warning"), @i18n("OK"), @i18n("Abort")) == 1) @@ -3416,144 +3700,78 @@ fi - - kblayout_box - widgetTextChanged(const QString&) - setKB - execute() - GroupBox6 widgetOpened() - Timer1 - execute() - - - installer - selected(const QString&) - wizardScript - execute() - - - mbrbox - widgetOpened() - setBootableCheckbox - execute() - - - licenseBrowser - widgetOpened() - loadLicense - execute() - - - GroupBox6 - widgetOpened() - setTimeLabel - execute() - - - AcceptBox - stateChanged(int) - enableNext - execute(int) - - - devicesbox - widgetOpened() - scanDevices - execute() - - - GroupBox7_3 - widgetOpened() - setKeyboardLabel + ScriptObject15 execute() NextBox - widgetOpened() + stateChanged(int) wizardScript execute() - timelabel - widgetOpened() - Timer1 - execute() - - - progressBar - widgetOpened() - launchinstall - execute() - - - licenseBrowser - widgetOpened() - ScriptObject15_2 - execute() - - - devicesbox_2 - selectionChanged() - setlabel_2 - execute() - - - mbrbox - textChanged(const QString&) - setBootableCheckbox - execute() - - - devicesbox - selectionChanged() - setlabel - execute() - - - swapcheckbox + removablebox stateChanged(int) scandisks execute() - - GroupBox6 - widgetOpened() - ScriptObject15 - execute() - devicesbox_2 widgetOpened() scanDevices_2 execute() + + licenseBrowser + widgetOpened() + ScriptObject15_2 + execute() + partitionslabel widgetOpened() scandisks execute() - - kbgeometry_box - widgetTextChanged(const QString&) - setKB - execute() - - - mbrbox - widgetTextChanged(const QString&) - setBootableCheckbox - execute() - GroupBox5 widgetOpened() setLangLabel execute() + + devicesbox_3 + widgetOpened() + scanDevices_3 + execute() + + + GroupBox6 + widgetOpened() + setTimeLabel + execute() + + + kbgeometry_box + widgetTextChanged(const QString&) + setKB + execute() + + + GroupBox6 + widgetOpened() + Timer1 + execute() + + + installlog + widgetOpened() + ScriptObject7 + execute() + NextBox widgetOpened() @@ -3561,11 +3779,41 @@ fi execute() - NextBox + progressBar + widgetOpened() + launchinstall + execute() + + + swapcheckbox stateChanged(int) + scandisks + execute() + + + installer + selected(const QString&) wizardScript execute() + + devicesbox + selectionChanged() + setlabel + execute() + + + licenseBrowser + widgetOpened() + loadLicense + execute() + + + GroupBox7_3 + widgetOpened() + setKeyboardLabel + execute() + format_home_box toggled(bool) @@ -3573,15 +3821,45 @@ fi setEnabled(bool) - installlog + NextBox widgetOpened() - ScriptObject7 + wizardScript execute() - removablebox + devicesbox + widgetOpened() + scanDevices + execute() + + + kblayout_box + widgetTextChanged(const QString&) + setKB + execute() + + + devicesbox_3 + selectionChanged() + setlabel_3 + execute() + + + AcceptBox stateChanged(int) - scandisks + enableNext + execute(int) + + + devicesbox_2 + selectionChanged() + setlabel_2 + execute() + + + timelabel + widgetOpened() + Timer1 execute() diff --git a/installer/installer.sh b/installer/installer.sh index 9dc9007..1fbedbf 100755 --- a/installer/installer.sh +++ b/installer/installer.sh @@ -170,6 +170,26 @@ if [ "$INSTALL_HOME_DEVICE" ]; then esac fi +if [ "$INSTALL_BOOT_DEVICE" ]; then + case "$INSTALL_BOOT_FSTYPE" in + ext2|ext3|ext4) FORMAT_BOOT_CMD="/sbin/mkfs.$INSTALL_BOOT_FSTYPE" + FORMAT_BOOT_APPEND="$FORMAT_APPEND -L boot" + ;; + reiserfs|reiser4) FORMAT_BOOT_CMD="/sbin/mkfs.$INSTALL_BOOT_FSTYPE" + FORMAT_BOOT_APPEND="$FORMAT_APPEND -ff -l home" + ;; + *) FORMAT_BOOT_CMD="/sbin/mkfs.$INSTALL_BOOT_FSTYPE" + [ -e "$FORMAT_BOOT_CMD" ] || { + echo $"Error: $INSTALL_BOOT_FSTYPE is not a supported filesystem type; aborting." >&2 + abort + } + ;; + "") echo $"Error: filesystem type non specified; aborting." >&2 + abort + ;; + esac +fi + [ $INSTALL_DEVICE ] || { echo $"Error: installation device is not defined in $INPUT_FILE; aborting." >&2 abort @@ -216,6 +236,7 @@ mapfile=`tempfile 2>/dev/null` set -- $line [ "$1" = "${INSTALL_DEVICE:0:8}" ] && REMAPPED_INSTALL_DEVICE="${INSTALL_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_DEVICE:8:2}" [ "$1" = "${INSTALL_HOME_DEVICE:0:8}" ] && REMAPPED_INSTALL_HOME_DEVICE="${INSTALL_HOME_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_HOME_DEVICE:8:2}" + [ "$1" = "${INSTALL_BOOT_DEVICE:0:8}" ] && REMAPPED_INSTALL_BOOT_DEVICE="${INSTALL_BOOT_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_BOOT_DEVICE:8:2}" [ "$2" = "$INSTALL_DRIVER" ] && { DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1) DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]}) @@ -227,6 +248,7 @@ mapfile=`tempfile 2>/dev/null` done < $mapfile [ "$REMAPPED_INSTALL_DEVICE" ] || REMAPPED_INSTALL_DEVICE=$INSTALL_DEVICE [ "$REMAPPED_INSTALL_HOME_DEVICE" ] || REMAPPED_INSTALL_HOME_DEVICE=$INSTALL_HOME_DEVICE + [ "$REMAPPED_INSTALL_BOOT_DEVICE" ] || REMAPPED_INSTALL_BOOT_DEVICE=$INSTALL_BOOT_DEVICE echo $"Install device $INSTALL_DEVICE will be known as $REMAPPED_INSTALL_DEVICE in the installed system" # other drivers follow the root disk device driver @@ -259,6 +281,16 @@ if [ "$INSTALL_HOME_DEVICE" ]; then } fi +if [ "$INSTALL_BOOT_DEVICE" ]; then + mount | grep "$INSTALL_BOOT_DEVICE " && { + echo $"Info: device $INSTALL_BOOT_DEVICE already mounted; unmounting." + umount $INSTALL_BOOT_DEVICE || { + echo $"Error: could not unmount $INSTALL_BOOT_DEVICE; aborting." >&2 + abort + } + } +fi + mount | grep "$INSTALL_DEVICE " && { echo $"Info: device $INSTALL_DEVICE already mounted; unmounting." [ -e $MOUNTPOINT/dev ] && umount $MOUNTPOINT/dev @@ -319,7 +351,7 @@ if [ "$INSTALL_HOME_DEVICE" ]; then echo $"Formatting device $INSTALL_HOME_DEVICE" $FORMAT_HOME_CMD $INSTALL_HOME_DEVICE $FORMAT_HOME_APPEND [ $? -ne 0 ] && { - echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2 + echo $"Error: could not format device $INSTALL_HOME_DEVICE; aborting." >&2 abort } fi @@ -333,6 +365,26 @@ if [ "$INSTALL_HOME_DEVICE" ]; then } fi +if [ "$INSTALL_BOOT_DEVICE" ]; then + if [ "$INSTALL_BOOT_FORMAT" == "1" ]; then + dcop_write $"Formatting device $INSTALL_BOOT_DEVICE..." 10 + echo $"Formatting device $INSTALL_BOOT_DEVICE" + $FORMAT_BOOT_CMD $INSTALL_BOOT_DEVICE $FORMAT_BOOT_APPEND + [ $? -ne 0 ] && { + echo $"Error: could not format device $INSTALL_BOOT_DEVICE; aborting." >&2 + abort + } + fi + + dcop_write $"Mounting boot filesystem..." 10 + echo $"Mounting boot filesystem" + mkdir -p $MOUNTPOINT/boot + mount $INSTALL_BOOT_DEVICE $MOUNTPOINT/boot || { + echo $"Error: could not mount boot filesystem; aborting." >&2 + abort + } +fi + echo -n $"Copying files..." dcop_write $"Copying files..." 15 prog=15 @@ -422,6 +474,18 @@ if [ "$INSTALL_HOME_DEVICE" ]; then echo "$REMAPPED_INSTALL_HOME_DEVICE /home $INSTALL_HOME_FSTYPE defaults,noatime 2 2" >> $MOUNTPOINT/etc/fstab.new fi fi + +if [ "$INSTALL_BOOT_DEVICE" ]; then + eval `blkid $INSTALL_BOOT_DEVICE -o udev` + [ "$ID_FS_UUID" ] && INSTALL_BOOT_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_BOOT_DEVICE_UUID + [ "$INSTALL_BOOT_FORMAT" == "1" ] || INSTALL_BOOT_FSTYPE="auto" + if [ "$INSTALL_BOOT_DEVICE_UUID" ]; then + echo "UUID=$INSTALL_BOOT_DEVICE_UUID /boot $INSTALL_BOOT_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new + else + echo "$REMAPPED_INSTALL_BOOT_DEVICE /boot $INSTALL_BOOT_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new + fi +fi + mv $MOUNTPOINT/etc/fstab.new $MOUNTPOINT/etc/fstab if [ "$INSTALL_DRIVER" ]; then @@ -635,6 +699,7 @@ umount $MOUNTPOINT/proc umount $MOUNTPOINT/run umount $MOUNTPOINT/sys [ "$INSTALL_HOME_DEVICE" ] && umount $MOUNTPOINT/home +[ "$INSTALL_BOOT_DEVICE" ] && umount $MOUNTPOINT/boot # NOTE: move INPUT_FILE instead of copying to prevent mambawelcome from starting from # bootusb after an installation