--- /dev/null
+package SbuildHack;
+
+use Sbuild qw(binNMU_version);
+
+sub new_binNMU_version {
+ my $v = shift;
+ my $binNMUver = shift;
+ die("Wrong binNMUver!") unless ($binNMUver == 171717);
+ die("No NMUTAG set in environment!") unless ($ENV{"NMUTAG"});
+ return $v . $ENV{"NMUTAG"};
+};
+
+{
+ no warnings 'redefine';
+ *Sbuild::binNMU_version = \&new_binNMU_version;
+}
+
+1;
+invirt-dev (0.1.11) unstable; urgency=low
+
+ * Add a prefix to binary package versions based on the distribution they
+ are built for, allowing the same version to coexist for multiple
+ distributions
+
+ -- Quentin Smith <quentin@mit.edu> Sat, 15 Oct 2011 11:30:57 -0400
+
invirt-dev (0.1.10) unstable; urgency=low
* Improve zephyr notifications
repository-config/* srv/repository/conf
build-hooks usr/share/invirt-dev
git-hooks usr/share/invirt-dev
+SbuildHack.pm usr/share/invirt-dev
from invirt.config import structs as config
-DISTRIBUTION = 'hardy'
logfile = None
def logAndRun(cmd, *args, **kwargs):
package] + binaries)
-def sbuild(package, ref, arch, workdir, arch_all=False):
- """Build a package for a particular architecture."""
- args = ['sbuild', '-v', '-d', DISTRIBUTION, '--arch', arch]
+def sbuild(package, ref, distro, arch, workdir, arch_all=False):
+ """Build a package for a particular architecture and distro."""
+ # We append a suffix like ~ubuntu8.04 to differentiate the same
+ # version built for multiple distros
+ nmutag = b.distroToSuffix(distro)
+ env = os.environ.copy()
+ env['NMUTAG'] = nmutag
+
+ # Run sbuild with a hack in place to append arbitrary versions
+ args = ['perl', '-I/usr/share/invirt-dev',
+ '/usr/bin/sbuild',
+ '--binNMU=171717', '--make-binNMU=Build with sbuild',
+ '-v', '-d', distro, '--arch', arch]
if arch_all:
args.append('-A')
args.append(getDscName(package, ref))
- logAndRun(args, cwd=workdir)
+ logAndRun(args, cwd=workdir, env=env)
-def sbuildAll(package, ref, workdir):
+def sbuildAll(package, ref, distro, workdir):
"""Build a package for all architectures it supports."""
arches = getArches(package, ref)
if 'all' in arches or 'any' in arches or 'amd64' in arches:
- sbuild(package, ref, 'amd64', workdir, arch_all=True)
+ sbuild(package, ref, distro, 'amd64', workdir, arch_all=True)
if 'any' in arches or 'i386' in arches:
- sbuild(package, ref, 'i386', workdir)
+ sbuild(package, ref, distro, 'i386', workdir)
def tagSubmodule(pocket, package, commit, principal, version, env):
_LOG_DIR = '/var/log/invirt/builds'
_HOOKS_DIR = '/usr/share/invirt-dev/build-hooks'
+_DEFAULT_DISTRIBUTION = 'hardy'
+
class InvalidBuild(ValueError):
pass
+_DISTRO_TO_SUFFIX = {
+ 'etch': '~debian4.0',
+ 'lenny': '~debian5.0',
+ 'squeeze': '~debian6.0',
+
+ 'hardy': '~ubuntu8.04',
+ 'lucid': '~ubuntu10.04',
+ 'maverick': '~ubuntu10.10',
+ 'natty': '~ubuntu11.04',
+ 'oneiric': '~ubuntu11.10',
+ 'precise': '~ubuntu12.04',
+ }
+
+def distroToSuffix(distro):
+ return _DISTRO_TO_SUFFIX.get(distro, '~'+distro)
def getRepo(package):
"""Return the path to the git repo for a given package."""
"""Map a pocket in the configuration to an apt repo pocket."""
return getattr(getattr(config.build.pockets, pocket), 'apt', pocket)
+def pocketToDistro(pocket):
+ """Map a pocket in the configuration to the distro we build for."""
+ return getattr(getattr(config.build.pockets, pocket), 'distro', _DEFAULT_DISTRIBUTION)
def getGitFile(package, ref, path):
"""Return the contents of a path from a git ref in a package."""
ensureValidPackage(package)
package_repo = getRepo(package)
new_version = getVersion(package, commit)
+ new_distro = pocketToDistro(pocket)
ret = True
continue
current_version = getVersion(package, b)
+ current_distro = pocketToDistro(pocket)
+
+ # NB: Neither current_version nor new_version will have the
+ # distro-specific prefix.
- if current_version == new_version:
+ if current_version == new_version and current_distro == new_distro:
if current_commit == commit:
ret = p
else: