installer.sh.in: fixes and improvements
Unified · Split
| @@ -93,6 +93,13 @@ DIALOG() { · 92 unmodified lines | ||
| 93 | 93 | return $? |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | +INFOBOX() { | |
| 97 | + # Note: dialog --infobox and --keep-tite don't work together | |
| 98 | + dialog --colors --no-shadow --no-mouse \ | |
| 99 | + --backtitle "${BOLD}${WHITE}Void Linux installation -- http://www.voidlinux.eu/ (@@MKLIVE_VERSION@@)${RESET}" \ | |
| 100 | + --title "${TITLE}" --aspect 20 --infobox "$@" | |
| 101 | +} | |
| 102 | + | |
| 96 | 103 | DIE() { |
| 97 | 104 | rval=$1 |
| 98 | 105 | [ -z "$rval" ] && rval=0 |
| @@ -517,13 +524,13 @@ menu_locale() { · 418 unmodified lines | ||
| 517 | 524 | local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" |
| 518 | 525 | local LOCALES ISO639 ISO3166 |
| 519 | 526 | local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) |
| 520 | − | |
| 521 | − echo "Scanning locales..." | |
| 527 | + INFOBOX "Scanning locales ..." 4 60 | |
| 522 | 528 | for f in ${_locales}; do |
| 523 | 529 | eval $(echo $f | awk 'BEGIN { FS="." } \ |
| 524 | 530 | { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') |
| 525 | 531 | echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE |
| 526 | 532 | done |
| 533 | + clear | |
| 527 | 534 | # Sort by ISO-639 language names |
| 528 | 535 | LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') |
| 529 | 536 | rm -f $TMPFILE |
| @@ -596,10 +603,10 @@ menu_rootpassword() { · 66 unmodified lines | ||
| 596 | 603 | local _firstpass _secondpass _desc |
| 597 | 604 | |
| 598 | 605 | while true; do |
| 599 | − if [ -n "${_firstpass}" ]; then | |
| 600 | − _desc="Enter the root password again" | |
| 601 | − else | |
| 606 | + if [ -z "${_firstpass}" ]; then | |
| 602 | 607 | _desc="Enter the root password" |
| 608 | + else | |
| 609 | + _desc="$_desc again" | |
| 603 | 610 | fi |
| 604 | 611 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} |
| 605 | 612 | if [ $? -eq 0 ]; then |
| @@ -610,9 +617,9 @@ menu_rootpassword() { · 4 unmodified lines | ||
| 610 | 617 | fi |
| 611 | 618 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then |
| 612 | 619 | if [ "${_firstpass}" != "${_secondpass}" ]; then |
| 613 | − DIALOG --infobox "Passwords do not match! Please enter again." 6 80 | |
| 620 | + INFOBOX "Passwords do not match! Please enter again." 6 60 | |
| 614 | 621 | unset _firstpass _secondpass |
| 615 | − sleep 2 && continue | |
| 622 | + sleep 2 && clear && continue | |
| 616 | 623 | fi |
| 617 | 624 | set_option ROOTPASSWORD "${_firstpass}" |
| 618 | 625 | ROOTPASSWORD_DONE=1 |
| @@ -631,9 +638,12 @@ set_rootpassword() { · 12 unmodified lines | ||
| 631 | 638 | menu_useraccount() { |
| 632 | 639 | local _firstpass _secondpass _desc |
| 633 | 640 | local _groups _status _group _checklist |
| 641 | + local _preset | |
| 634 | 642 | |
| 635 | 643 | while true; do |
| 636 | − DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "void" | |
| 644 | + _preset=$(get_option USERLOGIN) | |
| 645 | + [ -z "$_preset" ] && _preset="void" | |
| 646 | + DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset" | |
| 637 | 647 | if [ $? -eq 0 ]; then |
| 638 | 648 | set_option USERLOGIN "$(cat $ANSWER)" |
| 639 | 649 | USERLOGIN_DONE=1 |
| @@ -644,8 +654,10 @@ menu_useraccount() { · 4 unmodified lines | ||
| 644 | 654 | done |
| 645 | 655 | |
| 646 | 656 | while true; do |
| 657 | + _preset=$(get_option USERNAME) | |
| 658 | + [ -z "$_preset" ] && _preset="Void User" | |
| 647 | 659 | DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \ |
| 648 | − ${INPUTSIZE} "$(get_option USERLOGIN)" | |
| 660 | + ${INPUTSIZE} "$_preset" | |
| 649 | 661 | if [ $? -eq 0 ]; then |
| 650 | 662 | set_option USERNAME "$(cat $ANSWER)" |
| 651 | 663 | USERNAME_DONE=1 |
| @@ -656,10 +668,10 @@ menu_useraccount() { · 4 unmodified lines | ||
| 656 | 668 | done |
| 657 | 669 | |
| 658 | 670 | while true; do |
| 659 | − if [ -n "${_firstpass}" ]; then | |
| 660 | − _desc="Enter the password for login '$(get_option USERLOGIN)' again" | |
| 661 | − else | |
| 671 | + if [ -z "${_firstpass}" ]; then | |
| 662 | 672 | _desc="Enter the password for login '$(get_option USERLOGIN)'" |
| 673 | + else | |
| 674 | + _desc="$_desc again" | |
| 663 | 675 | fi |
| 664 | 676 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} |
| 665 | 677 | if [ $? -eq 0 ]; then |
| @@ -670,9 +682,9 @@ menu_useraccount() { · 4 unmodified lines | ||
| 670 | 682 | fi |
| 671 | 683 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then |
| 672 | 684 | if [ "${_firstpass}" != "${_secondpass}" ]; then |
| 673 | − DIALOG --infobox "Passwords do not match! Please enter again." 6 80 | |
| 685 | + INFOBOX "Passwords do not match! Please enter again." 6 60 | |
| 674 | 686 | unset _firstpass _secondpass |
| 675 | − sleep 2 && continue | |
| 687 | + sleep 2 && clear && continue | |
| 676 | 688 | fi |
| 677 | 689 | set_option USERPASSWORD "${_firstpass}" |
| 678 | 690 | USERPASSWORD_DONE=1 |
| @@ -1003,7 +1015,8 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} · 324 unmodified lines | ||
| 1003 | 1015 | vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;; |
| 1004 | 1016 | xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;; |
| 1005 | 1017 | esac |
| 1006 | − DIALOG --infobox "Creating filesystem $fstype on $dev for $mntpt ..." 8 60 | |
| 1018 | + TITLE="Check $LOG for details ..." | |
| 1019 | + INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60 | |
| 1007 | 1020 | echo "Running $MKFS $dev..." >$LOG |
| 1008 | 1021 | $MKFS $dev >$LOG 2>&1; rv=$? |
| 1009 | 1022 | if [ $rv -ne 0 ]; then |
| @@ -1087,13 +1100,38 @@ umount_filesystems() { · 77 unmodified lines | ||
| 1087 | 1100 | umount $TARGETDIR >$LOG 2>&1 |
| 1088 | 1101 | } |
| 1089 | 1102 | |
| 1103 | +log_and_count() { | |
| 1104 | + local progress whole tenth | |
| 1105 | + while read line; do | |
| 1106 | + echo "$line" >$LOG | |
| 1107 | + copy_count=$((copy_count + 1)) | |
| 1108 | + progress=$((1000 * copy_count / copy_total)) | |
| 1109 | + if [ "$progress" != "$copy_progress" ]; then | |
| 1110 | + whole=$((progress / 10)) | |
| 1111 | + tenth=$((progress % 10)) | |
| 1112 | + printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total | |
| 1113 | + copy_progress=$progress | |
| 1114 | + fi | |
| 1115 | + done | |
| 1116 | +} | |
| 1117 | + | |
| 1090 | 1118 | copy_rootfs() { |
| 1091 | − DIALOG --title "Check $LOG for details" \ | |
| 1092 | − --infobox "Copying live image to target rootfs, please wait ..." 4 60 | |
| 1093 | − LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&1 | |
| 1119 | + local tar_in="--create --one-file-system" | |
| 1120 | + local tar_out="--extract --preserve-permissions" | |
| 1121 | + TITLE="Check $LOG for details ..." | |
| 1122 | + INFOBOX "Counting files, please be patient ..." 4 60 | |
| 1123 | + copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l) | |
| 1124 | + export copy_total copy_count=0 copy_progress= | |
| 1125 | + clear | |
| 1126 | + tar ${tar_in} -f - / 2>/dev/null | \ | |
| 1127 | + tar ${tar_out} -v -f - -C $TARGETDIR | \ | |
| 1128 | + log_and_count | \ | |
| 1129 | + DIALOG --title "${TITLE}" \ | |
| 1130 | + --progressbox "Copying live image to target rootfs." 5 60 | |
| 1094 | 1131 | if [ $? -ne 0 ]; then |
| 1095 | 1132 | DIE 1 |
| 1096 | 1133 | fi |
| 1134 | + unset copy_total copy_count copy_percent | |
| 1097 | 1135 | } |
| 1098 | 1136 | |
| 1099 | 1137 | install_packages() { |
| @@ -1171,14 +1209,13 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 71 unmodified lines | ||
| 1171 | 1209 | echo "Removing $USERNAME live user from targetdir ..." >$LOG |
| 1172 | 1210 | chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 |
| 1173 | 1211 | sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers |
| 1174 | − DIALOG --title "Check $LOG for details" \ | |
| 1175 | − --infobox "Rebuilding initramfs for target ..." 4 60 | |
| 1212 | + TITLE="Check $LOG for details ..." | |
| 1213 | + INFOBOX "Rebuilding initramfs for target ..." 4 60 | |
| 1176 | 1214 | echo "Rebuilding initramfs for target ..." >$LOG |
| 1177 | 1215 | # mount required fs |
| 1178 | 1216 | mount_filesystems |
| 1179 | 1217 | chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 |
| 1180 | − DIALOG --title "Check $LOG for details" \ | |
| 1181 | − --infobox "Removing temporary packages from target ..." 4 60 | |
| 1218 | + INFOBOX "Removing temporary packages from target ..." 4 60 | |
| 1182 | 1219 | echo "Removing temporary packages from target ..." >$LOG |
| 1183 | 1220 | xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1 |
| 1184 | 1221 | rmdir $TARGETDIR/mnt/target |
| @@ -1189,7 +1226,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 4 unmodified lines | ||
| 1189 | 1226 | install_packages |
| 1190 | 1227 | fi |
| 1191 | 1228 | |
| 1192 | − DIALOG --infobox "Applying installer settings..." 4 60 | |
| 1229 | + INFOBOX "Applying installer settings..." 4 60 | |
| 1193 | 1230 | |
| 1194 | 1231 | # copy target fstab. |
| 1195 | 1232 | install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab |