How do I set up a private apt repository that can support multiple versions?

I needed a multi-versioned repo for the same reasons like you and this is what I ended up with:

apt-get install apache2 dpkg-dev
mkdir -p /var/www/repo/binary

Then create update-repo.sh that will update your repo with the packages' info

#!/bin/bash
cd /var/www/repo
dpkg-scanpackages -m binary /dev/null | gzip -9c > /var/www/repo/binary/Packages.gz

Place your .deb files in /var/www/repo/binary and run update-repo.sh

On the rest of the machines:

echo "deb http://myserver/repo binary" > /etc/apt/sources.list.d/myrepo.list
apt-get update

etc etc...

The magic happens because of -m when running dpkg-scanpackages. Without -m, only one version is listed in Packages.gz

I haven't tried it but it should be trivial to do the same for separate sub-repos, like hbdgaf proposed.


Host it under a different distribution name. lucid and testing for example. Then change your entries in your test box
from: deb http://homegrown.local/ubuntu lucid main
to: deb http://homegrown.local/ubuntu testing main