public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: targets/stage2/, targets/support/
  2020-05-16  6:55 [gentoo-commits] proj/catalyst:wip/mattst88 commit in: targets/stage2/, targets/support/ Matt Turner
@ 2020-05-16  6:54 ` Matt Turner
  2020-05-17  3:26 ` [gentoo-commits] proj/catalyst:master " Matt Turner
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Turner @ 2020-05-16  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     e5855beff25ac9315c1dfe5466bb4b0bb2240fa6
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 03:37:51 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat May 16 06:45:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e5855bef

targets: Use arrays rather than string concatenation

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 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 ]


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/catalyst:wip/mattst88 commit in: targets/stage2/, targets/support/
@ 2020-05-16  6:55 Matt Turner
  2020-05-16  6:54 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
  2020-05-17  3:26 ` [gentoo-commits] proj/catalyst:master " Matt Turner
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Turner @ 2020-05-16  6:55 UTC (permalink / raw
  To: gentoo-commits

commit:     e5855beff25ac9315c1dfe5466bb4b0bb2240fa6
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 03:37:51 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat May 16 06:45:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e5855bef

targets: Use arrays rather than string concatenation

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 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 ]


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/catalyst:master commit in: targets/stage2/, targets/support/
  2020-05-16  6:55 [gentoo-commits] proj/catalyst:wip/mattst88 commit in: targets/stage2/, targets/support/ Matt Turner
  2020-05-16  6:54 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
@ 2020-05-17  3:26 ` Matt Turner
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Turner @ 2020-05-17  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     e5855beff25ac9315c1dfe5466bb4b0bb2240fa6
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 03:37:51 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sat May 16 06:45:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e5855bef

targets: Use arrays rather than string concatenation

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 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 ]


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-17  3:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-16  6:55 [gentoo-commits] proj/catalyst:wip/mattst88 commit in: targets/stage2/, targets/support/ Matt Turner
2020-05-16  6:54 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-17  3:26 ` [gentoo-commits] proj/catalyst:master " Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox