@@ -4,30 +4,73 @@ set -eux
44
55sudo apt-get update
66
7+
8+ # required packages
79packages=" postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-common"
810
11+ # exit code
12+ status=0
13+
14+ # pg_config path
15+ config_path=/usr/lib/postgresql/$PGVERSION /bin/pg_config
16+
17+
918# bug: http://www.postgresql.org/message-id/20130508192711.GA9243@msgid.df7cb.de
1019sudo update-alternatives --remove-all postmaster.1.gz
1120
1221# stop all existing instances (because of https://github.com/travis-ci/travis-cookbooks/pull/221)
1322sudo service postgresql stop
14- # and make sure they don't come back
23+ # ... and make sure they don't come back
1524echo ' exit 0' | sudo tee /etc/init.d/postgresql
1625sudo chmod a+x /etc/init.d/postgresql
1726
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
1929
20- status=0
30+ # create cluster 'test'
2131sudo pg_createcluster --start $PGVERSION test -p 55435 -- -A trust
2232
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
2566
26- # add pg_pathman to shared_preload_libraries
67+ # add pg_pathman to shared_preload_libraries and restart cluster 'test'
2768sudo bash -c " echo \" shared_preload_libraries = 'pg_pathman'\" >> /etc/postgresql/$PGVERSION /test/postgresql.conf"
2869sudo pg_ctlcluster $PGVERSION test restart
2970
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=$?
3173
74+ # show diff if it exists
3275if test -f regression.diffs; then cat regression.diffs; fi
3376exit $status
0 commit comments