mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
backportpackage, doc/backportpackage.1: Accept codenames from any
distribution in the parenting chain. Makes it possible to, e.g., backport from Debian. (LP: #703099)
This commit is contained in:
parent
2560aa210b
commit
1a6fb270b4
@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010, Evan Broder <evan@ebroder.net>
|
# Copyright (C) 2010-2011, Evan Broder <evan@ebroder.net>
|
||||||
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
# Copyright (C) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
@ -28,11 +28,15 @@ import tempfile
|
|||||||
from launchpadlib.launchpad import Launchpad
|
from launchpadlib.launchpad import Launchpad
|
||||||
import lsb_release
|
import lsb_release
|
||||||
|
|
||||||
|
from debian.debian_support import Version
|
||||||
|
|
||||||
from devscripts.logger import Logger
|
from devscripts.logger import Logger
|
||||||
|
|
||||||
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
from ubuntutools.archive import SourcePackage, DebianSourcePackage, UbuntuSourcePackage, DownloadError, rmadison
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
from ubuntutools.builder import get_builder
|
from ubuntutools.builder import get_builder
|
||||||
|
from ubuntutools.distro_info import vendor_to_distroinfo, codename_to_distribution
|
||||||
|
from ubuntutools.misc import system_distribution
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion
|
||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
@ -105,9 +109,9 @@ def parse(args):
|
|||||||
'(default: temporary dir)',
|
'(default: temporary dir)',
|
||||||
metavar='WORKDIR')
|
metavar='WORKDIR')
|
||||||
parser.add_option('-m', '--mirror',
|
parser.add_option('-m', '--mirror',
|
||||||
dest='ubuntu_mirror',
|
dest='mirror',
|
||||||
default=None,
|
default=None,
|
||||||
help='Preferred Ubuntu mirror (default: Launchpad)',
|
help='Preferred mirror (default: Launchpad)',
|
||||||
metavar='INSTANCE')
|
metavar='INSTANCE')
|
||||||
parser.add_option('-l', '--lpinstance',
|
parser.add_option('-l', '--lpinstance',
|
||||||
dest='lpinstance',
|
dest='lpinstance',
|
||||||
@ -134,58 +138,74 @@ def parse(args):
|
|||||||
opts.workdir = config.get_value('WORKDIR')
|
opts.workdir = config.get_value('WORKDIR')
|
||||||
if opts.lpinstance is None:
|
if opts.lpinstance is None:
|
||||||
opts.lpinstance = config.get_value('LPINSTANCE')
|
opts.lpinstance = config.get_value('LPINSTANCE')
|
||||||
if opts.ubuntu_mirror is None:
|
|
||||||
opts.ubuntu_mirror = config.get_value('UBUNTU_MIRROR')
|
|
||||||
if not opts.upload and not opts.workdir:
|
if not opts.upload and not opts.workdir:
|
||||||
parser.error('Please specify either a working dir or an upload target!')
|
parser.error('Please specify either a working dir or an upload target!')
|
||||||
|
|
||||||
return opts, args
|
return opts, args
|
||||||
|
|
||||||
def find_release_package(launchpad, package, version, source_release):
|
def get_current_version(package, distribution, source_release):
|
||||||
ubuntu = launchpad.distributions['ubuntu']
|
latest_version = None
|
||||||
archive = ubuntu.main_archive
|
|
||||||
series = ubuntu.getSeries(name_or_version=source_release)
|
for record in rmadison(distribution.lower(), package, suite=source_release):
|
||||||
status = 'Published'
|
if 'source' not in record:
|
||||||
for pocket in ('Updates', 'Security', 'Release'):
|
|
||||||
try:
|
|
||||||
srcpkg = archive.getPublishedSources(source_name=package,
|
|
||||||
distro_series=series,
|
|
||||||
pocket=pocket,
|
|
||||||
status=status,
|
|
||||||
exact_match=True)[0]
|
|
||||||
break
|
|
||||||
except IndexError:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if (not latest_version or
|
||||||
|
Version(latest_version) < Version(record['version'])):
|
||||||
|
latest_version = record['version']
|
||||||
|
|
||||||
|
return latest_version
|
||||||
|
|
||||||
|
def find_release_package(launchpad, mirror, workdir, package, version, source_release):
|
||||||
|
srcpkg = None
|
||||||
|
|
||||||
|
if source_release:
|
||||||
|
distribution = codename_to_distribution(source_release)
|
||||||
else:
|
else:
|
||||||
|
distribution = system_distribution()
|
||||||
|
mirrors = (mirror,) if mirror else ()
|
||||||
|
|
||||||
|
if not version:
|
||||||
|
version = get_current_version(package, distribution, source_release)
|
||||||
|
|
||||||
|
if not version:
|
||||||
error('Unable to find package %s in release %s.' %
|
error('Unable to find package %s in release %s.' %
|
||||||
(package, source_release))
|
(package, source_release))
|
||||||
|
|
||||||
if version and version != srcpkg.source_package_version:
|
if distribution == 'Debian':
|
||||||
error('Requested backport of version %s but %s is at version %s.' %
|
srcpkg = DebianSourcePackage(package,
|
||||||
(version, package, srcpkg.source_package_version))
|
version,
|
||||||
|
workdir=workdir,
|
||||||
|
lp=launchpad,
|
||||||
|
mirrors=mirrors)
|
||||||
|
elif distribution == 'Ubuntu':
|
||||||
|
srcpkg = UbuntuSourcePackage(package,
|
||||||
|
version,
|
||||||
|
workdir=workdir,
|
||||||
|
lp=launchpad,
|
||||||
|
mirrors=mirrors)
|
||||||
|
|
||||||
return srcpkg
|
return srcpkg
|
||||||
|
|
||||||
def find_package(launchpad, mirror, workdir, package, version, source_release):
|
def find_package(launchpad, mirror, workdir, package, version, source_release):
|
||||||
"Returns the SourcePackage"
|
"Returns the SourcePackage"
|
||||||
if package.endswith('.dsc'):
|
if package.endswith('.dsc'):
|
||||||
return UbuntuSourcePackage(version=version, dscfile=package,
|
return SourcePackage(version=version, dscfile=package,
|
||||||
workdir=workdir, lp=launchpad,
|
workdir=workdir, lp=launchpad,
|
||||||
mirrors=[mirror])
|
mirrors=(mirror,))
|
||||||
|
|
||||||
if not source_release and not version:
|
if not source_release and not version:
|
||||||
source_release = launchpad.distributions['ubuntu'].current_series.name
|
info = vendor_to_distroinfo(system_distribution())
|
||||||
|
source_release = info().devel()
|
||||||
|
|
||||||
component = None
|
srcpkg = find_release_package(launchpad, mirror, workdir, package, version, source_release)
|
||||||
# If source_release is specified, then version is just for verification
|
if version and srcpkg.version != version:
|
||||||
if source_release:
|
error('Requested backport of version %s but %s is at version %s in %s.' %
|
||||||
srcpkg = find_release_package(launchpad, package, version,
|
(version, package, srcpkg.version, source_release))
|
||||||
source_release)
|
|
||||||
version = srcpkg.source_package_version
|
|
||||||
component = srcpkg.component_name
|
|
||||||
|
|
||||||
return UbuntuSourcePackage(package, version, component, workdir=workdir,
|
return srcpkg
|
||||||
lp=launchpad, mirrors=[mirror])
|
|
||||||
|
return UbuntuSourcePackage
|
||||||
|
|
||||||
def get_backport_version(version, suffix, upload, release):
|
def get_backport_version(version, suffix, upload, release):
|
||||||
backport_version = version + ('~%s1' % release)
|
backport_version = version + ('~%s1' % release)
|
||||||
@ -257,7 +277,6 @@ def do_backport(workdir, pkg, suffix, release, build, builder, update, upload,
|
|||||||
shutil.rmtree(srcdir)
|
shutil.rmtree(srcdir)
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
|
||||||
ubu_email()
|
ubu_email()
|
||||||
|
|
||||||
opts, (package_or_dsc,) = parse(args[1:])
|
opts, (package_or_dsc,) = parse(args[1:])
|
||||||
@ -282,7 +301,7 @@ def main(args):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pkg = find_package(launchpad,
|
pkg = find_package(launchpad,
|
||||||
opts.ubuntu_mirror,
|
opts.mirror,
|
||||||
workdir,
|
workdir,
|
||||||
package_or_dsc,
|
package_or_dsc,
|
||||||
opts.version,
|
opts.version,
|
||||||
|
5
debian/changelog
vendored
5
debian/changelog
vendored
@ -28,8 +28,11 @@ ubuntu-dev-tools (0.125) UNRELEASED; urgency=low
|
|||||||
each distribution's parent.
|
each distribution's parent.
|
||||||
* ubuntutools.distro_info: Add a function to find the distribution that
|
* ubuntutools.distro_info: Add a function to find the distribution that
|
||||||
used a given release codename.
|
used a given release codename.
|
||||||
|
* backportpackage, doc/backportpackage.1: Accept codenames from any
|
||||||
|
distribution in the parenting chain. Makes it possible to, e.g.,
|
||||||
|
backport from Debian. (LP: #703099)
|
||||||
|
|
||||||
-- Evan Broder <evan@ebroder.net> Sat, 11 Jun 2011 05:06:44 -0700
|
-- Evan Broder <evan@ebroder.net> Sat, 11 Jun 2011 05:11:23 -0700
|
||||||
|
|
||||||
ubuntu-dev-tools (0.124) unstable; urgency=low
|
ubuntu-dev-tools (0.124) unstable; urgency=low
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ backportpackage \- helper to test package backports
|
|||||||
.PP
|
.PP
|
||||||
.B backportpackage \-h
|
.B backportpackage \-h
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBbackportpackage\fR fetches a package from one Ubuntu release or
|
\fBbackportpackage\fR fetches a package from one distribution release
|
||||||
from a specified .dsc path or URL and creates a no-change backport of
|
or from a specified .dsc path or URL and creates a no-change backport
|
||||||
that package to a previous release, optionally doing a test build of
|
of that package to one or more Ubuntu releases release, optionally
|
||||||
the package and/or uploading the resulting backport for testing.
|
doing a test build of the package and/or uploading the resulting
|
||||||
|
backport for testing.
|
||||||
.PP
|
.PP
|
||||||
Unless a working directory is specified, the backported package is
|
Unless a working directory is specified, the backported package is
|
||||||
fetched and built in a temporary directory in \fB/tmp\fR, which is
|
fetched and built in a temporary directory in \fB/tmp\fR, which is
|
||||||
@ -29,10 +30,11 @@ is unspecified, then \fBbackportpackage\fR defaults to the release on
|
|||||||
which it is currently running.
|
which it is currently running.
|
||||||
.TP
|
.TP
|
||||||
.B \-s \fISOURCE\fR, \fB\-\-source\fR=\fISOURCE\fR
|
.B \-s \fISOURCE\fR, \fB\-\-source\fR=\fISOURCE\fR
|
||||||
Backport the package from the specified Ubuntu release. If neither
|
Backport the package from the specified release, which can be any
|
||||||
this option nor \fB\-\-version\fR are specified, then
|
release of your distribution or any of your distribution's parent
|
||||||
\fBbackportpackage\fR defaults to the current Ubuntu development
|
distributions. If neither this option nor \fB\-\-version\fR are
|
||||||
release.
|
specified, then \fBbackportpackage\fR defaults to the current
|
||||||
|
development release for your distribution.
|
||||||
.TP
|
.TP
|
||||||
.B \-S \fISUFFIX\fR, \fB\-\-suffix\fR=\fISUFFIX\fR
|
.B \-S \fISUFFIX\fR, \fB\-\-suffix\fR=\fISUFFIX\fR
|
||||||
Add the specified suffix to the version number when
|
Add the specified suffix to the version number when
|
||||||
@ -72,9 +74,10 @@ If the \fB\-\-source\fR option is specified, then
|
|||||||
\fBbackportpackage\fR verifies that the current version of \fIsource
|
\fBbackportpackage\fR verifies that the current version of \fIsource
|
||||||
package\fR in \fISOURCE\fR is the same as \fIVERSION\fR. Otherwise,
|
package\fR in \fISOURCE\fR is the same as \fIVERSION\fR. Otherwise,
|
||||||
\fBbackportpackage\fR finds version \fIVERSION\fR of \fIsource
|
\fBbackportpackage\fR finds version \fIVERSION\fR of \fIsource
|
||||||
package\fR, regardless of the release in which it was published (or if
|
package\fR in your distribution's publishing history, regardless of
|
||||||
that version is still current). This option is ignored if a .dsc URL
|
the release in which it was published (or if that version is still
|
||||||
or path is passed in instead of a source package name.
|
current). This option is ignored if a .dsc URL or path is passed in
|
||||||
|
instead of a source package name.
|
||||||
.TP
|
.TP
|
||||||
.B \-w \fIWORKDIR\fR, \fB\-\-workdir\fR=\fIWORKDIR\fR
|
.B \-w \fIWORKDIR\fR, \fB\-\-workdir\fR=\fIWORKDIR\fR
|
||||||
If \fIWORKDIR\fR is specified, then all files are downloaded,
|
If \fIWORKDIR\fR is specified, then all files are downloaded,
|
||||||
@ -82,7 +85,7 @@ unpacked, built into, and otherwise manipulated in
|
|||||||
\fIWORKDIR\fR. Otherwise, a temporary directory is created, which is
|
\fIWORKDIR\fR. Otherwise, a temporary directory is created, which is
|
||||||
deleted before \fIbackportpackage\fR exits.
|
deleted before \fIbackportpackage\fR exits.
|
||||||
.TP
|
.TP
|
||||||
.B \-m \fIUBUNTU_MIRROR\fR, \fB\-\-mirror\fR=\fIUBUNTU_MIRROR\fR
|
.B \-m \fIMIRROR\fR, \fB\-\-mirror\fR=\fIMIRROR\fR
|
||||||
Use the specified mirror.
|
Use the specified mirror.
|
||||||
Should be in the form \fBhttp://archive.ubuntu.com/ubuntu\fR.
|
Should be in the form \fBhttp://archive.ubuntu.com/ubuntu\fR.
|
||||||
If the package isn't found on this mirror, \fBbackportpackage\fR
|
If the package isn't found on this mirror, \fBbackportpackage\fR
|
||||||
@ -124,7 +127,12 @@ The default value for \fB--update\fR.
|
|||||||
The default value for \fB--workdir\fR.
|
The default value for \fB--workdir\fR.
|
||||||
.TP
|
.TP
|
||||||
.BR BACKPORTPACKAGE_UBUNTU_MIRROR ", " UBUNTUTOOLS_UBUNTU_MIRROR
|
.BR BACKPORTPACKAGE_UBUNTU_MIRROR ", " UBUNTUTOOLS_UBUNTU_MIRROR
|
||||||
The default value for \fB\-\-mirror\fR.
|
The default value for \fB\-\-mirror\fR if the specified \fISOURCE\fR
|
||||||
|
release is an Ubuntu release.
|
||||||
|
.TP
|
||||||
|
.BR BACKPORTPACKAGE_DEBIAN_MIRROR ", " UBUNTUTOOLS_DEBIAN_MIRROR
|
||||||
|
The default value for \fB\-\-mirror\fR if the specified \fISOURCE\fR
|
||||||
|
release is a Debian release.
|
||||||
.TP
|
.TP
|
||||||
.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
|
.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
|
||||||
The default value for \fB--lpinstance\fR.
|
The default value for \fB--lpinstance\fR.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user