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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1C8D41382C5 for ; Sat, 16 May 2020 06:53:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 507FDE08DD; Sat, 16 May 2020 06:53:29 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 46478E08DD for ; Sat, 16 May 2020 06:53:29 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id n18so2113446pfa.2 for ; Fri, 15 May 2020 23:53:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XHewE2vkGwj2n6GRSiv2SnC66/3tvM8QRmCSZUOkMKY=; b=q8QPE8UQGA9q62BaoJHcRdnzcz22pZuhwa5NDhreAUPugDFAxn5LznGiV7dWBk8mEE l5ndxFQ/a8YX7+uBqlSjeiDDdEOhzwdi+dCLDJx4vUI1olSzG+0FFFsDh2Y4Do9cQVn0 Vw8UEs4oxMCZEp97hgxv3fvUc1cjZ/CILspfGS41FlkAhFHYE43Br3U1sg7YCa3ZABjL KEPFOuywPFCPVm3s+xEOSmD1w89vgDYaFlXy3ZSXKmdVXzkx72QeLXsIf3vCKmmLkQz0 /EVqWAnTzxas1CFC33Bvltf7S4u6ZBcqWoniX7USRVpYo87ZkNufCyWDzHDdTIzWr9zs 90og== X-Gm-Message-State: AOAM531YpcKRaeSemD0b97pcZxX9cahmroY2lE3wocQijkYQvwAu/fqP CAJnUSQmuYyVmny3sBJaY0wo5hDF X-Google-Smtp-Source: ABdhPJyMVs3tssAko87x61Sm7AHB963z8luID8kaiZGKlyM5MMqm9HpR/zhhtu42Z98jdmP6I0YB3Q== X-Received: by 2002:a62:343:: with SMTP id 64mr7540242pfd.47.1589612007854; Fri, 15 May 2020 23:53:27 -0700 (PDT) Received: from localhost ([108.161.26.224]) by smtp.gmail.com with ESMTPSA id i25sm3404755pfo.196.2020.05.15.23.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 23:53:27 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 3/9] targets: Use arrays rather than string concatenation Date: Fri, 15 May 2020 23:53:11 -0700 Message-Id: <20200516065317.2678080-3-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200516065317.2678080-1-mattst88@gentoo.org> References: <20200516065317.2678080-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 31dc5407-33b8-4e4b-9f45-c13d46eb3ac6 X-Archives-Hash: eaf8b4aa3daa9ea2847571e11f9f4a75 Signed-off-by: Matt Turner --- targets/stage2/chroot.sh | 2 +- targets/support/bootloader-setup.sh | 38 ++++++++++++++------------- targets/support/chroot-functions.sh | 40 +++++++++++++++++------------ targets/support/kmerge.sh | 14 +++++----- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/targets/stage2/chroot.sh b/targets/stage2/chroot.sh index 0cbaeb1d..4f1019f2 100755 --- a/targets/stage2/chroot.sh +++ b/targets/stage2/chroot.sh @@ -9,7 +9,7 @@ export CONFIG_PROTECT="-* /etc/locale.gen" echo "$locales" > /etc/locale.gen ## START BUILD -${clst_repo_basedir}/${clst_repo_name}/scripts/bootstrap.sh ${bootstrap_opts} || exit 1 +${clst_repo_basedir}/${clst_repo_name}/scripts/bootstrap.sh ${bootstrap_opts[@]} || exit 1 # Replace modified /etc/locale.gen with default etc-update --automode -5 diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh index d3a6b2dc..e3d8037c 100755 --- a/targets/support/bootloader-setup.sh +++ b/targets/support/bootloader-setup.sh @@ -20,27 +20,29 @@ fi extract_kernels $1/boot +cmdline_opts=() + # Add any additional options if [ -n "${clst_livecd_bootargs}" ] then for x in ${clst_livecd_bootargs} do - cmdline_opts="${cmdline_opts} ${x}" + cmdline_opts+=(${x}) done fi case ${clst_fstype} in squashfs) - cmdline_opts="${cmdline_opts} looptype=squashfs loop=/image.squashfs" + cmdline_opts+=(looptype=squashfs loop=/image.squashfs) ;; jffs2) - cmdline_opts="${cmdline_opts} looptype=jffs2 loop=/image.jffs2" + cmdline_opts+=(looptype=jffs2 loop=/image.jffs2) ;; esac -default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot" -[ -n "${clst_splash_theme}" ] && default_append_line="${default_append_line} splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet" +default_append_line=(root=/dev/ram0 init=/linuxrc ${cmdline_opts[@]} ${custom_kopts} cdroot) +[ -n "${clst_splash_theme}" ] && default_append_line+=(splash=silent,theme:${clst_livecd_splash_theme} CONSOLE=/dev/tty1 quiet) case ${clst_hostarch} in alpha) @@ -52,16 +54,16 @@ case ${clst_hostarch} in do echo -n "${bctr}:/boot/${x} " >> ${acfg} echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg} - echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg} + echo "init=/linuxrc ${cmdline_opts[@]} cdroot" >> ${acfg} ((bctr=${bctr}+1)) done # Pass 2 is for serial - cmdline_opts="${cmdline_opts} console=ttyS0" + cmdline_opts+=(console=ttyS0) for x in ${clst_boot_kernel} do echo -n "${bctr}:/boot/${x} " >> ${acfg} echo -n "initrd=/boot/${x}.igz root=/dev/ram0 " >> ${acfg} - echo "init=/linuxrc ${cmdline_opts} cdroot" >> ${acfg} + echo "init=/linuxrc ${cmdline_opts[@]} cdroot" >> ${acfg} ((bctr=${bctr}+1)) done ;; @@ -81,14 +83,14 @@ case ${clst_hostarch} in for x in ${clst_boot_kernel} do - eval kopts=\$clst_boot_kernel_${x}_kernelopts - my_kopts="${my_kopts} ${kopts}" + eval kopt=\$clst_boot_kernel_${x}_kernelopts + kopts+=(${kopt}) done # copy the bootloader for the final image cp /usr/share/palo/iplboot $1/boot/ - echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz ${default_append_line} ${my_kopts}" >> ${icfg} + echo "--commandline=0/${boot_kernel_common_name} initrd=${first}.igz ${default_append_line[@]} ${kopts[@]}" >> ${icfg} echo "--bootloader=boot/iplboot" >> ${icfg} echo "--ramdisk=boot/${first}.igz" >> ${icfg} for x in ${clst_boot_kernel} @@ -134,25 +136,25 @@ case ${clst_hostarch} in do echo "label ${x}-${y}" >> ${icfg} echo " kernel /boot/${x}" >> ${icfg} - echo " append ${default_append_line} softlevel=${y} initrd=/boot/${x}.igz vga=791" >> ${icfg} + echo " append ${default_append_line[@]} softlevel=${y} initrd=/boot/${x}.igz vga=791" >> ${icfg} echo >> ${icfg} echo " ${x}" >> ${kmsg} echo "label ${x}-${y}-nofb" >> ${icfg} echo " kernel /boot/${x}" >> ${icfg} - echo " append ${default_append_line} softlevel=${y} initrd=/boot/${x}.igz" >> ${icfg} + echo " append ${default_append_line[@]} softlevel=${y} initrd=/boot/${x}.igz" >> ${icfg} echo >> ${icfg} echo " ${x}-nofb" >> ${kmsg} done else echo "label ${x}" >> ${icfg} echo " kernel /boot/${x}" >> ${icfg} - echo " append ${default_append_line} initrd=/boot/${x}.igz vga=791" >> ${icfg} + echo " append ${default_append_line[@]} initrd=/boot/${x}.igz vga=791" >> ${icfg} echo >> ${icfg} echo " ${x}" >> ${kmsg} echo "label ${x}-nofb" >> ${icfg} echo " kernel /boot/${x}" >> ${icfg} - echo " append ${default_append_line} initrd=/boot/${x}.igz" >> ${icfg} + echo " append ${default_append_line[@]} initrd=/boot/${x}.igz" >> ${icfg} echo >> ${icfg} echo " ${x}-nofb" >> ${kmsg} fi @@ -186,12 +188,12 @@ case ${clst_hostarch} in eval custom_kopts=\$${x}_kernelopts echo "menuentry 'Boot LiveCD (kernel: ${x})' --class gnu-linux --class os {" >> ${iacfg} - echo " linux ${kern_subdir}/${x} ${default_append_line}" >> ${iacfg} + echo " linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg} echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} echo "}" >> ${iacfg} echo "" >> ${iacfg} echo "menuentry 'Boot LiveCD (kernel: ${x}) (cached)' --class gnu-linux --class os {" >> ${iacfg} - echo " linux ${kern_subdir}/${x} ${default_append_line} docache" >> ${iacfg} + echo " linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg} echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} echo "}" >> ${iacfg} if [ -n "${clst_kernel_console}" ] @@ -200,7 +202,7 @@ case ${clst_hostarch} in for y in ${clst_kernel_console} do echo "menuentry 'Boot LiveCD (kernel: ${x} console=${y})' --class gnu-linux --class os {" >> ${iacfg} - echo " linux ${kern_subdir}/${x} ${default_append_line} console=${y}" >> ${iacfg} + echo " linux ${kern_subdir}/${x} ${default_append_line[@]} console=${y}" >> ${iacfg} echo " initrd ${kern_subdir}/${x}.igz" >> ${iacfg} echo "}" >> ${iacfg} echo "" >> ${iacfg} diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index a4074d91..b7969607 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -78,17 +78,17 @@ get_libdir() { setup_features() { setup_emerge_opts - local features="-news binpkg-multi-instance clean-logs parallel-install" - export FEATURES="${features}" + local features=(-news binpkg-multi-instance clean-logs parallel-install) + export FEATURES="${features[@]}" if [ -n "${clst_CCACHE}" ] then - features="${features} ccache" + features+=(ccache) clst_root_path=/ run_merge --oneshot --noreplace dev-util/ccache || exit 1 fi if [ -n "${clst_DISTCC}" ] then - features="${features} distcc" + features+=(distcc) export DISTCC_HOSTS="${clst_distcc_hosts}" [ -e ${clst_make_conf} ] && \ echo 'USE="${USE} -avahi -gtk -gnome"' >> ${clst_make_conf} @@ -133,28 +133,34 @@ setup_features() { export PATH="/usr/lib/icecc/bin:${PATH}" export PREROOTPATH="/usr/lib/icecc/bin" fi - export FEATURES="${features}" + export FEATURES="${features[@]}" } setup_emerge_opts() { + emerge_opts=() + bootstrap_opts=() + if [[ "${clst_VERBOSE}" == "true" ]] then - emerge_opts="--verbose" - bootstrap_opts="${bootstrap_opts} -v" + emerge_opts+=(--verbose) + bootstrap_opts+=(-v) else - emerge_opts="--quiet" - bootstrap_opts="${bootstrap_opts} -q" + emerge_opts+=(--quiet) + bootstrap_opts+=(-q) fi if [ -n "${clst_FETCH}" ] then - export bootstrap_opts="${bootstrap_opts} -f" - export emerge_opts="${emerge_opts} -f" + emerge_opts+=(--fetchonly) + bootstrap_opts+=(-f) # if we have PKGCACHE, and either update_seed is empty or 'no', make and use binpkgs elif [ -n "${clst_PKGCACHE}" ] && [ -z "${clst_update_seed}" -o "${clst_update_seed}" = "no" ] then - export emerge_opts="${emerge_opts} --usepkg --buildpkg --binpkg-respect-use=y --newuse" - export bootstrap_opts="${bootstrap_opts} -r" + emerge_opts+=(--usepkg --buildpkg --binpkg-respect-use=y --newuse) + bootstrap_opts+=(-r) fi + + export emerge_opts + export bootstrap_opts } setup_binutils(){ @@ -274,13 +280,13 @@ run_merge() { if [[ "${clst_VERBOSE}" == "true" ]] then - echo "ROOT=${ROOT} emerge ${emerge_opts} -pt $@" || exit 1 - emerge ${emerge_opts} -pt $@ || exit 3 + echo "ROOT=${ROOT} emerge ${emerge_opts[@]} -pt $@" || exit 1 + emerge ${emerge_opts[@]} -pt $@ || exit 3 fi - echo "emerge ${emerge_opts} $@" || exit 1 + echo "emerge ${emerge_opts[@]} $@" || exit 1 - emerge ${emerge_opts} $@ || exit 1 + emerge ${emerge_opts[@]} $@ || exit 1 } show_debug() { diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh index 8a15fc04..23489d8e 100755 --- a/targets/support/kmerge.sh +++ b/targets/support/kmerge.sh @@ -104,22 +104,22 @@ genkernel_compile(){ # callback is put here to avoid escaping issues if [[ "${clst_VERBOSE}" == "true" ]] then - gk_callback_opts="-vN" + gk_callback_opts=(-vN) else - gk_callback_opts="-qN" + gk_callback_opts=(-qN) fi PKGDIR=${PKGDIR} if [ -n "${clst_KERNCACHE}" ] then - gk_callback_opts="${gk_callback_opts} -kb" + gk_callback_opts+=(-kb) fi if [ -n "${clst_FETCH}" ] then - gk_callback_opts="${gk_callback_opts} -f" + gk_callback_opts+=(-f) fi if [ "${clst_kernel_merge}" != "" ] then - genkernel --callback="emerge ${gk_callback_opts} ${clst_kernel_merge}" \ + genkernel --callback="emerge ${gk_callback_opts[@]} ${clst_kernel_merge}" \ "${GK_ARGS[@]}" || exit 1 else genkernel "${GK_ARGS[@]}" || exit 1 @@ -212,7 +212,7 @@ then # install dependencies of kernel sources ahead of time in case # package.provided generated below causes them not to be (re)installed - PKGDIR=${PKGDIR} emerge_opts="--quiet --usepkg --buildpkg --binpkg-respect-use=y --update --newuse --onlydeps" run_merge "${clst_ksource}" || exit 1 + PKGDIR=${PKGDIR} emerge_opts=(--quiet --usepkg --buildpkg --binpkg-respect-use=y --update --newuse --onlydeps) run_merge "${clst_ksource}" || exit 1 # Create the kerncache directory if it doesn't exists mkdir -p /tmp/kerncache/${clst_kname} @@ -236,7 +236,7 @@ then [ -L /usr/src/linux ] && rm -f /usr/src/linux - PKGDIR=${PKGDIR} emerge_opts="--quiet --update --newuse" run_merge "${clst_ksource}" || exit 1 + PKGDIR=${PKGDIR} emerge_opts=(--quiet --update --newuse) run_merge "${clst_ksource}" || exit 1 SOURCESDIR="/tmp/kerncache/${clst_kname}/sources" if [ -L /usr/src/linux ] -- 2.26.2