summaryrefslogtreecommitdiff
path: root/resources/scripts/build/boot
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-13 00:13:54 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-13 00:13:54 +0100
commit3bd82b7679ae9af99caf4da1a81e4fde85f56a42 (patch)
tree5e4dc30653af27f7729b5383f7f90f12e0b2556f /resources/scripts/build/boot
parent9eee0fb483e2abf9698ffc3a946304166ec9b1e9 (diff)
build/boot/roms: reduced code indentation
Diffstat (limited to 'resources/scripts/build/boot')
-rwxr-xr-xresources/scripts/build/boot/roms80
-rwxr-xr-xresources/scripts/build/boot/roms_helper151
2 files changed, 119 insertions, 112 deletions
diff --git a/resources/scripts/build/boot/roms b/resources/scripts/build/boot/roms
index 92bcc4c4..f0398273 100755
--- a/resources/scripts/build/boot/roms
+++ b/resources/scripts/build/boot/roms
@@ -36,53 +36,53 @@ firstoption="${1}"
main()
{
- if [ $# -gt 0 ]; then
- if [ "${firstoption}" = "help" ]; then
- usage
- exit 0
- fi
- if [ "${firstoption}" = "list" ]; then
- listboards
- exit 0
- fi
+ if [ $# -lt 1 ]; then
+ usage
+ exit 1
+ fi
- while [ $# -gt 0 ]; do
- case ${1} in
- -d)
- opts="${opts} -d ${2}"
- shift ;;
- -p)
- opts="${opts} -p ${2}"
- shift ;;
- -k)
- opts="${opts} -k ${2}"
- shift ;;
- *)
- boards="${boards} ${1} " ;;
- esac
- shift
- done
+ if [ "${firstoption}" = "help" ]; then
+ usage
+ exit 0
+ fi
+ if [ "${firstoption}" = "list" ]; then
+ listboards
+ exit 0
+ fi
+
+ while [ $# -gt 0 ]; do
+ case ${1} in
+ -d)
+ opts="${opts} -d ${2}"
+ shift ;;
+ -p)
+ opts="${opts} -p ${2}"
+ shift ;;
+ -k)
+ opts="${opts} -k ${2}"
+ shift ;;
+ *)
+ boards="${boards} ${1} " ;;
+ esac
+ shift
+ done
if [ -z ${opts+x} ]; then
opts=""
fi
- printf "Building %s ROM images\n" "${projectname}"
-
- if [ "${firstoption}" = "all" ]; then
- for boardname in $(listboards); do
- buildrom "${boardname}" \
- || die "build/roms: error"
- done
- else
- for board in ${boards}; do
- buildrom "${board}" \
- || die "build/roms: error"
- done
- fi
+ printf "Building %s ROM images\n" "${projectname}"
+
+ if [ "${firstoption}" = "all" ]; then
+ for boardname in $(listboards); do
+ buildrom "${boardname}" \
+ || die "build/roms: error"
+ done
else
- usage
- exit 1
+ for board in ${boards}; do
+ buildrom "${board}" \
+ || die "build/roms: error"
+ done
fi
printf "\n\nDone! Your ROMs are in bin/\n\n"
diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper
index 92fc2e4a..d1a80335 100755
--- a/resources/scripts/build/boot/roms_helper
+++ b/resources/scripts/build/boot/roms_helper
@@ -180,19 +180,21 @@ load_config()
load_config_overrides()
{
# Override all payload directives with cmdline args
- if [ ! -z ${payloads} ]; then
- echo "setting payloads $payloads"
- payload_grub="n"
- payload_grub_withseabios="n" # seabios chainloaded from grub
- payload_seabios="n"
- payload_seabios_withgrub="n" # grub from SeaBIOS menu
- payload_uboot="n"
- payload_memtest="n"
+ if [ -z ${payloads} ]; then
+ return 0
+ fi
- for payload in ${payloads} ; do
- eval "payload_${payload}=y"
- done
- fi
+ echo "setting payloads $payloads"
+ payload_grub="n"
+ payload_grub_withseabios="n" # seabios chainloaded from grub
+ payload_seabios="n"
+ payload_seabios_withgrub="n" # grub from SeaBIOS menu
+ payload_uboot="n"
+ payload_memtest="n"
+
+ for payload in ${payloads} ; do
+ eval "payload_${payload}=y"
+ done
}
die_if_cbconfig_and_nopayload()
@@ -201,17 +203,20 @@ die_if_cbconfig_and_nopayload()
# defined in the lbmk config, exit with error
# if no configs exist, this won't fail. this way, cbtrees
# like "default" can exist which just contain patches
- if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] \
- && [ "${payload_uboot}" != "y" ]; then
- for configfile in "${boardcfgdir}/config/"*; do
- if [ ! -e "${configfile}" ]; then
- continue
- fi
- printf "build/roms %s: Payload undefined. Exiting.\n" \
- ${board}
- exit 1
- done
+
+ if [ "${payload_grub}" = "y" ] || [ "${payload_seabios}" = "y" ] \
+ || [ "${payload_uboot}" = "y" ]; then
+ return 0
fi
+
+ for configfile in "${boardcfgdir}/config/"*; do
+ if [ ! -e "${configfile}" ]; then
+ continue
+ fi
+ printf "build/roms %s: Payload undefined. Exiting.\n" \
+ ${board}
+ exit 1
+ done
}
build_dependencies()
@@ -282,72 +287,74 @@ build_dependency_seabios()
./build payload seabios
fi
fi
- if [ "${payload_memtest}" = "y" ]; then
- if [ ! -f "memtest86plus/memtest" ]; then
- ./build module memtest86plus
- fi
+ if [ "${payload_memtest}" = "y" ] && [ ! -f "memtest86plus/memtest" ]
+ then
+ ./build module memtest86plus
fi
}
build_dependency_grub()
{
- if [ "${payload_grub}" = "y" ] \
- || [ "${payload_seabios_withgrub}" = "y" ]
- then
- if [ -f "payload/grub/grub_usqwerty.cfg" ]; then
- sha1cmd="sha1sum resources/grub/config/grub.cfg"
- grubrefchecksum="$(${sha1cmd} | awk '{print $1}')"
+ if [ "${payload_grub}" != "y" ] \
+ && [ "${payload_seabios_withgrub}" != "y" ]; then
+ return 0
+ fi
- sha1cmd="sha1sum payload/grub/grub_usqwerty.cfg"
- grubsha1="$(${sha1cmd} | awk '{print $1}')"
+ if [ -f "payload/grub/grub_usqwerty.cfg" ]; then
+ sha1cmd="sha1sum resources/grub/config/grub.cfg"
+ grubrefchecksum="$(${sha1cmd} | awk '{print $1}')"
- if [ "${grubrefchecksum}" != "${grubsha1}" ]; then
- rm -Rf payload/grub/
- printf "GRUB change detected. Rebuilding:\n"
- fi
- else
- printf "GRUB payloads needed. Building:\n"
- rm -Rf payload/grub/ # just in case
+ sha1cmd="sha1sum payload/grub/grub_usqwerty.cfg"
+ grubsha1="$(${sha1cmd} | awk '{print $1}')"
+
+ if [ "${grubrefchecksum}" != "${grubsha1}" ]; then
+ rm -Rf payload/grub/
+ printf "GRUB change detected. Rebuilding:\n"
+ fi
+ else
+ printf "GRUB payloads needed. Building:\n"
+ rm -Rf payload/grub/ # just in case
+ fi
+ for keymapfile in ${kmapdir}/*; do
+ if [ ! -f "${keymapfile}" ]; then
+ continue
fi
- for keymapfile in ${kmapdir}/*; do
- if [ ! -f "${keymapfile}" ]; then
- continue
- fi
- keymap="${keymapfile##*/}"
- keymap="${keymap%.gkb}"
+ keymap="${keymapfile##*/}"
+ keymap="${keymap%.gkb}"
- grubelf="payload/grub/grub_${keymap}.elf"
- grubcfg="payload/grub/grub_${keymap}.cfg"
- grubtestcfg="payload/grub/grub_${keymap}_test.cfg"
+ grubelf="payload/grub/grub_${keymap}.elf"
+ grubcfg="payload/grub/grub_${keymap}.cfg"
+ grubtestcfg="payload/grub/grub_${keymap}_test.cfg"
- if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \
- [ ! -f "${grubtestcfg}" ]; then
- ./build payload grub
- fi
- done
- fi
+ if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \
+ [ ! -f "${grubtestcfg}" ]; then
+ ./build payload grub
+ fi
+ done
}
build_dependency_uboot()
{
- if [ "${payload_uboot}" = "y" ]; then
- ubdir=""
- if [ "${uboot_config}" = "default" ]; then
- ubdir="payload/u-boot/${board}"
- else
- ubdir="payload/u-boot/${board}/${uboot_config}"
- fi
+ if [ "${payload_uboot}" != "y" ]; then
+ return 0
+ fi
- if [ -f "${ubdir}/u-boot.elf" ]; then
- ubootelf="${ubdir}/u-boot.elf"
- elif [ -f "${ubdir}/u-boot" ]; then
- ubootelf="${ubdir}/u-boot"
- else
- printf "U-Boot needed. Building:\n"
- rm -Rf "payload/u-boot/${board}" # just in case
- ./build payload u-boot "${board}"
- fi
+ ubdir=""
+ if [ "${uboot_config}" = "default" ]; then
+ ubdir="payload/u-boot/${board}"
+ else
+ ubdir="payload/u-boot/${board}/${uboot_config}"
+ fi
+
+ if [ -f "${ubdir}/u-boot.elf" ]; then
+ ubootelf="${ubdir}/u-boot.elf"
+ elif [ -f "${ubdir}/u-boot" ]; then
+ ubootelf="${ubdir}/u-boot"
+ else
+ printf "U-Boot needed. Building:\n"
+ rm -Rf "payload/u-boot/${board}" # just in case
+ ./build payload u-boot "${board}"
fi
}