3 # Automated OpenWrt package dependency checker
5 # Copyright (C) 2009-2010 OpenWrt.org
7 # This is free software, licensed under the GNU General Public License v2.
8 # See /LICENSE for more information.
11 SCRIPTDIR="$(dirname "$0")"
12 [ "${SCRIPTDIR:0:1}" = "/" ] || SCRIPTDIR="$PWD/$SCRIPTDIR"
13 BASEDIR="$SCRIPTDIR/.."
15 DIR="$BASEDIR/tmp/deptest"
16 STAMP_DIR_SUCCESS="$DIR/stamp-success"
17 STAMP_DIR_FAILED="$DIR/stamp-failed"
18 STAMP_DIR_BLACKLIST="$DIR/stamp-blacklist"
19 BUILD_DIR="$DIR/build_dir/target"
20 BUILD_DIR_HOST="$DIR/build_dir/host"
21 STAGING_DIR="$DIR/staging_dir"
22 STAGING_DIR_HOST="$STAGING_DIR/host"
23 STAGING_DIR_HOST_TMPL="$DIR/staging_dir_host_tmpl"
34 echo "deptest.sh [OPTIONS] [PACKAGES]"
37 echo " --lean Run a lean test. Do not clean the build directory for each"
39 echo " --force Force a test, even if a success stamp is available"
41 echo "PACKAGES are packages to test. If not specified, all installed packages"
42 echo "will be tested."
45 test_package() # $1=pkgname
48 [ -n "$pkg" -a -z "$(echo "$pkg" | grep -e '/')" -a "$pkg" != "." -a "$pkg" != ".." ] || \
49 die "Package name \"$pkg\" contains illegal characters"
51 for conf in `grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'`; do
52 grep "$conf=" .config > /dev/null && SELECTED=1 && break
54 local STAMP_SUCCESS="$STAMP_DIR_SUCCESS/$pkg"
55 local STAMP_FAILED="$STAMP_DIR_FAILED/$pkg"
56 local STAMP_BLACKLIST="$STAMP_DIR_BLACKLIST/$pkg"
58 [ -f "$STAMP_SUCCESS" -a $force -eq 0 ] && return
59 rm -f "$STAMP_SUCCESS"
60 [ -n "$SELECTED" ] || {
61 echo "Package $pkg is not selected"
64 [ -f "$STAMP_BLACKLIST" ] && {
65 echo "Package $pkg is blacklisted"
68 echo "Testing package $pkg..."
70 mkdir -p "$STAGING_DIR"
71 cp -al "$STAGING_DIR_HOST_TMPL" "$STAGING_DIR_HOST"
72 [ $lean_test -eq 0 ] && rm -rf "$BUILD_DIR" "$BUILD_DIR_HOST"
73 mkdir -p "$BUILD_DIR" "$BUILD_DIR_HOST"
74 make package/$pkg/compile \
75 BUILD_DIR="$BUILD_DIR" \
76 BUILD_DIR_HOST="$BUILD_DIR_HOST" \
77 STAGING_DIR="$STAGING_DIR" \
78 STAGING_DIR_HOST="$STAGING_DIR_HOST" \
79 FORCE_HOST_INSTALL=1 \
80 V=99 >"$LOG_DIR/$(basename $pkg).log" 2>&1
82 touch "$STAMP_SUCCESS"
85 echo "Building package $pkg failed!"
89 # parse commandline options
93 while [ $# -ne 0 ]; do
106 packages="$packages $1"
112 [ -f "$BASEDIR/include/toplevel.mk" ] || \
113 die "Error: Could not find buildsystem base directory"
114 [ -f "$BASEDIR/.config" ] || \
115 die "The buildsystem is not configured. Please run make menuconfig."
116 cd "$BASEDIR" || die "Failed to enter base directory"
118 mkdir -p "$STAMP_DIR_SUCCESS" "$STAMP_DIR_FAILED" "$STAMP_DIR_BLACKLIST" "$LOG_DIR"
120 [ -d "$STAGING_DIR_HOST_TMPL" ] || {
121 rm -rf staging_dir/host
122 make tools/install V=99 || die "make tools/install failed, please check"
123 cp -al staging_dir/host "$STAGING_DIR_HOST_TMPL"
124 make toolchain/install V=99 || die "make toolchain/install failed, please check"
125 make target/linux/install V=99 || die "make target/linux/install failed, please check"
128 if [ -z "$packages" ]; then
129 # iterate over all packages
130 for pkg in `cat tmp/.packagedeps | grep CONFIG_PACKAGE | grep -v curdir | sed -e 's,.*[/=]\s*,,' | sort -u`; do
134 # only check the specified packages
135 for pkg in $packages; do