1fail() 2{ 3 echo 4 echo "Test setup failed: $@" 5 echo 6 exit 1 7} 8 9makedir() 10{ 11 rm -rf "$1" 12 mkdir -p "$1" || fail "could not mkdir $1" 13} 14 15cdir() 16{ 17 cd "$1" || fail "could not cd to $1" 18} 19 20build_and_install() 21{ 22 # Create a build directory, and fill it with the source. 23 makedir "$build" 24 makedir "$build/test" 25 26 ls ../ | while read f ; do 27 [ "$f" = "test" ] && continue 28 [ "$f" = ".git" ] && continue 29 cp -a ../"$f" "$build" || fail "could not copy ../$f to $build" 30 done || exit 1 31 32 tolink="$build/utest/test_cmd.c" 33 # Add some hard links, to make the test harder. 34 ln "$tolink" "$build/utest/testhardlink1" || fail 35 ln "$tolink" "$build/utest/testhardlink2" || fail 36 ln "$tolink" "$build/utest/testhardlink3" || fail 37 ln "$tolink" "$build/utest/testhardlink4" || fail 38 # Add a file starting with a character whose ASCII number is greater 39 # than 127, to check for differences between client phase1 sorting and 40 # server sorting. 41 touch "$build/utest/á" || fail 42 # Add some extra directories/files. 43 cp -ar fs-data "$build" 44 45 # Create a .bz2 file, to exercise exclude_comp. 46 # Some tars (like on NetBSd) do not like having '..' in the arguments. 47 # So cd up and back again. 48 cdir .. 49 tar -cjf "$build/autoconf/autoconf.tar.bz2" autoconf || fail 50 cdir - 51 52 # Create a target directory, compile burp and install it into the 53 # target. 54 makedir "$target" 55 cdir "$build" 56 make clean 57 ./configure --prefix=/usr --sysconfdir=/etc/burp --localstatedir=/var || fail "configure failed" 58 make || fail "make failed" 59 # For some reason, make is not returning an error code. 60 # Look for important binaries before carrying on. 61 [ -x burp ] || fail "make failed to build burp" 62 make install-all DESTDIR="$target" || fail "make install failed" 63 [ -x "$target/usr/bin/vss_strip" ] \ 64 || fail "make failed to install vss_strip" 65 [ -h "$target/usr/sbin/bedup" ] \ 66 || fail "make failed to install bedup" 67 [ -h "$target/usr/sbin/bsigs" ] \ 68 || fail "make failed to install bsigs" 69 cdir - 70} 71 72build_and_install 73