Releases with source and binary packages
0release can be used to create releases of your software from a version control system. The main page described how to make releases of programs which are architecture-independent (e.g. programs written in Python) where a single package is produced. This page explains what happens for programs which must be compiled for different architectures (e.g. C programs).
The extended release process looks like this:
TODO: 0release doesn't currently unit-test the binaries it produces
After generating an archive and a feed for the source code release candidate (where arch='*-src'), 0release also compiles a binary for the host system (using 0compile). It uploads both the source and binary archive and publishes both in the Zero Install feed.
For an example of a simple binary package that works this way, have a look at the c-prog.tgz package in 0release's tests directory:
$ tar xzf c-prog.tgz $ mkdir release-c-prog $ cd release-c-prog $ 0launch http://0install.net/2007/interfaces/0release.xml ../c-prog/c-prog.xml
Compiling on multiple systems
To build binaries for multiple architectures, you'll need to create a configuration file listing the available builders. 0release uses the Base Directory Specification to find its configuration files; with the default settings, you need to create the file ~/.config/0install.net/0release/builders.conf.
The builders.conf file has a [global] section listing the builders to use, followed by one section for each builder. Each builder can have three commands specified: one to start the builder (optional), one the actually do the build, and one to shutdown the builder (optional). Here is an example configuration:
[global] builders = host, freebsd [builder-host] build = 0launch --not-before 0.10 http://0install.net/2007/interfaces/0release.xml --build-slave "$@" [builder-freebsd] start = VBoxManage startvm "FreeBSD" --type vrdp build = build-on-vm 2222 "$@" stop = VBoxManage controlvm "FreeBSD" savestate
This defines two builders named "host" and "freebsd". "host" simply runs 0release in build-slave mode on the local machine (in fact, you don't need to specify this section because it exists by default). The "freebsd" builder runs some other scripts which bring up a VirtualBox virtual machine, submit the build to it, and then shut it down again.
The reason for having separate start/build/stop commands is simply to make error handling easier. If the start command succeeds then the stop command will always be run, even if the build command fails. If start fails, the other commands are not run.
The build command
The build command is called with four arguments:
- The name of the generated XML feed file for the source release candidate.
- The name of the generated source archive.
- The URL of the directory where the release will be hosted eventually.
- The name of the binary feed to be generated.
The three names are of files in the current directory without the directory part; this simplifies the copying. The build command must do three things:
- Copy the input files (the source feed and archive) to the build system.
- Invoke "0release --build-slave" to do the build.
- Copy the results (the binary feed and archive) back to the local system.
For example, the build-on-vm script might look like this:
#!/bin/sh -e
PORT="$1"
shift
LOGIN="builder@localhost"
while true; do
ssh -p $PORT $LOGIN 'rm -rf build; mkdir build' && break
echo Waiting for VM to be ready...
sleep 2
done
ssh -p $PORT $LOGIN 'ntpdate your.server.here' # Avoid clock-skew problems
scp -P $PORT "$1" "$2" ${LOGIN}:build/
ssh -p $PORT $LOGIN 'cd build && 0launch -v --not-before 0.10 http://0install.net/2007/interfaces/0release.xml -v --build-slave "$@"' "$@"
scp -P $PORT "${LOGIN}:build/*" .
This assumes that the virtual machine is listening on some port which is forwarded to port 22 in the guest, and has a user named "builder".