#!/bin/bash
#simple place this in the parent dir of trunk and run it to build debs
#give it the install arguement to install them at the same time
svnver=`svn info | grep vision | awk '{print $2}'`
debdir=~/building/beryl/debs
build=1
force=0
update=1
install=0
clean=1
function getopt {
if echo $* | grep no-build >> /dev/null
then
build=0
fi
if echo $* | grep force >> /dev/null
then
force=1
fi
if echo $* | grep no-update >> /dev/null
then
update=0
fi
if echo $* | grep install >> /dev/null
then
install=1
fi
if echo $* | grep no-clean >> /dev/null
then
clean=0
fi
}
function updater {
if svn up > /dev/null
then
echo svn update success
else
echo svn update fail; servers might be down, use no-update to build
exit 25
fi
if [ $svnver -eq `svn info | grep vision | awk '{print $2}'` ]
then
nochange=1
else
svnver=`svn info | grep vision | awk '{print $2}'`
nochange=0
fi
}
function copysafe {
if [ -d $1 -a -d $2 ]
then
cp -R $1 $2
fi
}
function debianize { #matches the debianizations with their projects
for i in `ls trunk/distro-specific-build-files/`
do
if [ -d trunk/$i/debian ]
then
rm -rf trunk/$i/debian
fi
copysafe trunk/distro-specific-build-files/$i/debian trunk/$i
done
}
function getlist { #looks for debianized projects
cd trunk
initlist=$(find . -maxdepth 1 -type d | sed -e 's/^\.\///') #make sure beryl-core is done first
for i in ${initlist}
do
if [ -d $i/debian ]
then
list=`echo $list $i`
fi
done
list=$(echo beryl-core `echo $list | sed -e 's/beryl-core//'`)
cd ..
}
function version {
for i in ${list}
do
sed "1 s/)/svn$svnver)/" -i trunk/$i/debian/changelog
done
}
function mover {
newdebs=`ls | grep deb$ | grep svn$svnver`
if [ -d $debdir/$svnver ]
then
echo found
else
mkdir $debdir/$svnver
fi
for i in ${newdebs}
do
mv $i $debdir/$svnver
done
}
function build {
for i in ${list}
do
cd trunk/$i
./autogen.sh && dpkg-buildpackage -us -uc -rfakeroot
cd ..
mover
if [ "$i" == "beryl-core" ]
then
sudo dpkg -i $debdir/$svnver/beryl-dev*svn$svnver*.deb
fi
cd ..
done
}
function install {
cd $debdir/$svnver
sudo dpkg -i ../debs/$latest/beryl* ../debs/$latest/emerald*
}
function clean {
rm trunk/*svn*.deb 2>> /dev/null
rm trunk/*svn*.changes 2>> /dev/null
rm trunk/*svn*.tar.gz 2>> /dev/null
rm trunk/*svn*.dsc 2>> /dev/null
}
getopt $@#replace this with getopts when you have time
if [ $clean -eq 1 ] ## could have done this [ blah blah ] && blah style, but people get confused
then
clean
fi
if [ $update -eq 1 ]
then
updater
fi
if [ $nochange -eq 0 -o $force -eq 1 ]
then
debianize
getlist
version
if [ $build -eq 1 ]
then
build
fi
if [ $install -eq 1 ]
then
install
fi
else
echo no updates found
fi