140923b0cSNathan Whitehorn#!/bin/sh 240923b0cSNathan Whitehorn#- 340923b0cSNathan Whitehorn# Copyright (c) 2011 Nathan Whitehorn 440923b0cSNathan Whitehorn# Copyright (c) 2013-2018 Devin Teske 540923b0cSNathan Whitehorn# All rights reserved. 640923b0cSNathan Whitehorn# 740923b0cSNathan Whitehorn# Redistribution and use in source and binary forms, with or without 840923b0cSNathan Whitehorn# modification, are permitted provided that the following conditions 940923b0cSNathan Whitehorn# are met: 1040923b0cSNathan Whitehorn# 1. Redistributions of source code must retain the above copyright 1140923b0cSNathan Whitehorn# notice, this list of conditions and the following disclaimer. 1240923b0cSNathan Whitehorn# 2. Redistributions in binary form must reproduce the above copyright 1340923b0cSNathan Whitehorn# notice, this list of conditions and the following disclaimer in the 1440923b0cSNathan Whitehorn# documentation and/or other materials provided with the distribution. 1540923b0cSNathan Whitehorn# 1640923b0cSNathan Whitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1740923b0cSNathan Whitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1840923b0cSNathan Whitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1940923b0cSNathan Whitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2040923b0cSNathan Whitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2140923b0cSNathan Whitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2240923b0cSNathan Whitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2340923b0cSNathan Whitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2440923b0cSNathan Whitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2540923b0cSNathan Whitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2640923b0cSNathan Whitehorn# SUCH DAMAGE. 2740923b0cSNathan Whitehorn# 2840923b0cSNathan Whitehorn# 2940923b0cSNathan Whitehorn 302913e785SBrad DavisBSDCFG_SHARE="/usr/share/bsdconfig" 312913e785SBrad Davis. $BSDCFG_SHARE/common.subr || exit 1 322913e785SBrad Davis 3340923b0cSNathan Whitehornerror() 3440923b0cSNathan Whitehorn{ 352913e785SBrad Davis bsddialog --backtitle "$OSNAME Installer" --title "Error" --msgbox "$1" 0 0 3640923b0cSNathan Whitehorn exit 1 3740923b0cSNathan Whitehorn} 3840923b0cSNathan Whitehorn 3940923b0cSNathan WhitehornFETCH_DISTRIBUTIONS="" 4040923b0cSNathan WhitehornLOCAL_DISTRIBUTIONS="" 4140923b0cSNathan Whitehornfor dist in $DISTRIBUTIONS; do 4240923b0cSNathan Whitehorn if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then 4340923b0cSNathan Whitehorn FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" 4440923b0cSNathan Whitehorn else 4540923b0cSNathan Whitehorn LOCAL_DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS $dist" 4640923b0cSNathan Whitehorn fi 4740923b0cSNathan Whitehorndone 4840923b0cSNathan WhitehornLOCAL_DISTRIBUTIONS=`echo $LOCAL_DISTRIBUTIONS` # Trim white space 4940923b0cSNathan WhitehornFETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space 5040923b0cSNathan Whitehorn 5140923b0cSNathan Whitehornif [ -z "$FETCH_DISTRIBUTIONS" ]; then 5240923b0cSNathan Whitehorn echo $BSDINSTALL_DISTDIR >&2 5340923b0cSNathan Whitehorn exit 0 5440923b0cSNathan Whitehornfi 5540923b0cSNathan Whitehorn 5640923b0cSNathan WhitehornWANT_DEBUG= 5740923b0cSNathan Whitehorn 5840923b0cSNathan Whitehorn# Download to a directory in the new system as scratch space 5940923b0cSNathan WhitehornBSDINSTALL_FETCHDEST="$BSDINSTALL_CHROOT/usr/freebsd-dist" 6040923b0cSNathan Whitehornmkdir -p "$BSDINSTALL_FETCHDEST" || error "Could not create directory $BSDINSTALL_FETCHDEST" 6140923b0cSNathan Whitehorn 6240923b0cSNathan Whitehornif [ -z "$BSDINSTALL_DISTSITE" ]; then 63*c0e249d3SLars Kellogg-Stedman exec 5>&1 64*c0e249d3SLars Kellogg-Stedman BSDINSTALL_DISTSITE=$(`dirname $0`/mirrorselect 2>&1 1>&5) 6540923b0cSNathan Whitehorn MIRROR_BUTTON=$? 66*c0e249d3SLars Kellogg-Stedman exec 5>&- 6740923b0cSNathan Whitehorn test $MIRROR_BUTTON -eq 0 || error "No mirror selected" 6840923b0cSNathan Whitehorn export BSDINSTALL_DISTSITE 6940923b0cSNathan Whitehornfi 7040923b0cSNathan Whitehorn 7140923b0cSNathan WhitehornBSDINSTALL_DISTDIR_ORIG="$BSDINSTALL_DISTDIR" 7240923b0cSNathan Whitehornexport BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST" 7340923b0cSNathan Whitehornexport FTP_PASSIVE_MODE=YES 7440923b0cSNathan Whitehorn 7540923b0cSNathan Whitehornif [ -f "$BSDINSTALL_DISTDIR_ORIG/MANIFEST" ]; then 7640923b0cSNathan Whitehorn cp "$BSDINSTALL_DISTDIR_ORIG/MANIFEST" "$BSDINSTALL_DISTDIR/MANIFEST" 7740923b0cSNathan Whitehornelse 7840923b0cSNathan Whitehorn FETCH_DISTRIBUTIONS="MANIFEST $FETCH_DISTRIBUTIONS" 7940923b0cSNathan Whitehorn 8040923b0cSNathan Whitehorn # XXX actually verify signature on manifest 81cc42ef53SBrad Davis bsddialog --backtitle "$OSNAME Installer" --title "Warning" --msgbox "Manifest not found on local disk and will be fetched from an unverified source. This is a potential security risk. If you do not wish to proceed, press control-C now." 0 0 8240923b0cSNathan Whitehornfi 8340923b0cSNathan Whitehorn 8440923b0cSNathan Whitehornif [ ! -z "$LOCAL_DISTRIBUTIONS" ]; then 8540923b0cSNathan Whitehorn # Copy local stuff first 8640923b0cSNathan Whitehorn env DISTRIBUTIONS="$LOCAL_DISTRIBUTIONS" \ 8712b92f3eSKyle Evans BSDINSTALL_DISTSITE="file://$BSDINSTALL_DISTDIR_ORIG" \ 8840923b0cSNathan Whitehorn bsdinstall distfetch || \ 8940923b0cSNathan Whitehorn error "Failed to fetch distribution from local media" 9040923b0cSNathan Whitehornfi 9140923b0cSNathan Whitehorn 9240923b0cSNathan Whitehornexport DISTRIBUTIONS="$FETCH_DISTRIBUTIONS" 9340923b0cSNathan Whitehorn 9440923b0cSNathan Whitehorn# Iterate through the distribution list and set a flag if debugging 9540923b0cSNathan Whitehorn# distributions have been selected. 9640923b0cSNathan Whitehornfor _DISTRIBUTION in $DISTRIBUTIONS; do 9740923b0cSNathan Whitehorn case $_DISTRIBUTION in 9840923b0cSNathan Whitehorn *-dbg.*) 9940923b0cSNathan Whitehorn [ -e $BSDINSTALL_DISTDIR/$_DISTRIBUTION ] \ 10040923b0cSNathan Whitehorn && continue 10140923b0cSNathan Whitehorn WANT_DEBUG=1 10240923b0cSNathan Whitehorn DEBUG_LIST="\n$DEBUG_LIST\n$_DISTRIBUTION" 10340923b0cSNathan Whitehorn ;; 10440923b0cSNathan Whitehorn *) 10540923b0cSNathan Whitehorn ;; 10640923b0cSNathan Whitehorn esac 10740923b0cSNathan Whitehorndone 10840923b0cSNathan Whitehorn 10940923b0cSNathan Whitehorn# Fetch the distributions. 11040923b0cSNathan Whitehornbsdinstall distfetch 11140923b0cSNathan Whitehornrc=$? 11240923b0cSNathan Whitehorn 11340923b0cSNathan Whitehornif [ $rc -ne 0 ]; then 11440923b0cSNathan Whitehorn # If unable to fetch the remote distributions, recommend 11540923b0cSNathan Whitehorn # deselecting the debugging distributions, and retrying the 11640923b0cSNathan Whitehorn # installation, since failure to fetch *-dbg.txz should not 11740923b0cSNathan Whitehorn # be considered a fatal installation error. 11840923b0cSNathan Whitehorn msg="Failed to fetch remote distribution" 11940923b0cSNathan Whitehorn if [ ! -z "$WANT_DEBUG" ]; then 12040923b0cSNathan Whitehorn # Trim leading and trailing newlines. 12140923b0cSNathan Whitehorn DEBUG_LIST="${DEBUG_LIST%%\n}" 12240923b0cSNathan Whitehorn DEBUG_LIST="${DEBUG_LIST##\n}" 12340923b0cSNathan Whitehorn msg="$msg\n\nPlease deselect the following distributions" 12440923b0cSNathan Whitehorn msg="$msg and retry the installation:" 12540923b0cSNathan Whitehorn msg="$msg\n$DEBUG_LIST" 12640923b0cSNathan Whitehorn fi 12740923b0cSNathan Whitehorn error "$msg" 12840923b0cSNathan Whitehornfi 12940923b0cSNathan Whitehorn 13040923b0cSNathan Whitehornecho $BSDINSTALL_DISTDIR >&2 13140923b0cSNathan Whitehorn 132