ci_build.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/usr/bin/env bash
  2. # Script for CI system build
  3. #
  4. # Alexander Smirnov <asmirnov@ilbers.de>
  5. # Copyright (c) 2016-2018 ilbers GmbH
  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. # install avocado in virtualenv in case it is not there already
  13. if ! command -v avocado > /dev/null; then
  14. sudo apt-get update -qq
  15. sudo apt-get install -y virtualenv
  16. rm -rf /tmp/avocado_venv
  17. virtualenv --python python3 /tmp/avocado_venv
  18. source /tmp/avocado_venv/bin/activate
  19. pip install avocado-framework
  20. fi
  21. # Get Avocado build tests path
  22. BUILD_TEST_DIR="$(pwd)/testsuite/build_test"
  23. # Start build in Isar tree by default
  24. BUILD_DIR=./build
  25. # Check dependencies
  26. DEPENDENCIES="umoci skopeo"
  27. for prog in ${DEPENDENCIES} ; do
  28. if [ ! -x "$(which $prog)" ] ; then
  29. echo "missing $prog in PATH" >&2
  30. fi
  31. done
  32. show_help() {
  33. echo "This script builds the default Isar images."
  34. echo
  35. echo "Usage:"
  36. echo " $0 [params]"
  37. echo
  38. echo "Parameters:"
  39. echo " -b, --build BUILD_DIR set path to build directory. If not set,"
  40. echo " the build will be started in current path."
  41. echo " -c, --cross enable cross-compilation."
  42. echo " -d, --debug enable debug bitbake output."
  43. echo " -f, --fast cross build reduced set of configurations."
  44. echo " -q, --quiet suppress verbose bitbake output."
  45. echo " -r, --repro enable use of cached base repository."
  46. echo " --help display this message and exit."
  47. echo
  48. echo "Exit status:"
  49. echo " 0 if OK,"
  50. echo " 3 if invalid parameters are passed."
  51. }
  52. TAGS="full"
  53. CROSS_BUILD="0"
  54. QUIET="0"
  55. # Parse command line to get user configuration
  56. while [ $# -gt 0 ]
  57. do
  58. key="$1"
  59. case $key in
  60. -h|--help)
  61. show_help
  62. exit 0
  63. ;;
  64. -b|--build)
  65. BUILD_DIR="$2"
  66. shift
  67. ;;
  68. -c|--cross)
  69. CROSS_BUILD="1"
  70. ;;
  71. -d|--debug)
  72. VERBOSE="--show=app,test"
  73. ;;
  74. -f|--fast)
  75. # Start build for the reduced set of configurations
  76. # Enforce cross-compilation to speed up the build
  77. TAGS="fast"
  78. CROSS_BUILD="1"
  79. ;;
  80. -q|--quiet)
  81. QUIET="1"
  82. ;;
  83. -r|--repro)
  84. REPRO_BUILD="1"
  85. # This switch is deprecated, just here to not cause failing CI on
  86. # legacy configs
  87. case "$2" in
  88. -s|--sign) shift ;;
  89. esac
  90. ;;
  91. *)
  92. echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
  93. exit $ES_BUG
  94. ;;
  95. esac
  96. shift
  97. done
  98. if [ -z "$REPRO_BUILD" ]; then
  99. TAGS="$TAGS,-repro"
  100. fi
  101. # Provide working path
  102. mkdir -p .config/avocado
  103. cat <<EOF > .config/avocado/avocado.conf
  104. [datadir.paths]
  105. base_dir = $(realpath $BUILD_DIR)/
  106. test_dir = $(realpath $BUILD_DIR)/tests
  107. data_dir = $(realpath $BUILD_DIR)/data
  108. logs_dir = $(realpath $BUILD_DIR)/job-results
  109. EOF
  110. export VIRTUAL_ENV="./"
  111. # the real stuff starts here, trace commands from now on
  112. set -x
  113. avocado $VERBOSE run "$BUILD_TEST_DIR/build_test.py" \
  114. -t $TAGS --test-runner=runner --disable-sysinfo \
  115. -p build_dir="$BUILD_DIR" -p quiet=$QUIET -p cross=$CROSS_BUILD