Changeset b59836d5 in mainline


Ignore:
Timestamp:
2019-04-06T11:46:44Z (6 years ago)
Author:
Petr Pavlu <setup@…>
Children:
0d073b8
Parents:
512282d
git-author:
Petr Pavlu <setup@…> (2019-03-31 12:33:30)
git-committer:
Petr Pavlu <setup@…> (2019-04-06 11:46:44)
Message:

arm64: Add GRUB files for the architecture

  • Teach tools/grub/grub-update.sh how to build GRUB for AArch64.
  • Add pre-compiled GRUB binaries for this architecture, built with Linaro GCC 6.3-2017.02.
Files:
226 added
1 edited

Legend:

Unmodified
Added
Removed
  • tools/grub/grub-update.sh

    r512282d rb59836d5  
    4040grub_rev="bc220962e366b1b46769ed6f9fa5be603ba58ab5"
    4141
     42build_ia32amd64_pc=false
     43build_ia32amd64_efi=false
     44build_arm64_efi=false
     45
    4246function grub_build()
    4347{
    44         target="$1"
    45         platform="$2"
     48        platform="$1"
     49        conf_target="$2"
     50        conf_platform="$3"
    4651
    47         ./configure --prefix="$builddir/$target-$platform" --target="$target" --with-platform="$platform" --disable-werror || exit 1
     52        ./configure --prefix="$builddir/$platform" --target="$conf_target" --with-platform="$conf_platform" --disable-werror || exit 1
    4853        make clean || exit 1
    4954        make install || exit 1
     
    5560        platform="$2"
    5661
    57         rm -rf "$helenosdir"/boot/"$gdir"/"$platform" || exit 1
    58         cp -R "$builddir"/"$platform"/lib64/grub/"$platform" "$helenosdir"/boot/"$gdir" || exit 1
    59         rm -f "$helenosdir"/boot/"$gdir"/"$platform"/*.image || exit 1
    60         rm -f "$helenosdir"/boot/"$gdir"/"$platform"/*.module || exit 1
    61         git add "$helenosdir"/boot/"$gdir"/"$platform" || exit 1
     62        echo "$grub_rev" > "$helenosdir"/boot/grub/"$gdir"/REVISION || exit 1
     63        rm -rf "$helenosdir"/boot/grub/"$gdir"/"$platform" || exit 1
     64        cp -R "$builddir"/"$platform"/lib*/grub/"$platform" "$helenosdir"/boot/grub/"$gdir" || exit 1
     65        rm -f "$helenosdir"/boot/grub/"$gdir"/"$platform"/*.image || exit 1
     66        rm -f "$helenosdir"/boot/grub/"$gdir"/"$platform"/*.module || exit 1
     67        git add "$helenosdir"/boot/grub/"$gdir"/"$platform" || exit 1
    6268}
     69
     70function show_usage()
     71{
     72        echo "Script to generate/update prebuild Grub2 in HelenOS source tree"
     73        echo
     74        echo "Syntax:"
     75        echo " $0 <target>"
     76        echo
     77        echo "Possible targets are:"
     78        echo " ia32+amd64-pc"
     79        echo " ia32+amd64-efi"
     80        echo " arm64-efi"
     81        echo " all             build all targets"
     82        echo
     83
     84        exit 3
     85}
     86
     87if [ "$#" -ne "1" ] ; then
     88        show_usage
     89fi
     90
     91case "$1" in
     92        ia32+amd64-pc)
     93                build_ia32amd64_pc=true
     94                ;;
     95        ia32+amd64-efi)
     96                build_ia32amd64_efi=true
     97                ;;
     98        arm64-efi)
     99                build_arm64_efi=true
     100                ;;
     101        all)
     102                build_ia32amd64_pc=true
     103                build_ia32amd64_efi=true
     104                build_arm64_efi=true
     105                ;;
     106        *)
     107                show_usage
     108                ;;
     109esac
    63110
    64111# Prepare a clone of Grub2 repo
     
    72119git reset --hard "$grub_rev" || exit 1
    73120
    74 echo "$grub_rev" >"$helenosdir"/boot/grub/ia32-pc/REVISION || exit 1
    75 echo "$grub_rev" > "$helenosdir"/boot/grub/ia32-efi/REVISION || exit 1
     121./autogen.sh || exit 1
    76122
    77 # Build each platform to a different directory
    78 ./autogen.sh || exit 1
    79 grub_build i386 pc
    80 grub_build i386 efi
    81 grub_build x86_64 efi
     123if $build_ia32amd64_pc ; then
     124        cd "$workdir" || exit 1
     125        grub_build i386-pc i386 pc
    82126
    83 # Extract El Torrito boot image for i386-pc
    84 cd "$helenosdir"/boot/grub/ia32-pc || exit 1
    85 rm -f pc.img || exit 1
    86 "$builddir"/i386-pc/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
     127        # Extract El Torrito boot image for i386-pc
     128        cd "$helenosdir"/boot/grub/ia32-pc || exit 1
     129        rm -f pc.img || exit 1
     130        "$builddir"/i386-pc/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
    87131
    88 # Extract El Torrito boot image for i386-efi
    89 cd "$helenosdir"/boot/grub/ia32-efi || exit 1
    90 rm -f efi.img.gz || exit 1
    91 "$builddir"/i386-efi/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
    92 mv efi.img i386-efi.img
     132        grub_files_update ia32-pc i386-pc
     133fi
    93134
    94 # Extract El Torrito boot image for x86_64-efi
    95 cd "$helenosdir"/boot/grub/ia32-efi || exit 1
    96 rm -f efi.img.gz || exit 1
    97 "$builddir"/x86_64-efi/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
     135if $build_ia32amd64_efi ; then
     136        cd "$workdir" || exit 1
    98137
    99 # Combine El Torrito boot images for x86_64-efi and i386-efi
    100 mkdir tmp || exit 1
    101 mcopy -ns -i i386-efi.img ::efi tmp || exit 1
    102 mcopy -s -i efi.img tmp/* :: || exit 1
    103 gzip efi.img || exit 1
    104 rm -rf tmp || exit 1
    105 rm -f i386-efi.img || exit 1
     138        # Build each platform to a different directory
     139        grub_build i386-efi i386 efi
     140        grub_build x86_64-efi x86_64 efi
    106141
    107 # Update Grub files for all platforms
    108 grub_files_update grub/ia32-pc i386-pc
    109 grub_files_update grub/ia32-efi i386-efi
    110 grub_files_update grub/ia32-efi x86_64-efi
     142        # Extract El Torrito boot image for i386-efi
     143        cd "$helenosdir"/boot/grub/ia32-efi || exit 1
     144        rm -f efi.img.gz || exit 1
     145        "$builddir"/i386-efi/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
     146        mv efi.img i386-efi.img
     147
     148        # Extract El Torrito boot image for x86_64-efi
     149        cd "$helenosdir"/boot/grub/ia32-efi || exit 1
     150        rm -f efi.img.gz || exit 1
     151        "$builddir"/x86_64-efi/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
     152
     153        # Combine El Torrito boot images for x86_64-efi and i386-efi
     154        mkdir tmp || exit 1
     155        mcopy -ns -i i386-efi.img ::efi tmp || exit 1
     156        mcopy -s -i efi.img tmp/* :: || exit 1
     157        gzip efi.img || exit 1
     158        rm -rf tmp || exit 1
     159        rm -f i386-efi.img || exit 1
     160
     161        # Update Grub files for all platforms
     162        grub_files_update ia32-efi i386-efi
     163        grub_files_update ia32-efi x86_64-efi
     164fi
     165
     166if $build_arm64_efi ; then
     167        cd "$workdir" || exit 1
     168
     169        # Check that the expected compiler is present on PATH
     170        if ! [ -x "$(command -v aarch64-linux-gnu-gcc)" ] ; then
     171                echo "Error: aarch64-linux-gnu-gcc is missing" >&2
     172                exit 1
     173        fi
     174
     175        grub_build arm64-efi aarch64-linux-gnu efi
     176
     177        # Extract El Torrito boot image for arm64-efi
     178        cd "$helenosdir"/boot/grub/arm64-efi || exit 1
     179        rm -f efi.img.gz || exit 1
     180        "$builddir"/arm64-efi/bin/grub-mkrescue -o phony --xorriso="$origdir/getimage.sh" || exit 1
     181        gzip efi.img || exit 1
     182
     183        grub_files_update arm64-efi arm64-efi
     184fi
    111185
    112186echo "GRUB update successful."
Note: See TracChangeset for help on using the changeset viewer.