LaTeX build server with Git and Hudson on Ubuntu 10.04
I’m currently working on a bigger paper for university using LaTeX. As it’s necessary to compile source files multiple times (especially when using BibTeX or TOCs), build runs can take quite some time. As an example, my current build script:
#!/bin/bash BN=paper pdflatex -interaction=nonstopmode $BN.tex bibtex $BN pdflatex -interaction=nonstopmode $BN.tex bibtex $BN pdflatex -interaction=nonstopmode $BN.tex makeindex -s $BN.ist -t $BN.glg -o $BN.gls $BN.glo pdflatex -interaction=nonstopmode $BN.tex pdflatex -interaction=nonstopmode $BN.tex rm -rf $BN.aux rm -rf $BN.lof rm -rf $BN.lot rm -rf $BN.out rm -rf $BN.toc rm -rf $BN.bbl rm -rf $BN.blg rm -rf $BN.brf rm -rf $BN.idx rm -rf $BN.glo rm -rf $BN.ist rm -rf $BN.glg rm -rf $BN.gls rm -rf texput.log
This is OK on my workstation, but running a build on my notebook using a small 1.4 GHz single core processor can take up to a minute which is definitely too long. So I looked for solutions how to move the build process to a central server. As I was already using Git for source control on the project, I tried setting up a remote repository on the server which triggered a build using a post-receive script. This basically worked fine, but I wanted to go a step further. I had a look at CI servers and gave Hudson a try as it seems to have a lot of features while being quite easy to set up.
The result is the following: Hudson is polling the Git repository (can be remote or local, in my case it’s a self-hosted remote gitosis installation, but could be github too), starting a new build on changes and publishing the resulting PDF if successful. Hudson is accessible over https using an Apache2 server as frontend to a Tomcat installation.
Ready? Let’s go.
Continuous Integration with phpUnderControl and Git
I was looking for a decent continuous integration solution for my PHP projects for some time now, but always had the problem that most of the described solutions used SVN instead of Git as VCS system. Yesterday I found an article which describes the setup exactly as I needed it: phpUnderControl with Git on a Debian/Ubuntu system. Using the article, I managed to set up a working system quickly, which basically works as expected: CruiseControl checks the repository for modifications and starts the build process if there are any new commits. The build process includes generating API documentation (phpdocumentor), running static code analysis (php-codesniffer) and executing unit tests (phpunit). If the build succeeds, the results are published and can be accessed through a nice webinterface powered by phpUnderControl (see screenshot above which I stole from the phpUnderControl site).
However, the described setup has a few issues which bugged me:
- CruiseControl runs from the shellscript as root, posts all output to the console and is not automatically started at boot time.
- CruiseControl runs on port 8080, but I wanted to manage access to the webinterface through the apache which is already running on the box
- There’s no authentication – everybody can access my CI server, see the build details and start new builds through the webinterface.
gitosis-create-repo
A simple script to create a new gitosis-repository on the fly. I’m not really familiar with bash scripting so don’t expect too much ;)
#!/bin/bash if [ -z $1 ]; then echo "Please specify a repository." exit 1 fi if [ -z $2 ]; then echo "Please specify a remote url." exit 1 fi if [ -d $1 ]; then echo "Repository already exists." exit 1 fi mkdir $1 cd $1 git init touch .gitignore git add .gitignore git commit -a -m "Initial commit." git remote add origin $2:$1.git git push origin master:refs/heads/master
Please make sure you set the correct permissions in gitosis.conf. Example:
[group me] members = me@example.com writable = test</pre>
Then you can run the script to create a new repository test on myhost.example.org:
$ gitosis-create-repo test git@myhost.example.org
Use PuTTY as Cygwin terminal
“Cygwin is a Linux-like environment for Windows.” This means, you can use linux/unix commandline tools like ls, grep and find on your Windows system. However, the default installation of Cygwin uses Windows’ default commandline terminal cmd.exe, which is not really handy. Fortunately, there’s a solution to use PuTTY as Cygwin terminal.
- Download and install Cygwin. The setup will download all needed packages, so make sure you check what you need (my main reason to install Cygwin was to have a Git client on Windows)
- Download PuTTYcyg and extract the contents of the archive anywhere on you hard drive
- Start
putty.exe, selectCygtermas connection type and enter-(dash) as command. Enter a session name (e.g.cygwin) in the text field belowSaved Sessionsand click onSave. - Create a shortcut to
putty.exe. Right click the shortcut, selectPropertiesand append the following string to the target field:-load "cygwin". Of course you have to replacecygwinwith the name of the session you saved in PuTTYcyg. - Open the shortcut and you should directly get into your Cygwin shell
Install git 1.6 from source on debian etch
aptitude install build-essential gettext wget http://kernel.org/pub/software/scm/git/git-1.6.0.1.tar.gz tar xvzf git-1.6.0.1.tar.gz cd git-1.6.0.1 ./configure make make install