mirror of
https://github.com/opnsense/src.git
synced 2026-03-02 05:13:58 -05:00
The bsdinstall script target did not have the infrastructure to fetch distfiles from a remote server the way the interactive installer does on e.g. bootonly media. Solve this by factoring out the parts of the installer that deal with fetching missing distributions into a new install stage called 'fetchmissingdists', which is called by both the interactive and scripted installer frontends. In the course of these changes, cleaned up a few other issues with the fetching of missing distribution files and added a warning if fetching the MANIFEST file, which is used to verify the integrity of the distribution files. We should at some point add cryptographic signatures to MANIFEST so that it can be fetched safely if not present on the install media (which it is for bootonly media). Initial patch by: Vinícius Zavam PR: 255659, 250928 Reviewed by: dteske MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D27121
94 lines
3.7 KiB
Bash
Executable file
94 lines
3.7 KiB
Bash
Executable file
#!/bin/sh
|
|
#-
|
|
# Copyright (c) 2018 Rebecca Cran
|
|
# Copyright (c) 2017 Nathan Whitehorn
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
# SUCH DAMAGE.
|
|
#
|
|
# $FreeBSD$
|
|
|
|
BSDCFG_SHARE="/usr/share/bsdconfig"
|
|
. $BSDCFG_SHARE/common.subr || exit 1
|
|
|
|
: ${TMPDIR:="/tmp"}
|
|
|
|
die() {
|
|
echo $*
|
|
exit 1
|
|
}
|
|
|
|
if [ `uname -m` == powerpc ]; then
|
|
platform=`sysctl -n hw.platform`
|
|
if [ "$platform" == ps3 -o "$platform" == powernv ]; then
|
|
rootpart=$(awk '{ if($2 == "/") printf("%s:%s\n", $3, $1); }' $PATH_FSTAB)
|
|
mkdir -p $BSDINSTALL_CHROOT/boot/etc/
|
|
echo FreeBSD=\'/kernel/kernel kernelname=/boot/kernel/kernel vfs.root.mountfrom=${rootpart}\' > $BSDINSTALL_CHROOT/boot/etc/kboot.conf
|
|
fi
|
|
fi
|
|
|
|
# Update the ESP (EFI System Partition) with the new bootloader if we have an ESP
|
|
if [ -n "$(awk '{if ($2=="/boot/efi") printf("%s\n",$1);}' $PATH_FSTAB)" ]; then
|
|
case $(uname -m) in
|
|
arm64) ARCHBOOTNAME=aa64 ;;
|
|
amd64) ARCHBOOTNAME=x64 ;;
|
|
riscv) ARCHBOOTNAME=riscv64 ;;
|
|
# arm) ARCHBOOTNAME=arm ;; # No other support for arm install
|
|
# i386) ARCHBOOTNAME=ia32 ;; # no support for this in i386 kernels, rare machines
|
|
*) die "Unsupported arch $(uname -m) for UEFI install"
|
|
esac
|
|
BOOTDIR="/efi/boot"
|
|
BOOTNAME="${BOOTDIR}/boot${ARCHBOOTNAME}.efi"
|
|
FREEBSD_BOOTDIR="/efi/freebsd"
|
|
FREEBSD_BOOTNAME="${FREEBSD_BOOTDIR}/loader.efi"
|
|
mntpt="$BSDINSTALL_CHROOT/boot/efi"
|
|
|
|
f_dprintf "Installing loader.efi onto ESP"
|
|
mkdir -p "${mntpt}/${FREEBSD_BOOTDIR}" "${mntpt}/${BOOTDIR}"
|
|
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${FREEBSD_BOOTNAME}"
|
|
|
|
#
|
|
# The following shouldn't be necessary. UEFI defines a way to
|
|
# specifically select what to boot (which we do via
|
|
# efibootmgr). However, virtual environments often times lack
|
|
# support for the NV variables efibootmgr sets. In addition,
|
|
# some UEFI implementations have features that interfere with
|
|
# the setting of these variables. To combat that, we install the
|
|
# default removable media boot file as a fallback if it doesn't
|
|
# exist. We don't install it all the time since that can
|
|
# interfere with other installations on the drive (like rEFInd).
|
|
#
|
|
if [ ! -f "${mntpt}/${BOOTNAME}" ]; then
|
|
cp "$BSDINSTALL_CHROOT/boot/loader.efi" "${mntpt}/${BOOTNAME}"
|
|
fi
|
|
|
|
bootlabel="FreeBSD"
|
|
|
|
if [ "$BSDINSTALL_CONFIGCURRENT" ]; then
|
|
f_dprintf "Creating UEFI boot entry"
|
|
efibootmgr --create --activate --label "$bootlabel" --loader "${mntpt}/${FREEBSD_BOOTNAME}" > /dev/null
|
|
fi
|
|
|
|
f_dprintf "Finished configuring ESP"
|
|
fi
|
|
|
|
# Add boot0cfg for MBR BIOS booting?
|