6 . tests/scripts/common-functions
7 . tests/scripts/common-vm
11 export FORGE_HOME=/usr/share/gforge
19 COWBUILDERBASE=/var/lib/jenkins/builder/
20 COWBUILDERCONFIG=$COWBUILDERBASE/config/$DIST.config
23 PKGNAME=$(dpkg-parsechangelog | awk '/^Source:/ { print $2 }')
24 PKGVERS=$(dpkg-parsechangelog | awk '/^Version:/ { print $2 }')
28 if [ -d $CHECKOUTPATH/.svn ] ; then
29 MINOR=-$MINOR+svn$(svn info | awk '/^Revision:/ { print $2 }')
30 elif [ -d $CHECKOUTPATH/.bzr ] ; then
31 MINOR=-$MINOR+bzr$(bzr revno)
32 elif [ -d $CHECKOUTPATH/.git ] ; then
33 MINOR=-$MINOR+git$(git describe --always)
35 MINOR=-$MINOR+$(TZ=UTC date +%Y%m%d%H%M%S)
37 ARCH=$(dpkg-architecture -qDEB_BUILD_ARCH)
39 dch -b -v $MAJOR$MINOR -D UNRELEASED "This is $DIST-$ARCH autobuild"
40 sed -i -e "1s/UNRELEASED/$DIST/" debian/changelog
41 pdebuild --configfile $COWBUILDERCONFIG --buildresult $BUILDRESULT
43 CHANGEFILE=${PKGNAME}_$SMAJOR${MINOR}_$ARCH.changes
46 REPOPATH=$WORKSPACE/build/debian
48 [ ! -d $REPOPATH ] || rm -r $REPOPATH
49 mkdir -p $REPOPATH/conf
50 cat > $REPOPATH/conf/distributions <<EOF
55 Architectures: amd64 i386 source
56 Origin: buildbot.fusionforge.org
57 Description: FusionForge autobuilt repository
58 SignWith: buildbot@$(hostname -f)
61 reprepro -Vb $REPOPATH include $DIST $CHANGEFILE
65 destroy_vm -t debian7 $HOST
66 start_vm_if_not_keeped -t debian7 $HOST
69 # make -C 3rd-party -f Makefile.deb BUILDRESULT=$BUILDRESULT LOCALREPODEB=$WORKSPACE/build/debian BUILDDIST=$DIST DEBMIRROR=$DEBMIRROR botclean botbuild
72 # make -f Makefile.debian BUILDRESULT=$WORKSPACE/build/packages LOCALREPODEB=$WORKSPACE/build/debian rwheezy
76 # cat tests/preseed/* | sed s/@FORGE_ADMIN_PASSWORD@/$FORGE_ADMIN_PASSWORD/ | ssh root@$HOST "LANG=C debconf-set-selections"
79 export DEBMIRROR DEBMIRRORSEC
80 ssh root@$HOST "echo \"deb $DEBMIRROR $DIST main\" > /etc/apt/sources.list"
81 ssh root@$HOST "echo \"deb $DEBMIRRORSEC $DIST/updates main\" > /etc/apt/sources.list.d/security.list"
83 ssh root@$HOST "echo \"deb $DEBMIRROR unstable main\" >> /etc/apt/sources.list"
84 ssh root@$HOST "apt-get update"
85 ssh root@$HOST "UCF_FORCE_CONFFNEW=yes DEBIAN_FRONTEND=noninteractive LANG=C apt-get -o debug::pkgproblemresolver=true -y --force-yes install loggerhead libapache2-mod-wsgi"
87 ssh root@$HOST "echo \"deb $DEBMIRROR $DIST main\" > /etc/apt/sources.list"
88 ssh root@$HOST "echo \"deb file:/debian $DIST main\" >> /etc/apt/sources.list"
89 scp -r $WORKSPACE/build/debian root@$HOST:/
90 gpg --export --armor | ssh root@$HOST "apt-key add -"
92 ssh root@$HOST "apt-get update"
95 ssh root@$HOST "UCF_FORCE_CONFFNEW=yes DEBIAN_FRONTEND=noninteractive LANG=C apt-get -y --force-yes install rsync postgresql-contrib fusionforge-full"
96 echo "Set forge admin password"
97 ssh root@$HOST "/usr/share/gforge/bin/forge_set_password $FORGE_ADMIN_USERNAME $FORGE_ADMIN_PASSWORD"
98 ssh root@$HOST "LANG=C a2dissite default ; LANG=C invoke-rc.d apache2 reload"
99 ssh root@$HOST "(echo [core];echo use_ssl=no) > /etc/gforge/config.ini.d/zzz-buildbot.ini"
100 ssh root@$HOST "(echo [moinmoin];echo use_frame=no) >> /etc/gforge/config.ini.d/zzz-buildbot.ini"
101 ssh root@$HOST "(echo [mediawiki];echo unbreak_frames=yes) >> /etc/gforge/config.ini.d/zzz-buildbot.ini"
104 echo "Dump freshly installed database"
105 ssh root@$HOST "su - postgres -c \"pg_dumpall\" > /root/dump"
108 echo "Stop cron daemon"
109 ssh root@$HOST "invoke-rc.d cron stop" || true
111 # Install selenium tests
112 ssh root@$HOST mkdir $FORGE_HOME/tests
113 make -C 3rd-party/selenium selenium-server.jar
114 cp 3rd-party/selenium/selenium-server.jar tests/
115 rsync -a --delete tests/ root@$HOST:$FORGE_HOME/tests/
117 ssh root@$HOST "cat > $FORGE_HOME/tests/config/phpunit" <<-EOF
118 HUDSON_URL=$HUDSON_URL
124 echo "Run phpunit test on $HOST in $FORGE_HOME"
126 ssh root@$HOST "apt-get -y install xfonts-base vnc4server ; mkdir -p /root/.vnc"
127 ssh root@$HOST "cat > /root/.vnc/xstartup ; chmod +x /root/.vnc/xstartup" <<EOF
129 # Setup ssh key and parameters
132 if ! [ -e .ssh/id_rsa.pub ] ; then
133 ssh-keygen -f .ssh/id_rsa -N ''
134 cat .ssh/id_rsa.pub >> .ssh/authorized_keys
136 if ! grep -q StrictHostKeyChecking .ssh/config ; then
137 echo StrictHostKeyChecking no >> .ssh/config
140 [ -e /var/lib/gforge/.bazaar/bazaar.conf ] && sed -i -e s,https://,http://,g /var/lib/gforge/.bazaar/bazaar.conf
142 : > /root/phpunit.exitcode
143 $FORGE_HOME/tests/scripts/phpunit.sh DEBDebian70Tests.php &> /var/log/phpunit.log &
144 echo \$! > /root/phpunit.pid
146 echo \$? > /root/phpunit.exitcode
148 ssh root@$HOST vncpasswd <<EOF
153 ssh root@$HOST "vncserver :1"
155 pid=$(ssh root@$HOST cat /root/phpunit.pid)
156 ssh root@$HOST "tail -f /var/log/phpunit.log --pid=$pid"
158 retcode=$(ssh root@$HOST cat /root/phpunit.exitcode)
159 rsync -av root@$HOST:/var/log/ $WORKSPACE/reports/
160 ssh root@$HOST "vncserver -kill :1" || retcode=$?
162 stop_vm_if_not_keeped -t debian7 $@