From: Quentin Smith Date: Sat, 15 Oct 2011 15:31:35 +0000 (-0400) Subject: Add a prefix to binary package versions based on the distribution they X-Git-Tag: 0.1.11^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/commitdiff_plain/d6660755c5b38b89e3b9ec852f17502f6c59e806 Add a prefix to binary package versions based on the distribution they are built for, allowing the same version to coexist for multiple distributions --- diff --git a/SbuildHack.pm b/SbuildHack.pm new file mode 100644 index 0000000..ed9c866 --- /dev/null +++ b/SbuildHack.pm @@ -0,0 +1,18 @@ +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; diff --git a/debian/changelog b/debian/changelog index 4d07161..a07f957 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +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 Sat, 15 Oct 2011 11:30:57 -0400 + invirt-dev (0.1.10) unstable; urgency=low * Improve zephyr notifications diff --git a/debian/invirt-dev.install b/debian/invirt-dev.install index 471b2e2..91e2716 100644 --- a/debian/invirt-dev.install +++ b/debian/invirt-dev.install @@ -3,3 +3,4 @@ invirt-configure-git-hooks usr/bin repository-config/* srv/repository/conf build-hooks usr/share/invirt-dev git-hooks usr/share/invirt-dev +SbuildHack.pm usr/share/invirt-dev diff --git a/invirtibuilder b/invirtibuilder index b6d4eb8..b4487b9 100755 --- a/invirtibuilder +++ b/invirtibuilder @@ -47,7 +47,6 @@ from invirt import database from invirt.config import structs as config -DISTRIBUTION = 'hardy' logfile = None def logAndRun(cmd, *args, **kwargs): @@ -124,22 +123,32 @@ def aptCopy(package, commit, dst_pocket, src_pocket): 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): diff --git a/python/invirt/builder.py b/python/invirt/builder.py index 2e2e405..1a736bd 100644 --- a/python/invirt/builder.py +++ b/python/invirt/builder.py @@ -19,10 +19,27 @@ _REPO_DIR = '/srv/git' _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.""" @@ -59,6 +76,9 @@ def pocketToApt(pocket): """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.""" @@ -116,6 +136,7 @@ def validateBuild(pocket, package, commit): ensureValidPackage(package) package_repo = getRepo(package) new_version = getVersion(package, commit) + new_distro = pocketToDistro(pocket) ret = True @@ -132,8 +153,12 @@ def validateBuild(pocket, package, commit): 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: