From f92868bd30bcd8484c7eaffbce647e9915726010 Mon Sep 17 00:00:00 2001 From: Austin English Date: Wed, 20 May 2020 13:00:00 -0500 Subject: [PATCH 1/5] scripts: fix shellcheck SC2006 'Use $(...) notation instead of legacy backticked `...`.' --- scripts/buildFilesystem.sh | 2 +- scripts/buildInitramFs.sh | 4 ++-- scripts/buildKernel.sh | 4 ++-- scripts/crossmenuconfig.sh | 2 +- scripts/injectKernelIntoFS.sh | 2 +- scripts/patchKernel.sh | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/buildFilesystem.sh b/scripts/buildFilesystem.sh index bbebc67..f7b0996 100755 --- a/scripts/buildFilesystem.sh +++ b/scripts/buildFilesystem.sh @@ -56,7 +56,7 @@ DEBIAN_SUITE=$2 BASE=$3 PRAWNOS_ROOT=$4 -outmnt=$(mktemp -d -p `pwd`) +outmnt=$(mktemp -d -p "$(pwd)") outdev=/dev/loop5 diff --git a/scripts/buildInitramFs.sh b/scripts/buildInitramFs.sh index 14d6c6e..474428e 100755 --- a/scripts/buildInitramFs.sh +++ b/scripts/buildInitramFs.sh @@ -22,7 +22,7 @@ set -e # along with PrawnOS. If not, see . -outmnt=$(mktemp -d -p `pwd`) +outmnt=$(mktemp -d -p "$(pwd)") outdev=/dev/loop7 if [ -z "$1" ] then @@ -30,7 +30,7 @@ then exit 1 fi BASE=$1 -ROOT_DIR=`pwd` +ROOT_DIR="$(pwd)" build_resources=$ROOT_DIR/resources/BuildResources if [ ! -f $ROOT_DIR/$BASE ] diff --git a/scripts/buildKernel.sh b/scripts/buildKernel.sh index f192076..68529f1 100755 --- a/scripts/buildKernel.sh +++ b/scripts/buildKernel.sh @@ -28,7 +28,7 @@ then fi KVER=$1 -ROOT_DIR=`pwd` +ROOT_DIR="$(pwd)" RESOURCES=$ROOT_DIR/resources/BuildResources [ ! -d build ] && mkdir build @@ -66,7 +66,7 @@ make mrproper #copy in the initramfs and kernel config cp $ROOT_DIR/build/PrawnOS-initramfs.cpio.gz . cp $RESOURCES/config .config -make -j $((`nproc` +1)) CROSS_COMPILE=arm-none-eabi- ARCH=arm zImage modules dtbs +make -j $(($(nproc) +1)) CROSS_COMPILE=arm-none-eabi- ARCH=arm zImage modules dtbs [ ! -h kernel.its ] && ln -s $RESOURCES/kernel.its . mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg dd if=/dev/zero of=bootloader.bin bs=512 count=1 diff --git a/scripts/crossmenuconfig.sh b/scripts/crossmenuconfig.sh index 3f4e56f..087d91f 100755 --- a/scripts/crossmenuconfig.sh +++ b/scripts/crossmenuconfig.sh @@ -30,7 +30,7 @@ fi KVER=$1 -ROOT_DIR=`pwd` +ROOT_DIR="$(pwd)" RESOURCES=$ROOT_DIR/resources/BuildResources [ ! -d build ] && mkdir build diff --git a/scripts/injectKernelIntoFS.sh b/scripts/injectKernelIntoFS.sh index d98ac38..e090452 100755 --- a/scripts/injectKernelIntoFS.sh +++ b/scripts/injectKernelIntoFS.sh @@ -32,7 +32,7 @@ fi KVER=$1 OUTNAME=$2 -outmnt=$(mktemp -d -p `pwd`) +outmnt=$(mktemp -d -p "$(pwd)") outdev=/dev/loop7 build_resources=resources/BuildResources diff --git a/scripts/patchKernel.sh b/scripts/patchKernel.sh index 8850daa..eb21684 100755 --- a/scripts/patchKernel.sh +++ b/scripts/patchKernel.sh @@ -10,7 +10,7 @@ then fi KVER=$1 -ROOT_DIR=`pwd` +ROOT_DIR="$(pwd)" RESOURCES=$ROOT_DIR/resources/BuildResources From be640d4c49b988a059672f350cfc7e8acd42b5bf Mon Sep 17 00:00:00 2001 From: Austin English Date: Wed, 20 May 2020 15:32:43 -0500 Subject: [PATCH 2/5] scripts: fix shellcheck SC2231 'Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .' --- scripts/buildKernel.sh | 6 +++--- scripts/crossmenuconfig.sh | 6 +++--- scripts/patchKernel.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/buildKernel.sh b/scripts/buildKernel.sh index 68529f1..dcf205b 100755 --- a/scripts/buildKernel.sh +++ b/scripts/buildKernel.sh @@ -59,9 +59,9 @@ cd linux-$KVER make clean make mrproper #Apply the usb and mmc patches if unapplied -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/5.x-dwc2/*.patch; do echo $i; patch -p1 < $i; done -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/DTS/*.patch; do echo $i; patch -p1 < $i; done -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/kernel/5.x-dwc2/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/DTS/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/kernel/*.patch; do echo $i; patch -p1 < $i; done #copy in the initramfs and kernel config cp $ROOT_DIR/build/PrawnOS-initramfs.cpio.gz . diff --git a/scripts/crossmenuconfig.sh b/scripts/crossmenuconfig.sh index 087d91f..33eb62d 100755 --- a/scripts/crossmenuconfig.sh +++ b/scripts/crossmenuconfig.sh @@ -42,9 +42,9 @@ cd linux-$KVER make clean make mrproper #Apply the usb and mmc patches if unapplied -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/5.x-dwc2/*.patch; do echo $i; patch -p1 < $i; done -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/DTS/*.patch; do echo $i; patch -p1 < $i; done -[ "$FRESH" = true ] && for i in $RESOURCES/patches-tested/kernel/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/kernel/5.x-dwc2/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/DTS/*.patch; do echo $i; patch -p1 < $i; done +[ "$FRESH" = true ] && for i in "$RESOURCES"/patches-tested/kernel/*.patch; do echo $i; patch -p1 < $i; done cp $RESOURCES/config .config make menuconfig ARCH=arm CROSS_COMPILE=arm-none-eabi- .config diff --git a/scripts/patchKernel.sh b/scripts/patchKernel.sh index eb21684..1ce09ce 100755 --- a/scripts/patchKernel.sh +++ b/scripts/patchKernel.sh @@ -20,8 +20,8 @@ cd build cd linux-$KVER make clean make mrproper -#Apply the usb and mmc patches if unapplie -for i in $RESOURCES/patches-tested/DTS/*.patch; do patch -p1 < $i; done -for i in $RESOURCES/patches-tested/kernel/*.patch; do patch -p1 < $i; done +#Apply the usb and mmc patches if unapplied +for i in "$RESOURCES"/patches-tested/DTS/*.patch; do patch -p1 < $i; done +for i in "$RESOURCES"/patches-tested/kernel/*.patch; do patch -p1 < $i; done cd $ROOT_DIR From 33667c45651cedbfcf4be4c71212ae21e53d4caa Mon Sep 17 00:00:00 2001 From: Austin English Date: Wed, 20 May 2020 17:07:13 -0500 Subject: [PATCH 3/5] scripts/InstallScripts: fix shellcheck SC2162 'read without -r will mangle backslashes.' --- scripts/InstallScripts/InstallPackages.sh | 6 +++--- scripts/InstallScripts/InstallPrawnOS.sh | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/InstallScripts/InstallPackages.sh b/scripts/InstallScripts/InstallPackages.sh index 48bd931..db4a903 100755 --- a/scripts/InstallScripts/InstallPackages.sh +++ b/scripts/InstallScripts/InstallPackages.sh @@ -24,7 +24,7 @@ cat $DIR/icons/ascii-icon.txt echo "" while true; do - read -p "Install (X)fce4, (L)xqt or (G)nome, if unsure choose (X)fce: " XL + read -r -p "Install (X)fce4, (L)xqt or (G)nome, if unsure choose (X)fce: " XL case $XL in [Gg]* ) DE=gnome; break;; [Xx]* ) DE=xfce; break;; @@ -175,7 +175,7 @@ done #Force a safe username while true; do echo "-----Enter new username:-----" - read username + read -r username #ensure no whitespace case $username in *\ *) echo usernames may not contain whitespace;; *) break;; esac done @@ -183,7 +183,7 @@ until adduser $username --gecos "" do while true; do echo "-----Enter new username:-----" - read username + read -r username #ensure no whitespace case $username in *\ *) echo usernames may not contain whitespace;; *) break;; esac done diff --git a/scripts/InstallScripts/InstallPrawnOS.sh b/scripts/InstallScripts/InstallPrawnOS.sh index d6e14ec..187d3b1 100755 --- a/scripts/InstallScripts/InstallPrawnOS.sh +++ b/scripts/InstallScripts/InstallPrawnOS.sh @@ -37,7 +37,7 @@ main() { echo "Expand or Install?: " echo "The currently booted device is ${BOOT_DEVICE}" while true; do - read -p "[I]nstall or [E]xpand?" IE + read -r -p "[I]nstall or [E]xpand?" IE case $IE in [Ii]* ) install; break;; [Ee]* ) expand; break;; @@ -54,7 +54,7 @@ install() { echo "Please ensure you have only have the booted device and the desired target device inserted." echo "The currently booted device is ${BOOT_DEVICE}" while true; do - read -p "[I]nternal Emmc, [S]D card, or [U]SB device?: " ISU + read -r -p "[I]nternal Emmc, [S]D card, or [U]SB device?: " ISU case $ISU in [Ii]* ) TARGET=/dev/mmcblk2p; break;; [Ss]* ) TARGET=/dev/mmcblk0p; break;; @@ -87,7 +87,7 @@ install() { #Now on to the installation, basically copy InstallToInternal.sh while true; do - read -p "This will ERASE ALL DATA ON ${TARGET_NO_P} and reboot when finished, do you want to continue? [y/N]" yn + read -r -p "This will ERASE ALL DATA ON ${TARGET_NO_P} and reboot when finished, do you want to continue? [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) exit;; @@ -160,7 +160,7 @@ install() { echo "${ROOT_PARTITION} / ext4 defaults,noatime 0 1" > $INSTALL_MOUNT/etc/fstab while true; do - read -p "Install a desktop environment and the supporting packages? [Y/n]" ins + read -r -p "Install a desktop environment and the supporting packages? [Y/n]" ins case $ins in [Yy]* ) install_packages $INSTALL_MOUNT; break;; [Nn]* ) break;; @@ -179,7 +179,7 @@ install() { fi echo "Please remove the booted device after power off is complete" while true; do - read -p "Reboot? [y/N]" re + read -r -p "Reboot? [y/N]" re case $re in [Yy]* ) reboot;; [Nn]* ) exit;; @@ -273,7 +273,7 @@ expand() { resize2fs -f ${BOOT_DEVICE}2 echo "/dev/${BOOT_DEVICE}2 / ext4 defaults,noatime 0 1" > /etc/fstab while true; do - read -p "Install a desktop environment and the supporting packages? [Y/n]" ins + read -r -p "Install a desktop environment and the supporting packages? [Y/n]" ins case $ins in [Yy]* ) /InstallResources/InstallPackages.sh; reboot;; [Nn]* ) exit;; From 9ed8e86ab122eea28b2e791ca6975810ad576a92 Mon Sep 17 00:00:00 2001 From: Austin English Date: Wed, 20 May 2020 16:01:04 -0500 Subject: [PATCH 4/5] scripts/InstallScripts/UpgradeKernel.sh: RESOURCES is unused, remove it Also remove leading newline; that's not a valid shebang --- scripts/InstallScripts/UpgradeKernel.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/InstallScripts/UpgradeKernel.sh b/scripts/InstallScripts/UpgradeKernel.sh index 540adba..3759583 100755 --- a/scripts/InstallScripts/UpgradeKernel.sh +++ b/scripts/InstallScripts/UpgradeKernel.sh @@ -1,4 +1,3 @@ - #!/bin/bash #Replace the PrawnOS linux kernel that is installed on the internal emmc storage with @@ -20,7 +19,6 @@ # You should have received a copy of the GNU General Public License # along with PrawnOS. If not, see . -RESOURCES=/InstallResources # Grab the boot device, which is either /dev/sda for usb or /dev/mmcblk0 for an sd card BOOT_DEVICE=$(mount | head -n 1 | cut -d '2' -f 1) From 56aff1dfc2e1801ac284c34eca7206153d9e9a77 Mon Sep 17 00:00:00 2001 From: Austin English Date: Wed, 20 May 2020 17:10:16 -0500 Subject: [PATCH 5/5] scripts/InstallScripts/InstallPrawnOS.sh: fix shellcheck SC2053 'Quote the right-hand side of == in [[ ]] to prevent glob matching.' --- scripts/InstallScripts/InstallPrawnOS.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/InstallScripts/InstallPrawnOS.sh b/scripts/InstallScripts/InstallPrawnOS.sh index 187d3b1..4a0ab88 100755 --- a/scripts/InstallScripts/InstallPrawnOS.sh +++ b/scripts/InstallScripts/InstallPrawnOS.sh @@ -71,7 +71,7 @@ install() { TARGET=/dev/sda fi fi - if [[ $TARGET == $BOOT_DEVICE ]] + if [[ "$TARGET" == "$BOOT_DEVICE" ]] then echo "Can't install to booted device, please ensure you have *only* the booted device and target device inserted" exit