diff --git a/bootstrap_sdk b/bootstrap_sdk index 2227d9f605..c7c40a3c42 100755 --- a/bootstrap_sdk +++ b/bootstrap_sdk @@ -29,13 +29,7 @@ # Command line option refs need caution though, since # stage1 must not contain updated ebuilds (see build_stage1 below). # -# 3. stage2: Run gentoo-subset/scripts/bootstrap.sh -# This rebuilds the toolchain using Gentoo bootstrapping, ensuring it's not linked -# to or otherwise influenced by whatever was in the "seed" tarball. -# The toolchain rebuild may contain updated package ebuilds from -# repos/(gentoo-subset|flatcar-overlay). -# This and all following stages use gentoo-subset and flatcar-overlay -# from repos/... (see 1.) +# 3. stage2: This is skipped as recommended by upstream Gentoo. # # 4. stage3: Run emerge -e system to rebuild everything using the fresh updated # toolchain from 3., using the normal USE flags provided by the profile. This @@ -45,7 +39,7 @@ # 5. stage4: Install any extra packages or other desired tweaks. For the # sdk we just install all the packages normally make_chroot.sh does. # -# Usage: bootstrap_sdk [stage1 stage2 etc] +# Usage: bootstrap_sdk [stage1 stage3 etc] # By default all four stages will be built using the latest stage4 as a seed. SCRIPT_ROOT=$(dirname $(readlink -f "$0")) @@ -107,7 +101,7 @@ cp "${BUILD_LIBRARY_DIR}/toolchain_util.sh" "${ROOT_OVERLAY}/tmp" # Stage 1 uses "known-good" ebuilds (from both flatcar-overlay and gentoo-subset) -# to build a minimal toolchain (USE="-*") for stage 2. +# to build a minimal toolchain (USE="-*") for stage 3. # # No package updates must happen in stage 1, so we use the gentoo-subset and # flatcar-overlay paths included with the current SDK (from the SDK chroot's @@ -115,14 +109,14 @@ cp "${BUILD_LIBRARY_DIR}/toolchain_util.sh" "${ROOT_OVERLAY}/tmp" # 'cork enter', i.e. the SDK we run ./bootstrap_sdk in. # # Using ebuilds from the above mentioned sources will ensure that stage 1 builds -# a minimal stage 2 from known-good ebuild versions - the same ebuild versions +# a stage 3 from known-good ebuild versions - the same ebuild versions # that were used to build the very SDK we run ./bootstrap_sdk in. # # DANGER ZONE # # Stage 1 lacks proper isolation and will link all packages built for -# stage 2 against its own seed libraries ("/" in the catalyst chroot) instead of against libraries -# installed into the FS root of the stage 2 seed ("/tmp/stage1root" in the catalyst chroot). +# stage 3 against its own seed libraries ("/" in the catalyst chroot) instead of against libraries +# installed into the FS root of the stage 3 seed ("/tmp/stage1root" in the catalyst chroot). # This is why we must prevent any updated package ebuilds to "leak" into stage 1, hence we use # "known good" ebuild repo versions outlined above. # @@ -130,10 +124,10 @@ cp "${BUILD_LIBRARY_DIR}/toolchain_util.sh" "${ROOT_OVERLAY}/tmp" # for either (or both) portage and overlay. The command line options # --stage1-portage-path and --stage1-overlay-path may be used to specify # a repo path known to work for stage1. In that case the stage1 seed (i.e. the seed SDK) -# will be updated prior to starting to build stage 2. +# will be updated prior to starting to build stage 3. # NOTE that this should never be used to introduce library updates in stage 1. All binaries # produced in stage 1 are linked against libraries in the seed tarball, NOT libraries produced -# by stage one. Therefore, these binaries will cease to work in stage 2 when linked against +# by stage 1. Therefore, these binaries will cease to work in stage 3 when linked against # outdated "seed tarball" libraries which have been updated to newer versions in stage 1. catalyst_build diff --git a/build_library/catalyst.sh b/build_library/catalyst.sh index 7493683659..31ffa8d155 100644 --- a/build_library/catalyst.sh +++ b/build_library/catalyst.sh @@ -112,14 +112,6 @@ EOF catalyst_stage_default 1 } -catalyst_stage2() { -cat < "$TEMPDIR/stage2.spec" - build_stage stage2 - used_seed=1 - fi - if [[ "$STAGES" =~ stage3 ]]; then if [[ $used_seed -eq 1 ]]; then - SEED="${TYPE}/stage2-${ARCH}-latest" + SEED="${TYPE}/stage1-${ARCH}-latest" fi info " stage3.spec" catalyst_stage3 > "$TEMPDIR/stage3.spec" diff --git a/repos/gentoo-subset/scripts/bootstrap.sh b/repos/gentoo-subset/scripts/bootstrap.sh deleted file mode 100755 index e07310e8e8..0000000000 --- a/repos/gentoo-subset/scripts/bootstrap.sh +++ /dev/null @@ -1,356 +0,0 @@ -#!/bin/bash -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# Maintainer: releng@gentoo.org - -file_version="2024.0" # update manually: . - -# people who were here: -# (drobbins, 06 Jun 2003) -# (solar, Jul 2004) -# (vapier, Aug 2004) -# (compnerd, Nov 2004) -# (wolf31o2, Jan 2005) -# (azarah, Mar 2005) -# (uberlord, May 2007) -# (kumba, May 2007) -# (williamh, Mar 2014) -# (kumba, Feb 2015) - -# sanity check -[[ -e /etc/profile ]] && . /etc/profile - -if [[ -e /lib/gentoo/functions.sh ]] ; then - source /lib/gentoo/functions.sh - elif [[ -e /etc/init.d/functions.sh ]] ; then - source /etc/init.d/functions.sh -else - eerror() { echo "!!! $*"; } - einfo() { echo "* $*"; } -fi - -# Use our own custom script, else logger cause things to -# 'freeze' if we do not have a system logger running -esyslog() { - : -} - -show_status() { - local num=$1 - shift - echo " [[ ($num/3) $* ]]" -} - -# Track progress of the bootstrap process to allow for -# semi-transparent resuming -progressfile=/var/run/bootstrap-progress -[[ -e ${progressfile} ]] && source ${progressfile} -export BOOTSTRAP_STAGE=${BOOTSTRAP_STAGE:-1} - -set_bootstrap_stage() { - [[ -z ${STRAP_RUN} ]] && return 0 - export BOOTSTRAP_STAGE=$1 - echo "BOOTSTRAP_STAGE=$1" > ${progressfile} -} - -v_echo() { - einfo "Executing: $*" - env "$@" -} - -file_copyright=$(sed -n '/Copyright/!b;s/^# *//;p;q' $0) - -usage() { - echo -e "Usage: ${HILITE}${0##*/}${NORMAL} ${GOOD}[options]${NORMAL}" - echo -e " ${GOOD}--debug (-d)${NORMAL} Run with debug information turned on" - echo -e " ${GOOD}--fetchonly (-f)${NORMAL} Just download all the source files" - echo -e " ${GOOD}--info (-i)${NORMAL} Show system related information" - echo -e " ${GOOD}--pretend (-p)${NORMAL} Display the packages that will be merged" - echo -e " ${GOOD}--quiet (-q)${NORMAL} Reduced or condensed output from portage" - echo -e " ${GOOD}--tree (-t)${NORMAL} Display the dependency tree, forces -p" - echo -e " ${GOOD}--resume (-r)${NORMAL} Build/use binary packages" - echo -e " ${GOOD}--verbose (-v)${NORMAL} Verbose output from portage" -} - -STRAP_EMERGE_OPTS="--oneshot" -STRAP_RUN=1 -V_ECHO=env -DEBUG=0 - -for opt in "$@" ; do - case ${opt} in - --fetchonly|-f) - echo "Running in fetch-only mode ..." - STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -f" - unset STRAP_RUN;; - --help|-h) - usage - exit 0;; - --debug|-d) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --debug"; DEBUG=1;; - --info|-i) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --info" ; unset STRAP_RUN ;; - --pretend|-p) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -p" ; unset STRAP_RUN ;; - --quiet|-q) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -q" ; unset STRAP_RUN ;; - --tree|-t) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -p -t" ; unset STRAP_RUN ;; - --resume|-r) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --usepkg --buildpkg";; - --verbose|-v) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -v" ; V_ECHO=v_echo;; - --version|-V) - einfo "Gentoo Linux bootstrap ${file_version}" - exit 0 - ;; - *) - eerror "Unknown option '${opt}'" - usage - exit 1;; - esac -done - -RESUME=0 -if [[ -n ${STRAP_RUN} ]] ; then - if [ ${BOOTSTRAP_STAGE} -ge 3 ] ; then - echo - einfo "System has been bootstrapped already!" - einfo "If you re-bootstrap the system, you must complete the entire bootstrap process" - einfo "otherwise you will have a broken system." - einfo "Press enter to continue or CTRL+C to abort ..." - read - set_bootstrap_stage 1 - elif [ ${BOOTSTRAP_STAGE} -gt 1 ] ; then - einfo "Resuming bootstrap at internal stage #${BOOTSTRAP_STAGE} ..." - RESUME=1 - fi -else - export BOOTSTRAP_STAGE=0 -fi - -for p in /etc/portage /etc ; do - p+="/make.profile" - [[ -e ${p} ]] || continue - if type -P realpath >/dev/null ; then - MYPROFILEDIR=$(realpath ${p}) - else - MYPROFILEDIR=$(readlink -f ${p}) - fi -done -if [[ ! -d ${MYPROFILEDIR} ]] ; then - eerror "Error: '${MYPROFILEDIR}' does not exist. Exiting." - exit 1 -fi - -echo -e "\n${GOOD}Gentoo Linux; ${BRACKET}https://www.gentoo.org/${NORMAL}" -echo -e "${file_copyright}; Distributed under the GPLv2" -if [[ " ${STRAP_EMERGE_OPTS} " == *" -f "* ]] ; then - echo "Fetching all bootstrap-related archives ..." -elif [[ -n ${STRAP_RUN} ]] ; then - if [ ${BOOTSTRAP_STAGE} -gt 2 ] ; then - echo "Resuming Bootstrap of base system ..." - else - echo "Starting Bootstrap of base system ..." - fi -fi -echo ------------------------------------------------------------------------------- -show_status 0 Locating packages - -# This should not be set to get glibc to build properly. See bug #7652. -unset LD_LIBRARY_PATH - -# We do not want stray $TMP, $TMPDIR or $TEMP settings -unset TMP TMPDIR TEMP - -cleanup() { - if [[ -n ${STRAP_RUN} ]] ; then - if [ ${BOOTSTRAP_STAGE} -le 2 ] ; then - cp -f /var/cache/edb/mtimedb /var/run/bootstrap-mtimedb - else - rm -f /var/run/bootstrap-mtimedb - fi - fi - exit $1 -} - -pycmd() { - [[ ${DEBUG} = "1" ]] && echo /usr/bin/python -c "$@" > /dev/stderr - /usr/bin/python -c "$@" -} - -# TSTP messes ^Z of bootstrap up, so we don't trap it anymore. -trap "cleanup" TERM INT QUIT ABRT - -# Bug #50158 (don't use `which` in a bootstrap). -if ! type -path portageq &>/dev/null ; then - echo ------------------------------------------------------------------------------- - eerror "Your portage version is too old. Please use a newer stage1 image." - echo - cleanup 1 -fi - -# USE may be set from the environment so we back it up for later. -export ORIGUSE=$(portageq envvar USE) - -# Check for 'build' or 'bootstrap' in USE ... -INVALID_USE=$(gawk -v ORIGUSE="${ORIGUSE}" ' - BEGIN { - if (ORIGUSE ~ /[[:space:]](build|bootstrap)[[:space:]]/) - print "yes" - }') - -# Do not do the check for stage build scripts ... -if [[ ${INVALID_USE} = "yes" ]] ; then - echo - eerror "You have 'build' or 'bootstrap' in your USE flags. Please" - eerror "remove it before trying to continue, since these USE flags" - eerror "are used for internal purposes and shouldn't be specified" - eerror "by you." - echo - cleanup 1 -fi - -# since our logic here ignores stuff found in package.use, let's warn the -# user so they can avert disaster early -if [[ -n $(sed -n '/^[ ]*#/d;/^[ ]*$/d;p' /etc/portage/package.use 2>/dev/null) ]] ; then - echo - ewarn "You appear to have custom USE flags set in /etc/portage/package.use." - ewarn "Be aware that these settings may be ignored while running this script" - ewarn "(due to limitations in the bootstrap process). If you have some USE" - ewarn "flags you wish to apply to say gcc or glibc, you should hit CTRL+C" - ewarn "now, export them in your environment (see below), and then restart." - ewarn " # export USE='some flags i want'" -fi - -# gettext should only be needed when used with nls -for opt in ${ORIGUSE} ; do - case "${opt}" in - bindist) - ALLOWED_USE="${ALLOWED_USE} bindist" - ;; - nls) - USE_NLS=1 - ALLOWED_USE="${ALLOWED_USE} nls" - ;; - multilib) - ALLOWED_USE="${ALLOWED_USE} multilib" - ;; - esac -done - -# With cascading profiles, the packages profile at the leaf is not a -# complete system, just the restrictions to it for the specific profile. -# The complete profile consists of an aggregate of the leaf and all its -# parents. So we now call portage to read the aggregate profile and store -# that into a variable. - -eval $(pycmd ' -import portage -from portage.dbapi._expand_new_virt import expand_new_virt -import sys -root = portage.settings["EROOT"] -for atom in portage.settings.packages: - if not isinstance(atom, portage.dep.Atom): - atom = portage.dep.Atom(atom.lstrip("*")) - varname = "my" + portage.catsplit(atom.cp)[1].upper().replace("-", "_") - atom = list(expand_new_virt(portage.db[root]["vartree"].dbapi, atom))[0] - sys.stdout.write("%s=\"%s\"; " % (varname, atom)) -') - -# This stuff should never fail but will if not enough is installed. -[[ -z ${myBASELAYOUT} ]] && myBASELAYOUT=">=$(portageq best_version / sys-apps/baselayout)" -[[ -z ${myPORTAGE} ]] && myPORTAGE="sys-apps/portage" -[[ -z ${myBINUTILS} ]] && myBINUTILS="sys-devel/binutils" -[[ -z ${myGCC} ]] && myGCC="sys-devel/gcc" -[[ -z ${myGETTEXT} ]] && myGETTEXT="sys-devel/gettext" -[[ -z ${myLIBC} ]] && myLIBC="$(portageq expand_virtual / virtual/libc)" -[[ -z ${myTEXINFO} ]] && myTEXINFO="sys-apps/texinfo" -[[ -z ${myZLIB} ]] && myZLIB="sys-libs/zlib" -[[ -z ${myNCURSES} ]] && myNCURSES="sys-libs/ncurses" -[[ -z ${myOS_HEADERS} ]] && myOS_HEADERS="$(portageq expand_virtual / virtual/os-headers)" -# Flatcar: install curl with BOOTSTRAP_USE=ssl to fetch from https URLs -[[ -z ${myCURL} ]] && myCURL="net-misc/curl" -# Flatcar: upgrade to openssl-3 before system rebuild in stage3 -[[ -z ${myOPENSSL} ]] && myOPENSSL="dev-libs/openssl" - -# Do we really want gettext/nls? -[[ ${USE_NLS} != 1 ]] && myGETTEXT= - -einfo "Using baselayout : ${myBASELAYOUT}" -einfo "Using portage : ${myPORTAGE}" -einfo "Using os-headers : ${myOS_HEADERS}" -einfo "Using binutils : ${myBINUTILS}" -einfo "Using gcc : ${myGCC}" -[[ ${USE_NLS} = "1" ]] && einfo "Using gettext : ${myGETTEXT}" -einfo "Using libc : ${myLIBC}" -einfo "Using texinfo : ${myTEXINFO}" -einfo "Using zlib : ${myZLIB}" -einfo "Using ncurses : ${myNCURSES}" -# Flatcar: install curl with BOOTSTRAP_USE=ssl to fetch from https URLs -einfo "Using curl : ${myCURL}" -# Flatcar: upgrade to openssl-3 before system rebuild in stage3 -einfo "Using openssl : ${myOPENSSL}" -echo ------------------------------------------------------------------------------- -show_status 1 Configuring environment -echo ------------------------------------------------------------------------------- - -[[ -x /usr/sbin/gcc-config ]] && GCC_CONFIG="/usr/sbin/gcc-config" -[[ -x /usr/bin/gcc-config ]] && GCC_CONFIG="/usr/bin/gcc-config" - -# Allow portage to overwrite stuff -[[ $CONFIG_PROTECT != "-*"* ]] && export CONFIG_PROTECT="-*" - -# disable collision-protection -export FEATURES="${FEATURES} -collision-protect" - -# query BOOTSTRAP_USE from the profile -BOOTSTRAP_USE=$(portageq envvar BOOTSTRAP_USE) - -if [ ${BOOTSTRAP_STAGE} -le 1 ] ; then - show_status 2 Updating portage - ${V_ECHO} USE="-* build bootstrap ${ALLOWED_USE} ${BOOTSTRAP_USE}" emerge ${STRAP_EMERGE_OPTS} ${myPORTAGE} || cleanup 1 - echo ------------------------------------------------------------------------------- - set_bootstrap_stage 2 -fi -export USE="-* bootstrap ${ALLOWED_USE} ${BOOTSTRAP_USE}" - -if [ ${BOOTSTRAP_STAGE} -le 2 ] ; then - show_status 3 Emerging packages - if [[ ${RESUME} -eq 1 ]] ; then - STRAP_EMERGE_POSARGS="" - STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --resume" - cp /var/run/bootstrap-mtimedb /var/cache/edb - else - # Flatcar: install curl with BOOTSTRAP_USE=ssl to fetch from https URLs - STRAP_EMERGE_POSARGS="\ - ${myOS_HEADERS} ${myTEXINFO} ${myGETTEXT} ${myBINUTILS} \ - ${myGCC} ${myLIBC} ${myCURL} ${myBASELAYOUT} ${myZLIB}" - # Flatcar: upgrade to openssl-3 before system rebuild in stage3 - STRAP_EMERGE_POSARGS="${STRAP_EMERGE_POSARGS} ${myOPENSSL}" - fi - ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} ${STRAP_EMERGE_POSARGS} || cleanup 1 - echo ------------------------------------------------------------------------------- - set_bootstrap_stage 3 -fi - -# Basic support for gcc multi version/arch scheme ... -if [[ -n ${STRAP_RUN} ]] ; then - if [[ -x ${GCC_CONFIG} ]] && ${GCC_CONFIG} --get-current-profile &>/dev/null - then - output=$(${V_ECHO} emerge ${STRAP_EMERGE_OPTS} --prune --pretend --quiet sys-devel/gcc 2>/dev/null) - if [[ ${DEBUG} = "1" ]] ; then - echo "${output}" - fi - if [[ "${output}" = *'All selected packages:'* ]] ; then - # Make sure we get the old gcc unmerged ... - ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} --prune sys-devel/gcc - # Make sure the profile and /lib/cpp and /usr/bin/cc are valid ... - ${GCC_CONFIG} "$(${GCC_CONFIG} --get-current-profile)" &>/dev/null - fi - fi -fi - -if [[ -n ${STRAP_RUN} ]] ; then - echo ------------------------------------------------------------------------------- - einfo "Please note that you should now add the '-e' option for emerge system:" - echo - einfo " # emerge -e @system" - echo -fi - -cleanup 0