build-ubuntu.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. #
  3. # Copyright (c) Contributors to the Open 3D Engine Project.
  4. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. #
  6. # SPDX-License-Identifier: Apache-2.0 OR MIT
  7. #
  8. # The function below is used to check if the docker application
  9. # is installed via checking the Ubuntu package manager
  10. function check_docker_requirements()
  11. {
  12. echo "Checking cross compiling requirements."
  13. pkg_list=(docker-ce qemu binfmt-support qemu-user-static)
  14. for package_check in "${pkg_list[@]}"
  15. do
  16. echo "Checking package $package_check"
  17. dpkg -s $package_check > /dev/null 2>&1
  18. if [ $? -ne 0 ]
  19. then
  20. echo ""
  21. echo "Missing package $package_check. Make sure to install it with your local package manager."
  22. echo ""
  23. return 1
  24. fi
  25. done
  26. # Only cross compilation of an ARM64 image on an x86_64 host is supported
  27. if [ "${TARGET_ARCH}" = "aarch64" ]
  28. then
  29. # Make sure qemu-aarch64 is installed properly
  30. QEMU_AARCH_COUNT=$(update-binfmts --display | grep qemu-aarch64 | wc -l)
  31. if [ $QEMU_AARCH_COUNT -eq 0 ]
  32. then
  33. echo ""
  34. echo "QEMU aarch64 binary format not registered."
  35. echo "Run the following command to register"
  36. echo ""
  37. echo "sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes"
  38. echo ""
  39. return 1
  40. fi
  41. echo ""
  42. echo "Cross compiling aarch64 on an amd64 machine validated."
  43. echo ""
  44. fi
  45. }
  46. source ./build-linux.sh "$@" "check_docker_requirements"