2010-04-13 23:18:24 +02:00
|
|
|
#!/usr/bin/python
|
2010-04-13 23:22:32 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2010-12-27 18:24:21 +02:00
|
|
|
# Copyright (C) 2008-2010 Martin Pitt <martin.pitt@canonical.com>,
|
2011-01-31 19:01:10 +02:00
|
|
|
# 2010 Benjamin Drung <bdrung@ubuntu.com>,
|
|
|
|
# 2010-2011 Stefano Rivera <stefanor@ubuntu.com>
|
2010-04-13 23:22:32 +02: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 3.
|
2010-12-03 00:06:43 +01:00
|
|
|
#
|
2010-04-13 23:22:32 +02:00
|
|
|
# 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-3 for more details.
|
|
|
|
#
|
|
|
|
# ##################################################################
|
2010-04-13 23:18:24 +02:00
|
|
|
|
2010-08-02 15:37:48 +02:00
|
|
|
import debian.deb822
|
2010-07-30 00:58:26 +02:00
|
|
|
import debian.debian_support
|
2010-05-10 00:05:22 +02:00
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
2010-04-13 23:18:24 +02:00
|
|
|
|
2011-05-23 23:41:00 +02:00
|
|
|
from devscripts.logger import Logger
|
|
|
|
|
2011-01-31 19:01:10 +02:00
|
|
|
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
|
|
|
DownloadError)
|
2010-12-27 21:09:24 +02:00
|
|
|
from ubuntutools.config import UDTConfig, ubu_email
|
2011-01-31 19:01:10 +02:00
|
|
|
from ubuntutools.requestsync.mail import (getDebianSrcPkg
|
|
|
|
as requestsync_mail_getDebianSrcPkg)
|
2010-05-10 00:05:22 +02:00
|
|
|
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
|
|
|
from ubuntutools.lp import udtexceptions
|
2010-06-02 16:00:30 +02:00
|
|
|
from ubuntutools.lp.lpapicache import Launchpad
|
2011-05-24 20:22:37 +02:00
|
|
|
from ubuntutools import subprocess
|
2010-05-15 17:55:36 +02:00
|
|
|
|
|
|
|
|
2010-07-30 00:58:26 +02:00
|
|
|
class Version(debian.debian_support.Version):
|
2010-10-30 18:45:14 +02:00
|
|
|
def strip_epoch(self):
|
|
|
|
'''Removes the epoch from a Debian version string.
|
|
|
|
|
|
|
|
strip_epoch(1:1.52-1) will return "1.52-1" and strip_epoch(1.1.3-1) will
|
|
|
|
return "1.1.3-1".'''
|
|
|
|
|
|
|
|
parts = self.full_version.split(':')
|
|
|
|
if len(parts) > 1:
|
|
|
|
del parts[0]
|
|
|
|
version_without_epoch = ':'.join(parts)
|
|
|
|
return version_without_epoch
|
|
|
|
|
|
|
|
def get_related_debian_version(self):
|
|
|
|
related_debian_version = self.full_version
|
|
|
|
uidx = related_debian_version.find('ubuntu')
|
|
|
|
if uidx > 0:
|
|
|
|
related_debian_version = related_debian_version[:uidx]
|
|
|
|
uidx = related_debian_version.find('build')
|
|
|
|
if uidx > 0:
|
|
|
|
related_debian_version = related_debian_version[:uidx]
|
|
|
|
return Version(related_debian_version)
|
|
|
|
|
|
|
|
def is_modified_in_ubuntu(self):
|
2010-12-28 15:35:15 +02:00
|
|
|
return 'ubuntu' in self.full_version
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
|
2010-12-22 23:53:09 +01:00
|
|
|
def remove_signature(dscname):
|
2010-10-30 18:45:14 +02:00
|
|
|
'''Removes the signature from a .dsc file if the .dsc file is signed.'''
|
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
dsc_file = open(dscname)
|
|
|
|
if dsc_file.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
2010-10-30 18:45:14 +02:00
|
|
|
unsigned_file = []
|
|
|
|
# search until begin of body found
|
2010-12-27 15:20:49 +01:00
|
|
|
for line in dsc_file:
|
2010-12-22 23:53:09 +01:00
|
|
|
if line.strip() == "":
|
2010-10-30 18:45:14 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
# search for end of body
|
2010-12-27 15:20:49 +01:00
|
|
|
for line in dsc_file:
|
2010-12-22 23:53:09 +01:00
|
|
|
if line.strip() == "":
|
2010-10-30 18:45:14 +02:00
|
|
|
break
|
2010-12-22 23:53:09 +01:00
|
|
|
unsigned_file.append(line)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
dsc_file.close()
|
|
|
|
dsc_file = open(dscname, "w")
|
|
|
|
dsc_file.writelines(unsigned_file)
|
|
|
|
dsc_file.close()
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
def add_fixed_bugs(changes, bugs):
|
2010-12-22 23:53:09 +01:00
|
|
|
'''Add additional Launchpad bugs to the list of fixed bugs in changes
|
|
|
|
file.'''
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
changes = [l for l in changes.split("\n") if l.strip() != ""]
|
2010-10-30 18:45:14 +02:00
|
|
|
# Remove duplicates
|
|
|
|
bugs = set(bugs)
|
|
|
|
|
|
|
|
for i in xrange(len(changes)):
|
|
|
|
if changes[i].startswith("Launchpad-Bugs-Fixed:"):
|
|
|
|
bugs.update(changes[i][22:].strip().split(" "))
|
|
|
|
changes[i] = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
|
|
|
break
|
|
|
|
elif i == len(changes) - 1:
|
|
|
|
# Launchpad-Bugs-Fixed entry does not exist in changes file
|
|
|
|
line = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
|
|
|
changes.append(line)
|
|
|
|
|
|
|
|
return "\n".join(changes + [""])
|
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
2010-12-28 15:35:15 +02:00
|
|
|
keyid=None):
|
2010-10-30 18:45:14 +02:00
|
|
|
uploader = name + " <" + email + ">"
|
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
src_pkg.pull_dsc()
|
|
|
|
new_ver = Version(src_pkg.dsc["Version"])
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
try:
|
2010-12-30 17:16:58 +02:00
|
|
|
ubuntu_source = getUbuntuSrcPkg(src_pkg.source, release)
|
2010-10-30 18:45:14 +02:00
|
|
|
ubuntu_ver = Version(ubuntu_source.getVersion())
|
2010-12-30 17:16:58 +02:00
|
|
|
ubu_pkg = UbuntuSourcePackage(src_pkg.source, ubuntu_ver.full_version,
|
|
|
|
ubuntu_source.getComponent(),
|
|
|
|
mirrors=[ubuntu_mirror])
|
|
|
|
ubu_pkg.pull_dsc()
|
2011-01-15 15:50:07 +02:00
|
|
|
need_orig = ubuntu_ver.upstream_version != new_ver.upstream_version
|
2010-10-30 18:45:14 +02:00
|
|
|
except udtexceptions.PackageNotFoundException:
|
|
|
|
ubuntu_ver = Version('~')
|
2010-12-30 17:16:58 +02:00
|
|
|
ubu_pkg = None
|
2011-01-15 15:50:07 +02:00
|
|
|
need_orig = True
|
|
|
|
Logger.info('%s does not exist in Ubuntu.', name)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.debug('Source %s: current version %s, new version %s',
|
2010-12-30 17:16:58 +02:00
|
|
|
src_pkg.source, ubuntu_ver, new_ver)
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.debug('Needs source tarball: %s', str(need_orig))
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
cur_ver = ubuntu_ver.get_related_debian_version()
|
|
|
|
if ubuntu_ver.is_modified_in_ubuntu():
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.warn('Overwriting modified Ubuntu version %s, '
|
|
|
|
'setting current version to %s',
|
|
|
|
ubuntu_ver.full_version, cur_ver.full_version)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2011-01-31 19:01:10 +02:00
|
|
|
try:
|
|
|
|
src_pkg.pull()
|
|
|
|
except DownloadError, e:
|
|
|
|
Logger.error('Failed to download: %s', str(e))
|
|
|
|
sys.exit(1)
|
2010-12-30 17:16:58 +02:00
|
|
|
src_pkg.unpack()
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2011-01-25 09:41:59 +02:00
|
|
|
fakesync = not (need_orig or ubu_pkg.verify_orig())
|
2011-01-15 15:50:07 +02:00
|
|
|
|
|
|
|
if fakesync:
|
|
|
|
Logger.warn('The checksums of the Debian and Ubuntu packages mismatch. '
|
|
|
|
'A fake sync is required.')
|
2010-10-30 18:45:14 +02:00
|
|
|
# Download Ubuntu files (override Debian source tarballs)
|
2011-01-31 19:01:10 +02:00
|
|
|
try:
|
|
|
|
ubu_pkg.pull()
|
|
|
|
except DownloadError, e:
|
|
|
|
Logger.error('Failed to download: %s', str(e))
|
|
|
|
sys.exit(1)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# change into package directory
|
2010-12-30 17:16:58 +02:00
|
|
|
directory = src_pkg.source + '-' + new_ver.upstream_version
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(('cd', directory))
|
2010-10-30 18:45:14 +02:00
|
|
|
os.chdir(directory)
|
|
|
|
|
|
|
|
# read Debian distribution from debian/changelog if not specified
|
|
|
|
if debian_dist is None:
|
|
|
|
line = open("debian/changelog").readline()
|
|
|
|
debian_dist = line.split(" ")[2].strip(";")
|
|
|
|
|
2011-01-15 15:50:07 +02:00
|
|
|
if not fakesync:
|
2010-10-30 18:45:14 +02:00
|
|
|
# create the changes file
|
2010-12-27 15:20:49 +01:00
|
|
|
changes_filename = "%s_%s_source.changes" % \
|
2010-12-30 17:16:58 +02:00
|
|
|
(src_pkg.source, new_ver.strip_epoch())
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd = ["dpkg-genchanges", "-S", "-v" + cur_ver.full_version,
|
|
|
|
"-DDistribution=" + release,
|
|
|
|
"-DOrigin=debian/" + debian_dist,
|
|
|
|
"-e" + uploader]
|
|
|
|
if need_orig:
|
|
|
|
cmd.append("-sa")
|
|
|
|
else:
|
|
|
|
cmd.append("-sd")
|
2010-12-27 18:24:21 +02:00
|
|
|
if not Logger.verbose:
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd += ["-q"]
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(cmd + ['>', '../' + changes_filename])
|
2010-12-30 17:16:58 +02:00
|
|
|
changes = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# Add additional bug numbers
|
|
|
|
if len(bugs) > 0:
|
2010-12-27 15:20:49 +01:00
|
|
|
changes = add_fixed_bugs(changes, bugs)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# remove extracted (temporary) files
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(('cd', '..'))
|
2010-10-30 18:45:14 +02:00
|
|
|
os.chdir('..')
|
|
|
|
shutil.rmtree(directory, True)
|
|
|
|
|
|
|
|
# write changes file
|
2010-12-27 15:20:49 +01:00
|
|
|
changes_file = open(changes_filename, "w")
|
|
|
|
changes_file.writelines(changes)
|
|
|
|
changes_file.close()
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
# remove signature and sign package
|
2010-12-30 17:16:58 +02:00
|
|
|
remove_signature(src_pkg.dsc_name)
|
2010-10-30 18:45:14 +02:00
|
|
|
if keyid is not False:
|
2010-12-27 15:20:49 +01:00
|
|
|
cmd = ["debsign", changes_filename]
|
2010-10-30 18:45:14 +02:00
|
|
|
if not keyid is None:
|
|
|
|
cmd.insert(1, "-k" + keyid)
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(cmd)
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd)
|
|
|
|
else:
|
|
|
|
# Create fakesync changelog entry
|
|
|
|
new_ver = Version(new_ver.full_version + "fakesync1")
|
2010-12-27 15:20:49 +01:00
|
|
|
changes_filename = "%s_%s_source.changes" % \
|
2010-12-30 17:16:58 +02:00
|
|
|
(src_pkg.source, new_ver.strip_epoch())
|
2010-10-30 18:45:14 +02:00
|
|
|
if len(bugs) > 0:
|
|
|
|
message = "Fake sync due to mismatching orig tarball (LP: %s)." % \
|
2010-12-22 23:53:09 +01:00
|
|
|
(", ".join(["#" + str(b) for b in bugs]))
|
2010-10-30 18:45:14 +02:00
|
|
|
else:
|
|
|
|
message = "Fake sync due to mismatching orig tarball."
|
2010-12-30 17:16:58 +02:00
|
|
|
cmd = ['dch', '-v', new_ver.full_version, '--force-distribution',
|
|
|
|
'-D', release, message]
|
|
|
|
env = {'DEBFULLNAME': name, 'DEBEMAIL': email}
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(cmd)
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd, env=env)
|
|
|
|
|
|
|
|
# update the Maintainer field
|
|
|
|
cmd = ["update-maintainer"]
|
2010-12-27 18:24:21 +02:00
|
|
|
if not Logger.verbose:
|
2010-10-30 18:45:14 +02:00
|
|
|
cmd.append("-q")
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(cmd)
|
2010-10-30 18:45:14 +02:00
|
|
|
subprocess.check_call(cmd)
|
2010-12-03 00:06:43 +01:00
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
# Build source package
|
|
|
|
cmd = ["debuild", "--no-lintian", "-S", "-v" + cur_ver.full_version]
|
|
|
|
if need_orig:
|
|
|
|
cmd += ['-sa']
|
|
|
|
if keyid:
|
|
|
|
cmd += ["-k" + keyid]
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.command(cmd)
|
2010-12-30 17:16:58 +02:00
|
|
|
returncode = subprocess.call(cmd)
|
2010-10-30 20:36:42 +02:00
|
|
|
if returncode != 0:
|
2010-12-27 18:24:21 +02:00
|
|
|
Logger.error('Source-only build with debuild failed. '
|
|
|
|
'Please check build log above.')
|
2010-10-30 20:36:42 +02:00
|
|
|
sys.exit(1)
|
2010-05-15 17:55:36 +02:00
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
|
|
|
"""Download the specified source package.
|
|
|
|
dist, version, component, mirror can all be None.
|
|
|
|
"""
|
2010-12-30 17:16:58 +02:00
|
|
|
if package.endswith('.dsc'):
|
|
|
|
return DebianSourcePackage(dscfile=package, mirrors=[mirror])
|
|
|
|
|
2010-10-30 18:45:14 +02:00
|
|
|
if dist is None:
|
2010-12-22 23:53:09 +01:00
|
|
|
dist = "unstable"
|
2010-12-28 15:35:15 +02:00
|
|
|
requested_version = version
|
2010-10-30 18:45:14 +02:00
|
|
|
if type(version) == str:
|
|
|
|
version = Version(version)
|
|
|
|
|
|
|
|
if version is None or component is None:
|
2011-01-01 19:51:03 +02:00
|
|
|
try:
|
|
|
|
debian_srcpkg = getDebianSrcPkg(package, dist)
|
|
|
|
except (udtexceptions.PackageNotFoundException,
|
|
|
|
udtexceptions.SeriesNotFoundException), e:
|
|
|
|
Logger.error(str(e))
|
|
|
|
sys.exit(1)
|
2010-12-28 15:35:15 +02:00
|
|
|
if version is None:
|
|
|
|
version = Version(debian_srcpkg.getVersion())
|
2010-10-30 18:45:14 +02:00
|
|
|
try:
|
2010-12-28 15:35:15 +02:00
|
|
|
ubuntu_srcpkg = getUbuntuSrcPkg(package, ubuntu_release)
|
|
|
|
ubuntu_version = Version(ubuntu_srcpkg.getVersion())
|
2010-10-30 18:45:14 +02:00
|
|
|
except udtexceptions.PackageNotFoundException:
|
|
|
|
ubuntu_version = Version('~')
|
2011-01-01 19:51:03 +02:00
|
|
|
except udtexceptions.SeriesNotFoundException, e:
|
|
|
|
Logger.error(str(e))
|
|
|
|
sys.exit(1)
|
2010-12-28 15:35:15 +02:00
|
|
|
if ubuntu_version >= version:
|
2010-10-30 18:45:14 +02:00
|
|
|
# The LP importer is maybe out of date
|
|
|
|
debian_srcpkg = requestsync_mail_getDebianSrcPkg(package, dist)
|
2010-12-28 15:35:15 +02:00
|
|
|
if requested_version is None:
|
|
|
|
version = Version(debian_srcpkg.getVersion())
|
|
|
|
if ubuntu_version >= version:
|
|
|
|
Logger.error("Version in Debian %s (%s) isn't newer than "
|
|
|
|
"Ubuntu %s (%s)",
|
|
|
|
version, dist, ubuntu_version, ubuntu_release)
|
|
|
|
sys.exit(1)
|
2010-10-30 18:45:14 +02:00
|
|
|
if component is None:
|
|
|
|
component = debian_srcpkg.getComponent()
|
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
assert component in ('main', 'contrib', 'non-free')
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
return DebianSourcePackage(package, version.full_version, component,
|
|
|
|
mirrors=[mirror])
|
2010-05-10 00:05:22 +02:00
|
|
|
|
2010-12-27 15:20:49 +01:00
|
|
|
def main():
|
2010-12-27 18:24:21 +02:00
|
|
|
usage = "%prog [options] <.dsc URL/path or package name>"
|
|
|
|
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
2010-10-30 18:45:14 +02:00
|
|
|
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
|
|
|
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option("-d", "--distribution",
|
2010-10-30 18:45:14 +02:00
|
|
|
dest="dist", default=None,
|
|
|
|
help="Debian distribution to sync from.")
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option("-r", "--release",
|
|
|
|
dest="release", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Specify target Ubuntu release.")
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option("-V", "--debian-version",
|
|
|
|
dest="debversion", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Specify the version to sync from.")
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option("-c", "--component",
|
|
|
|
dest="component", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Specify the Debian component to sync from.")
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option("-v", "--verbose",
|
|
|
|
dest="verbose", action="store_true", default=False,
|
|
|
|
help="Display more progress information.")
|
|
|
|
parser.add_option("-n", "--uploader-name",
|
|
|
|
dest="uploader_name", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Use UPLOADER_NAME as the name of the maintainer "
|
2010-12-27 21:09:24 +02:00
|
|
|
"for this upload.")
|
|
|
|
parser.add_option("-e", "--uploader-email",
|
|
|
|
dest="uploader_email", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Use UPLOADER_EMAIL as email address of the "
|
2010-12-27 21:09:24 +02:00
|
|
|
"maintainer for this upload.")
|
|
|
|
parser.add_option("-k", "--key",
|
|
|
|
dest="keyid", default=None,
|
2010-10-30 18:45:14 +02:00
|
|
|
help="Specify the key ID to be used for signing.")
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option('--dont-sign',
|
|
|
|
dest='keyid', action='store_false',
|
|
|
|
help='Do not sign the upload.')
|
2010-10-30 18:45:14 +02:00
|
|
|
parser.add_option("-b", "--bug", metavar="BUG",
|
2010-12-27 21:09:24 +02:00
|
|
|
dest="bugs", action="append", default=list(),
|
|
|
|
help="Mark Launchpad bug BUG as being fixed by this "
|
|
|
|
"upload.")
|
2010-12-28 15:35:15 +02:00
|
|
|
parser.add_option('-D', '--debian-mirror', metavar='DEBIAN_MIRROR',
|
|
|
|
dest='debian_mirror',
|
|
|
|
help='Preferred Debian mirror '
|
|
|
|
'(default: %s)'
|
|
|
|
% UDTConfig.defaults['DEBIAN_MIRROR'])
|
|
|
|
parser.add_option('-U', '--ubuntu-mirror', metavar='UBUNTU_MIRROR',
|
|
|
|
dest='ubuntu_mirror',
|
2011-01-25 09:43:15 +02:00
|
|
|
help='Preferred Ubuntu mirror '
|
2010-12-28 15:35:15 +02:00
|
|
|
'(default: %s)'
|
|
|
|
% UDTConfig.defaults['UBUNTU_MIRROR'])
|
2010-12-27 21:09:24 +02:00
|
|
|
parser.add_option('--no-conf',
|
|
|
|
dest='no_conf', default=False, action='store_true',
|
|
|
|
help="Don't read config files or environment variables.")
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if len(args) == 0:
|
2010-12-27 18:24:21 +02:00
|
|
|
parser.error('No .dsc URL/path or package name specified.')
|
|
|
|
if len(args) > 1:
|
|
|
|
parser.error('Multiple .dsc URLs/paths or package names specified: '
|
|
|
|
+ ', '.join(args))
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-22 23:53:09 +01:00
|
|
|
invalid_bug_numbers = [bug for bug in options.bugs if not bug.isdigit()]
|
2010-10-30 18:45:14 +02:00
|
|
|
if len(invalid_bug_numbers) > 0:
|
2010-12-27 18:24:21 +02:00
|
|
|
parser.error('Invalid bug number(s) specified: '
|
|
|
|
+ ', '.join(invalid_bug_numbers))
|
2010-10-30 19:17:30 +02:00
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
if options.component not in (None, "main", "contrib", "non-free"):
|
|
|
|
parser.error('%s is not a valid Debian component. '
|
|
|
|
'It should be one of main, contrib, or non-free.'
|
|
|
|
% options.component)
|
2010-12-27 21:09:24 +02:00
|
|
|
|
2010-12-28 15:35:15 +02:00
|
|
|
Logger.verbose = options.verbose
|
|
|
|
config = UDTConfig(options.no_conf)
|
|
|
|
if options.debian_mirror is None:
|
|
|
|
options.debian_mirror = config.get_value('DEBIAN_MIRROR')
|
|
|
|
if options.ubuntu_mirror is None:
|
|
|
|
options.ubuntu_mirror = config.get_value('UBUNTU_MIRROR')
|
2010-10-30 19:17:30 +02:00
|
|
|
if options.uploader_name is None:
|
2010-12-27 21:09:24 +02:00
|
|
|
options.uploader_name = ubu_email(export=False)[0]
|
2010-10-30 19:17:30 +02:00
|
|
|
if options.uploader_email is None:
|
2010-12-27 21:09:24 +02:00
|
|
|
options.uploader_email = ubu_email(export=False)[1]
|
2010-10-30 18:45:14 +02:00
|
|
|
|
|
|
|
Launchpad.login_anonymously()
|
|
|
|
if options.release is None:
|
|
|
|
options.release = Launchpad.distributions["ubuntu"].current_series.name
|
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
|
|
|
|
|
|
|
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
|
|
|
options.component, options.release,
|
|
|
|
options.debian_mirror)
|
2010-10-30 18:45:14 +02:00
|
|
|
|
2010-12-30 17:16:58 +02:00
|
|
|
sync_dsc(src_pkg, options.dist, options.release, options.uploader_name,
|
2010-12-28 15:35:15 +02:00
|
|
|
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
|
|
|
options.keyid)
|
2010-12-27 15:20:49 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|