You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9 KiB

  1. #!/bin/sh
  2. #
  3. # MIT Alexander Couzens <lynxis@fe80.eu>
  4. set -e
  5. SDK_HOME="$HOME/sdk"
  6. SDK_PATH=https://downloads.lede-project.org/snapshots/targets/ar71xx/generic/
  7. SDK=lede-sdk-ar71xx-generic_gcc-5.4.0_musl.Linux-x86_64
  8. PACKAGES_DIR="$PWD"
  9. # download will run on the `before_script` step
  10. # The travis cache will be used (all files under $HOME/sdk/). Meaning
  11. # We don't have to download the file again
  12. download_sdk() {
  13. mkdir -p "$SDK_HOME"
  14. cd "$SDK_HOME"
  15. echo "=== download SDK"
  16. wget "$SDK_PATH/sha256sums" -O sha256sums
  17. wget "$SDK_PATH/sha256sums.gpg" -O sha256sums.asc
  18. # LEDE Build System (LEDE GnuPG key for unattended build jobs)
  19. gpg --recv 0xCD84BCED626471F1
  20. # LEDE Release Builder (17.01 "Reboot" Signing Key)
  21. gpg --recv 0x833C6010D52BBB6B
  22. gpg --verify sha256sums.asc
  23. grep "$SDK" sha256sums > sha256sums.small
  24. # if missing, outdated or invalid, download again
  25. if ! sha256sum -c ./sha256sums.small ; then
  26. wget "$SDK_PATH/$SDK.tar.xz" -O "$SDK.tar.xz"
  27. fi
  28. # check again and fail here if the file is still bad
  29. sha256sum -c ./sha256sums.small
  30. echo "=== SDK is up-to-date"
  31. }
  32. # test_package will run on the `script` step.
  33. # test_package call make download check for very new/modified package in it's
  34. # own clean sdk directory
  35. test_packages() {
  36. # search for new or modified packages. PKGS will hold a list of package like 'admin/muninlite admin/monit ...'
  37. PKGS=$(git diff --stat "$TRAVIS_COMMIT_RANGE" | grep Makefile | grep -v '/files/' | awk '{ print $1}' | awk -F'/Makefile' '{ print $1 }')
  38. if [ -z "$PKGS" ] ; then
  39. echo "No new or modified packages found!" >&2
  40. exit 0
  41. fi
  42. echo "=== Found new/modified packages:"
  43. for pkg in $PKGS ; do
  44. echo "===+ $pkg"
  45. done
  46. # E.g: pkg_dir => admin/muninlite
  47. # pkg_name => muninlite
  48. for pkg_dir in $PKGS ; do
  49. pkg_name=$(echo "$pkg_dir" | awk -F/ '{ print $NF }')
  50. tmp_path=$HOME/tmp/$pkg_name/
  51. echo "=== $pkg_name Testing package"
  52. # create a clean sdk for every package
  53. mkdir -p "$tmp_path"
  54. cd "$tmp_path"
  55. tar Jxf "$SDK_HOME/$SDK.tar.xz"
  56. cd "$SDK"
  57. cat > feeds.conf <<EOF
  58. src-git base https://git.lede-project.org/source.git
  59. src-link packages $PACKAGES_DIR
  60. src-git luci https://git.lede-project.org/project/luci.git
  61. src-git routing https://git.lede-project.org/feed/routing.git
  62. src-git telephony https://git.lede-project.org/feed/telephony.git
  63. EOF
  64. ./scripts/feeds update 2>/dev/null >/dev/null
  65. ./scripts/feeds install "$pkg_name"
  66. make defconfig
  67. make "package/$pkg_name/download" V=s
  68. make "package/$pkg_name/check" V=s | tee -a logoutput
  69. grep WARNING logoutput && exit 1
  70. rm -rf "$tmp_path"
  71. echo "=== $pkg_name Finished package"
  72. done
  73. }
  74. export
  75. if [ "$TRAVIS_PULL_REQUEST" = false ] ; then
  76. echo "Only Pull Requests are supported at the moment." >&2
  77. exit 0
  78. fi
  79. if [ $# -ne 1 ] ; then
  80. cat <<EOF
  81. Usage: $0 (download_sdk|test_packages)
  82. download_sdk - download the SDK to $HOME/sdk.tar.xz
  83. test_packages - do a make check on the package
  84. EOF
  85. exit 1
  86. fi
  87. $@