]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/setup
regress: Fix error with new perl systems
[bacula/bacula] / regress / scripts / setup
1 #!/bin/sh
2 #
3 # Script to setup running Bacula regression tests
4 #
5 # Copyright (C) 2000-2016 Kern Sibbald
6 # License: BSD 2-Clause; see file LICENSE-FOSS
7 #
8
9 check_exit_code()
10 {
11    if [ $? != 0 ] ; then
12       echo "Bad exit code giving up"
13       exit 1 
14    fi
15 }
16
17 . ./config
18
19 cwd=`pwd`
20 tmp=${tmp:-"$cwd/tmp"}
21 mkdir -p $tmp
22 if [ ! -d ${BACULA_SOURCE} ] ; then
23    echo "The BACULA_SOURCE environment variable must be a Bacula release directory, but is not."
24    echo " "
25    exit 1
26 fi
27
28 MAKEOPTS=${MAKEOPT:-"-j3"}
29
30
31 # we build and setup binaries to the $cwd/bin directory not $bin
32 rm -rf build bin
33 # Copy new source
34 echo "Copying source from ${BACULA_SOURCE}"
35 cp -rp ${BACULA_SOURCE} build
36 check_exit_code
37 if [ x$PREBUILT != xyes ]; then
38   which git >/dev/null 2>/dev/null
39   if [ $? = 0 ] ; then
40     git show HEAD | grep -m 1 commit | awk '{print $2}' > build/git-version
41   else
42     echo "Git not found." >build/git-version
43   fi
44 fi
45 scripts/create_sed
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
51
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
56
57 rm -f tmp/t$$ tmp/o$$
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
63 cd 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
69   check_exit_code
70   # Cleanup any build in source
71   make clean
72   make ${MAKEOPT}
73   check_exit_code
74   make install
75 fi
76 if [ a${KEEP_SOURCE} = a ]; then
77    rm -rf examples patches
78    check_exit_code
79    # eliminate non-essential directories to reduce
80    #   size.  Otherwise regress run too long
81    rm -rf src/win32 examples patches
82 fi
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
87   cd ${cwd}
88   mkdir bin
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
101   cd ${cwd}/bin
102   for i in create_*_database drop_*_database drop_*_tables make_*_tables grant_*_privileges; do
103     echo "Doing $i"
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
108     mv 4 $i
109     chmod +x $i
110     rm -f 1 2 3
111   done
112   cd ${cwd}
113   scripts/prepare-other-loc2
114 else
115   cd src/tools
116   make installall
117   check_exit_code
118 fi
119
120
121 cd ${cwd}
122 bin/bacula stop -KILL
123
124 mkdir -p working
125 cd bin
126 echo "Running database creation scripts"
127 ./create_bacula_database
128 ./drop_bacula_tables
129 ./make_bacula_tables
130 ./grant_bacula_privileges
131 cd ${cwd}
132 # Start and stop Bacula to ensure conf files are OK
133 bin/bacula start
134 bin/bacula stop
135 #
136 # Save Bacula default conf files into scripts for later use
137 #
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
143 else
144   # these were installed so take them from bin
145   cp -f bin/*.conf scripts
146   check_exit_code
147 fi