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.

184 lines
7.0 KiB

  1. version: 2.0
  2. jobs:
  3. build:
  4. docker:
  5. - image: docker.io/openwrtorg/packages-cci:v1.0.5
  6. environment:
  7. - SDK_HOST: "cdn.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. PATTERN=$(echo "$SDK_FILE\$" | sed -e 's/\./\\./g' -e 's/\*/.*/g')
  83. FILENAME=$(grep -m1 -o "$PATTERN" sha256sums)
  84. curl "https://$SDK_HOST/$SDK_PATH/$FILENAME" -sS -o "$FILENAME"
  85. sha256sum -c --ignore-missing sha256sums
  86. - run:
  87. name: Prepare build_dir
  88. working_directory: ~/build_dir
  89. command: |
  90. tar Jxf ~/sdk/$SDK_FILE --strip=1
  91. touch .config
  92. make prepare-tmpinfo scripts/config/conf
  93. ./scripts/config/conf --defconfig=.config Config.in
  94. make prereq
  95. rm .config
  96. cat > feeds.conf <<EOF
  97. src-git base https://github.com/openwrt/openwrt.git;$BRANCH
  98. src-link packages $HOME/openwrt_packages
  99. src-git luci https://github.com/openwrt/luci.git;$BRANCH
  100. EOF
  101. cat feeds.conf
  102. ./scripts/feeds update -a > /dev/null
  103. make defconfig > /dev/null
  104. # enable BUILD_LOG
  105. sed -i 's/# CONFIG_BUILD_LOG is not set/CONFIG_BUILD_LOG=y/' .config
  106. - run:
  107. name: Install & download source, check package, compile
  108. working_directory: ~/build_dir
  109. command: |
  110. set +o pipefail
  111. PKGS=$(cd ~/openwrt_packages; git diff --diff-filter=d --name-only "origin/$BRANCH..." | grep 'Makefile$' | grep -Ev '/files/|/src/' | awk -F/ '{ print $(NF-1) }')
  112. if [ -z "$PKGS" ] ; then
  113. echo_blue "WARNING: No new or modified packages found!"
  114. exit 0
  115. fi
  116. echo_blue "=== Found new/modified packages: $PKGS"
  117. for PKG in $PKGS ; do
  118. echo_blue "===+ Install: $PKG"
  119. ./scripts/feeds install "$PKG"
  120. echo_blue "===+ Download: $PKG"
  121. make "package/$PKG/download" V=s
  122. echo_blue "===+ Check package: $PKG"
  123. make "package/$PKG/check" V=s 2>&1 | tee logtmp
  124. RET=${PIPESTATUS[0]}
  125. if [ $RET -ne 0 ]; then
  126. echo_red "=> Package check failed: $RET)"
  127. exit $RET
  128. fi
  129. badhash_msg="HASH does not match "
  130. badhash_msg+="|HASH uses deprecated hash,"
  131. badhash_msg+="|HASH is missing,"
  132. if grep -qE "$badhash_msg" logtmp; then
  133. echo_red "=> Package HASH check failed"
  134. exit 1
  135. fi
  136. echo_green "=> Package check OK"
  137. done
  138. make \
  139. -f .config \
  140. -f tmp/.packagedeps \
  141. -f <(echo '$(info $(sort $(package-y) $(package-m)))'; echo -en 'a:\n\t@:') \
  142. | tr ' ' '\n' >enabled-package-subdirs.txt
  143. for PKG in $PKGS ; do
  144. if ! grep -m1 -qE "(^|/)$PKG$" enabled-package-subdirs.txt; then
  145. echo_red "===+ Building: $PKG skipped. It cannot be enabled with $SDK_FILE"
  146. continue
  147. fi
  148. echo_blue "===+ Building: $PKG"
  149. make "package/$PKG/compile" -j3 V=s || {
  150. RET=$?
  151. echo_red "===+ Building: $PKG failed, rebuilding with -j1 for human readable error log"
  152. make "package/$PKG/compile" -j1 V=s; exit $RET
  153. }
  154. done
  155. - store_artifacts:
  156. path: ~/build_dir/logs
  157. - store_artifacts:
  158. path: ~/build_dir/bin
  159. workflows:
  160. version: 2
  161. buildpr:
  162. jobs:
  163. - build:
  164. filters:
  165. branches:
  166. ignore: master