Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 175 lines (166 sloc) 4.29 KB
#!/bin/bash
# Usage: smoke-parrot [ branchname ] [config-opts...]
# or set a config via sym or hardlink
# Some system dependant configs
suffix=
parrotdir=/usr/src/p6
smokedir=$parrotdir/smoke
if [ ! -d $smokedir ]; then
smokedir=$parrotdir/master
fi
lsmokedir=$smokedir
opts=
perl=perl
make="make -j3"
# setup mingw paths, or msvc paths via global batch file
winbat=perl514
# set special env by basename
# e.g. ln smoke-parrot smoke-parrot-win; => cmd=win)
# This calls cmd for every remote command, perl Configure, and make
cmd=
if echo `hostname` | grep win 2>/dev/null; then
# already on windows, via cygwin crontab
function win_init() {
smokedir=/usr/src/parrot/win32
suffix=.mingw
make=gmake
opts=
}
function cygwin_init() {
smokedir=/usr/src/parrot/parrot-git
suffix=.cygwin
opts=
}
function msvc_init() {
smokedir=/usr/src/parrot/msvc
suffix=.msvc
make=nmake
opts=
}
function win() {
cmd /c "call $winbat & $*"
}
function msvc() {
cmd /c "call msvc & $*"
}
else
# ssh remote commands
remotehost=win
function ppc_init() {
#opts=--without-pcre
opts=
}
function solaris_init() {
compiler=
opts='--ldflags="-L/usr/lib -L/usr/ccs/lib -L/lib -L/usr/gnu/lib/amd64" --linkflags="-L/usr/lib -L/usr/ccs/li -L/lib -L/usr/gnu/lib/"'
make=gmake
}
function win_init() {
# for git checkouts we need either a remote git or a local mountpoint
parrotdir=/mnt/win/cygwin/usr/src/parrot
lsmokedir=$parrotdir/win32
smokedir=/usr/src/parrot/win32
suffix=.win32
opts=
sudo virsh resume win
/mnt/mnt-win.sh
}
function msvc_init() {
parrotdir=/mnt/win/cygwin/usr/src/parrot
lsmokedir=$parrotdir/msvc
smokedir=/usr/src/parrot/msvc
suffix=.msvc
make=nmake
opts=
sudo virsh resume win
/mnt/mnt-win.sh
}
function cygwin_init() {
#parrotdir=/mnt/win/cygwin/usr/src/parrot
#lsmokedir=$parrotdir/parrot-git
smokedir=/usr/src/parrot/parrot-git
suffix=.cygwin
opts=
#sudo virsh resume win
#/mnt/mnt-win.sh
}
function solaris() {
"$*"
}
function ppc() {
"$*"
}
#function cygwin() {
# ssh $remotehost "cd $smokedir; $*"
#}
function win() {
ssh $remotehost "cd $smokedir; cmd /c \"call $winbat & $*\""
}
function msvc() {
ssh $remotehost "cd $smokedir; cmd /c \"call msvc & $*\""
}
fi
# end of configs
base=$(basename $0)
if [ "$base" != "smoke-parrot" ]; then
cmd=`echo $base|sed 's,smoke-parrot-,,'`
${cmd}_init
else
if `ccache g++ --version 2>&1 >/dev/null`; then
compiler="ccache g++"
elif `ccache cc --version 2>&1 >/dev/null`; then
compiler="ccache cc"
elif `g++ --version 2>&1 >/dev/null`; then
compiler="g++"
fi
fi
cd $lsmokedir || exit 1
lock=$parrotdir/smoke$suffix.lock
trap "rm $lock; exit 255" INT TERM
if [ -e $lock ]; then
echo "Another smoker still running, $lock exists"
exit
fi
branch=${1:-master}
test -n "$1" && shift
# stash changes if dirty or detached head
if git symbolic-ref -q HEAD >/dev/null
then
if git status|grep " Changes " 2>/dev/null
then
git stash save "smoke `date +%F` `git name-rev --name-only HEAD`"
git clean -q -dxf || git clean -d -x
git reset --hard
fi
fi
smoked=smoked$suffix
fbranch=$smoked."`echo $branch|sed -e's,/,_,'`"
git fetch origin
oldrev="`cat $parrotdir/smoked/$fbranch`"
newrev="`git rev-parse origin/$branch`"
if [ x$oldrev = x$newrev ]
then
echo "no changes for $branch $newrev"
else
perl -S cpan TAP::Harness::Archive >/dev/null 2>/dev/null
git checkout $branch
# older git, e.g. solaris
git clean -q -dxf || git clean -d -x
git reset --hard
git pull -q origin $branch </dev/null >/dev/null 2>/dev/null
git reset --hard origin/$branch
echo $newrev >$lock
echo $base $cmd $branch
if test -n "$compiler"; then
echo $cmd $perl Configure.pl --debugging --cc="$compiler" --link="$compiler" --ld="$compiler" $opts $@
$cmd $perl Configure.pl --debugging --cc="$compiler" --link="$compiler" --ld="$compiler" $opts $@ >/dev/null
else
echo $cmd $perl Configure.pl --debugging $opts $@
$cmd $perl Configure.pl --debugging $opts $@ >/dev/null
fi
$cmd $make -s
$cmd $make -s smolder_test
echo branch $branch
git rev-parse $branch && test -f Makefile && echo $newrev > $parrotdir/smoked/$fbranch
rm $lock 2>/dev/null
fi