From 47533fd974d596edb15aa640d1b97a2ef2ba0c4d Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 25 Jun 2020 23:01:54 +0200 Subject: Introducing shellcheck in gitlab CI archiso/mkarchiso: Quoting all variables. Changing pkg_list to be an array instead of a string for easier handling. Using read to properly populate pkg_list from OPTARG with stripped whitespaces. Not exporting iso_label anymore as there seems to be no reason to do so. Introducing line breaks. .editorconfig: Setting max_line_length to 120. Adding a section for YAML files (e.g. .gitlab-ci.yml). configs/releng/build.sh Quting nearly all variables. Introducing line breaks. configs/baseline/build.sh: Quoting all variables. Introducing line breaks. .gitlab-ci.yml: Adding gitlab CI for shelleck linting of the config build scripts, mkarchiso and startup scripts in releng. Closes #19 --- configs/baseline/build.sh | 52 +++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'configs/baseline') diff --git a/configs/baseline/build.sh b/configs/baseline/build.sh index 7c61d03..ad0b529 100755 --- a/configs/baseline/build.sh +++ b/configs/baseline/build.sh @@ -10,15 +10,15 @@ arch=$(uname -m) work_dir=work out_dir=out -script_path=$(readlink -f ${0%/*}) +script_path=$(readlink -f "${0%/*}") umask 0022 # Helper function to run make_*() only one time per architecture. run_once() { - if [[ ! -e ${work_dir}/build.${1}_${arch} ]]; then - $1 - touch ${work_dir}/build.${1}_${arch} + if [[ ! -e "${work_dir}/build.${1}_${arch}" ]]; then + "$1" + touch "${work_dir}/build.${1}_${arch}" fi } @@ -29,39 +29,42 @@ make_basefs() { # Copy mkinitcpio archiso hooks and build initramfs (airootfs) make_setup_mkinitcpio() { - mkdir -p ${work_dir}/airootfs/etc/initcpio/hooks - mkdir -p ${work_dir}/airootfs/etc/initcpio/install - cp /usr/lib/initcpio/hooks/archiso ${work_dir}/airootfs/etc/initcpio/hooks - cp /usr/lib/initcpio/install/archiso ${work_dir}/airootfs/etc/initcpio/install - cp ${script_path}/mkinitcpio.conf ${work_dir}/airootfs/etc/mkinitcpio-archiso.conf - mkarchiso -v -w "${work_dir}" -D "${install_dir}" -r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' run + mkdir -p "${work_dir}/airootfs/etc/initcpio/hooks" + mkdir -p "${work_dir}/airootfs/etc/initcpio/install" + cp /usr/lib/initcpio/hooks/archiso "${work_dir}/airootfs/etc/initcpio/hooks" + cp /usr/lib/initcpio/install/archiso "${work_dir}/airootfs/etc/initcpio/install" + cp "${script_path}/mkinitcpio.conf" "${work_dir}/airootfs/etc/mkinitcpio-archiso.conf" + mkarchiso -v -w "${work_dir}" -D "${install_dir}" \ + -r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' run } # Prepare ${install_dir}/boot/ make_boot() { - mkdir -p ${work_dir}/iso/${install_dir}/boot/${arch} - cp ${work_dir}/airootfs/boot/archiso.img ${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img - cp ${work_dir}/airootfs/boot/vmlinuz-linux ${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz + mkdir -p "${work_dir}/iso/${install_dir}/boot/${arch}" + cp "${work_dir}/airootfs/boot/archiso.img" "${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img" + cp "${work_dir}/airootfs/boot/vmlinuz-linux" "${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz" } # Prepare /${install_dir}/boot/syslinux make_syslinux() { - mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux + mkdir -p "${work_dir}/iso/${install_dir}/boot/syslinux" sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%INSTALL_DIR%|${install_dir}|g; - s|%ARCH%|${arch}|g" ${script_path}/syslinux/syslinux.cfg > ${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/ - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/menu.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/ - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/libutil.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/ + s|%ARCH%|${arch}|g" "${script_path}/syslinux/syslinux.cfg" > \ + "${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/menu.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/libutil.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/" } # Prepare /isolinux make_isolinux() { - mkdir -p ${work_dir}/iso/isolinux - sed "s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/isolinux.bin ${work_dir}/iso/isolinux/ - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/isohdpfx.bin ${work_dir}/iso/isolinux/ - cp ${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32 ${work_dir}/iso/isolinux/ + mkdir -p "${work_dir}/iso/isolinux" + sed "s|%INSTALL_DIR%|${install_dir}|g" "${script_path}/isolinux/isolinux.cfg" > \ + "${work_dir}/iso/isolinux/isolinux.cfg" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/isolinux.bin" "${work_dir}/iso/isolinux/" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/isohdpfx.bin" "${work_dir}/iso/isolinux/" + cp "${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32" "${work_dir}/iso/isolinux/" } # Build airootfs filesystem image @@ -71,7 +74,8 @@ make_prepare() { # Build ISO make_iso() { - mkarchiso -v -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso "${iso_name}-${iso_version}-${arch}.iso" + mkarchiso -v -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso \ + "${iso_name}-${iso_version}-${arch}.iso" } run_once make_basefs -- cgit v1.2.3-70-g09d2