backportpackage: new script for testing backport requests in a PPA.

This commit is contained in:
Evan Broder 2010-12-11 14:12:02 -08:00
parent 53652d8cee
commit cb41838b48
3 changed files with 131 additions and 1 deletions

108
backportpackage Executable file
View File

@ -0,0 +1,108 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ##################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See file /usr/share/common-licenses/GPL-2 for more details.
#
# ##################################################################
import logging
import optparse
import os
import shutil
import subprocess
import sys
import tempfile
from debian.changelog import Changelog
devnull = open('/dev/null', 'r+')
def error(msg, *args, **kwargs):
logging.error(msg, *args, **kwargs)
sys.exit(1)
def parse(args):
usage = 'Usage: %prog <source package> <source release> <dest release> <upload target>'
p = optparse.OptionParser(usage)
opts, args = p.parse_args(args)
if len(args) != 4:
p.error('Invalid arguments')
return opts, args
def main(args):
logging.basicConfig(level=logging.INFO)
_, (package, source_release, dest_release, upload) = parse(args[1:])
tmpdir = tempfile.mkdtemp()
try:
for pocket in ('-updates', '-security', ''):
try:
subprocess.check_call(['pull-lp-source', package, source_release + pocket],
cwd=tmpdir,
stdout=devnull, stderr=devnull)
logging.info('Found package %s in pocket %s' % (package, source_release + pocket))
break
except subprocess.CalledProcessError:
continue
else:
error('Unable to find package %s in release %s' % (package, source_release))
for srcdir in os.listdir(tmpdir):
srcdir = os.path.join(tmpdir, srcdir)
if os.path.isdir(srcdir):
break
else:
error('Something went wrong unpacking package %s' % package)
cl = Changelog(open(os.path.join(srcdir, 'debian/changelog')))
v = cl.get_version()
bp_version = str(v) + ('~%s1' % dest_release)
bp_dist = dest_release
if upload.startswith('ppa:'):
bp_version += '~ppa1'
elif upload == 'ubuntu':
bp_dist += '-backports'
subprocess.check_call(['dch',
'--force-bad-version',
'--preserve',
'--newversion', bp_version,
'--distribution', dest_release,
'No-change backport to %s' % dest_release],
cwd=srcdir)
subprocess.check_call(['debuild', '-S'],
cwd=srcdir)
if ':' in bp_version:
bp_version = bp_version[bp_version.find(':')+1:]
print 'Please check the package in %s carefully' % tmpdir
while True:
answer = raw_input('Do you still want to upload this to %s? [Y/n] ' % upload).strip().lower()
if answer in ('', 'y', 'yes'):
break
elif answer in ('n', 'no'):
return 2
subprocess.check_call(['dput',
upload,
'%s_%s_source.changes' % (package, bp_version)],
cwd=tmpdir)
finally:
shutil.rmtree(tmpdir)
if __name__ == '__main__':
sys.exit(main(sys.argv))

6
debian/changelog vendored
View File

@ -1,10 +1,14 @@
ubuntu-dev-tools (0.108) UNRELEASED; urgency=low
[ Stefano Rivera ]
* lp-shell, import-bug-from-debian:
Use the 'production' LP instance instead of 'edge' (which is going away).
* pbuilder-dist: Fix typo in local archive support, introduced in 0.107.
-- Stefano Rivera <stefanor@ubuntu.com> Sat, 11 Dec 2010 12:33:37 +0200
[ Evan Broder ]
* backportpackage: new script for testing backport requests in a PPA.
-- Evan Broder <evan@ebroder.net> Sat, 11 Dec 2010 14:11:54 -0800
ubuntu-dev-tools (0.107) experimental; urgency=low

18
doc/backportpackage.1 Normal file
View File

@ -0,0 +1,18 @@
.TH BACKPORTPACKAGE "1" "December 2010" "ubuntu-dev-tools"
.SH NAME
backportpackage \- helper to test package backports
.SH SYNOPSIS
.B backportpackage
\fI<package name> <source release> <dest release> <upload target>\fR
.SH DESCRIPTION
\fIbackportpackage\fR fetches a package from one Ubuntu release and
creates a no-change backport of that package to a previous release,
uploading the resulting backport for testing.
.PP
\fIbackportpackage\fR is only recommended for testing backports in a
PPA, not uploading backports to the Ubuntu archive.
.SH AUTHOR
\fIbackportpackage\fR and this manpage were written by Evan Broder
<evan@ebroder.net>
.PP
Both are released under GNU General Public License, version 2.