]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/setup
Fix slow regress setups
[bacula/bacula] / regress / scripts / setup
1 #!/bin/sh
2 #
3 # Script to setup running Bacula regression tests
4 #
5
6 check_exit_code()
7 {
8    if [ $? != 0 ] ; then
9       echo "Bad exit code giving up"
10       exit 1 
11    fi
12 }
13
14 . ./config
15
16 cwd=`pwd`
17 if [ ! -d ${BACULA_SOURCE} ] ; then
18    echo "The BACULA_SOURCE environment variable must be a Bacula release directory, but is not."
19    echo " "
20    exit 1
21 fi
22
23 MAKEOPTS=${MAKEOPT:-"-j3"}
24
25
26 # we build and setup binaries to the $cwd/bin directory not $bin
27 rm -rf build bin
28 # Copy new source
29 echo "Copying source from ${BACULA_SOURCE}"
30 cp -rp ${BACULA_SOURCE} build
31 which git >/dev/null 2>/dev/null
32 if [ $? = 0 ] ; then
33   git show HEAD | grep -m 1 commit | awk '{print $2}' > build/git-version
34 else
35   echo "Git not found." >build/git-version
36 fi
37 scripts/create_sed
38 # In default bacula-dir.conf.in, change default file 
39 # to backup to be build directory
40 echo "s%File = @sbindir@%File = @BUILD_DIR@%g" >tmp/t$$
41 sed -f tmp/t$$ build/src/dird/bacula-dir.conf.in >tmp/o$$
42 cp tmp/o$$ build/src/dird/bacula-dir.conf.in
43 rm -f tmp/t$$ tmp/o$$
44 # remove unneeded directories
45 rm -rf build/txt build/src/testprogs
46 sed -f tmp/sed_tmp scripts/regress-config.in >scripts/regress-config
47 chmod 755 scripts/regress-config
48 cp scripts/regress-config build
49 cd build
50 rm -f Makefile config.*
51 # Run Bacula configuration, make, install
52 ./regress-config ${cwd}
53 check_exit_code
54 # Cleanup any build in source
55 make clean
56 make ${MAKEOPT}
57 check_exit_code
58 make install
59 if [ a${KEEP_SOURCE} = a ]; then
60    rm -rf examples patches
61    check_exit_code
62    # eliminate non-essential directories to reduce
63    #   size.  Otherwise regress run too long
64    rm -rf src/win32 examples patches
65 fi
66 # get all tools -- especially testls
67 cd src/tools
68 make installall
69 check_exit_code
70
71 cd ${cwd}
72 bin/bacula stop
73
74 mkdir -p working
75 cd bin
76 echo "Running database creation scripts"
77 ./create_bacula_database
78 ./drop_bacula_tables
79 ./make_bacula_tables
80 ./grant_bacula_privileges
81 cd ${cwd}
82 # Start and stop Bacula to ensure conf files are OK
83 bin/bacula start
84 bin/bacula stop
85 #
86 # Save Bacula default conf files for later use
87 #
88 cp -f bin/*.conf scripts