33dfa8337642a1e35387e723023d2b3560a6b973
[openwrt/svn-archive/archive.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 STAMP_DIR_BLACKLIST="$DIR/stamp-blacklist"
11 BUILD_DIR="$DIR/build_dir/target"
12 BUILD_DIR_HOST="$DIR/build_dir/host"
13 STAGING_DIR="$DIR/staging_dir"
14 STAGING_DIR_HOST="$DIR/staging_dir_host"
15 STAGING_DIR_HOST_TMPL="$DIR/staging_dir_host_tmpl"
16 LOG_DIR="$DIR/logs"
17
18 die()
19 {
20 echo "$@"
21 exit 1
22 }
23
24 [ -f "$BASEDIR/include/toplevel.mk" ] || \
25 die "Error: Could not find buildsystem base directory"
26 [ -f "$BASEDIR/.config" ] || \
27 die "The buildsystem is not configured. Please run make menuconfig."
28 cd "$BASEDIR" || die "Failed to enter base directory"
29
30 mkdir -p "$STAMP_DIR_SUCCESS" "$STAMP_DIR_FAILED" "$STAMP_DIR_BLACKLIST" \
31 "$BUILD_DIR" "$BUILD_DIR_HOST" "$LOG_DIR"
32
33 [ -d "$STAGING_DIR_HOST_TMPL" ] || {
34 rm -rf staging_dir/host
35 make tools/install V=99 || die "make tools/install failed, please check"
36 cp -al staging_dir/host "$STAGING_DIR_HOST_TMPL"
37 make toolchain/install V=99 || die "make toolchain/install failed, please check"
38 make target/linux/install V=99 || die "make target/linux/install failed, please check"
39 }
40
41 for pkg in `cat tmp/.packagedeps | grep CONFIG_PACKAGE | grep -v curdir | sed -e 's,.*[/=]\s*,,' | sort -u`; do
42 SELECTED=
43 for conf in `grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'`; do
44 grep "$conf=" .config > /dev/null && SELECTED=1
45 done
46 STAMP_SUCCESS="$STAMP_DIR_SUCCESS/$pkg"
47 STAMP_FAILED="$STAMP_DIR_FAILED/$pkg"
48 STAMP_BLACKLIST="$STAMP_DIR_BLACKLIST/$pkg"
49 rm -f "$STAMP_FAILED"
50 [ -f "$STAMP_SUCCESS" ] && continue
51 [ -n "$SELECTED" ] || {
52 echo "Package $pkg is not selected"
53 continue
54 }
55 [ -f "$STAMP_BLACKLIST" ] && {
56 echo "Package $pkg is blacklisted"
57 continue
58 }
59 echo "Testing package $pkg..."
60 rm -rf "$STAGING_DIR"
61 mkdir -p "$STAGING_DIR"
62 rm -rf "$STAGING_DIR_HOST"
63 cp -al "$STAGING_DIR_HOST_TMPL" "$STAGING_DIR_HOST"
64 make package/$pkg/compile \
65 BUILD_DIR="$BUILD_DIR" \
66 BUILD_DIR_HOST="$BUILD_DIR_HOST" \
67 STAGING_DIR="$STAGING_DIR" \
68 STAGING_DIR_HOST="$STAGING_DIR_HOST" \
69 V=99 >"$LOG_DIR/$(basename $pkg).log" 2>&1
70 if [ $? -eq 0 ]; then
71 touch "$STAMP_SUCCESS"
72 else
73 touch "$STAMP_FAILED"
74 echo "Building package $pkg failed!"
75 fi
76 done