ci_build.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # Script for CI system build
  2. #
  3. # Alexander Smirnov <asmirnov@ilbers.de>
  4. # Copyright (c) 2016-2018 ilbers GmbH
  5. #!/bin/sh
  6. set -e
  7. ES_BUG=3
  8. # Export $PATH to use 'parted' tool
  9. export PATH=$PATH:/sbin
  10. # Go to Isar root
  11. cd "$(dirname "$0")/.."
  12. # Start build in Isar tree by default
  13. BUILD_DIR=./build
  14. BB_ARGS="-v"
  15. TARGETS_SET="\
  16. multiconfig:qemuarm-stretch:isar-image-base \
  17. multiconfig:qemuarm-buster:isar-image-base \
  18. multiconfig:qemuarm64-stretch:isar-image-base \
  19. multiconfig:qemui386-stretch:isar-image-base \
  20. multiconfig:qemui386-buster:isar-image-base \
  21. multiconfig:qemuamd64-stretch:isar-image-base \
  22. multiconfig:qemuamd64-buster:isar-image-base \
  23. multiconfig:qemuamd64-buster-tgz:isar-image-base \
  24. multiconfig:nand-ubi-demo-buster:isar-image-ubi \
  25. multiconfig:rpi-stretch:isar-image-base"
  26. # qemu-user-static of <= buster too old to build that
  27. # multiconfig:qemuarm64-buster:isar-image-base
  28. show_help() {
  29. echo "This script builds the default Isar images."
  30. echo
  31. echo "Usage:"
  32. echo " $0 [params]"
  33. echo
  34. echo "Parameters:"
  35. echo " -b, --build BUILD_DIR set path to build directory. If not set,"
  36. echo " the build will be started in current path."
  37. echo " -c, --cross enable cross-compilation."
  38. echo " -d, --debug enable debug bitbake output."
  39. echo " -f, --fast cross build reduced set of configurations."
  40. echo " -q, --quiet suppress verbose bitbake output."
  41. echo " -r, --repro enable use of cached base repository."
  42. echo " --help display this message and exit."
  43. echo
  44. echo "Exit status:"
  45. echo " 0 if OK,"
  46. echo " 3 if invalid parameters are passed."
  47. }
  48. # Parse command line to get user configuration
  49. while [ $# -gt 0 ]
  50. do
  51. key="$1"
  52. case $key in
  53. -h|--help)
  54. show_help
  55. exit 0
  56. ;;
  57. -b|--build)
  58. BUILD_DIR="$2"
  59. shift
  60. ;;
  61. -c|--cross)
  62. CROSS_BUILD="1"
  63. ;;
  64. -d|--debug)
  65. BB_ARGS="$BB_ARGS -d"
  66. ;;
  67. -f|--fast)
  68. # Start build for the reduced set of configurations
  69. # Enforce cross-compilation to speed up the build
  70. FAST_BUILD="1"
  71. CROSS_BUILD="1"
  72. TARGETS_SET="\
  73. multiconfig:qemuarm-stretch:isar-image-base \
  74. multiconfig:qemuarm64-stretch:isar-image-base \
  75. multiconfig:qemuamd64-stretch:isar-image-base \
  76. multiconfig:rpi-stretch:isar-image-base"
  77. ;;
  78. -q|--quiet)
  79. BB_ARGS=""
  80. ;;
  81. -r|--repro)
  82. REPRO_BUILD="1"
  83. ;;
  84. *)
  85. echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
  86. exit $ES_BUG
  87. ;;
  88. esac
  89. shift
  90. done
  91. # Setup build folder for the current build
  92. if [ ! -d "$BUILD_DIR" ]; then
  93. mkdir -p "$BUILD_DIR"
  94. fi
  95. source isar-init-build-env "$BUILD_DIR"
  96. if [ -n "$CROSS_BUILD" ]; then
  97. sed -i -e 's/ISAR_CROSS_COMPILE ?= "0"/ISAR_CROSS_COMPILE ?= "1"/g' conf/local.conf
  98. fi
  99. if [ -n "$REPRO_BUILD" ]; then
  100. # Enable use of cached base repository
  101. bitbake $BB_ARGS -c cache_base_repo $TARGETS_SET
  102. while [ -e bitbake.sock ]; do sleep 1; done
  103. sudo rm -rf tmp
  104. sed -i -e 's/#ISAR_USE_CACHED_BASE_REPO ?= "1"/ISAR_USE_CACHED_BASE_REPO ?= "1"/g' conf/local.conf
  105. fi
  106. # Start build for the defined set of configurations
  107. bitbake $BB_ARGS $TARGETS_SET
  108. # Note: de0-nano-soc build is launched separately as
  109. # parallel build with the same target arch (armhf) fails.
  110. # The problem is being investigated
  111. if [ -n "$FAST_BUILD" ]; then
  112. bitbake $BB_ARGS multiconfig:de0-nano-soc-stretch:isar-image-base
  113. fi
  114. cp -a "${ISARROOT}/meta/classes/dpkg-base.bbclass" "${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup"
  115. echo -e "do_fetch_append() {\n\n}" >> "${ISARROOT}/meta/classes/dpkg-base.bbclass"
  116. bitbake $BB_ARGS multiconfig:qemuamd64-stretch:isar-image-base
  117. mv "${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup" "${ISARROOT}/meta/classes/dpkg-base.bbclass"