From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-catalyst] [PATCH 3/9] targets: Use arrays rather than string concatenation
Date: Fri, 15 May 2020 23:53:11 -0700 [thread overview]
Message-ID: <20200516065317.2678080-3-mattst88@gentoo.org> (raw)
In-Reply-To: <20200516065317.2678080-1-mattst88@gentoo.org>
Signed-off-by: Matt Turner <mattst88@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 ]
--
2.26.2
next prev parent reply other threads:[~2020-05-16 6:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 6:53 [gentoo-catalyst] [PATCH 1/9] targets: Remove clst_my* prefix Matt Turner
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 2/9] targets: Make features variable local Matt Turner
2020-05-16 19:10 ` Brian Dolbec
2020-05-16 6:53 ` Matt Turner [this message]
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 4/9] targets: Drop duplicate FEATURES=-news Matt Turner
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 5/9] targets: Don't unnecessarily override emerge_opts Matt Turner
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 6/9] targets: Remove || exit 1 from run_merge invocations Matt Turner
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 7/9] targets: Decouple distfile fetching from binary packages Matt Turner
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 8/9] catalyst: Remove remnants of options="preserve_libs" Matt Turner
2020-05-16 19:16 ` Brian Dolbec
2020-05-16 6:53 ` [gentoo-catalyst] [PATCH 9/9] catalyst: Remove fbsplash support Matt Turner
2020-05-16 19:20 ` Brian Dolbec
2020-05-16 19:01 ` [gentoo-catalyst] [PATCH 1/9] targets: Remove clst_my* prefix Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200516065317.2678080-3-mattst88@gentoo.org \
--to=mattst88@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox