From f15b3053dac53ce119eac4845c3b53c3348b56ae Mon Sep 17 00:00:00 2001 From: PythonHacker24 Date: Sat, 22 Jun 2024 21:58:07 +0530 Subject: [PATCH] optimised sh scripts: build-berryboot.sh, rebuild-berryboot.sh, rebuild-kernel.sh --- build-berryboot.sh | 34 +++++++++++++++++----------------- rebuild-berryboot.sh | 4 +--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/build-berryboot.sh b/build-berryboot.sh index 64a7a82b8..a3c1f4b7b 100755 --- a/build-berryboot.sh +++ b/build-berryboot.sh @@ -7,42 +7,42 @@ EXTERNAL="$PWD/external" cd $BUILDROOT -if [ -n "$1" ]; then - if [ ! -e "../configs/$1" ]; then - echo configs/$1 does not exist +[ -n "$1" ] && { + [ ! -e "../configs/$1" ] && { + echo configs/$1 does not exist && exit 1 - fi + } - support/kconfig/merge_config.sh -m ../configs/berryboot_defconfig ../configs/$1 + support/kconfig/merge_config.sh -m ../configs/berryboot_defconfig ../configs/"$1" make BR2_EXTERNAL=$EXTERNAL olddefconfig -fi +} -if [ ! -e .config ]; then - echo No target device selected yet +[ ! -e .config ] && { + echo No target device selected yet echo echo Run: $0 \ echo -n "Supported devices: " (cd ../configs ; ls device*) echo exit 1 -fi +} # Let buildroot build everything -make BR2_EXTERNAL=$EXTERNAL +make BR2_EXTERNAL="$EXTERNAL" cd .. cp -n LICENSE.berryboot output #cp -f $BUILDROOT/output/images/rootfs.cpio.uboot output/berryboot.img -cp -f $BUILDROOT/output/images/rootfs.cpio.lzo output/berryboot.img -cp -f $BUILDROOT/output/images/bbloader.img output/ -cp -f $BUILDROOT/output/images/kernel*.img $BUILDROOT/output/images/shared.img output || true +cp -f "$BUILDROOT/output/images/rootfs.cpio.lzo" output/berryboot.img +cp -f "$BUILDROOT/output/images/bbloader.img" output/ +cp -f "$BUILDROOT/output/images/kernel*".img "$BUILDROOT/output/images/shared.img" output || true -if [ -e $BUILDROOT/output/images/rpi-firmware ]; then - cp -rf $BUILDROOT/output/images/rpi-firmware/* output - for f in $BUILDROOT/output/images/bcm27*.dtb $BUILDROOT/output/images/broadcom/bcm27*.dtb; do +if [ -e "$BUILDROOT/output/images/rpi-firmware" ]; then + cp -rf "$BUILDROOT/output/images/rpi-firmware/"* output + for f in "$BUILDROOT/output/images/bcm27"*.dtb "$BUILDROOT/output/images/broadcom/bcm27"*.dtb; do [ -f "$f" ] && cp -f "$f" output done - cp -rf $BUILDROOT/output/images/overlays output + cp -rf "$BUILDROOT/output/images/overlays" output rm -f output/start_db.elf output/start4db.elf output/fixup_db.dat output/fixup4db.dat fi diff --git a/rebuild-berryboot.sh b/rebuild-berryboot.sh index ac8166e53..03132a298 100755 --- a/rebuild-berryboot.sh +++ b/rebuild-berryboot.sh @@ -5,8 +5,6 @@ set -e BUILDROOT=buildroot-2018.08 # Force rebuild of BerrybootGUI -if [ -e $BUILDROOT/output/build/berrybootgui2-1.0 ]; then - make -C $BUILDROOT berrybootgui2-dirclean -fi +[ -e $BUILDROOT/output/build/berrybootgui2-1.0 ] && make -C $BUILDROOT berrybootgui2-dirclean ./build-berryboot.sh "$@"