installer.sh.in: fixes and improvements
+ Add INFOBOX() because dialog --infobox is incompatible with --keep-tite on xterm + Use clear after INFOBOX() to not leave irritating info on the screen + Make the live system copy process use a --progressbox + Use a tar pipe to copy from live ISO to target file system
This commit is contained in:
parent
50148f369f
commit
b820b28d66
|
@ -93,6 +93,13 @@ DIALOG() {
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INFOBOX() {
|
||||||
|
# Note: dialog --infobox and --keep-tite don't work together
|
||||||
|
dialog --colors --no-shadow --no-mouse \
|
||||||
|
--backtitle "${BOLD}${WHITE}Void Linux installation -- http://www.voidlinux.eu/ (@@MKLIVE_VERSION@@)${RESET}" \
|
||||||
|
--title "${TITLE}" --aspect 20 --infobox "$@"
|
||||||
|
}
|
||||||
|
|
||||||
DIE() {
|
DIE() {
|
||||||
rval=$1
|
rval=$1
|
||||||
[ -z "$rval" ] && rval=0
|
[ -z "$rval" ] && rval=0
|
||||||
|
@ -517,13 +524,13 @@ menu_locale() {
|
||||||
local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
|
local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
|
||||||
local LOCALES ISO639 ISO3166
|
local LOCALES ISO639 ISO3166
|
||||||
local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1)
|
local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1)
|
||||||
|
INFOBOX "Scanning locales ..." 4 60
|
||||||
echo "Scanning locales..."
|
|
||||||
for f in ${_locales}; do
|
for f in ${_locales}; do
|
||||||
eval $(echo $f | awk 'BEGIN { FS="." } \
|
eval $(echo $f | awk 'BEGIN { FS="." } \
|
||||||
{ FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }')
|
{ FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }')
|
||||||
echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
|
echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
|
||||||
done
|
done
|
||||||
|
clear
|
||||||
# Sort by ISO-639 language names
|
# Sort by ISO-639 language names
|
||||||
LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g')
|
LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g')
|
||||||
rm -f $TMPFILE
|
rm -f $TMPFILE
|
||||||
|
@ -596,10 +603,10 @@ menu_rootpassword() {
|
||||||
local _firstpass _secondpass _desc
|
local _firstpass _secondpass _desc
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ -n "${_firstpass}" ]; then
|
if [ -z "${_firstpass}" ]; then
|
||||||
_desc="Enter the root password again"
|
|
||||||
else
|
|
||||||
_desc="Enter the root password"
|
_desc="Enter the root password"
|
||||||
|
else
|
||||||
|
_desc="$_desc again"
|
||||||
fi
|
fi
|
||||||
DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
|
DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -610,9 +617,9 @@ menu_rootpassword() {
|
||||||
fi
|
fi
|
||||||
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
|
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
|
||||||
if [ "${_firstpass}" != "${_secondpass}" ]; then
|
if [ "${_firstpass}" != "${_secondpass}" ]; then
|
||||||
DIALOG --infobox "Passwords do not match! Please enter again." 6 80
|
INFOBOX "Passwords do not match! Please enter again." 6 60
|
||||||
unset _firstpass _secondpass
|
unset _firstpass _secondpass
|
||||||
sleep 2 && continue
|
sleep 2 && clear && continue
|
||||||
fi
|
fi
|
||||||
set_option ROOTPASSWORD "${_firstpass}"
|
set_option ROOTPASSWORD "${_firstpass}"
|
||||||
ROOTPASSWORD_DONE=1
|
ROOTPASSWORD_DONE=1
|
||||||
|
@ -631,9 +638,12 @@ set_rootpassword() {
|
||||||
menu_useraccount() {
|
menu_useraccount() {
|
||||||
local _firstpass _secondpass _desc
|
local _firstpass _secondpass _desc
|
||||||
local _groups _status _group _checklist
|
local _groups _status _group _checklist
|
||||||
|
local _preset
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "void"
|
_preset=$(get_option USERLOGIN)
|
||||||
|
[ -z "$_preset" ] && _preset="void"
|
||||||
|
DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
set_option USERLOGIN "$(cat $ANSWER)"
|
set_option USERLOGIN "$(cat $ANSWER)"
|
||||||
USERLOGIN_DONE=1
|
USERLOGIN_DONE=1
|
||||||
|
@ -644,8 +654,10 @@ menu_useraccount() {
|
||||||
done
|
done
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
_preset=$(get_option USERNAME)
|
||||||
|
[ -z "$_preset" ] && _preset="Void User"
|
||||||
DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \
|
DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \
|
||||||
${INPUTSIZE} "$(get_option USERLOGIN)"
|
${INPUTSIZE} "$_preset"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
set_option USERNAME "$(cat $ANSWER)"
|
set_option USERNAME "$(cat $ANSWER)"
|
||||||
USERNAME_DONE=1
|
USERNAME_DONE=1
|
||||||
|
@ -656,10 +668,10 @@ menu_useraccount() {
|
||||||
done
|
done
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ -n "${_firstpass}" ]; then
|
if [ -z "${_firstpass}" ]; then
|
||||||
_desc="Enter the password for login '$(get_option USERLOGIN)' again"
|
|
||||||
else
|
|
||||||
_desc="Enter the password for login '$(get_option USERLOGIN)'"
|
_desc="Enter the password for login '$(get_option USERLOGIN)'"
|
||||||
|
else
|
||||||
|
_desc="$_desc again"
|
||||||
fi
|
fi
|
||||||
DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
|
DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -670,9 +682,9 @@ menu_useraccount() {
|
||||||
fi
|
fi
|
||||||
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
|
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
|
||||||
if [ "${_firstpass}" != "${_secondpass}" ]; then
|
if [ "${_firstpass}" != "${_secondpass}" ]; then
|
||||||
DIALOG --infobox "Passwords do not match! Please enter again." 6 80
|
INFOBOX "Passwords do not match! Please enter again." 6 60
|
||||||
unset _firstpass _secondpass
|
unset _firstpass _secondpass
|
||||||
sleep 2 && continue
|
sleep 2 && clear && continue
|
||||||
fi
|
fi
|
||||||
set_option USERPASSWORD "${_firstpass}"
|
set_option USERPASSWORD "${_firstpass}"
|
||||||
USERPASSWORD_DONE=1
|
USERPASSWORD_DONE=1
|
||||||
|
@ -1003,7 +1015,8 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
|
||||||
vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
|
vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
|
||||||
xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;;
|
xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;;
|
||||||
esac
|
esac
|
||||||
DIALOG --infobox "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
|
TITLE="Check $LOG for details ..."
|
||||||
|
INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
|
||||||
echo "Running $MKFS $dev..." >$LOG
|
echo "Running $MKFS $dev..." >$LOG
|
||||||
$MKFS $dev >$LOG 2>&1; rv=$?
|
$MKFS $dev >$LOG 2>&1; rv=$?
|
||||||
if [ $rv -ne 0 ]; then
|
if [ $rv -ne 0 ]; then
|
||||||
|
@ -1087,13 +1100,38 @@ umount_filesystems() {
|
||||||
umount $TARGETDIR >$LOG 2>&1
|
umount $TARGETDIR >$LOG 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_and_count() {
|
||||||
|
local progress whole tenth
|
||||||
|
while read line; do
|
||||||
|
echo "$line" >$LOG
|
||||||
|
copy_count=$((copy_count + 1))
|
||||||
|
progress=$((1000 * copy_count / copy_total))
|
||||||
|
if [ "$progress" != "$copy_progress" ]; then
|
||||||
|
whole=$((progress / 10))
|
||||||
|
tenth=$((progress % 10))
|
||||||
|
printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total
|
||||||
|
copy_progress=$progress
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
copy_rootfs() {
|
copy_rootfs() {
|
||||||
DIALOG --title "Check $LOG for details" \
|
local tar_in="--create --one-file-system"
|
||||||
--infobox "Copying live image to target rootfs, please wait ..." 4 60
|
local tar_out="--extract --preserve-permissions"
|
||||||
LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&1
|
TITLE="Check $LOG for details ..."
|
||||||
|
INFOBOX "Counting files, please be patient ..." 4 60
|
||||||
|
copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l)
|
||||||
|
export copy_total copy_count=0 copy_progress=
|
||||||
|
clear
|
||||||
|
tar ${tar_in} -f - / 2>/dev/null | \
|
||||||
|
tar ${tar_out} -v -f - -C $TARGETDIR | \
|
||||||
|
log_and_count | \
|
||||||
|
DIALOG --title "${TITLE}" \
|
||||||
|
--progressbox "Copying live image to target rootfs." 5 60
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
DIE 1
|
DIE 1
|
||||||
fi
|
fi
|
||||||
|
unset copy_total copy_count copy_percent
|
||||||
}
|
}
|
||||||
|
|
||||||
install_packages() {
|
install_packages() {
|
||||||
|
@ -1171,14 +1209,13 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
|
||||||
echo "Removing $USERNAME live user from targetdir ..." >$LOG
|
echo "Removing $USERNAME live user from targetdir ..." >$LOG
|
||||||
chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
|
chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
|
||||||
sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers
|
sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers
|
||||||
DIALOG --title "Check $LOG for details" \
|
TITLE="Check $LOG for details ..."
|
||||||
--infobox "Rebuilding initramfs for target ..." 4 60
|
INFOBOX "Rebuilding initramfs for target ..." 4 60
|
||||||
echo "Rebuilding initramfs for target ..." >$LOG
|
echo "Rebuilding initramfs for target ..." >$LOG
|
||||||
# mount required fs
|
# mount required fs
|
||||||
mount_filesystems
|
mount_filesystems
|
||||||
chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
|
chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
|
||||||
DIALOG --title "Check $LOG for details" \
|
INFOBOX "Removing temporary packages from target ..." 4 60
|
||||||
--infobox "Removing temporary packages from target ..." 4 60
|
|
||||||
echo "Removing temporary packages from target ..." >$LOG
|
echo "Removing temporary packages from target ..." >$LOG
|
||||||
xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
|
xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
|
||||||
rmdir $TARGETDIR/mnt/target
|
rmdir $TARGETDIR/mnt/target
|
||||||
|
@ -1189,7 +1226,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
|
||||||
install_packages
|
install_packages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DIALOG --infobox "Applying installer settings..." 4 60
|
INFOBOX "Applying installer settings..." 4 60
|
||||||
|
|
||||||
# copy target fstab.
|
# copy target fstab.
|
||||||
install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab
|
install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab
|
||||||
|
|
Loading…
Reference in New Issue