From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1CB69158041 for ; Fri, 29 Mar 2024 17:17:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 487B6E29E5; Fri, 29 Mar 2024 17:17:13 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 16646E29E5 for ; Fri, 29 Mar 2024 17:17:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1A3D53430DD for ; Fri, 29 Mar 2024 17:17:12 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9F985BEB for ; Fri, 29 Mar 2024 17:17:10 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1711732614.c509de99f99cdd760a80dcef64e9d9051c2ca71a.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: scripts/bootstrap-prefix.sh X-VCS-Directories: scripts/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: c509de99f99cdd760a80dcef64e9d9051c2ca71a X-VCS-Branch: master Date: Fri, 29 Mar 2024 17:17:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9cd28f43-c76b-421d-9e1b-715e24f3373d X-Archives-Hash: e8c2f14b7e820401a02d42cfe94d53e9 commit: c509de99f99cdd760a80dcef64e9d9051c2ca71a Author: Fabian Groffen gentoo org> AuthorDate: Fri Mar 29 17:16:54 2024 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Mar 29 17:16:54 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=c509de99 scripts/bootstrap-prefix: shellcheck Signed-off-by: Fabian Groffen gentoo.org> scripts/bootstrap-prefix.sh | 74 ++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh index 0e3bf1ef75..351cf89f20 100755 --- a/scripts/bootstrap-prefix.sh +++ b/scripts/bootstrap-prefix.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +#shellcheck disable=SC2016,SC2030,SC2038,SC2185,SC2120 # Copyright 2006-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 @@ -200,13 +201,15 @@ configure_toolchain() { esac ;; *-darwin*) + local ccvers + local llvm_deps einfo "Triggering Darwin with LLVM/Clang toolchain" # for compilers choice, see bug: # https://bugs.gentoo.org/show_bug.cgi?id=538366 compiler_stage1="sys-apps/darwin-miscutils" compiler_type="clang" - local ccvers="$(unset CHOST; ${CC} --version 2>/dev/null)" - local llvm_deps="dev-build/ninja" + ccvers="$(unset CHOST; ${CC} --version 2>/dev/null)" + llvm_deps="dev-build/ninja" case "${ccvers}" in *"Apple clang version "*|*"Apple LLVM version "*) # this is Clang, recent enough to compile recent clang @@ -683,8 +686,8 @@ bootstrap_portage() { einfo "Compiling ${A%.tar.*}" econf \ --with-offset-prefix="${ROOT}"/tmp \ - --with-portage-user="`id -un`" \ - --with-portage-group="`id -gn`" \ + --with-portage-user="$(id -un)" \ + --with-portage-group="$(id -gn)" \ --with-extra-path="${PATH}" \ || return 1 emake || return 1 @@ -980,7 +983,7 @@ bootstrap_gnu() { emake install || return 1 fi - cd "${ROOT}" + cd "${ROOT}" || return 1 rm -Rf "${S}" einfo "${A%.tar.*} successfully bootstrapped" } @@ -1242,13 +1245,13 @@ bootstrap_zlib_core() { # compiler to 32-bits code generation if requested here export CC="${CC} -m32" fi - local makeopts=( ${MAKEOPTS} ) + local makeopts=() # 1.2.5 suffers from a concurrency problem - [[ ${PV} == 1.2.5 ]] && makeopts=() + [[ ${PV} == 1.2.5 ]] || read -a makeopts <<< "${MAKEOPTS}" einfo "Compiling ${A%.tar.*}" CHOST= ${CONFIG_SHELL} ./configure --prefix="${ROOT}"/tmp/usr || return 1 - MAKEOPTS= + MAKEOPTS='' emake "${makeopts[@]}" || return 1 einfo "Installing ${A%.tar.*}" @@ -1502,8 +1505,8 @@ bootstrap_stage1() { || [[ $(m4 --version 2>&1) == *GNU*1.4.1?* ]] \ || (bootstrap_m4) || return 1 [[ -x ${ROOT}/tmp/usr/bin/bison ]] \ - || [[ $(bison --version 2>&1) == *GNU" "Bison") "2.[3-7]* ]] \ - || [[ $(bison --version 2>&1) == *GNU" "Bison") "[3-9]* ]] \ + || [[ $(bison --version 2>&1) == *"GNU Bison) "2.[3-7]* ]] \ + || [[ $(bison --version 2>&1) == *"GNU Bison) "[3-9]* ]] \ || (bootstrap_bison) || return 1 if [[ ! -x ${ROOT}/tmp/usr/bin/uniq ]]; then # If the system has a uniq, let's use it to test whether @@ -1612,12 +1615,12 @@ bootstrap_stage1() { # Portage) and binutils use it # note that this actually breaks the concept of stage1, this will be # compiled for the target prefix - for zlib in ${ROOT}/tmp/usr/lib*/libz.* ; do + for zlib in "${ROOT}"/tmp/usr/lib*/libz.* ; do [[ -e ${zlib} ]] && break zlib= done [[ -n ${zlib} ]] || (bootstrap_zlib) || return 1 - for libffi in ${ROOT}/tmp/usr/lib*/libffi.* ; do + for libffi in "${ROOT}"/tmp/usr/lib*/libffi.* ; do [[ -e ${libffi} ]] && break libffi= done @@ -1661,9 +1664,9 @@ bootstrap_stage1_log() { echo "IDENT: ${CHOST_IDENTIFY}" echo "===========================================" } >> ${ROOT}/stage1.log - bootstrap_stage1 "${@}" 2>&1 | tee -a ${ROOT}/stage1.log + bootstrap_stage1 "${@}" 2>&1 | tee -a "${ROOT}"/stage1.log local ret=${PIPESTATUS[0]} - [[ ${ret} == 0 ]] && touch ${ROOT}/.stage1-finished + [[ ${ret} == 0 ]] && touch "${ROOT}"/.stage1-finished return ${ret} } @@ -1682,18 +1685,18 @@ do_emerge_pkgs() { else vdb=${vdb}-\* fi - for pvdb in ${EPREFIX}/var/db/pkg/${vdb%-*}-* ; do + for pvdb in "${EPREFIX}/var/db/pkg/${vdb%-*}"-* ; do if [[ -d ${pvdb} ]] ; then evdb=${pvdb##*/} if [[ ${pkg} == "="* ]] ; then # exact match required (* should work here) - [[ ${evdb} == ${vdb##*/} ]] && break + [[ ${evdb} == "${vdb##*/}" ]] && break else vdb=${vdb%-*} evdb=${evdb%-r*} evdb=${evdb%_p*} evdb=${evdb%-*} - [[ ${evdb} == ${vdb#*/} ]] && break + [[ ${evdb} == "${vdb#*/}" ]] && break fi fi pvdb= @@ -1718,7 +1721,7 @@ do_emerge_pkgs() { clang internal-glib ) - local override_make_conf_dir="${PORTAGE_OVERRIDE_EPREFIX}${MAKE_CONF_DIR#${ROOT}}" + local override_make_conf_dir="${PORTAGE_OVERRIDE_EPREFIX}${MAKE_CONF_DIR#"${ROOT}"}" if [[ " ${USE} " == *" prefix-stack "* ]] && [[ ${PORTAGE_OVERRIDE_EPREFIX} == */tmp ]] && @@ -1733,15 +1736,15 @@ do_emerge_pkgs() { echo "USE=\"\${USE} ${myuse[*]}\" # by bootstrap-prefix.sh" \ >> "${override_make_conf_dir}/0101_bootstrap_prefix_stack.conf" fi - myuse=" ${myuse[*]} " + local smyuse=" ${myuse[*]} " local use for use in ${USE} ; do - myuse=" ${myuse/ ${use} /} " - myuse=" ${myuse/ -${use} /} " - myuse=" ${myuse/ ${use#-} /} " - myuse+=" ${use} " + smyuse=" ${smyuse/ ${use} /} " + smyuse=" ${smyuse/ -${use} /} " + smyuse=" ${smyuse/ ${use#-} /} " + smyuse=" ${smyuse} ${use} " done - myuse=( ${myuse} ) + read -a myuse <<< "${smyuse}" # Disable the STALE warning because the snapshot frequently gets stale. # @@ -1755,15 +1758,14 @@ do_emerge_pkgs() { estatus "${STAGE}: emerge ${pkg}" unset CFLAGS CXXFLAGS [[ -n ${OVERRIDE_CFLAGS} ]] \ - && export CFLAGS=${OVERRIDE_CFLAGS} + && export CFLAGS="${OVERRIDE_CFLAGS}" [[ -n ${OVERRIDE_CXXFLAGS} ]] \ - && export CXXFLAGS=${OVERRIDE_CXXFLAGS} + && export CXXFLAGS="${OVERRIDE_CXXFLAGS}" PORTAGE_SYNC_STALE=0 \ FEATURES="-news ${FEATURES}" \ USE="${myuse[*]}" \ emerge --color n -v --oneshot --root-deps ${opts} "${pkg}" - ) - [[ $? -eq 0 ]] || return 1 + ) || return 1 done } @@ -1791,7 +1793,7 @@ bootstrap_stage2() { # bison's configure checks for perl, but doesn't use it, # except for tests. Since we don't want to pull in perl at this # stage, fake it - export PERL=$(which touch) + PERL="$(which touch)" ; export PERL # GCC sometimes decides that it needs to run makeinfo to update some # info pages from .texi files. Obviously we don't care at this # stage and rather have it continue instead of abort the build @@ -1866,7 +1868,7 @@ bootstrap_stage2() { # provide active SDK link on Darwin if [[ ${CHOST} == *-darwin* ]] ; then rm -f "${ROOT}"/tmp/MacOSX.sdk - ( cd "${ROOT}"/tmp && ln -s ../MacOSX.sdk ) + ( cd "${ROOT}"/tmp && ln -s ../MacOSX.sdk MacOSX.sdk ) fi # cmake has some external dependencies which require autoconf, etc. @@ -2014,13 +2016,15 @@ bootstrap_stage3() { for pef in python{,3} python{,3}-config ; do rm -f "${ROOT}"/tmp/usr/bin/${pef} [[ ${pef} == *-config ]] && ppf=-config || ppf= - ( cd "${ROOT}"/tmp/usr/bin && ln -s python$(python_ver)${ppf} ${pef} ) + ( cd "${ROOT}"/tmp/usr/bin && \ + ln -s "python$(python_ver)${ppf}" "${pef}" ) done get_libdir() { - local l=$(portageq envvar LIBDIR_$(portageq envvar ABI) 2>/dev/null) + local l + l="$(portageq envvar LIBDIR_$(portageq envvar ABI) 2>/dev/null)" [[ -z ${l} ]] && l=lib - echo ${l} + echo "${l}" } # Remember: binutils-config and gcc were built in ROOT/tmp, so they @@ -2030,7 +2034,7 @@ bootstrap_stage3() { export CONFIG_SHELL="${ROOT}"/tmp/bin/bash [[ ${compiler_type} == gcc ]] && \ export CPPFLAGS="-isystem ${ROOT}/usr/include" - export LDFLAGS="-L${ROOT}/usr/$(get_libdir)" + LDFLAGS="-L${ROOT}/usr/$(get_libdir)" ; export LDFLAGS [[ ${CHOST} == *-darwin* ]] || \ LDFLAGS+=" -Wl,-rpath=${ROOT}/usr/$(get_libdir)" unset CC CXX @@ -2117,7 +2121,7 @@ bootstrap_stage3() { # Tell dynamic loader the path of libgcc_s.so of stage2 if [[ ! -f "${ROOT}"/etc/ld.so.conf.d/stage2.conf ]]; then mkdir -p "${ROOT}"/etc/ld.so.conf.d - dirname $(gcc -print-libgcc-file-name) \ + dirname "$(gcc -print-libgcc-file-name)" \ > "${ROOT}"/etc/ld.so.conf.d/stage2.conf fi