diff --git a/rescue/rescue/Makefile b/rescue/rescue/Makefile index de3dd8a64575..4c351e632638 100644 --- a/rescue/rescue/Makefile +++ b/rescue/rescue/Makefile @@ -1,271 +1,264 @@ .include .include PACKAGE=rescue MAN= MK_SSP= no # Static-PIE is not supported so we should not be linking against _pie.a libs. # This is also needed to avoid linking against sanitizer-instrumented libraries # since MK_ASAN/MK_UBSAN will instrument the .pieo object files. MK_PIE= no NO_SHARED= yes CRUNCH_BUILDOPTS+= MK_PIE=no NO_SHARED=yes # lld >= 16 became more strict about multiply defined symbols. Since there are # many of those in crunchgen'd programs, turn off the check. .if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 160000 LDFLAGS+= -Wl,--allow-multiple-definition .endif PROG= rescue BINDIR?=/rescue -# Shell scripts need #! line to be edited from /bin/sh to /rescue/sh -SCRIPTS= nextboot_FIXED -SCRIPTSNAME_nextboot_FIXED= nextboot -nextboot_FIXED: ../../sbin/reboot/nextboot.sh - sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} -CLEANFILES+= nextboot_FIXED - SCRIPTS+= dhclient_FIXED SCRIPTSNAME_dhclient_FIXED= dhclient-script dhclient_FIXED: ../../sbin/dhclient/dhclient-script sed '1s/\/bin\//\/rescue\//' ${.ALLSRC} > ${.TARGET} CLEANFILES+= dhclient_FIXED # The help which used to be here is now in mk/bsd.crunchgen.mk # Define Makefile variable RESCUE CRUNCH_BUILDOPTS+= -DRESCUE # Define compile-time RESCUE symbol when compiling components CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE # An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk # rather than incorporating rescue-specific logic into standard files. #MAKEFLAGS= -m ${.CURDIR} ${.MAKEFLAGS} # Hackery: 'librescue' exists merely as a tool for appropriately # recompiling specific library entries. We _know_ they're needed, and # regular archive searching creates ugly library ordering problems. # Easiest fix: tell the linker to include them into the executable # first, so they are guaranteed to override the regular lib entries. # Note that if 'librescue' hasn't been compiled, we'll just get the # regular lib entries from libc and friends. CRUNCH_LIBS+= ${.OBJDIR}/../librescue/*.o ################################################################### # Programs from stock /bin # # WARNING: Changing this list may require adjusting # /usr/include/paths.h as well! You were warned! # CRUNCH_SRCDIRS+= bin CRUNCH_PROGS_bin= cat chflags chio chmod cp date dd df echo \ ed expr getfacl hostname kenv kill ln ls mkdir mv \ pkill ps pwd realpath rm rmdir setfacl sh sleep stty \ sync test CRUNCH_LIBS+= -lcrypt -ledit -ljail -lkvm -lelf -ltermcapw -lutil -lxo CRUNCH_BUILDTOOLS+= bin/sh # Additional options for specific programs CRUNCH_ALIAS_test= [ CRUNCH_ALIAS_sh= -sh # The -sh alias shouldn't appear in /rescue as a hard link CRUNCH_SUPPRESS_LINK_-sh= 1 CRUNCH_ALIAS_ln= link CRUNCH_ALIAS_rm= unlink CRUNCH_ALIAS_ed= red CRUNCH_ALIAS_pkill= pgrep .if ${MK_TCSH} != "no" CRUNCH_PROGS_bin+= csh CRUNCH_ALIAS_csh= -csh tcsh -tcsh CRUNCH_BUILDTOOLS+= bin/csh CRUNCH_SUPPRESS_LINK_-csh= 1 CRUNCH_SUPPRESS_LINK_-tcsh= 1 .endif ################################################################### # Programs from standard /sbin # # WARNING: Changing this list may require adjusting # /usr/include/paths.h as well! You were warned! # # Note that mdmfs have their own private 'pathnames.h' # headers in addition to the standard 'paths.h' header. # CRUNCH_SRCDIRS+= sbin CRUNCH_PROGS_sbin= \ camcontrol clri devfs dmesg dump \ dumpfs dumpon fsck fsck_ffs fsck_msdosfs fsdb \ fsirand gbde geom ifconfig init \ kldconfig kldload kldstat kldunload ldconfig \ md5 mdconfig mdmfs mknod mount mount_cd9660 \ mount_msdosfs mount_nfs mount_nullfs \ mount_udf mount_unionfs newfs \ newfs_msdos nos-tun reboot \ restore rcorder route savecore \ shutdown swapon sysctl tunefs umount .if ${MK_CCD} != "no" CRUNCH_PROGS_sbin+= ccdconfig .endif .if ${MK_INET} != "no" || ${MK_INET6} != "no" CRUNCH_PROGS_sbin+= ping .endif .if ${MK_INET6_SUPPORT} != "no" CRUNCH_ALIAS_ping= ping6 CRUNCH_PROGS_sbin+= rtsol .endif .if ${MK_IPFILTER} != "no" CRUNCH_PROGS_sbin+= ipf CRUNCH_LIBS_ipf+= ${LIBIPF} .endif .if ${MK_ROUTED} != "no" CRUNCH_PROGS_sbin+= routed rtquery .endif .if ${MK_ZFS} != "no" CRUNCH_PROGS_sbin+= bectl CRUNCH_PROGS_sbin+= zfs CRUNCH_PROGS_sbin+= zfsbootcfg CRUNCH_PROGS_sbin+= zpool CRUNCH_PROGS_usr.sbin+= zdb .endif # crunchgen does not like C++ programs; this should be fixed someday # CRUNCH_PROGS+= devd CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma .if ${MK_ZFS} != "no" CRUNCH_LIBS+= -lavl -lpthread -luutil -lumem -ltpool -lspl -lrt CRUNCH_LIBS_zfs+= ${LIBBE} \ ${LIBZPOOL} \ ${LIBZFS} \ ${LIBZUTIL} \ ${LIBZFS_CORE} \ ${LIBZFSBOOTENV} \ ${LIBICP_RESCUE} \ ${LIBNVPAIR} CRUNCH_LIBS_bectl+= ${CRUNCH_LIBS_zfs} CRUNCH_LIBS_zpool+= ${CRUNCH_LIBS_zfs} CRUNCH_LIBS_zdb+= ${CRUNCH_LIBS_zfs} ${LIBZDB} CRUNCH_LIBS_zfsbootcfg+=${LIBZFSBOOTENV} .else # liblzma needs pthread CRUNCH_LIBS+= -lpthread .endif CRUNCH_LIBS+= -lgeom -lbsdxml -lkiconv .if ${MK_OPENSSL} == "no" CRUNCH_LIBS+= -lmd .endif CRUNCH_LIBS+= -lmt -lsbuf -lufs -lz .if ${MACHINE_CPUARCH} == "i386" CRUNCH_PROGS_sbin+= bsdlabel fdisk CRUNCH_ALIAS_bsdlabel= disklabel #CRUNCH_PROGS+= mount_smbfs #CRUNCH_LIBS+= -lsmb .endif .if ${MACHINE_CPUARCH} == "amd64" CRUNCH_PROGS_sbin+= bsdlabel fdisk CRUNCH_ALIAS_bsdlabel= disklabel .endif CRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery CRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf .if ${MK_ZFS} != "no" CRUNCH_SRCDIR_zfs= ${SRCTOP}/cddl/sbin/zfs CRUNCH_SRCDIR_zpool= ${SRCTOP}/cddl/sbin/zpool CRUNCH_SRCDIR_zdb= ${SRCTOP}/cddl/usr.sbin/zdb .endif -CRUNCH_ALIAS_reboot= fastboot halt fasthalt +CRUNCH_ALIAS_reboot= fastboot halt fasthalt nextboot CRUNCH_ALIAS_restore= rrestore CRUNCH_ALIAS_dump= rdump CRUNCH_ALIAS_fsck_ffs= fsck_4.2bsd fsck_ufs CRUNCH_ALIAS_geom= glabel gpart CRUNCH_ALIAS_shutdown= poweroff # dhclient has historically been troublesome... CRUNCH_PROGS_sbin+= dhclient ################################################################## # Programs from stock /usr/bin # CRUNCH_SRCDIRS+= usr.bin CRUNCH_PROGS_usr.bin= head mt sed tail tee CRUNCH_PROGS_usr.bin+= gzip CRUNCH_ALIAS_gzip= gunzip gzcat zcat CRUNCH_PROGS_usr.bin+= bzip2 CRUNCH_ALIAS_bzip2= bunzip2 bzcat CRUNCH_LIBS+= -lbz2 CRUNCH_PROGS_usr.bin+= less CRUNCH_ALIAS_less= more CRUNCH_PROGS_usr.bin+= xz CRUNCH_ALIAS_xz= unxz lzma unlzma xzcat lzcat CRUNCH_PROGS_usr.bin+= zstd CRUNCH_ALIAS_zstd= unzstd zstdcat zstdmt CRUNCH_LIBS+= ${LDADD_zstd} CRUNCH_PROGS_usr.bin+= fetch CRUNCH_LIBS+= -lfetch CRUNCH_PROGS_usr.bin+= tar CRUNCH_LIBS+= -larchive .if ${MK_OPENSSL} != "no" CRUNCH_LIBS+= -lssl -lcrypto .endif CRUNCH_LIBS+= -lmd .if ${MK_NETCAT} != "no" CRUNCH_PROGS_usr.bin+= nc .endif .if ${MK_VI} != "no" CRUNCH_PROGS_usr.bin+= vi CRUNCH_ALIAS_vi= ex .endif CRUNCH_PROGS_usr.bin+= id CRUNCH_ALIAS_id= groups whoami ################################################################## # Programs from stock /usr/sbin # CRUNCH_SRCDIRS+= usr.sbin CRUNCH_PROGS_usr.sbin+= chroot CRUNCH_PROGS_usr.sbin+= chown CRUNCH_ALIAS_chown= chgrp ################################################################## CRUNCH_LIBS+= ${OBJTOP}/lib/libifconfig/libifconfig.a CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libifconfig CRUNCH_LIBS_ifconfig+= ${LIBNV} CRUNCH_LIBS+= -lm .if ${MK_ISCSI} != "no" CRUNCH_PROGS_usr.bin+= iscsictl CRUNCH_PROGS_usr.sbin+= iscsid CRUNCH_LIBS+= ${OBJTOP}/lib/libiscsiutil/libiscsiutil.a CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS+=-I${OBJTOP}/lib/libiscsiutil .endif .include .include diff --git a/sbin/reboot/Makefile b/sbin/reboot/Makefile index 4db6d5589e97..5e7a2fea15bf 100644 --- a/sbin/reboot/Makefile +++ b/sbin/reboot/Makefile @@ -1,21 +1,21 @@ PACKAGE=runtime PROG= reboot MAN= reboot.8 nextboot.8 MLINKS= reboot.8 halt.8 reboot.8 fastboot.8 reboot.8 fasthalt.8 .if exists(${.CURDIR}/boot_${MACHINE}.8) MAN+= boot_${MACHINE}.8 MLINKS+= boot_${MACHINE}.8 boot.8 .endif .if ${MACHINE} == "amd64" MAN+= boot_i386.8 MLINKS+= boot_i386.8 boot.8 .endif -LINKS= ${BINDIR}/reboot ${BINDIR}/halt ${BINDIR}/reboot ${BINDIR}/fastboot \ - ${BINDIR}/reboot ${BINDIR}/fasthalt - -SCRIPTS= nextboot.sh +LINKS= ${BINDIR}/reboot ${BINDIR}/halt \ + ${BINDIR}/reboot ${BINDIR}/fastboot \ + ${BINDIR}/reboot ${BINDIR}/fasthalt \ + ${BINDIR}/reboot ${BINDIR}/nextboot .include diff --git a/sbin/reboot/nextboot.sh b/sbin/reboot/nextboot.sh deleted file mode 100644 index 0c9cca51eb8d..000000000000 --- a/sbin/reboot/nextboot.sh +++ /dev/null @@ -1,132 +0,0 @@ -#! /bin/sh -# -# SPDX-License-Identifier: BSD-2-Clause -# -# Copyright (c) 2002 Gordon Tetlow. All rights reserved. -# Copyright (c) 2012 Sandvine Incorporated. 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. -# - -append="NO" -delete="NO" -kenv= -force="NO" -nextboot_file="/boot/nextboot.conf" -zfs= - -add_kenv() -{ - local var value - - var=$1 - # strip literal quotes if passed in - value=${2%\"*} - value=${value#*\"} - - if [ -n "${kenv}" ]; then - kenv="${kenv} -" - fi - kenv="${kenv}${var}=\"${value}\"" -} - -display_usage() { - cat <<-EOF - Usage: nextboot [-af] [-e variable=value] [-k kernel] [-o options] - nextboot -D - EOF -} - -while getopts "aDe:fk:o:" argument ; do - case "${argument}" in - a) - append="YES" - ;; - D) - delete="YES" - ;; - e) - var=${OPTARG%%=*} - value=${OPTARG#*=} - if [ -z "$var" -o -z "$value" ]; then - display_usage - exit 1 - fi - add_kenv "$var" "$value" - ;; - f) - force="YES" - ;; - k) - kernel="${OPTARG}" - add_kenv kernel "$kernel" - ;; - o) - add_kenv kernel_options "${OPTARG}" - ;; - *) - display_usage - exit 1 - ;; - esac -done - -if [ ${delete} = "YES" ]; then - rm -f ${nextboot_file} - exit 0 -fi - -if [ -z "${kenv}" ]; then - display_usage - exit 1 -fi - -if [ -n "${kernel}" -a ${force} = "NO" -a ! -d /boot/${kernel} ]; then - echo "Error: /boot/${kernel} doesn't exist. Use -f to override." - exit 1 -fi - -zfs=$(df -Tn "/boot/" 2>/dev/null | while read _fs _type _other ; do - [ "zfs" = "${_type}" ] || continue - echo "${_fs%%/*}" -done) - -set -e - -nextboot_tmp=$(mktemp $(dirname ${nextboot_file})/nextboot.XXXXXX) - -if [ -n "${zfs}" ]; then - zfsbootcfg -z ${zfs} -n freebsd:nvstore -k nextboot_enable -v YES - cat >> ${nextboot_tmp} << EOF -$kenv -EOF -else -cat >> ${nextboot_tmp} << EOF -nextboot_enable="YES" -$kenv -EOF -fi - -fsync ${nextboot_tmp} - -mv ${nextboot_tmp} ${nextboot_file}