mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
pull-pkg: create pull-[lp|debian|uca]-* scripts
for backwards compatibility (i.e. to keep pull-lp-source, pull-debian-source, and pull-uca-source) and for ease of use, create scripts that default the pull-pkg -p and -D params re-create pull-pkg script also, to call ubuntutools/pullpkg.py without any default pull or distro parameters
This commit is contained in:
parent
cdaf5d0761
commit
e3268a62f4
8
debian/control
vendored
8
debian/control
vendored
@ -104,7 +104,13 @@ Description: useful tools for Ubuntu developers
|
||||
a Debian package and its immediate parent to generate a debdiff.
|
||||
- pull-debian-source - downloads the latest source package available in
|
||||
Debian of a package.
|
||||
- pull-lp-source - downloads latest source package from Launchpad.
|
||||
- pull-lp-source - downloads source package from Launchpad.
|
||||
- pull-lp-debs - downloads debs package(s) from Launchpad.
|
||||
- pull-lp-ddebs - downloads dbgsym/ddebs package(s) from Launchpad.
|
||||
- pull-lp-udebs - downloads udebs package(s) from Launchpad.
|
||||
- pull-debian-* - same as pull-lp-* but for Debian packages.
|
||||
- pull-uca-* - same as pull-lp-* but for Ubuntu Cloud Archive packages.
|
||||
- pull-pkg - common script that provides above pull-* functionality.
|
||||
- pull-revu-source - downloads the latest source package from REVU
|
||||
- requestbackport - file a backporting request.
|
||||
- requestsync - files a sync request with Debian changelog and rationale.
|
||||
|
11
pull-debian-ddebs
Executable file
11
pull-debian-ddebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-debian-ddebs -- pull ddeb package files for debian
|
||||
# Basic usage: pull-debian-ddebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='debian', pull='ddebs')
|
11
pull-debian-debs
Executable file
11
pull-debian-debs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-debian-debs -- pull deb package files for debian
|
||||
# Basic usage: pull-debian-debs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='debian', pull='debs')
|
@ -1,148 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-debian-source -- pull a source package from Launchpad
|
||||
# Copyright (C) 2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# Inspired by a tool of the same name by Nathan Handler.
|
||||
# pull-debian-source -- pull source package files for debian
|
||||
# Basic usage: pull-debian-source <package name> [version|release]
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
import json
|
||||
import optparse
|
||||
import sys
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
|
||||
from distro_info import DebianDistroInfo, DistroDataOutdated
|
||||
|
||||
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
|
||||
from ubuntutools.config import UDTConfig
|
||||
from ubuntutools.logger import Logger
|
||||
|
||||
|
||||
def is_suite(version):
|
||||
"""If version could be considered to be a Debian suite, return the
|
||||
canonical suite name. Otherwise None
|
||||
"""
|
||||
debian_info = DebianDistroInfo()
|
||||
debian_releases = debian_info.all + ['experimental']
|
||||
|
||||
if '-' in version:
|
||||
release, pocket = version.split('-', 1)
|
||||
release = debian_info.codename(release, default=release)
|
||||
if release in debian_releases:
|
||||
if pocket in ('proposed-updates', 'p-u'):
|
||||
return (release + '-proposed-updates')
|
||||
elif pocket == 'security':
|
||||
return (release + '-security')
|
||||
else:
|
||||
release = debian_info.codename(version, default=version)
|
||||
if release in debian_releases:
|
||||
return release
|
||||
return None
|
||||
|
||||
|
||||
def source_package_for(binary, release):
|
||||
"""Query DDE to find the source package for a particular binary"""
|
||||
try:
|
||||
release = DebianDistroInfo().codename(release, default=release)
|
||||
except DistroDataOutdated as e:
|
||||
Logger.warn(e)
|
||||
url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json'
|
||||
% (release, binary))
|
||||
data = None
|
||||
try:
|
||||
data = json.load(urllib.request.urlopen(url))['r']
|
||||
except urllib.error.URLError as e:
|
||||
Logger.error('Unable to retrieve package information from DDE: '
|
||||
'%s (%s)', url, str(e))
|
||||
except ValueError as e:
|
||||
Logger.error('Unable to parse JSON response from DDE: '
|
||||
'%s (%s)', url, str(e))
|
||||
if not data:
|
||||
return None
|
||||
return data[0]['source']
|
||||
|
||||
|
||||
def main():
|
||||
usage = 'Usage: %prog <package> [release|version]'
|
||||
parser = optparse.OptionParser(usage)
|
||||
parser.add_option('-d', '--download-only',
|
||||
dest='download_only', default=False, action='store_true',
|
||||
help='Do not extract the source package')
|
||||
parser.add_option('-m', '--mirror', metavar='DEBIAN_MIRROR',
|
||||
dest='debian_mirror',
|
||||
help='Preferred Debian mirror (default: %s)'
|
||||
% UDTConfig.defaults['DEBIAN_MIRROR'])
|
||||
parser.add_option('-s', '--security-mirror', metavar='DEBSEC_MIRROR',
|
||||
dest='debsec_mirror',
|
||||
help='Preferred Debian Security mirror (default: %s)'
|
||||
% UDTConfig.defaults['DEBSEC_MIRROR'])
|
||||
parser.add_option('--no-conf',
|
||||
dest='no_conf', default=False, action='store_true',
|
||||
help="Don't read config files or environment variables")
|
||||
parser.add_option('--no-verify-signature',
|
||||
dest='verify_signature', default=True,
|
||||
action='store_false',
|
||||
help="Allow signature verification failure")
|
||||
(options, args) = parser.parse_args()
|
||||
if not args:
|
||||
parser.error('Must specify package name')
|
||||
elif len(args) > 2:
|
||||
parser.error('Too many arguments. '
|
||||
'Must only specify package and (optionally) release.')
|
||||
|
||||
config = UDTConfig(options.no_conf)
|
||||
if options.debian_mirror is None:
|
||||
options.debian_mirror = config.get_value('DEBIAN_MIRROR')
|
||||
if options.debsec_mirror is None:
|
||||
options.debsec_mirror = config.get_value('DEBSEC_MIRROR')
|
||||
|
||||
package = args[0].lower()
|
||||
|
||||
version = args[1] if len(args) > 1 else 'unstable'
|
||||
component = None
|
||||
|
||||
suite = is_suite(version)
|
||||
if suite is not None:
|
||||
line = list(rmadison('debian', package, suite, 'source'))
|
||||
if not line:
|
||||
source_package = source_package_for(package, suite)
|
||||
if source_package is not None and package != source_package:
|
||||
package = source_package
|
||||
line = list(rmadison('debian', package, suite, 'source'))
|
||||
if not line:
|
||||
Logger.error('Unable to find %s in Debian suite "%s".', package,
|
||||
suite)
|
||||
sys.exit(1)
|
||||
line = line[-1]
|
||||
version = line['version']
|
||||
component = line['component']
|
||||
|
||||
Logger.normal('Downloading %s version %s', package, version)
|
||||
srcpkg = DebianSourcePackage(package, version, component=component,
|
||||
mirrors=[options.debian_mirror,
|
||||
options.debsec_mirror])
|
||||
try:
|
||||
srcpkg.pull(verify_signature=options.verify_signature)
|
||||
except DownloadError as e:
|
||||
Logger.error('Failed to download: %s', str(e))
|
||||
sys.exit(1)
|
||||
if not options.download_only:
|
||||
srcpkg.unpack()
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
Logger.normal('User abort.')
|
||||
PullPkg.main(distro='debian', pull='source')
|
||||
|
11
pull-debian-udebs
Executable file
11
pull-debian-udebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-debian-udebs -- pull udeb package files for debian
|
||||
# Basic usage: pull-debian-udebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='debian', pull='udebs')
|
11
pull-lp-ddebs
Executable file
11
pull-lp-ddebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-lp-ddebs -- pull ddeb package files for ubuntu
|
||||
# Basic usage: pull-lp-ddebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='ubuntu', pull='ddebs')
|
11
pull-lp-debs
Executable file
11
pull-lp-debs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-lp-debs -- pull deb package files for ubuntu
|
||||
# Basic usage: pull-lp-debs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='ubuntu', pull='debs')
|
11
pull-lp-source
Executable file
11
pull-lp-source
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-lp-source -- pull source package files for ubuntu
|
||||
# Basic usage: pull-lp-source <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='ubuntu', pull='source')
|
11
pull-lp-udebs
Executable file
11
pull-lp-udebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-lp-udebs -- pull udeb package files for ubuntu
|
||||
# Basic usage: pull-lp-udebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='ubuntu', pull='udebs')
|
29
pull-pkg
Executable file
29
pull-pkg
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-pkg -- pull package files for debian/ubuntu/uca/ppa
|
||||
# Basic usage: pull-pkg -D distro -p type <package name> [version|release]
|
||||
#
|
||||
# Copyright (C) 2008, Iain Lane <iain@orangesquash.org.uk>,
|
||||
# 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# 2017-2018, Dan Streetman <ddstreet@canonical.com>
|
||||
#
|
||||
# ##################################################################
|
||||
#
|
||||
# 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; either version 3
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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 for more details.
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main()
|
11
pull-uca-ddebs
Executable file
11
pull-uca-ddebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-uca-ddebs -- pull ddeb package files for ubuntu cloud archive
|
||||
# Basic usage: pull-uca-ddebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='uca', pull='ddebs')
|
11
pull-uca-debs
Executable file
11
pull-uca-debs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-uca-debs -- pull deb package files for ubuntu cloud archive
|
||||
# Basic usage: pull-uca-debs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='uca', pull='debs')
|
156
pull-uca-source
156
pull-uca-source
@ -1,157 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-uca-source -- pull a source package from Ubuntu Cloud Archive
|
||||
# Basic usage: pull-uca-source <source package> <openstack release> [version]
|
||||
# pull-uca-source -- pull source package files for ubuntu cloud archive
|
||||
# Basic usage: pull-uca-source <package name> [version|release]
|
||||
#
|
||||
# Copyright (C) 2008, Iain Lane <iain@orangesquash.org.uk>,
|
||||
# 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# 2016, Corey Bryant <corey.bryant@ubuntu.com>
|
||||
# 2016, Dan Streetman <dan.streetman@canonical.com>
|
||||
#
|
||||
# ##################################################################
|
||||
#
|
||||
# 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; either version 3
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# 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 for more details.
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
|
||||
import re
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
from ubuntutools.archive import UbuntuCloudArchiveSourcePackage, DownloadError
|
||||
from ubuntutools.config import UDTConfig
|
||||
from ubuntutools.lp.lpapicache import Launchpad
|
||||
from ubuntutools.lp.udtexceptions import PocketDoesNotExistError
|
||||
from ubuntutools.logger import Logger
|
||||
from ubuntutools.misc import split_release_pocket
|
||||
|
||||
from lazr.restfulclient.errors import NotFound
|
||||
|
||||
from launchpadlib.launchpad import Launchpad as LP
|
||||
|
||||
|
||||
def showOpenstackReleases(uca):
|
||||
releases = []
|
||||
for p in uca.ppas:
|
||||
if re.match(r"\w*-staging", p.name):
|
||||
releases.append(re.sub("-staging", "", p.name))
|
||||
Logger.error("Openstack releases are:\n\t%s", ", ".join(releases))
|
||||
|
||||
|
||||
def getSPPH(lp, archive, package, version=None, series=None, pocket=None, try_binary=True):
|
||||
params = {'exact_match': True, 'order_by_date': True}
|
||||
if pocket:
|
||||
params['pocket'] = pocket
|
||||
if series:
|
||||
params['distro_series'] = series()
|
||||
elif version:
|
||||
params['version'] = version
|
||||
Logger.normal("checking %s version %s pocket %s", package, version, pocket)
|
||||
spphs = archive.getPublishedSources(source_name=package, **params)
|
||||
if spphs:
|
||||
return spphs[0]
|
||||
if not try_binary:
|
||||
return None
|
||||
|
||||
# Didn't find any, maybe the package is a binary package name
|
||||
if series:
|
||||
del params['distro_series']
|
||||
archs = lp.load(series().architectures_collection_link).entries
|
||||
params['distro_arch_series'] = archs[0]['self_link']
|
||||
bpphs = archive.getPublishedBinaries(binary_name=package, **params)
|
||||
if bpphs:
|
||||
bpph_build = lp.load(bpphs[0].build_link)
|
||||
source_package = bpph_build.source_package_name
|
||||
return getSPPH(lp, archive, source_package, version, series, pocket,
|
||||
try_binary=False)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
usage = "Usage: %prog <package> <openstack release> [version]"
|
||||
opt_parser = OptionParser(usage)
|
||||
opt_parser.add_option('-d', '--download-only',
|
||||
dest='download_only', default=False,
|
||||
action='store_true',
|
||||
help="Do not extract the source package")
|
||||
opt_parser.add_option('-m', '--mirror', metavar='OPENSTACK_MIRROR',
|
||||
dest='openstack_mirror',
|
||||
help='Preferred Openstack mirror (default: Launchpad)')
|
||||
opt_parser.add_option('--no-conf',
|
||||
dest='no_conf', default=False, action='store_true',
|
||||
help="Don't read config files or environment "
|
||||
"variables")
|
||||
(options, args) = opt_parser.parse_args()
|
||||
if len(args) < 2:
|
||||
opt_parser.error("Must specify package name and openstack release")
|
||||
|
||||
config = UDTConfig(options.no_conf)
|
||||
if options.openstack_mirror is None:
|
||||
options.openstack_mirror = config.get_value('OPENSTACK_MIRROR')
|
||||
mirrors = []
|
||||
if options.openstack_mirror:
|
||||
mirrors.append(options.openstack_mirror)
|
||||
|
||||
# Login anonymously to LP
|
||||
Launchpad.login_anonymously()
|
||||
lp = LP.login_anonymously("pull-uca-source", "production")
|
||||
uca = lp.people("ubuntu-cloud-archive")
|
||||
|
||||
package = str(args[0]).lower()
|
||||
release = str(args[1]).lower()
|
||||
version = None
|
||||
if len(args) > 2:
|
||||
version = str(args[2])
|
||||
|
||||
pocket = None
|
||||
try:
|
||||
(release, pocket) = split_release_pocket(release, default=None)
|
||||
except PocketDoesNotExistError:
|
||||
pass
|
||||
|
||||
try:
|
||||
archive = uca.getPPAByName(name="%s-staging" % release)
|
||||
except NotFound:
|
||||
Logger.error('Archive does not exist for Openstack release: %s',
|
||||
release)
|
||||
showOpenstackReleases(uca)
|
||||
sys.exit(1)
|
||||
|
||||
spph = getSPPH(lp, archive, package, version, pocket=pocket)
|
||||
if not spph:
|
||||
Logger.error("Package %s in %s not found.", package, release)
|
||||
sys.exit(1)
|
||||
|
||||
package = spph.source_package_name
|
||||
version = spph.source_package_version
|
||||
component = spph.component_name
|
||||
Logger.normal('Downloading %s version %s component %s', package, version, component)
|
||||
srcpkg = UbuntuCloudArchiveSourcePackage(release, package, version, component=component,
|
||||
mirrors=mirrors)
|
||||
|
||||
try:
|
||||
srcpkg.pull()
|
||||
except DownloadError as e:
|
||||
Logger.error('Failed to download: %s', str(e))
|
||||
sys.exit(1)
|
||||
if not options.download_only:
|
||||
srcpkg.unpack()
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
Logger.normal('User abort.')
|
||||
PullPkg.main(distro='uca', pull='source')
|
||||
|
11
pull-uca-udebs
Executable file
11
pull-uca-udebs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# pull-uca-udebs -- pull udeb package files for ubuntu cloud archive
|
||||
# Basic usage: pull-uca-udebs <package name> [version|release]
|
||||
#
|
||||
# See pull-pkg
|
||||
|
||||
from ubuntutools.pullpkg import PullPkg
|
||||
|
||||
if __name__ == '__main__':
|
||||
PullPkg.main(distro='uca', pull='udebs')
|
10
setup.py
10
setup.py
@ -27,11 +27,21 @@ scripts = [
|
||||
'mk-sbuild',
|
||||
'pbuilder-dist',
|
||||
'pbuilder-dist-simple',
|
||||
'pull-pkg',
|
||||
'pull-debian-debdiff',
|
||||
'pull-debian-source',
|
||||
'pull-debian-debs',
|
||||
'pull-debian-ddebs',
|
||||
'pull-debian-udebs',
|
||||
'pull-lp-source',
|
||||
'pull-lp-debs',
|
||||
'pull-lp-ddebs',
|
||||
'pull-lp-udebs',
|
||||
'pull-revu-source',
|
||||
'pull-uca-source',
|
||||
'pull-uca-debs',
|
||||
'pull-uca-ddebs',
|
||||
'pull-uca-udebs',
|
||||
'requestbackport',
|
||||
'requestsync',
|
||||
'reverse-build-depends',
|
||||
|
Loading…
x
Reference in New Issue
Block a user