diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2016-03-30 21:28:23 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-04-05 13:15:19 +0000 |
commit | 60238ff6aad2e14870bab1c7adee633976571423 (patch) | |
tree | 42859a242fbc96f17abe26b8daedf00f7eaf52e4 /.travis/common.sh | |
parent | 3962c0d948aa2ba5cc3820aea8cf685794a42e5b (diff) | |
download | aports-60238ff6aad2e14870bab1c7adee633976571423.tar.bz2 aports-60238ff6aad2e14870bab1c7adee633976571423.tar.xz |
Set up Travis to build modified packages
Diffstat (limited to '.travis/common.sh')
-rw-r--r-- | .travis/common.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/.travis/common.sh b/.travis/common.sh new file mode 100644 index 0000000000..bf4b2ff945 --- /dev/null +++ b/.travis/common.sh @@ -0,0 +1,61 @@ +# vim: set ts=4: + +readonly ALPINE_ROOT='/mnt/alpine' +readonly ALPINE_USER='alpine' +readonly CLONE_DIR="${CLONE_DIR:-$(pwd)}" + +# Runs commands inside the Alpine chroot. +alpine_run() { + local user="${1:-root}" + local cmd="${2:-sh}" + + local _sudo= + [ "$(id -u)" -eq 0 ] || _sudo='sudo' + + $_sudo chroot "$ALPINE_ROOT" /usr/bin/env -i su -l $user \ + sh -c "cd $CLONE_DIR; $cmd" +} + +die() { + print -s1 -c1 "$@\n" 1>&2 + exit 1 +} + +# Marks start of named folding section for Travis and prints title. +fold_start() { + local name="$1" + local title="$2" + + printf "\ntravis_fold:start:$name " + print -s1 -c6 "> $title\n" +} + +# Marks end of the named folding section. +fold_end() { + local name="$1" + + printf "travis_fold:end:$name\n" +} + +# Prints formatted and colored text. +print() { + local style=0 + local fcolor=9 + + local opt; while getopts 's:c:' opt; do + case "$opt" in + s) style="$OPTARG";; + c) fcolor="$OPTARG";; + esac + done + + shift $(( OPTIND - 1 )) + local text="$@" + + printf "\033[${style};3${fcolor}m$text\033[0m" +} + +title() { + printf '\n' + print -s1 -c6 "==> $@\n" +} |