[Midnightbsd-cvs] src [11338] U trunk/usr.sbin/bsdinstall/scripts: update auto
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jul 5 13:57:49 EDT 2018
Revision: 11338
http://svnweb.midnightbsd.org/src/?rev=11338
Author: laffer1
Date: 2018-07-05 13:57:48 -0400 (Thu, 05 Jul 2018)
Log Message:
-----------
update auto
Modified Paths:
--------------
trunk/usr.sbin/bsdinstall/scripts/auto
trunk/usr.sbin/bsdinstall/scripts/checksum
trunk/usr.sbin/bsdinstall/scripts/config
Property Changed:
----------------
trunk/usr.sbin/bsdinstall/scripts/auto
trunk/usr.sbin/bsdinstall/scripts/checksum
trunk/usr.sbin/bsdinstall/scripts/config
Modified: trunk/usr.sbin/bsdinstall/scripts/auto
===================================================================
--- trunk/usr.sbin/bsdinstall/scripts/auto 2018-07-05 17:54:38 UTC (rev 11337)
+++ trunk/usr.sbin/bsdinstall/scripts/auto 2018-07-05 17:57:48 UTC (rev 11338)
@@ -1,6 +1,7 @@
#!/bin/sh
#-
# Copyright (c) 2011 Nathan Whitehorn
+# Copyright (c) 2013 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -25,15 +26,26 @@
# SUCH DAMAGE.
#
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/auto 313764 2017-02-15 09:15:51Z garga $
+#
+############################################################ INCLUDES
-echo "Begun Installation at $(date)" > $BSDINSTALL_LOG
+BSDCFG_SHARE="/usr/share/bsdconfig"
+. $BSDCFG_SHARE/common.subr || exit 1
+f_include $BSDCFG_SHARE/dialog.subr
+############################################################ FUNCTIONS
+
error() {
+ local msg
+ if [ -n "$1" ]; then
+ msg="$1\n\n"
+ fi
test -n "$DISTDIR_IS_UNIONFS" && umount -f $BSDINSTALL_DISTDIR
test -f $PATH_FSTAB && bsdinstall umount
dialog --backtitle "MidnightBSD Installer" --title "Abort" \
--no-label "Exit" --yes-label "Restart" --yesno \
- "An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
+ "${msg}An installation step has been aborted. Would you like to restart the installation or exit the installer?" 0 0
if [ $? -ne 0 ]; then
exit 1
else
@@ -41,7 +53,58 @@
fi
}
+hline_arrows_tab_enter="Press arrows, TAB or ENTER"
+msg_gpt_active_fix="Your hardware is known to have issues booting in CSM/Legacy/BIOS mode from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?"
+msg_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?"
+msg_no="NO"
+msg_yes="YES"
+# dialog_workaround
+#
+# Ask the user if they wish to apply a workaround
+#
+dialog_workaround()
+{
+ local passed_msg="$1"
+ local title="$DIALOG_TITLE"
+ local btitle="$DIALOG_BACKTITLE"
+ local prompt # Calculated below
+ local hline="$hline_arrows_tab_enter"
+
+ local height=8 width=50 prefix=" "
+ local plen=${#prefix} list= line=
+ local max_width=$(( $width - 3 - $plen ))
+
+ local yes no defaultno extra_args format
+ if [ "$USE_XDIALOG" ]; then
+ yes=ok no=cancel defaultno=default-no
+ extra_args="--wrap --left"
+ format="$passed_msg"
+ else
+ yes=yes no=no defaultno=defaultno
+ extra_args="--cr-wrap"
+ format="$passed_msg"
+ fi
+
+ # Add height for Xdialog(1)
+ [ "$USE_XDIALOG" ] && height=$(( $height + $height / 5 + 3 ))
+
+ prompt=$( printf "$format" )
+ f_dprintf "%s: Workaround prompt" "$0"
+ $DIALOG \
+ --title "$title" \
+ --backtitle "$btitle" \
+ --hline "$hline" \
+ --$yes-label "$msg_yes" \
+ --$no-label "$msg_no" \
+ $extra_args \
+ --yesno "$prompt" $height $width
+}
+
+############################################################ MAIN
+
+f_dprintf "Began Installation at %s" "$( date )"
+
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
@@ -49,7 +112,7 @@
bsdinstall keymap
trap error SIGINT # Catch cntrl-C here
-bsdinstall hostname || error
+bsdinstall hostname || error "Set hostname failed"
export DISTRIBUTIONS="base.txz kernel.txz"
if [ -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
@@ -86,33 +149,152 @@
BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&3)
MIRROR_BUTTON=$?
exec 3>&-
- test $MIRROR_BUTTON -eq 0 || error
+ test $MIRROR_BUTTON -eq 0 || error "No mirror selected"
export BSDINSTALL_DISTSITE
fi
-rm $PATH_FSTAB
+rm -f $PATH_FSTAB
touch $PATH_FSTAB
-dialog --backtitle "MidnightBSD Installer" --title "Partitioning" --extra-button \
- --extra-label "Manual" --ok-label "Guided" --cancel-label "Shell" \
- --yesno "Would you like to use the guided partitioning tool (recommended for beginners) or to set up partitions manually (experts)? You can also open a shell and set up partitions entirely by hand." 0 0
+#
+# Try to detect known broken platforms and apply their workarounds
+#
-case $? in
-0) # Guided
- bsdinstall autopart || error
- bsdinstall mount || error
+if f_interactive; then
+ sys_maker=$( kenv -q smbios.system.maker )
+ f_dprintf "smbios.system.maker=[%s]" "$sys_maker"
+ sys_model=$( kenv -q smbios.system.product )
+ f_dprintf "smbios.system.product=[%s]" "$sys_model"
+ sys_version=$( kenv -q smbios.system.version )
+ f_dprintf "smbios.system.version=[%s]" "$sys_version"
+ sys_mb_maker=$( kenv -q smbios.planar.maker )
+ f_dprintf "smbios.planar.maker=[%s]" "$sys_mb_maker"
+ sys_mb_product=$( kenv -q smbios.planar.product )
+ f_dprintf "smbios.planar.product=[%s]" "$sys_mb_product"
+
+ #
+ # Laptop Models
+ #
+ case "$sys_maker" in
+ "LENOVO")
+ case "$sys_version" in
+ "ThinkPad X220"|"ThinkPad T420"|"ThinkPad T520")
+ dialog_workaround "$msg_lenovo_fix"
+ retval=$?
+ f_dprintf "lenovofix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ export ZFSBOOT_PARTITION_SCHEME="GPT + Lenovo Fix"
+ export WORKAROUND_LENOVO=1
+ fi
+ ;;
+ esac
+ ;;
+ "Dell Inc.")
+ case "$sys_model" in
+ "Latitude E7440"|"Latitude E7240"|"Precision Tower 5810")
+ dialog_workaround "$msg_gpt_active_fix"
+ retval=$?
+ f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
+ export WORKAROUND_GPTACTIVE=1
+ fi
+ ;;
+ esac
+ ;;
+ "Hewlett-Packard")
+ case "$sys_model" in
+ "HP ProBook 4330s")
+ dialog_workaround "$msg_gpt_active_fix"
+ retval=$?
+ f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
+ export WORKAROUND_GPTACTIVE=1
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ #
+ # Motherboard Models
+ #
+ case "$sys_mb_maker" in
+ "Intel Corporation")
+ case "$sys_mb_product" in
+ "DP965LT"|"D510MO")
+ dialog_workaround "$msg_gpt_active_fix"
+ retval=$?
+ f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
+ export WORKAROUND_GPTACTIVE=1
+ fi
+ ;;
+ esac
+ ;;
+ "Acer")
+ case "$sys_mb_product" in
+ "Veriton M6630G")
+ dialog_workaround "$msg_gpt_active_fix"
+ retval=$?
+ f_dprintf "gpt_active_fix_prompt=[%s]" "$retval"
+ if [ $retval -eq $DIALOG_OK ]; then
+ export ZFSBOOT_PARTITION_SCHEME="GPT + Active"
+ export WORKAROUND_GPTACTIVE=1
+ fi
+ ;;
+ esac
+ ;;
+ esac
+fi
+
+PMODES="\
+\"Auto (UFS)\" \"Guided Disk Setup\" \
+Manual \"Manual Disk Setup (experts)\" \
+Shell \"Open a shell and partition by hand\""
+
+CURARCH=$( uname -m )
+case $CURARCH in
+ amd64|i386) # Booting ZFS Supported
+ PMODES="$PMODES \"Auto (ZFS)\" \"Guided Root-on-ZFS\""
+ ;;
+ *) # Booting ZFS Unspported
+ ;;
+esac
+
+exec 3>&1
+PARTMODE=`echo $PMODES | xargs dialog --backtitle "MidnightBSD Installer" \
+ --title "Partitioning" \
+ --menu "How would you like to partition your disk?" \
+ 0 0 0 2>&1 1>&3` || exit 1
+exec 3>&-
+
+case "$PARTMODE" in
+"Auto (UFS)") # Guided
+ bsdinstall autopart || error "Partitioning error"
+ bsdinstall mount || error "Failed to mount filesystem"
;;
-1) # Shell
+"Shell") # Shell
clear
echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'."
sh 2>&1
;;
-3) # Manual
- bsdinstall partedit || error
- bsdinstall mount || error
+"Manual") # Manual
+ if f_isset debugFile; then
+ # Give partedit the path to our logfile so it can append
+ BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error"
+ else
+ bsdinstall partedit || error "Partitioning error"
+ fi
+ bsdinstall mount || error "Failed to mount filesystem"
;;
+"Auto (ZFS)") # ZFS
+ bsdinstall zfsboot || error "ZFS setup failed"
+ bsdinstall mount || error "Failed to mount filesystem"
+ ;;
*)
- error
+ error "Unknown partitioning mode"
;;
esac
@@ -120,8 +302,8 @@
ALL_DISTRIBUTIONS="$DISTRIBUTIONS"
# Download to a directory in the new system as scratch space
- BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/midnightbsd-dist"
- mkdir -p "$BSDINSTALL_FETCHDEST" || error
+ BSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist"
+ mkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST"
export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
# Try to use any existing distfiles
@@ -129,18 +311,18 @@
DISTDIR_IS_UNIONFS=1
mount_nullfs -o union "$BSDINSTALL_FETCHDEST" "$BSDINSTALL_DISTDIR"
else
- export DISTRIBUTIONS="MANIFEST $ALL_DISTRIBUTIONS"
+ export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST"
fi
export FTP_PASSIVE_MODE=YES
- bsdinstall distfetch || error
+ bsdinstall distfetch || error "Failed to fetch distribution"
export DISTRIBUTIONS="$ALL_DISTRIBUTIONS"
fi
-bsdinstall checksum || error
-bsdinstall distextract || error
-bsdinstall rootpass || error
+bsdinstall checksum || error "Distribution checksum failed"
+bsdinstall distextract || error "Distribution extract failed"
+bsdinstall rootpass || error "Could not set root password"
trap true SIGINT # This section is optional
if [ "$NETCONFIG_DONE" != yes ]; then
@@ -157,7 +339,7 @@
exec 3>&1
REVISIT=$(dialog --backtitle "MidnightBSD Installer" \
--title "Final Configuration" --no-cancel --menu \
- "Setup of your BSD system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
+ "Setup of your MidnightBSD system is nearly complete. You can now modify your configuration choices. After this screen, you will have an opportunity to make more complex changes using a shell." 0 0 0 \
"Exit" "Apply configuration and exit installer" \
"Add User" "Add a user to the system" \
"Root Password" "Change root password" \
@@ -164,7 +346,7 @@
"Hostname" "Set system hostname" \
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
- "Time Zone" "Set system timezone" 2>&1 1>&3)
+ "Time Zone" "Set system timezone"
exec 3>&-
case "$REVISIT" in
@@ -199,23 +381,31 @@
finalconfig
trap error SIGINT # SIGINT is bad again
-bsdinstall config || error
+bsdinstall config || error "Failed to save config"
+if [ -n "$DISTDIR_IS_UNIONFS" ]; then
+ umount -f $BSDINSTALL_DISTDIR
+fi
+
if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
- [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \
- umount "$BSDINSTALL_DISTDIR"
rm -rf "$BSDINSTALL_FETCHDEST"
fi
dialog --backtitle "MidnightBSD Installer" --title "Manual Configuration" \
- --yesno "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
+ --default-button no --yesno \
+ "The installation is now finished. Before exiting the installer, would you like to open a shell in the new system to make any final manual modifications?" 0 0
if [ $? -eq 0 ]; then
clear
- mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
echo This shell is operating in a chroot in the new system. \
When finished making configuration changes, type \"exit\".
chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
fi
-echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
+bsdinstall entropy
+bsdinstall umount
+f_dprintf "Installation Completed at %s" "$( date )"
+
+################################################################################
+# END
+################################################################################
Property changes on: trunk/usr.sbin/bsdinstall/scripts/auto
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/bsdinstall/scripts/checksum
===================================================================
--- trunk/usr.sbin/bsdinstall/scripts/checksum 2018-07-05 17:54:38 UTC (rev 11337)
+++ trunk/usr.sbin/bsdinstall/scripts/checksum 2018-07-05 17:57:48 UTC (rev 11338)
@@ -25,7 +25,7 @@
# SUCH DAMAGE.
#
# $MidnightBSD$
-# $FreeBSD: src/usr.sbin/bsdinstall/scripts/checksum,v 1.2 2011/03/23 13:43:56 nwhitehorn Exp $
+# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/checksum 219903 2011-03-23 13:43:56Z nwhitehorn $
test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0
Property changes on: trunk/usr.sbin/bsdinstall/scripts/checksum
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/bsdinstall/scripts/config
===================================================================
--- trunk/usr.sbin/bsdinstall/scripts/config 2018-07-05 17:54:38 UTC (rev 11337)
+++ trunk/usr.sbin/bsdinstall/scripts/config 2018-07-05 17:57:48 UTC (rev 11338)
@@ -1,6 +1,7 @@
#!/bin/sh
#-
# Copyright (c) 2011 Nathan Whitehorn
+# Copyright (c) 2013-2015 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,9 @@
# SUCH DAMAGE.
#
# $MidnightBSD$
-# $FreeBSD: src/usr.sbin/bsdinstall/scripts/config,v 1.2 2011/07/13 13:25:12 nwhitehorn Exp $
+# $FreeBSD: stable/10/usr.sbin/bsdinstall/scripts/config 323571 2017-09-14 01:24:17Z emaste $
+#
+############################################################ MAIN
cat $BSDINSTALL_TMPETC/rc.conf.* >> $BSDINSTALL_TMPETC/rc.conf
rm $BSDINSTALL_TMPETC/rc.conf.*
@@ -32,6 +35,19 @@
cp $BSDINSTALL_TMPETC/* $BSDINSTALL_CHROOT/etc
+cat $BSDINSTALL_TMPBOOT/loader.conf.* >> $BSDINSTALL_TMPBOOT/loader.conf
+rm $BSDINSTALL_TMPBOOT/loader.conf.*
+df -t zfs $BSDINSTALL_CHROOT > /dev/null && echo "zfs_load=\"YES\"" >> $BSDINSTALL_TMPBOOT/loader.conf
+
+cp $BSDINSTALL_TMPBOOT/* $BSDINSTALL_CHROOT/boot
+
+[ "${debugFile#+}" ] && cp "${debugFile#+}" $BSDINSTALL_CHROOT/var/log/
+
# Set up other things from installed config
-chroot $BSDINSTALL_CHROOT /usr/bin/newaliases
+chroot $BSDINSTALL_CHROOT /usr/bin/newaliases > /dev/null 2>&1
+exit 0
+
+################################################################################
+# END
+################################################################################
Property changes on: trunk/usr.sbin/bsdinstall/scripts/config
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list