2010-12-11 14:12:02 -08:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# ##################################################################
|
|
|
|
#
|
2011-06-11 05:45:21 -07:00
|
|
|
# Copyright (C) 2010-2011, Evan Broder <evan@ebroder.net>
|
2010-12-18 12:58:11 -08:00
|
|
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
2010-12-18 12:09:44 -08:00
|
|
|
#
|
2010-12-11 14:12:02 -08:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# ##################################################################
|
|
|
|
|
2012-05-06 12:32:54 +02:00
|
|
|
import glob
|
2010-12-11 14:12:02 -08:00
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
|
2010-12-15 20:50:30 -08:00
|
|
|
import lsb_release
|
2012-05-06 12:32:54 +02:00
|
|
|
from httplib2 import Http, HttpLib2Error
|
2011-05-23 23:41:00 +02:00
|
|
|
|
2011-06-24 17:50:10 +02:00
|
|
|
from ubuntutools.archive import (SourcePackage, DebianSourcePackage,
|
2011-12-21 22:13:25 +01:00
|
|
|
UbuntuSourcePackage, DownloadError)
|
2010-12-20 22:08:12 +02:00
|
|
|
from ubuntutools.config import UDTConfig, ubu_email
|
2010-12-22 23:31:35 +01:00
|
|
|
from ubuntutools.builder import get_builder
|
2011-11-23 01:45:49 +02:00
|
|
|
from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
|
|
|
|
SeriesNotFoundException,
|
|
|
|
PackageNotFoundException)
|
2013-03-19 00:18:02 +01:00
|
|
|
from ubuntutools.logger import Logger
|
2011-06-24 17:50:10 +02:00
|
|
|
from ubuntutools.misc import (system_distribution, vendor_to_distroinfo,
|
|
|
|
codename_to_distribution)
|
2010-12-18 19:22:07 +01:00
|
|
|
from ubuntutools.question import YesNoQuestion
|
2011-05-24 20:22:37 +02:00
|
|
|
from ubuntutools import subprocess
|
2010-12-12 19:27:08 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-12 19:27:08 -08:00
|
|
|
def error(msg):
|
|
|
|
Logger.error(msg)
|
2010-12-11 14:12:02 -08:00
|
|
|
sys.exit(1)
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-12 18:24:28 -08:00
|
|
|
def check_call(cmd, *args, **kwargs):
|
2010-12-12 19:27:08 -08:00
|
|
|
Logger.command(cmd)
|
2010-12-12 18:24:28 -08:00
|
|
|
ret = subprocess.call(cmd, *args, **kwargs)
|
|
|
|
if ret != 0:
|
2011-01-13 22:58:03 +02:00
|
|
|
error('%s returned %d.' % (cmd[0], ret))
|
2010-12-12 18:24:28 -08:00
|
|
|
|
2012-12-04 16:01:51 +02:00
|
|
|
|
|
|
|
def check_program_exists(name, package=None):
|
|
|
|
paths = set(os.environ['PATH'].split(':'))
|
|
|
|
paths |= set(('/sbin', '/usr/sbin', '/usr/local/sbin'))
|
|
|
|
if not any(os.path.exists(os.path.join(p, name)) for p in paths):
|
|
|
|
Logger.error('Could not find "%s". Please install the package "%s" '
|
|
|
|
'to use this functionality.',
|
|
|
|
name, package or name)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2010-12-11 14:12:02 -08:00
|
|
|
def parse(args):
|
2010-12-16 01:05:29 -08:00
|
|
|
usage = 'Usage: %prog [options] <source package name or .dsc URL/file>'
|
2010-12-27 20:32:07 +01:00
|
|
|
parser = optparse.OptionParser(usage)
|
|
|
|
parser.add_option('-d', '--destination',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='DEST',
|
2010-12-27 20:32:07 +01:00
|
|
|
dest='dest_releases',
|
|
|
|
default=[],
|
|
|
|
action='append',
|
|
|
|
help='Backport to DEST release '
|
2011-12-21 22:31:33 +02:00
|
|
|
'(default: current release)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-s', '--source',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='SOURCE',
|
2010-12-27 20:32:07 +01:00
|
|
|
dest='source_release',
|
|
|
|
help='Backport from SOURCE release '
|
2011-12-21 22:31:33 +02:00
|
|
|
'(default: devel release)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-S', '--suffix',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='SUFFIX',
|
2010-12-27 20:32:07 +01:00
|
|
|
help='Suffix to append to version number '
|
2011-12-21 22:49:24 +02:00
|
|
|
'(default: ~ppa1 when uploading to a PPA)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-b', '--build',
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='Build the package before uploading '
|
|
|
|
'(default: %default)')
|
|
|
|
parser.add_option('-B', '--builder',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='BUILDER',
|
|
|
|
help='Specify the package builder (default: pbuilder)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-U', '--update',
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='Update the build environment before '
|
|
|
|
'attempting to build')
|
|
|
|
parser.add_option('-u', '--upload',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='UPLOAD',
|
|
|
|
help='Specify an upload destination')
|
2012-05-06 13:09:54 +02:00
|
|
|
parser.add_option("-k", "--key",
|
2012-05-13 14:06:09 -07:00
|
|
|
dest='keyid',
|
2012-05-06 13:09:54 +02:00
|
|
|
help="Specify the key ID to be used for signing.")
|
|
|
|
parser.add_option('--dont-sign',
|
2013-05-24 12:58:12 -07:00
|
|
|
dest='keyid', action='store_false',
|
2012-05-06 13:09:54 +02:00
|
|
|
help='Do not sign the upload.')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-y', '--yes',
|
|
|
|
dest='prompt',
|
|
|
|
default=True,
|
|
|
|
action='store_false',
|
|
|
|
help='Do not prompt before uploading to a PPA')
|
|
|
|
parser.add_option('-v', '--version',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='VERSION',
|
|
|
|
help='Package version to backport (or verify)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-w', '--workdir',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='WORKDIR',
|
2010-12-27 20:32:07 +01:00
|
|
|
help='Specify a working directory '
|
2011-12-21 22:31:33 +02:00
|
|
|
'(default: temporary dir)')
|
2011-12-21 22:49:24 +02:00
|
|
|
parser.add_option('-r', '--release-pocket',
|
|
|
|
default=False,
|
|
|
|
action='store_true',
|
|
|
|
help='Target the release pocket in the .changes file. '
|
|
|
|
'Necessary (and default) for uploads to PPAs')
|
2012-05-11 09:56:19 -07:00
|
|
|
parser.add_option('-c', '--close',
|
|
|
|
metavar='BUG',
|
|
|
|
help='Bug to close in the changelog entry.')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-m', '--mirror',
|
2012-06-20 22:13:49 +02:00
|
|
|
metavar='URL',
|
2011-12-21 22:31:33 +02:00
|
|
|
help='Preferred mirror (default: Launchpad)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('-l', '--lpinstance',
|
2011-12-21 22:31:33 +02:00
|
|
|
metavar='INSTANCE',
|
2010-12-27 20:32:07 +01:00
|
|
|
help='Launchpad instance to connect to '
|
2011-12-21 22:31:33 +02:00
|
|
|
'(default: production)')
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.add_option('--no-conf',
|
|
|
|
default=False,
|
2011-12-21 22:31:33 +02:00
|
|
|
action='store_true',
|
|
|
|
help="Don't read config files or environment variables")
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2010-12-27 20:32:07 +01:00
|
|
|
opts, args = parser.parse_args(args)
|
2010-12-12 18:54:04 -08:00
|
|
|
if len(args) != 1:
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.error('You must specify a single source package or a .dsc '
|
|
|
|
'URL/path.')
|
2010-12-20 22:08:12 +02:00
|
|
|
config = UDTConfig(opts.no_conf)
|
|
|
|
if opts.builder is None:
|
|
|
|
opts.builder = config.get_value('BUILDER')
|
|
|
|
if not opts.update:
|
2010-12-21 02:02:38 +02:00
|
|
|
opts.update = config.get_value('UPDATE_BUILDER', boolean=True)
|
2010-12-20 22:08:12 +02:00
|
|
|
if opts.workdir is None:
|
|
|
|
opts.workdir = config.get_value('WORKDIR')
|
2010-12-21 15:14:45 +02:00
|
|
|
if opts.lpinstance is None:
|
|
|
|
opts.lpinstance = config.get_value('LPINSTANCE')
|
2012-03-28 23:25:33 +02:00
|
|
|
if opts.upload is None:
|
|
|
|
opts.upload = config.get_value('UPLOAD')
|
2012-05-06 13:09:54 +02:00
|
|
|
if opts.keyid is None:
|
|
|
|
opts.keyid = config.get_value('KEYID')
|
2010-12-18 12:32:48 -08:00
|
|
|
if not opts.upload and not opts.workdir:
|
2010-12-27 20:32:07 +01:00
|
|
|
parser.error('Please specify either a working dir or an upload target!')
|
2011-12-21 22:49:24 +02:00
|
|
|
if opts.upload and opts.upload.startswith('ppa:'):
|
|
|
|
opts.release_pocket = True
|
2012-12-04 16:01:51 +02:00
|
|
|
if opts.upload:
|
|
|
|
check_program_exists('dput')
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2011-06-23 17:55:14 -07:00
|
|
|
return opts, args, config
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2011-06-19 14:46:53 -07:00
|
|
|
|
2011-11-23 01:45:49 +02:00
|
|
|
def find_release_package(mirror, workdir, package, version, source_release,
|
|
|
|
config):
|
2011-06-11 05:45:21 -07:00
|
|
|
srcpkg = None
|
|
|
|
|
|
|
|
if source_release:
|
|
|
|
distribution = codename_to_distribution(source_release)
|
2011-06-19 14:35:50 -07:00
|
|
|
if not distribution:
|
|
|
|
error('Unknown release codename %s' % source_release)
|
2012-02-15 16:57:17 +02:00
|
|
|
info = vendor_to_distroinfo(distribution)()
|
|
|
|
source_release = info.codename(source_release, default=source_release)
|
2010-12-12 18:12:28 -08:00
|
|
|
else:
|
2011-06-11 05:45:21 -07:00
|
|
|
distribution = system_distribution()
|
2011-06-23 17:55:14 -07:00
|
|
|
mirrors = [mirror] if mirror else []
|
|
|
|
|
|
|
|
mirrors.append(config.get_value('%s_MIRROR' % distribution.upper()))
|
2011-06-11 05:45:21 -07:00
|
|
|
|
|
|
|
if not version:
|
2011-11-23 01:45:49 +02:00
|
|
|
archive = Distribution(distribution.lower()).getArchive()
|
|
|
|
try:
|
|
|
|
spph = archive.getSourcePackage(package, source_release)
|
2015-01-25 21:01:03 +03:00
|
|
|
except (SeriesNotFoundException, PackageNotFoundException) as e:
|
2011-11-23 01:45:49 +02:00
|
|
|
error(str(e))
|
|
|
|
version = spph.getVersion()
|
2010-12-12 18:12:28 -08:00
|
|
|
|
2011-06-11 05:45:21 -07:00
|
|
|
if distribution == 'Debian':
|
|
|
|
srcpkg = DebianSourcePackage(package,
|
|
|
|
version,
|
|
|
|
workdir=workdir,
|
|
|
|
mirrors=mirrors)
|
|
|
|
elif distribution == 'Ubuntu':
|
|
|
|
srcpkg = UbuntuSourcePackage(package,
|
|
|
|
version,
|
|
|
|
workdir=workdir,
|
|
|
|
mirrors=mirrors)
|
2010-12-12 18:12:28 -08:00
|
|
|
|
|
|
|
return srcpkg
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2011-11-23 01:45:49 +02:00
|
|
|
def find_package(mirror, workdir, package, version, source_release, config):
|
2010-12-30 18:05:55 +02:00
|
|
|
"Returns the SourcePackage"
|
2010-12-28 00:23:53 +02:00
|
|
|
if package.endswith('.dsc'):
|
2011-06-11 05:45:21 -07:00
|
|
|
return SourcePackage(version=version, dscfile=package,
|
2011-11-23 01:45:49 +02:00
|
|
|
workdir=workdir, mirrors=(mirror,))
|
2010-12-28 00:23:53 +02:00
|
|
|
|
2010-12-15 20:39:50 -08:00
|
|
|
if not source_release and not version:
|
2011-06-11 05:45:21 -07:00
|
|
|
info = vendor_to_distroinfo(system_distribution())
|
|
|
|
source_release = info().devel()
|
2010-12-12 18:12:28 -08:00
|
|
|
|
2011-11-23 01:45:49 +02:00
|
|
|
srcpkg = find_release_package(mirror, workdir, package, version,
|
2011-06-23 17:55:14 -07:00
|
|
|
source_release, config)
|
2011-06-11 05:45:21 -07:00
|
|
|
if version and srcpkg.version != version:
|
2011-06-19 14:50:52 -07:00
|
|
|
error('Requested backport of version %s but version of %s in %s is %s'
|
|
|
|
% (version, package, source_release, srcpkg.version))
|
2011-06-11 05:45:21 -07:00
|
|
|
|
|
|
|
return srcpkg
|
2010-12-12 18:12:28 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-18 12:16:02 -08:00
|
|
|
def get_backport_version(version, suffix, upload, release):
|
2012-05-13 13:49:49 -07:00
|
|
|
distribution = codename_to_distribution(release)
|
|
|
|
if not distribution:
|
|
|
|
error('Unknown release codename %s' % release)
|
|
|
|
series = Distribution(distribution.lower()).\
|
|
|
|
getSeries(name_or_version=release)
|
|
|
|
|
|
|
|
backport_version = version + ('~%s%s.1' % (distribution.lower(), series.version))
|
2010-12-18 12:33:10 -08:00
|
|
|
if suffix is not None:
|
2010-12-27 15:20:49 +01:00
|
|
|
backport_version += suffix
|
2010-12-18 12:16:02 -08:00
|
|
|
elif upload and upload.startswith('ppa:'):
|
2010-12-27 15:20:49 +01:00
|
|
|
backport_version += '~ppa1'
|
|
|
|
return backport_version
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2012-05-13 14:05:53 -07:00
|
|
|
def get_old_version(source, release):
|
|
|
|
try:
|
|
|
|
distribution = codename_to_distribution(release)
|
|
|
|
archive = Distribution(distribution.lower()).getArchive()
|
|
|
|
pkg = archive.getSourcePackage(source,
|
|
|
|
release,
|
|
|
|
('Release', 'Security', 'Updates',
|
|
|
|
'Proposed', 'Backports'))
|
|
|
|
return pkg.getVersion()
|
2017-05-01 00:20:03 +02:00
|
|
|
except (SeriesNotFoundException, PackageNotFoundException):
|
2012-05-13 14:05:53 -07:00
|
|
|
pass
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2011-12-21 22:49:24 +02:00
|
|
|
def get_backport_dist(release, release_pocket):
|
|
|
|
if release_pocket:
|
2010-12-12 18:48:50 -08:00
|
|
|
return release
|
2011-12-21 22:49:24 +02:00
|
|
|
else:
|
|
|
|
return '%s-backports' % release
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-30 18:05:55 +02:00
|
|
|
def do_build(workdir, dsc, release, builder, update):
|
2010-12-22 23:31:35 +01:00
|
|
|
builder = get_builder(builder)
|
2010-12-12 20:11:49 -08:00
|
|
|
if not builder:
|
|
|
|
return
|
|
|
|
|
2010-12-18 18:17:29 +01:00
|
|
|
if update:
|
2010-12-17 01:36:05 -08:00
|
|
|
if 0 != builder.update(release):
|
2010-12-18 23:08:13 +01:00
|
|
|
sys.exit(1)
|
2010-12-13 04:00:14 -08:00
|
|
|
|
2011-09-10 13:17:11 +02:00
|
|
|
# builder.build is going to chdir to buildresult:
|
|
|
|
workdir = os.path.realpath(workdir)
|
2010-12-30 18:05:55 +02:00
|
|
|
return builder.build(os.path.join(workdir, dsc),
|
2010-12-15 11:02:07 -08:00
|
|
|
release,
|
2010-12-18 20:35:20 +01:00
|
|
|
os.path.join(workdir, "buildresult"))
|
2010-12-12 20:11:49 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-30 18:05:55 +02:00
|
|
|
def do_upload(workdir, package, bp_version, changes, upload, prompt):
|
2017-05-01 00:20:03 +02:00
|
|
|
print('Please check %s %s in file://%s carefully!' % (package, bp_version, workdir))
|
2010-12-18 12:29:38 -08:00
|
|
|
if prompt or upload == 'ubuntu':
|
|
|
|
question = 'Do you want to upload the package to %s' % upload
|
|
|
|
answer = YesNoQuestion().ask(question, "yes")
|
2010-12-18 13:11:27 -08:00
|
|
|
if answer == "no":
|
2010-12-18 12:29:38 -08:00
|
|
|
return
|
|
|
|
|
2010-12-30 18:05:55 +02:00
|
|
|
check_call(['dput', upload, changes], cwd=workdir)
|
2010-12-12 20:11:49 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2012-05-06 12:32:54 +02:00
|
|
|
def orig_needed(upload, workdir, pkg):
|
|
|
|
'''Avoid a -sa if possible'''
|
|
|
|
if not upload or not upload.startswith('ppa:'):
|
|
|
|
return True
|
|
|
|
ppa = upload.split(':', 1)[1]
|
|
|
|
user, ppa = ppa.split('/', 1)
|
|
|
|
|
2012-06-02 20:34:20 +01:00
|
|
|
version = pkg.version.upstream_version
|
2012-05-06 12:32:54 +02:00
|
|
|
|
|
|
|
h = Http()
|
2017-05-01 00:20:03 +02:00
|
|
|
for filename in glob.glob(os.path.join(workdir, '%s_%s.orig*' % (pkg.source, version))):
|
2012-05-06 12:32:54 +02:00
|
|
|
url = ('https://launchpad.net/~%s/+archive/%s/+files/%s'
|
|
|
|
% (user, ppa, filename))
|
|
|
|
try:
|
|
|
|
headers, body = h.request(url, 'HEAD')
|
2017-05-01 00:20:03 +02:00
|
|
|
if (headers.status != 200 or
|
|
|
|
not headers['content-location'].startswith('https://launchpadlibrarian.net')):
|
2012-05-06 12:32:54 +02:00
|
|
|
return True
|
2015-01-25 21:01:03 +03:00
|
|
|
except HttpLib2Error as e:
|
2012-05-06 12:32:54 +02:00
|
|
|
Logger.info(e)
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2012-05-11 09:56:19 -07:00
|
|
|
def do_backport(workdir, pkg, suffix, close, release, release_pocket, build,
|
* check-mir, check-symbols, grep-merges, pbuilder-dist-simple,
setup-packaging-environment, submittodebian, ubuntu-iso:
Do enough argument parsing to handle --help (LP: #988009)
* dgetlp: Require a UTF-8 locale, or it'll crash when displaying errors
(LP: #979117)
* pbuilder-dist: Don't try to enable -updates for Debian testing
(LP: #993006)
* pbuilder-dist, pull-debian-source, pull-lp-source, requestsync,
reverse-depends, submittodebian, syncpackage:
Handle outdated distro-info data. Fall back to sane defaults where
possible.
* backportpackage: Avoid uploading orig tarballs if they are already present
in the destination PPA (LP: #691897)
* Allow mk-sbuild to be run by root if a configuration file exists
(LP: #888736)
* backportpackage: Allow unsigned backports (LP: #992739)
* update-maintainer: Add a function to restore the original maintainer.
* submittodebian: Revert Ubuntu Maintainer mangling, and re-build the source
package before diffing. (LP: #902233)
2012-05-11 18:13:04 -07:00
|
|
|
builder, update, upload, keyid, prompt):
|
2010-12-30 18:05:55 +02:00
|
|
|
dirname = '%s-%s' % (pkg.source, release)
|
|
|
|
srcdir = os.path.join(workdir, dirname)
|
2010-12-12 20:11:49 -08:00
|
|
|
|
2012-03-28 14:47:30 +02:00
|
|
|
if os.path.exists(srcdir):
|
|
|
|
question = 'Working directory %s already exists. Delete it?' % srcdir
|
|
|
|
if YesNoQuestion().ask(question, 'no') == 'no':
|
|
|
|
sys.exit(1)
|
|
|
|
shutil.rmtree(srcdir)
|
|
|
|
|
|
|
|
pkg.unpack(dirname)
|
|
|
|
|
2010-12-30 18:05:55 +02:00
|
|
|
bp_version = get_backport_version(pkg.version.full_version, suffix,
|
|
|
|
upload, release)
|
2012-05-13 14:05:53 -07:00
|
|
|
old_version = get_old_version(pkg.source, release)
|
2011-12-21 22:49:24 +02:00
|
|
|
bp_dist = get_backport_dist(release, release_pocket)
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2012-05-11 09:56:19 -07:00
|
|
|
changelog = 'No-change backport to %s' % (release,)
|
|
|
|
if close:
|
|
|
|
changelog += ' (LP: #%s)' % (close,)
|
2010-12-12 18:48:50 -08:00
|
|
|
check_call(['dch',
|
2011-05-28 19:41:07 +02:00
|
|
|
'--force-bad-version',
|
2010-12-30 18:05:55 +02:00
|
|
|
'--force-distribution',
|
2010-12-12 18:48:50 -08:00
|
|
|
'--preserve',
|
|
|
|
'--newversion', bp_version,
|
2010-12-12 20:19:37 -08:00
|
|
|
'--distribution', bp_dist,
|
2012-05-11 09:56:19 -07:00
|
|
|
changelog],
|
2010-12-12 18:48:50 -08:00
|
|
|
cwd=srcdir)
|
2012-05-06 12:32:54 +02:00
|
|
|
|
2012-05-06 13:09:54 +02:00
|
|
|
cmd = ['debuild', '--no-lintian', '-S', '-nc', '-uc', '-us']
|
2012-05-06 12:32:54 +02:00
|
|
|
if orig_needed(upload, workdir, pkg):
|
|
|
|
cmd.append('-sa')
|
|
|
|
else:
|
|
|
|
cmd.append('-sd')
|
2012-05-13 14:05:53 -07:00
|
|
|
if old_version:
|
|
|
|
cmd.append('-v%s' % old_version)
|
2012-06-13 23:21:17 +01:00
|
|
|
env = os.environ.copy()
|
2012-06-17 19:54:40 +01:00
|
|
|
# An ubuntu.com e-mail address would make dpkg-buildpackage fail if there
|
|
|
|
# wasn't an Ubuntu maintainer for an ubuntu-versioned package. LP: #1007042
|
|
|
|
env.pop('DEBEMAIL', None)
|
2012-06-13 23:21:17 +01:00
|
|
|
check_call(cmd, cwd=srcdir, env=env)
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2010-12-30 18:05:55 +02:00
|
|
|
fn_base = pkg.source + '_' + bp_version.split(':', 1)[-1]
|
2012-05-06 13:09:54 +02:00
|
|
|
changes = fn_base + '_source.changes'
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2010-12-15 20:39:50 -08:00
|
|
|
if build:
|
2010-12-30 18:05:55 +02:00
|
|
|
if 0 != do_build(workdir, fn_base + '.dsc', release, builder, update):
|
2010-12-18 23:08:13 +01:00
|
|
|
sys.exit(1)
|
2012-12-03 13:15:27 +02:00
|
|
|
|
|
|
|
# None: sign with the default signature. False: don't sign
|
|
|
|
if keyid is not False:
|
2012-05-06 13:09:54 +02:00
|
|
|
cmd = ['debsign']
|
|
|
|
if keyid:
|
|
|
|
cmd.append('-k' + keyid)
|
|
|
|
cmd.append(changes)
|
|
|
|
check_call(cmd, cwd=workdir)
|
2010-12-15 20:39:50 -08:00
|
|
|
if upload:
|
2012-05-06 13:09:54 +02:00
|
|
|
do_upload(workdir, pkg.source, bp_version, changes, upload, prompt)
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2010-12-12 20:11:49 -08:00
|
|
|
shutil.rmtree(srcdir)
|
2010-12-12 18:48:50 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-11 14:12:02 -08:00
|
|
|
def main(args):
|
2010-12-20 22:08:12 +02:00
|
|
|
ubu_email()
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2011-06-23 17:55:14 -07:00
|
|
|
opts, (package_or_dsc,), config = parse(args[1:])
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2011-11-23 01:45:49 +02:00
|
|
|
Launchpad.login_anonymously(service=opts.lpinstance)
|
2010-12-12 18:12:28 -08:00
|
|
|
|
2010-12-15 20:50:30 -08:00
|
|
|
if not opts.dest_releases:
|
2010-12-27 15:20:49 +01:00
|
|
|
distinfo = lsb_release.get_distro_information()
|
2010-12-15 20:50:30 -08:00
|
|
|
try:
|
|
|
|
opts.dest_releases = [distinfo['CODENAME']]
|
2010-12-27 15:20:49 +01:00
|
|
|
except KeyError:
|
2010-12-18 23:10:40 +01:00
|
|
|
error('No destination release specified and unable to guess yours.')
|
2010-12-15 20:50:30 -08:00
|
|
|
|
2010-12-16 00:06:57 -08:00
|
|
|
if opts.workdir:
|
|
|
|
workdir = os.path.expanduser(opts.workdir)
|
|
|
|
else:
|
|
|
|
workdir = tempfile.mkdtemp(prefix='backportpackage-')
|
|
|
|
|
|
|
|
if not os.path.exists(workdir):
|
|
|
|
os.makedirs(workdir)
|
|
|
|
|
2010-12-11 14:12:02 -08:00
|
|
|
try:
|
2011-11-23 01:45:49 +02:00
|
|
|
pkg = find_package(opts.mirror,
|
2010-12-30 18:05:55 +02:00
|
|
|
workdir,
|
|
|
|
package_or_dsc,
|
|
|
|
opts.version,
|
2011-06-23 17:55:14 -07:00
|
|
|
opts.source_release,
|
|
|
|
config)
|
2010-12-30 18:05:55 +02:00
|
|
|
pkg.pull()
|
2010-12-12 18:48:50 -08:00
|
|
|
|
|
|
|
for release in opts.dest_releases:
|
2010-12-15 20:39:50 -08:00
|
|
|
do_backport(workdir,
|
2010-12-30 18:05:55 +02:00
|
|
|
pkg,
|
2010-12-18 12:21:40 -08:00
|
|
|
opts.suffix,
|
2012-05-11 09:56:19 -07:00
|
|
|
opts.close,
|
2010-12-15 20:39:50 -08:00
|
|
|
release,
|
2011-12-21 22:49:24 +02:00
|
|
|
opts.release_pocket,
|
2010-12-15 20:39:50 -08:00
|
|
|
opts.build,
|
|
|
|
opts.builder,
|
2010-12-18 18:17:29 +01:00
|
|
|
opts.update,
|
2010-12-18 12:29:38 -08:00
|
|
|
opts.upload,
|
2012-12-03 13:13:46 +02:00
|
|
|
opts.keyid,
|
2010-12-18 12:29:38 -08:00
|
|
|
opts.prompt)
|
2015-01-25 21:01:03 +03:00
|
|
|
except DownloadError as e:
|
2011-01-01 19:51:03 +02:00
|
|
|
error(str(e))
|
2010-12-11 14:12:02 -08:00
|
|
|
finally:
|
2010-12-16 00:06:57 -08:00
|
|
|
if not opts.workdir:
|
|
|
|
shutil.rmtree(workdir)
|
2010-12-11 14:12:02 -08:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2010-12-11 14:12:02 -08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv))
|