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.

182 lines
6.9 KiB

  1. version: 2.0
  2. jobs:
  3. build:
  4. docker:
  5. - image: docker.io/openwrtorg/packages-cci:v1.0.6
  6. environment:
  7. - SDK_HOST: "downloads.openwrt.org"
  8. - SDK_PATH: "snapshots/targets/ath79/generic"
  9. - SDK_FILE: "openwrt-sdk-ath79-generic_*.Linux-x86_64.tar.xz"
  10. - BRANCH: "master"
  11. steps:
  12. - checkout:
  13. path: ~/openwrt_packages
  14. - run:
  15. name: Check changes / verify commits
  16. working_directory: ~/openwrt_packages
  17. command: |
  18. cat >> $BASH_ENV <<EOF
  19. echo_red() { printf "\033[1;31m\$*\033[m\n"; }
  20. echo_green() { printf "\033[1;32m\$*\033[m\n"; }
  21. echo_blue() { printf "\033[1;34m\$*\033[m\n"; }
  22. EOF
  23. source $BASH_ENV
  24. RET=0
  25. for commit in $(git rev-list HEAD ^origin/$BRANCH); do
  26. echo_blue "=== Checking commit '$commit'"
  27. if git show --format='%P' -s $commit | grep -qF ' '; then
  28. echo_red "Pull request should not include merge commits"
  29. RET=1
  30. fi
  31. author="$(git show -s --format=%aN $commit)"
  32. if echo $author | grep -q '\S\+\s\+\S\+'; then
  33. echo_green "Author name ($author) seems ok"
  34. else
  35. echo_red "Author name ($author) need to be your real name 'firstname lastname'"
  36. RET=1
  37. fi
  38. subject="$(git show -s --format=%s $commit)"
  39. if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
  40. echo_green "Commit subject line seems ok ($subject)"
  41. else
  42. echo_red "Commit subject line MUST start with '<package name>: ' ($subject)"
  43. RET=1
  44. fi
  45. body="$(git show -s --format=%b $commit)"
  46. sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
  47. if echo "$body" | grep -qF "$sob"; then
  48. echo_green "Signed-off-by match author"
  49. else
  50. echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')"
  51. RET=1
  52. fi
  53. done
  54. exit $RET
  55. - run:
  56. name: Download the SDK
  57. working_directory: ~/sdk
  58. command: |
  59. curl "https://$SDK_HOST/$SDK_PATH/sha256sums" -sS -o sha256sums
  60. curl "https://$SDK_HOST/$SDK_PATH/sha256sums.asc" -fs -o sha256sums.asc || true
  61. curl "https://$SDK_HOST/$SDK_PATH/sha256sums.sig" -fs -o sha256sums.sig || true
  62. if [ ! -f sha256sums.asc ] && [ ! -f sha256sums.sig ]; then
  63. echo_red "Missing sha256sums signature files"
  64. exit 1
  65. fi
  66. [ ! -f sha256sums.asc ] || gpg --with-fingerprint --verify sha256sums.asc sha256sums
  67. if [ -f sha256sums.sig ]; then
  68. VERIFIED=
  69. for KEY in ~/usign/*; do
  70. echo "Trying $KEY..."
  71. if signify-openbsd -V -q -p "$KEY" -x sha256sums.sig -m sha256sums; then
  72. echo "...verified"
  73. VERIFIED=1
  74. break
  75. fi
  76. done
  77. if [ -z "$VERIFIED" ]; then
  78. echo_red "Could not verify usign signature"
  79. exit 1
  80. fi
  81. fi
  82. rsync -av "$SDK_HOST::downloads/$SDK_PATH/$SDK_FILE" .
  83. sha256sum -c --ignore-missing sha256sums
  84. - run:
  85. name: Prepare build_dir
  86. working_directory: ~/build_dir
  87. command: |
  88. tar Jxf ~/sdk/$SDK_FILE --strip=1
  89. touch .config
  90. make prepare-tmpinfo scripts/config/conf
  91. ./scripts/config/conf --defconfig=.config Config.in
  92. make prereq
  93. rm .config
  94. cat > feeds.conf <<EOF
  95. src-git base https://github.com/openwrt/openwrt.git;$BRANCH
  96. src-link packages $HOME/openwrt_packages
  97. src-git luci https://github.com/openwrt/luci.git;$BRANCH
  98. EOF
  99. cat feeds.conf
  100. ./scripts/feeds update -a > /dev/null
  101. make defconfig > /dev/null
  102. # enable BUILD_LOG
  103. sed -i 's/# CONFIG_BUILD_LOG is not set/CONFIG_BUILD_LOG=y/' .config
  104. - run:
  105. name: Install & download source, check package, compile
  106. working_directory: ~/build_dir
  107. command: |
  108. set +o pipefail
  109. PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -Ev '/files/|/src/' | awk -F/ '{ print $(NF-1) }')
  110. if [ -z "$PKGS" ] ; then
  111. echo_blue "WARNING: No new or modified packages found!"
  112. exit 0
  113. fi
  114. echo_blue "=== Found new/modified packages: $PKGS"
  115. for PKG in $PKGS ; do
  116. echo_blue "===+ Install: $PKG"
  117. ./scripts/feeds install "$PKG"
  118. echo_blue "===+ Download: $PKG"
  119. make "package/$PKG/download" V=s
  120. echo_blue "===+ Check package: $PKG"
  121. make "package/$PKG/check" V=s 2>&1 | tee logtmp
  122. RET=${PIPESTATUS[0]}
  123. if [ $RET -ne 0 ]; then
  124. echo_red "=> Package check failed: $RET)"
  125. exit $RET
  126. fi
  127. badhash_msg="HASH does not match "
  128. badhash_msg+="|HASH uses deprecated hash,"
  129. badhash_msg+="|HASH is missing,"
  130. if grep -qE "$badhash_msg" logtmp; then
  131. echo_red "=> Package HASH check failed"
  132. exit 1
  133. fi
  134. echo_green "=> Package check OK"
  135. done
  136. make \
  137. -f .config \
  138. -f tmp/.packagedeps \
  139. -f <(echo '$(info $(sort $(package-y) $(package-m)))'; echo -en 'a:\n\t@:') \
  140. | tr ' ' '\n' >enabled-package-subdirs.txt
  141. for PKG in $PKGS ; do
  142. if ! grep -m1 -qE "(^|/)$PKG$" enabled-package-subdirs.txt; then
  143. echo_red "===+ Building: $PKG skipped. It cannot be enabled with $SDK_FILE"
  144. continue
  145. fi
  146. echo_blue "===+ Building: $PKG"
  147. make "package/$PKG/compile" -j3 V=s || {
  148. RET=$?
  149. echo_red "===+ Building: $PKG failed, rebuilding with -j1 for human readable error log"
  150. make "package/$PKG/compile" -j1 V=s; exit $RET
  151. }
  152. done
  153. - store_artifacts:
  154. path: ~/build_dir/logs
  155. - store_artifacts:
  156. path: ~/build_dir/bin
  157. workflows:
  158. version: 2
  159. buildpr:
  160. jobs:
  161. - build:
  162. filters:
  163. branches:
  164. ignore: master