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