aboutsummaryrefslogtreecommitdiffstats
path: root/.travis/build-pkgs
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2016-03-30 21:28:23 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2016-04-05 13:15:19 +0000
commit60238ff6aad2e14870bab1c7adee633976571423 (patch)
tree42859a242fbc96f17abe26b8daedf00f7eaf52e4 /.travis/build-pkgs
parent3962c0d948aa2ba5cc3820aea8cf685794a42e5b (diff)
downloadaports-60238ff6aad2e14870bab1c7adee633976571423.tar.gz
aports-60238ff6aad2e14870bab1c7adee633976571423.tar.bz2
aports-60238ff6aad2e14870bab1c7adee633976571423.tar.xz
Set up Travis to build modified packages
Diffstat (limited to '.travis/build-pkgs')
-rwxr-xr-x.travis/build-pkgs75
1 files changed, 75 insertions, 0 deletions
diff --git a/.travis/build-pkgs b/.travis/build-pkgs
new file mode 100755
index 0000000000..6c65407041
--- /dev/null
+++ b/.travis/build-pkgs
@@ -0,0 +1,75 @@
+#!/bin/sh
+# vim: set ts=4:
+set -eu
+
+. "$(dirname "$0")"/common.sh
+
+# Prints names of top-level directories (i.e. repositories) that has been
+# changed/created in the specified revisions.
+changed_repos() {
+ local commit_ish="$1"
+
+ git diff-tree --name-only "$commit_ish" | grep -v '^\..*' || echo ''
+}
+
+# Prints names of repo's subdirs (i.e. abuilds) that contains APKBUILDs which
+# has been changed/created in the specified revisions. The abuild names are
+# printed in a build order.
+changed_abuilds() {
+ local repo="$1"
+ local commit_ish="$2"
+
+ # Get names of repo's subdirectories with modified APKBUILD.
+ local aports="$(git diff-tree -r --relative="$repo" --name-only "$commit_ish" -- '*APKBUILD' \
+ | xargs -I% dirname % | xargs)"
+
+ # Sort abuilds by build order.
+ ap builddirs -d "$(pwd)/$repo" $aports 2>/dev/null | xargs -I% basename %
+}
+
+
+cd "$CLONE_DIR"
+
+# Workarounds for oddities of TRAVIS_COMMIT_RANGE that:
+# - may be empty when pushing single commit,
+# - uses triple-dot range instead of double-dot that we need,
+# - contains SHA of old (unreachable) commit when rebasing.
+commit_range="$(echo "${TRAVIS_COMMIT_RANGE:-}" | sed -E 's/\.{3}/../')"
+if ! git rev-parse "$commit_range" >/dev/null 2>&1; then
+ commit_range="$(git rev-parse HEAD^1)..HEAD"
+fi
+
+failed_pkgs=''
+successful_pkgs=''
+
+
+title "Building abuilds that has been modified/added between $commit_range\n"
+
+echo 'Diffstat:'
+git --no-pager diff --color --stat "$commit_range"
+
+for repo in $(changed_repos "$commit_range"); do
+ for pkgname in $(changed_abuilds "$repo" "$commit_range"); do
+ qname="$repo/$pkgname"
+
+ fold_start "$pkgname" "Building package $qname"
+
+ if APKBUILD="$qname/APKBUILD" abuild -fr; then
+ successful_pkgs="$successful_pkgs $qname"
+ else
+ failed_pkgs="$failed_pkgs $qname"
+ fi
+ fold_end "$pkgname"
+ done
+done
+
+printf '\n----\n'
+if [ -n "$successful_pkgs" ]; then
+ print -s1 -c2 "Successfully build packages:$successful_pkgs\n"
+fi
+if [ -n "$failed_pkgs" ]; then
+ die "Failed to build packages:$failed_pkgs"
+
+elif [ -z "$successful_pkgs" ]; then
+ die 'No packages found to be build.'
+fi