@@ -4,30 +4,73 @@ set -eux
4
4
5
5
sudo apt-get update
6
6
7
+
8
+ # required packages
7
9
packages=" postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-common"
8
10
11
+ # exit code
12
+ status=0
13
+
14
+ # pg_config path
15
+ config_path=/usr/lib/postgresql/$PGVERSION /bin/pg_config
16
+
17
+
9
18
# bug: http://www.postgresql.org/message-id/[email protected]
10
19
sudo update-alternatives --remove-all postmaster.1.gz
11
20
12
21
# stop all existing instances (because of https://github.com/travis-ci/travis-cookbooks/pull/221)
13
22
sudo service postgresql stop
14
- # and make sure they don't come back
23
+ # ... and make sure they don't come back
15
24
echo ' exit 0' | sudo tee /etc/init.d/postgresql
16
25
sudo chmod a+x /etc/init.d/postgresql
17
26
18
- sudo apt-get -o Dpkg::Options::=" --force-confdef" -o Dpkg::Options::=" --force-confold" install $packages
27
+ # install required packages
28
+ sudo apt-get -o Dpkg::Options::=" --force-confdef" -o Dpkg::Options::=" --force-confold" -y install -qq $packages
19
29
20
- status=0
30
+ # create cluster 'test'
21
31
sudo pg_createcluster --start $PGVERSION test -p 55435 -- -A trust
22
32
23
- make USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/$PGVERSION /bin/pg_config
24
- sudo make install USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/$PGVERSION /bin/pg_config
33
+ # perform code analysis if necessary
34
+ if [ $CHECK_CODE = " true" ]; then
35
+
36
+ if [ " $CC " = " clang" ]; then
37
+ sudo apt-get -y install -qq clang-3.5
38
+
39
+ scan-build-3.5 --status-bugs make USE_PGXS=1 PG_CONFIG=$config_path || status=$?
40
+ exit $status
41
+
42
+ elif [ " $CC " = " gcc" ]; then
43
+ sudo apt-get -y install -qq cppcheck
44
+
45
+ cppcheck --template " {file} ({line}): {severity} ({id}): {message}" \
46
+ --enable=warning,portability,performance \
47
+ --suppress=redundantAssignment \
48
+ --suppress=uselessAssignmentPtrArg \
49
+ --std=c89 src/* .c src/* .h 2> cppcheck.log
50
+
51
+ if [ -s cppcheck.log ]; then
52
+ cat cppcheck.log
53
+ status=1 # error
54
+ fi
55
+
56
+ exit $status
57
+ fi
58
+
59
+ # don't forget to "make clean"
60
+ make clean USE_PGXS=1 PG_CONFIG=$config_path
61
+ fi
62
+
63
+ # build pg_pathman
64
+ make USE_PGXS=1 PG_CONFIG=$config_path
65
+ sudo make install USE_PGXS=1 PG_CONFIG=$config_path
25
66
26
- # add pg_pathman to shared_preload_libraries
67
+ # add pg_pathman to shared_preload_libraries and restart cluster 'test'
27
68
sudo bash -c " echo \" shared_preload_libraries = 'pg_pathman'\" >> /etc/postgresql/$PGVERSION /test/postgresql.conf"
28
69
sudo pg_ctlcluster $PGVERSION test restart
29
70
30
- PGPORT=55435 make installcheck USE_PGXS=1 PGUSER=postgres PG_CONFIG=/usr/lib/postgresql/$PGVERSION /bin/pg_config || status=$?
71
+ # run regression tests
72
+ PGPORT=55435 make installcheck USE_PGXS=1 PGUSER=postgres PG_CONFIG=$config_path || status=$?
31
73
74
+ # show diff if it exists
32
75
if test -f regression.diffs; then cat regression.diffs; fi
33
76
exit $status
0 commit comments