deptest: Install the kernel at init stage
[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 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 make target/linux/install V=99 || die "make target/linux/install failed, please check"
35 }
36
37 for pkg in `cat tmp/.packagedeps | grep CONFIG_PACKAGE | grep -v curdir | sed -e 's,.*[/=]\s*,,' | sort -u`; do
38 SELECTED=
39 for conf in `grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'`; do
40 grep "$conf=" .config > /dev/null && SELECTED=1
41 done
42 STAMP_SUCCESS="$STAMP_DIR_SUCCESS/$pkg"
43 STAMP_FAILED="$STAMP_DIR_FAILED/$pkg"
44 rm -f "$STAMP_FAILED"
45 [ -f "$STAMP_SUCCESS" ] && continue
46 [ -n "$SELECTED" ] || {
47 echo "Package $pkg is not selected"
48 continue
49 }
50 echo "Testing package $pkg..."
51 rm -rf "$STAGING_DIR"
52 mkdir -p "$STAGING_DIR"
53 rm -rf "$STAGING_DIR_HOST"
54 cp -al "$STAGING_DIR_HOST_TMPL" "$STAGING_DIR_HOST"
55 make package/$pkg/compile \
56 BUILD_DIR="$BUILD_DIR" \
57 BUILD_DIR_HOST="$BUILD_DIR_HOST" \
58 STAGING_DIR="$STAGING_DIR" \
59 STAGING_DIR_HOST="$STAGING_DIR_HOST" \
60 V=99 >"$LOG_DIR/$(basename $pkg).log" 2>&1
61 if [ $? -eq 0 ]; then
62 touch "$STAMP_SUCCESS"
63 else
64 touch "$STAMP_FAILED"
65 echo "Building package $pkg failed!"
66 fi
67 done