mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 07:51:28 +00:00
syncpackage: Convert to new LP API, with --no-lp available for the old
style of operation.
This commit is contained in:
parent
7acdaaf977
commit
122e711d28
4
debian/changelog
vendored
4
debian/changelog
vendored
@ -6,6 +6,10 @@ ubuntu-dev-tools (0.128) UNRELEASED; urgency=low
|
|||||||
[ Julian Taylor ]
|
[ Julian Taylor ]
|
||||||
* lp-shell: use ipython shell if available
|
* lp-shell: use ipython shell if available
|
||||||
|
|
||||||
|
[ Colin Watson ]
|
||||||
|
* syncpackage: Convert to new LP API, with --no-lp available for the old
|
||||||
|
style of operation.
|
||||||
|
|
||||||
-- Julian Taylor <jtaylor.debian@googlemail.com> Sun, 14 Aug 2011 18:56:52 +0200
|
-- Julian Taylor <jtaylor.debian@googlemail.com> Sun, 14 Aug 2011 18:56:52 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.127) unstable; urgency=low
|
ubuntu-dev-tools (0.127) unstable; urgency=low
|
||||||
|
103
syncpackage
103
syncpackage
@ -35,8 +35,9 @@ from ubuntutools.config import UDTConfig, ubu_email
|
|||||||
from ubuntutools.requestsync.mail import (getDebianSrcPkg
|
from ubuntutools.requestsync.mail import (getDebianSrcPkg
|
||||||
as requestsync_mail_getDebianSrcPkg)
|
as requestsync_mail_getDebianSrcPkg)
|
||||||
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
from ubuntutools.requestsync.lp import getDebianSrcPkg, getUbuntuSrcPkg
|
||||||
from ubuntutools.lp import udtexceptions
|
from ubuntutools.lp import udtexceptions, api_version
|
||||||
from ubuntutools.lp.lpapicache import Launchpad
|
from ubuntutools.lp.lpapicache import Distribution, Launchpad
|
||||||
|
from ubuntutools.misc import split_release_pocket
|
||||||
from ubuntutools import subprocess
|
from ubuntutools import subprocess
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ def add_fixed_bugs(changes, bugs):
|
|||||||
return "\n".join(changes + [""])
|
return "\n".join(changes + [""])
|
||||||
|
|
||||||
def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
||||||
keyid=None):
|
keyid=None, simulate=False):
|
||||||
uploader = name + " <" + email + ">"
|
uploader = name + " <" + email + ">"
|
||||||
|
|
||||||
src_pkg.pull_dsc()
|
src_pkg.pull_dsc()
|
||||||
@ -139,6 +140,8 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
|||||||
Logger.warn('Overwriting modified Ubuntu version %s, '
|
Logger.warn('Overwriting modified Ubuntu version %s, '
|
||||||
'setting current version to %s',
|
'setting current version to %s',
|
||||||
ubuntu_ver.full_version, cur_ver.full_version)
|
ubuntu_ver.full_version, cur_ver.full_version)
|
||||||
|
if simulate:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
src_pkg.pull()
|
src_pkg.pull()
|
||||||
@ -292,6 +295,45 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release, mirror):
|
|||||||
return DebianSourcePackage(package, version.full_version, component,
|
return DebianSourcePackage(package, version.full_version, component,
|
||||||
mirrors=[mirror])
|
mirrors=[mirror])
|
||||||
|
|
||||||
|
def copy(src_pkg, debian_version, release, simulate=False):
|
||||||
|
debian = Distribution('debian')
|
||||||
|
ubuntu = Distribution('ubuntu')
|
||||||
|
debian_archive = debian.getArchive()
|
||||||
|
ubuntu_archive = ubuntu.getArchive()
|
||||||
|
if release is None:
|
||||||
|
ubuntu_series = ubuntu.getDevelopmentSeries().name
|
||||||
|
ubuntu_pocket = 'Release'
|
||||||
|
else:
|
||||||
|
ubuntu_series, ubuntu_pocket = split_release_pocket(release)
|
||||||
|
|
||||||
|
if debian_version is None:
|
||||||
|
debian_version = debian_archive.getSourcePackage(src_pkg).getVersion()
|
||||||
|
try:
|
||||||
|
ubuntu_version = ubuntu_archive.getSourcePackage(
|
||||||
|
src_pkg, ubuntu_series, ubuntu_pocket).getVersion()
|
||||||
|
|
||||||
|
Logger.info('Source %s -> %s/%s: current version %s, new version %s',
|
||||||
|
src_pkg, ubuntu_series, ubuntu_pocket,
|
||||||
|
ubuntu_version, debian_version)
|
||||||
|
if Version(debian_version) <= Version(ubuntu_version):
|
||||||
|
Logger.error('Debian version is <= Ubuntu version; nothing to do!')
|
||||||
|
sys.exit(1)
|
||||||
|
except udtexceptions.PackageNotFoundException:
|
||||||
|
Logger.info('Source %s -> %s/%s: not in Ubuntu, new version %s',
|
||||||
|
src_pkg, ubuntu_series, ubuntu_pocket, debian_version)
|
||||||
|
if simulate:
|
||||||
|
return
|
||||||
|
|
||||||
|
ubuntu_archive.copyPackage(
|
||||||
|
source_name=src_pkg,
|
||||||
|
version=debian_version,
|
||||||
|
from_archive=debian_archive.lp_object(),
|
||||||
|
to_series=ubuntu_series,
|
||||||
|
to_pocket=ubuntu_pocket,
|
||||||
|
include_binaries=False)
|
||||||
|
Logger.info('Request succeeded; you should get an e-mail once it is '
|
||||||
|
'processed.')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = "%prog [options] <.dsc URL/path or package name>"
|
usage = "%prog [options] <.dsc URL/path or package name>"
|
||||||
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
||||||
@ -312,6 +354,14 @@ def main():
|
|||||||
parser.add_option("-v", "--verbose",
|
parser.add_option("-v", "--verbose",
|
||||||
dest="verbose", action="store_true", default=False,
|
dest="verbose", action="store_true", default=False,
|
||||||
help="Display more progress information.")
|
help="Display more progress information.")
|
||||||
|
parser.add_option("--no-lp",
|
||||||
|
dest="lp", action="store_false", default=True,
|
||||||
|
help="Construct sync locally rather than letting "
|
||||||
|
"Launchpad copy the package directly.")
|
||||||
|
parser.add_option('-l', '--lpinstance', metavar='INSTANCE',
|
||||||
|
dest='lpinstance', default=None,
|
||||||
|
help='Launchpad instance to connect to '
|
||||||
|
'(default: production).')
|
||||||
parser.add_option("-n", "--uploader-name",
|
parser.add_option("-n", "--uploader-name",
|
||||||
dest="uploader_name", default=None,
|
dest="uploader_name", default=None,
|
||||||
help="Use UPLOADER_NAME as the name of the maintainer "
|
help="Use UPLOADER_NAME as the name of the maintainer "
|
||||||
@ -343,6 +393,10 @@ def main():
|
|||||||
parser.add_option('--no-conf',
|
parser.add_option('--no-conf',
|
||||||
dest='no_conf', default=False, action='store_true',
|
dest='no_conf', default=False, action='store_true',
|
||||||
help="Don't read config files or environment variables.")
|
help="Don't read config files or environment variables.")
|
||||||
|
parser.add_option('--simulate',
|
||||||
|
dest='simulate', default=False, action='store_true',
|
||||||
|
help="Show what would be done, but don't actually do "
|
||||||
|
"it.")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
@ -362,6 +416,14 @@ def main():
|
|||||||
'It should be one of main, contrib, or non-free.'
|
'It should be one of main, contrib, or non-free.'
|
||||||
% options.component)
|
% options.component)
|
||||||
|
|
||||||
|
if options.lp and options.uploader_name:
|
||||||
|
parser.error('Uploader name can only be overridden using --no-lp.')
|
||||||
|
if options.lp and options.uploader_email:
|
||||||
|
parser.error('Uploader email address can only be overridden using '
|
||||||
|
'--no-lp.')
|
||||||
|
# --key, --dont-sign, --debian-mirror, and --ubuntu-mirror are just
|
||||||
|
# ignored with options.lp, and do not require warnings.
|
||||||
|
|
||||||
Logger.verbose = options.verbose
|
Logger.verbose = options.verbose
|
||||||
config = UDTConfig(options.no_conf)
|
config = UDTConfig(options.no_conf)
|
||||||
if options.debian_mirror is None:
|
if options.debian_mirror is None:
|
||||||
@ -373,19 +435,34 @@ def main():
|
|||||||
if options.uploader_email is None:
|
if options.uploader_email is None:
|
||||||
options.uploader_email = ubu_email(export=False)[1]
|
options.uploader_email = ubu_email(export=False)[1]
|
||||||
|
|
||||||
Launchpad.login_anonymously()
|
if options.lp:
|
||||||
if options.release is None:
|
# We need devel for now.
|
||||||
options.release = Launchpad.distributions["ubuntu"].current_series.name
|
api_version = 'devel'
|
||||||
|
|
||||||
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
if options.lpinstance is None:
|
||||||
|
options.lpinstance = config.get_value('LPINSTANCE')
|
||||||
|
|
||||||
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
try:
|
||||||
options.component, options.release,
|
Launchpad.login(service=options.lpinstance)
|
||||||
options.debian_mirror)
|
except IOError:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
sync_dsc(src_pkg, options.dist, options.release, options.uploader_name,
|
copy(args[0], options.debversion, options.release, options.simulate)
|
||||||
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
else:
|
||||||
options.keyid)
|
Launchpad.login_anonymously()
|
||||||
|
if options.release is None:
|
||||||
|
ubuntu = Launchpad.distributions["ubuntu"]
|
||||||
|
options.release = ubuntu.current_series.name
|
||||||
|
|
||||||
|
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
||||||
|
|
||||||
|
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
||||||
|
options.component, options.release,
|
||||||
|
options.debian_mirror)
|
||||||
|
|
||||||
|
sync_dsc(src_pkg, options.dist, options.release, options.uploader_name,
|
||||||
|
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
||||||
|
options.keyid, options.simulate)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -172,6 +172,9 @@ class BaseWrapper(object):
|
|||||||
else:
|
else:
|
||||||
return '<%s: %r>' % (self.__class__.__name__, self._lpobject)
|
return '<%s: %r>' % (self.__class__.__name__, self._lpobject)
|
||||||
|
|
||||||
|
def lp_object(self):
|
||||||
|
return self._lpobject
|
||||||
|
|
||||||
|
|
||||||
class Distribution(BaseWrapper):
|
class Distribution(BaseWrapper):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user