mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
Mirror support in backportpackage
This commit is contained in:
parent
85f8548d5f
commit
53faae58dc
@ -34,6 +34,7 @@ from ubuntutools.config import UDTConfig, ubu_email
|
||||
from ubuntutools.builder import get_builder
|
||||
from ubuntutools.logger import Logger
|
||||
from ubuntutools.question import YesNoQuestion
|
||||
from ubuntutools.misc import dsc_url
|
||||
|
||||
def error(msg):
|
||||
Logger.error(msg)
|
||||
@ -98,6 +99,11 @@ def parse(args):
|
||||
default=None,
|
||||
help='Specify a working directory (default: temporary dir)',
|
||||
metavar='WORKDIR')
|
||||
p.add_option('-m', '--mirror',
|
||||
dest='ubuntu_mirror',
|
||||
default=None,
|
||||
help='Preferred Ubuntu mirror (default: Launchpad)',
|
||||
metavar='INSTANCE')
|
||||
p.add_option('-l', '--lpinstance',
|
||||
dest='lpinstance',
|
||||
default=None,
|
||||
@ -121,6 +127,8 @@ def parse(args):
|
||||
opts.workdir = config.get_value('WORKDIR')
|
||||
if opts.lpinstance is None:
|
||||
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:
|
||||
p.error('Please specify either a working dir or an upload target!')
|
||||
|
||||
@ -163,7 +171,7 @@ def find_version_package(lp, package, version):
|
||||
error('Version %s of package %s was never published in Ubuntu.' %
|
||||
(version, package))
|
||||
|
||||
def dscurl_from_package(lp, workdir, package, version, source_release):
|
||||
def dscurls_from_package(lp, mirror, workdir, package, version, source_release):
|
||||
if not source_release and not version:
|
||||
source_release = lp.distributions['ubuntu'].current_series.name
|
||||
|
||||
@ -173,9 +181,15 @@ def dscurl_from_package(lp, workdir, package, version, source_release):
|
||||
else:
|
||||
srcpkg = find_version_package(lp, package, version)
|
||||
|
||||
urls = []
|
||||
if mirror:
|
||||
urls.append(dsc_url(mirror, srcpkg.component_name, package,
|
||||
srcpkg.source_package_version))
|
||||
|
||||
for f in srcpkg.sourceFileUrls():
|
||||
if f.endswith('.dsc'):
|
||||
return urllib.unquote(f)
|
||||
urls.append(urllib.unquote(f))
|
||||
return urls
|
||||
else:
|
||||
error('Package %s contains no .dsc file.' % package)
|
||||
|
||||
@ -187,16 +201,19 @@ def dscurl_from_dsc(package):
|
||||
# Can't resolve it as a local path? Let's just hope it's good as-is
|
||||
return package
|
||||
|
||||
def fetch_package(lp, workdir, package, version, source_release):
|
||||
def fetch_package(lp, mirror, workdir, package, version, source_release):
|
||||
# Returns the path to the .dsc file that was fetched
|
||||
|
||||
if package.endswith('.dsc'):
|
||||
dsc = dscurl_from_dsc(package)
|
||||
dscs = [dscurl_from_dsc(package)]
|
||||
else:
|
||||
dsc = dscurl_from_package(lp, workdir, package, version, source_release)
|
||||
dscs = dscurls_from_package(lp, mirror, workdir, package, version,
|
||||
source_release)
|
||||
|
||||
check_call(['dget', '--download-only', '--allow-unauthenticated', dsc],
|
||||
cwd=workdir)
|
||||
for dsc in dscs:
|
||||
cmd = ('dget', '--download-only', '--allow-unauthenticated', dsc)
|
||||
Logger.command(cmd)
|
||||
ret = subprocess.call(cmd, cwd=workdir)
|
||||
if ret == 0:
|
||||
return os.path.join(workdir, os.path.basename(dsc))
|
||||
|
||||
def get_backport_version(version, suffix, upload, release):
|
||||
@ -295,6 +312,7 @@ def main(args):
|
||||
|
||||
try:
|
||||
dscfile = fetch_package(lp,
|
||||
opts.ubuntu_mirror,
|
||||
workdir,
|
||||
package_or_dsc,
|
||||
opts.version,
|
||||
|
@ -80,6 +80,12 @@ unpacked, built into, and otherwise manipulated in
|
||||
\fIWORKDIR\fR. Otherwise, a temporary directory is created, which is
|
||||
deleted before \fIbackportpackage\fR exits.
|
||||
.TP
|
||||
.B \-m \fIUBUNTU_MIRROR\fR, \fB\-\-mirror\fR=\fIUBUNTU_MIRROR\fR
|
||||
Use the specified mirror.
|
||||
Should be in the form \fBhttp://archive.ubuntu.com/ubuntu\fR.
|
||||
If the package isn't found on this mirror, \fBbackportpackage\fR
|
||||
will use Launchpad.
|
||||
.TP
|
||||
.B \-l \fIINSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR
|
||||
Use the specified instance of Launchpad (e.g. "staging"), instead of
|
||||
the default of "production".
|
||||
@ -108,6 +114,9 @@ The default value for \fB--update\fR.
|
||||
.BR BACKPORTPACKAGE_WORKDIR ", " UBUNTUTOOLS_WORKDIR
|
||||
The default value for \fB--workdir\fR.
|
||||
.TP
|
||||
.BR BACKPORTPACKAGE_UBUNTU_MIRROR ", " UBUNTUTOOLS_UBUNTU_MIRROR
|
||||
The default value for \fB\-\-mirror\fR.
|
||||
.TP
|
||||
.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
|
||||
The default value for \fB--lpinstance\fR.
|
||||
.SH EXAMPLES
|
||||
|
Loading…
x
Reference in New Issue
Block a user