2864cd1a359a28d12a067e1f9c64f0520c1795f1
[openwrt.git] / scripts / deptest.sh
1 #!/bin/bash
2
3 SCRIPTDIR="$(dirname "$0")"
4 [ "${SCRIPTDIR:0:1}" = "/" ] || SCRIPTDIR="$PWD/$SCRIPTDIR"
5 BASEDIR="$SCRIPTDIR/.."
6
7 DIR="$BASEDIR/tmp/deptest"
8 STAMP_DIR_SUCCESS="$DIR/stamp-success"
9 STAMP_DIR_FAILED="$DIR/stamp-failed"
10 BUILD_DIR="$DIR/build_dir/target"
11 BUILD_DIR_HOST="$DIR/build_dir/host"
12 STAGING_DIR="$DIR/staging_dir"
13 STAGING_DIR_HOST="$DIR/staging_dir_host"
14 STAGING_DIR_HOST_TMPL="$DIR/staging_dir_host_tmpl"
15 LOG_DIR="$DIR/logs"
16
17 die()
18 {
19 echo "$@"
20 exit 1
21 }
22
23 [ -f "$BASEDIR/include/toplevel.mk" ] || \
24 die "Error: Could not find buildsystem base directory"
25 cd "$BASEDIR" || die "Failed to enter base directory"
26
27 mkdir -p "$STAMP_DIR_SUCCESS" "$STAMP_DIR_FAILED" "$BUILD_DIR" "$BUILD_DIR_HOST" "$LOG_DIR"
28
29 [ -d "$STAGING_DIR_HOST_TMPL" ] || {
30 rm -rf staging_dir/host
31 make tools/install V=99 || die "make tools/install failed, please check"
32 cp -al staging_dir/host "$STAGING_DIR_HOST_TMPL"
33 make toolchain/install V=99 || die "make toolchain/install failed, please check"
34 }
35
36 for pkg in `cat tmp/.packagedeps | grep CONFIG_PACKAGE | grep -v curdir | sed -e 's,.*[/=]\s*,,' | sort -u`; do
37 SELECTED=
38 for conf in `grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'`; do
39 grep "$conf=" .config > /dev/null && SELECTED=1
40 done
41 STAMP_SUCCESS="$STAMP_DIR_SUCCESS/$pkg"
42 STAMP_FAILED="$STAMP_DIR_FAILED/$pkg"
43 rm -f "$STAMP_FAILED"
44 [ -f "$STAMP_SUCCESS" ] && continue
45 [ -n "$SELECTED" ] || {
46 echo "Package $pkg is not selected"
47 continue
48 }
49 echo "Testing package $pkg..."
50 rm -rf "$STAGING_DIR"
51 mkdir -p "$STAGING_DIR"
52 rm -rf "$STAGING_DIR_HOST"
53 cp -al "$STAGING_DIR_HOST_TMPL" "$STAGING_DIR_HOST"
54 make package/$pkg/compile \
55 BUILD_DIR="$BUILD_DIR" \
56 BUILD_DIR_HOST="$BUILD_DIR_HOST" \
57 STAGING_DIR="$STAGING_DIR" \
58 STAGING_DIR_HOST="$STAGING_DIR_HOST" \
59 V=99 >"$LOG_DIR/$(basename $pkg).log" 2>&1
60 if [ $? -eq 0 ]; then
61 touch "$STAMP_SUCCESS"
62 else
63 touch "$STAMP_FAILED"
64 echo "Building package $pkg failed!"
65 fi
66 done
This page took 0.041663 seconds and 3 git commands to generate.