3 # Script to setup running Bacula regression tests
5 # Copyright (C) 2000-2016 Kern Sibbald
6 # License: BSD 2-Clause; see file LICENSE-FOSS
12 echo "Bad exit code giving up"
20 tmp=${tmp:-"$cwd/tmp"}
22 if [ ! -d ${BACULA_SOURCE} ] ; then
23 echo "The BACULA_SOURCE environment variable must be a Bacula release directory, but is not."
28 MAKEOPTS=${MAKEOPT:-"-j3"}
31 # we build and setup binaries to the $cwd/bin directory not $bin
34 echo "Copying source from ${BACULA_SOURCE}"
35 cp -rp ${BACULA_SOURCE} build
37 if [ x$PREBUILT != xyes ]; then
38 which git >/dev/null 2>/dev/null
40 git show HEAD | grep -m 1 commit | awk '{print $2}' > build/git-version
42 echo "Git not found." >build/git-version
46 # In default bacula-dir.conf.in, change default file
47 # to backup to be build directory
48 echo "s%File = @sbindir@%File = @BUILD_DIR@%g" >tmp/t$$
49 sed -f tmp/t$$ build/src/dird/bacula-dir.conf.in >tmp/o$$
50 cp tmp/o$$ build/src/dird/bacula-dir.conf.in
52 # Now turn on DEVELOPER for regression testing
53 echo "s%^.*define DEVELOPER 1.*$%#define DEVELOPER 1%g" >tmp/t$$
54 sed -f tmp/t$$ build/src/version.h >tmp/o$$
55 cp tmp/o$$ build/src/version.h
58 # remove unneeded directories
59 rm -rf build/txt build/src/testprogs
60 sed -f tmp/sed_tmp scripts/regress-config.in >scripts/regress-config
61 chmod 755 scripts/regress-config
62 cp scripts/regress-config build
64 rm -f Makefile config.*
65 # Run Bacula configure
66 ./regress-config ${cwd}
67 if [ x$PREBUILT != xyes ]; then
68 # Run Bacula make, install
70 # Cleanup any build in source
76 if [ a${KEEP_SOURCE} = a ]; then
77 rm -rf examples patches
79 # eliminate non-essential directories to reduce
80 # size. Otherwise regress run too long
81 rm -rf src/win32 examples patches
83 # get all tools -- especially testls
84 if [ x$PREBUILT = xyes ]; then
85 # populate our bin with start/stop scripts
86 # and catalog manipulation scripts
89 cp ${bin}/../scripts/bacula ${cwd}/bin
90 cp ${bin}/../scripts/bacula-ctl-* ${cwd}/bin
91 cp ${bin}/../scripts/create_*_database ${cwd}/bin
92 cp ${bin}/../scripts/drop_*_database ${cwd}/bin
93 cp ${bin}/../scripts/drop_*_tables ${cwd}/bin
94 cp ${bin}/../scripts/make_*_tables ${cwd}/bin
95 cp ${bin}/../scripts/grant_*_privileges ${cwd}/bin
96 cp ${bin}/../scripts/storage*-ctl ${cwd}/bin
97 cp ${bin}/../scripts/storage*-ctl.conf ${cwd}/bin
98 cp ${bin}/../scripts/mtx-changer ${cwd}/bin
99 cp ${bin}/../scripts/mtx-changer.conf ${cwd}/bin
100 cp ${bin}/bconsole ${cwd}/bin
102 for i in create_*_database drop_*_database drop_*_tables make_*_tables grant_*_privileges; do
104 sed "s/db_name:-bacula/db_name:-regress/" $i >1
105 sed "s/db_name=bacula/db_name=regress/" 1 >2
106 sed "s/db_user:-bacula/db_user:-regress/" 2 >3
107 sed "s%/opt/bacula/scripts%${cwd}/bin%" 3 >4
113 scripts/prepare-other-loc2
122 bin/bacula stop -KILL
126 echo "Running database creation scripts"
127 ./create_bacula_database
130 ./grant_bacula_privileges
132 # Start and stop Bacula to ensure conf files are OK
136 # Save Bacula default conf files into scripts for later use
138 if [ x$PREBUILT = xyes ]; then
139 cp build/src/console/*.conf scripts
140 cp build/src/dird/*.conf scripts
141 cp build/src/filed/*.conf scripts
142 cp build/src/stored/*.conf scripts
144 # these were installed so take them from bin
145 cp -f bin/*.conf scripts