From ddf95932704dcf45259ccb6d2e766f1bf1c78f0c Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 14 Sep 2017 08:25:50 -0400 Subject: Remove unnecessary code duplication in GRUB build --- projects/grub/grub | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'projects') diff --git a/projects/grub/grub b/projects/grub/grub index 16b63634..42794dda 100755 --- a/projects/grub/grub +++ b/projects/grub/grub @@ -79,18 +79,15 @@ build() { grub_build_layout "${raw_keymap}" done - case "${target}" in - bios) - grub_build_floppy_image - grub_build_font - grub_copy_modules - ;; - *) - grub_build_standalone_image - grub_build_font - grub_copy_modules - ;; - esac + if [[ "${target}" == 'bios' ]]; then + grub_build_floppy_image + else + grub_build_standalone_image + fi + + grub_build_font + + grub_copy_modules # Temporary until the function project_make_distclean is written ( -- cgit v1.2.3-70-g09d2 From 0f24f78c782bda6b28e809440b14e6a15684ead9 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 14 Sep 2017 08:28:44 -0400 Subject: Use GNU Make's '-C' flag Forgot about that flag when that was written. Somehow. --- projects/grub/grub | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'projects') diff --git a/projects/grub/grub b/projects/grub/grub index 42794dda..1c729663 100755 --- a/projects/grub/grub +++ b/projects/grub/grub @@ -89,12 +89,7 @@ build() { grub_copy_modules - # Temporary until the function project_make_distclean is written - ( - cd "${sources_path}" || return - - make distclean - ) + make -C "${sources_path}" distclean } build_check() { -- cgit v1.2.3-70-g09d2 From 3359f8ef92d120f03e80b108f0fa68ae1882e90f Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 14 Sep 2017 08:31:29 -0400 Subject: Cook the GRUB image before misc. trimmings Out of: the image itself, keylayouts, and font, the image takes the longest to build so it would be best to attempt its build first to avoid wasted time and resources, however little, if the build fails. --- projects/grub/grub | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'projects') diff --git a/projects/grub/grub b/projects/grub/grub index 1c729663..c444841b 100755 --- a/projects/grub/grub +++ b/projects/grub/grub @@ -75,16 +75,16 @@ build() { grub_build_utils - for raw_keymap in "${raw_keymap_path}"/*; do - grub_build_layout "${raw_keymap}" - done - if [[ "${target}" == 'bios' ]]; then grub_build_floppy_image else grub_build_standalone_image fi + for raw_keymap in "${raw_keymap_path}"/*; do + grub_build_layout "${raw_keymap}" + done + grub_build_font grub_copy_modules -- cgit v1.2.3-70-g09d2 From 38c2a13e4b9a2de040864dbd0306cb38f329addf Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Thu, 14 Sep 2017 08:56:59 -0400 Subject: Make a few minor tweaks to the grub-helper script The check for an existing, non-directory file as $keymap_out_path was added to prevent the (unlikely) scenario of attempting writing a file to a file as if it were a directory. --- projects/grub/grub-helper | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'projects') diff --git a/projects/grub/grub-helper b/projects/grub/grub-helper index e7e8a1fe..604d4a54 100755 --- a/projects/grub/grub-helper +++ b/projects/grub/grub-helper @@ -114,6 +114,10 @@ grub_build_layout() { if ! [[ -e "${keymap_out_path}" ]]; then mkdir -p "${keymap_out_path}" + elif ! [[ -d "${keymap_out_path}" ]]; then + printf '\n%s\n' "Error: File ${keymap_out_path} is not a directory" 1>&2 + + return 1 fi "${grub_mklayout}" --output="${grub_kbd_layout}" --input="${raw_layout_path}" @@ -148,8 +152,9 @@ grub_build_floppy_image() { local grubimg="${build_path}/grub2" local tempfile="${build_path}/temp.file" - if ! ( grub_build_bootable_image "$@" ); then + if ! grub_build_bootable_image "$@"; then printf '\n%s\n\n' "Error: Failed to build a GRUB image" 1>&2 + return 1 fi @@ -161,6 +166,7 @@ grub_build_floppy_image() { dd if=/dev/zero of="${tempfile}" bs=1024 count="${size:-160}" else printf '\n%s\n\n' "Error: File ${tempfile} already exists!" 1>&2 + return 1 fi @@ -175,7 +181,8 @@ grub_build_floppy_image() { mv "${tempfile}" "${grubimg}" else printf '\n%s' "Error: Image ${grubimg##*/} is too large; " 1>&2 - printf '%s\n\n' "it must be less than ${size}KiB in size." 1>&2 + printf '%s\n\n' "it must be less than ${size}KiB in size" 1>&2 + return 1 fi } -- cgit v1.2.3-70-g09d2