build,travis: some tunings
- use 'git diff --name-only' - unpack the sdk only once as if there is no errors we don't need clean sdk fresh sdk mean new git checkout of the feeds each time - only include base, packages and luci, as we should not have dependencies on other feeds - use github for feeds - continue to test on error - add a bit of color - use bash Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
parent
2fb197ddc9
commit
2ce9c3a64a
1 changed files with 51 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# MIT Alexander Couzens <lynxis@fe80.eu>
|
||||
|
||||
|
@ -9,6 +9,23 @@ SDK_PATH=https://downloads.lede-project.org/snapshots/targets/ar71xx/generic/
|
|||
SDK=lede-sdk-ar71xx-generic_gcc-5.4.0_musl.Linux-x86_64
|
||||
PACKAGES_DIR="$PWD"
|
||||
|
||||
echo_red() { printf "\033[1;31m$*\033[m\n"; }
|
||||
echo_green() { printf "\033[1;32m$*\033[m\n"; }
|
||||
echo_blue() { printf "\033[1;34m$*\033[m\n"; }
|
||||
|
||||
exec_status() {
|
||||
("$@" 2>&1) > logoutput && status=0 || status=1
|
||||
grep -qE 'WARNING|ERROR' logoutput && status=1
|
||||
cat logoutput
|
||||
if [ $status -eq 0 ]; then
|
||||
echo_green "=> $* successful"
|
||||
return 0
|
||||
else
|
||||
echo_red "=> $* failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# download will run on the `before_script` step
|
||||
# The travis cache will be used (all files under $HOME/sdk/). Meaning
|
||||
# We don't have to download the file again
|
||||
|
@ -16,7 +33,7 @@ download_sdk() {
|
|||
mkdir -p "$SDK_HOME"
|
||||
cd "$SDK_HOME"
|
||||
|
||||
echo "=== download SDK"
|
||||
echo_blue "=== download SDK"
|
||||
wget "$SDK_PATH/sha256sums" -O sha256sums
|
||||
wget "$SDK_PATH/sha256sums.gpg" -O sha256sums.asc
|
||||
|
||||
|
@ -34,7 +51,7 @@ download_sdk() {
|
|||
|
||||
# check again and fail here if the file is still bad
|
||||
sha256sum -c ./sha256sums.small
|
||||
echo "=== SDK is up-to-date"
|
||||
echo_blue "=== SDK is up-to-date"
|
||||
}
|
||||
|
||||
# test_package will run on the `script` step.
|
||||
|
@ -42,52 +59,54 @@ download_sdk() {
|
|||
# own clean sdk directory
|
||||
test_packages() {
|
||||
# search for new or modified packages. PKGS will hold a list of package like 'admin/muninlite admin/monit ...'
|
||||
PKGS=$(git diff --stat "$TRAVIS_COMMIT_RANGE" | grep Makefile | grep -v '/files/' | awk '{ print $1}' | awk -F'/Makefile' '{ print $1 }')
|
||||
PKGS=$(git diff --name-only "$TRAVIS_COMMIT_RANGE" | grep 'Makefile$' | grep -v '/files/' | awk -F'/Makefile' '{ print $1 }')
|
||||
|
||||
if [ -z "$PKGS" ] ; then
|
||||
echo "No new or modified packages found!" >&2
|
||||
echo_blue "No new or modified packages found!" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "=== Found new/modified packages:"
|
||||
echo_blue "=== Found new/modified packages:"
|
||||
for pkg in $PKGS ; do
|
||||
echo "===+ $pkg"
|
||||
done
|
||||
|
||||
echo_blue "=== Setting up SDK"
|
||||
tmp_path=$(mktemp -d)
|
||||
cd "$tmp_path"
|
||||
tar Jxf "$SDK_HOME/$SDK.tar.xz" --strip=1
|
||||
|
||||
# use github mirrors to spare lede servers
|
||||
cat > feeds.conf <<EOF
|
||||
src-git base https://github.com/lede-project/source.git
|
||||
src-link packages $PACKAGES_DIR
|
||||
src-git luci https://github.com/openwrt/luci.git
|
||||
EOF
|
||||
|
||||
./scripts/feeds update -a
|
||||
./scripts/feeds install -a
|
||||
make defconfig
|
||||
echo_blue "=== Setting up SDK done"
|
||||
|
||||
RET=0
|
||||
# E.g: pkg_dir => admin/muninlite
|
||||
# pkg_name => muninlite
|
||||
# pkg_name => muninlite
|
||||
for pkg_dir in $PKGS ; do
|
||||
pkg_name=$(echo "$pkg_dir" | awk -F/ '{ print $NF }')
|
||||
tmp_path=$HOME/tmp/$pkg_name/
|
||||
echo_blue "=== $pkg_name Testing package"
|
||||
|
||||
echo "=== $pkg_name Testing package"
|
||||
exec_status make "package/$pkg_name/download" V=s || RET=1
|
||||
exec_status make "package/$pkg_name/check" V=s || RET=1
|
||||
|
||||
# create a clean sdk for every package
|
||||
mkdir -p "$tmp_path"
|
||||
cd "$tmp_path"
|
||||
tar Jxf "$SDK_HOME/$SDK.tar.xz"
|
||||
cd "$SDK"
|
||||
|
||||
cat > feeds.conf <<EOF
|
||||
src-git base https://git.lede-project.org/source.git
|
||||
src-link packages $PACKAGES_DIR
|
||||
src-git luci https://git.lede-project.org/project/luci.git
|
||||
src-git routing https://git.lede-project.org/feed/routing.git
|
||||
src-git telephony https://git.lede-project.org/feed/telephony.git
|
||||
EOF
|
||||
./scripts/feeds update 2>/dev/null >/dev/null
|
||||
./scripts/feeds install "$pkg_name"
|
||||
|
||||
make defconfig
|
||||
make "package/$pkg_name/download" V=s
|
||||
make "package/$pkg_name/check" V=s | tee -a logoutput
|
||||
grep WARNING logoutput && exit 1
|
||||
rm -rf "$tmp_path"
|
||||
echo "=== $pkg_name Finished package"
|
||||
echo_blue "=== $pkg_name Finished package"
|
||||
done
|
||||
|
||||
exit $RET
|
||||
}
|
||||
|
||||
export
|
||||
echo_blue "=== Travis ENV"
|
||||
env
|
||||
echo_blue "=== Travis ENV"
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" = false ] ; then
|
||||
echo "Only Pull Requests are supported at the moment." >&2
|
||||
|
|
Loading…
Reference in a new issue