diff --git a/debian/control b/debian/control index 1d39a8b..6baef43 100644 --- a/debian/control +++ b/debian/control @@ -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. diff --git a/pull-debian-ddebs b/pull-debian-ddebs new file mode 100755 index 0000000..330f315 --- /dev/null +++ b/pull-debian-ddebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-debian-ddebs -- pull ddeb package files for debian +# Basic usage: pull-debian-ddebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='debian', pull='ddebs') diff --git a/pull-debian-debs b/pull-debian-debs new file mode 100755 index 0000000..4f92407 --- /dev/null +++ b/pull-debian-debs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-debian-debs -- pull deb package files for debian +# Basic usage: pull-debian-debs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='debian', pull='debs') diff --git a/pull-debian-source b/pull-debian-source index 6bfc5fb..3ffb2dc 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -1,148 +1,11 @@ #!/usr/bin/python3 # -# pull-debian-source -- pull a source package from Launchpad -# Copyright (C) 2011, Stefano Rivera -# 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 [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 [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') diff --git a/pull-debian-udebs b/pull-debian-udebs new file mode 100755 index 0000000..b839f88 --- /dev/null +++ b/pull-debian-udebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-debian-udebs -- pull udeb package files for debian +# Basic usage: pull-debian-udebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='debian', pull='udebs') diff --git a/pull-lp-ddebs b/pull-lp-ddebs new file mode 100755 index 0000000..16aab20 --- /dev/null +++ b/pull-lp-ddebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-lp-ddebs -- pull ddeb package files for ubuntu +# Basic usage: pull-lp-ddebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='ubuntu', pull='ddebs') diff --git a/pull-lp-debs b/pull-lp-debs new file mode 100755 index 0000000..33ad826 --- /dev/null +++ b/pull-lp-debs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-lp-debs -- pull deb package files for ubuntu +# Basic usage: pull-lp-debs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='ubuntu', pull='debs') diff --git a/pull-lp-source b/pull-lp-source new file mode 100755 index 0000000..6b399fd --- /dev/null +++ b/pull-lp-source @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-lp-source -- pull source package files for ubuntu +# Basic usage: pull-lp-source [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='ubuntu', pull='source') diff --git a/pull-lp-udebs b/pull-lp-udebs new file mode 100755 index 0000000..580c65c --- /dev/null +++ b/pull-lp-udebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-lp-udebs -- pull udeb package files for ubuntu +# Basic usage: pull-lp-udebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='ubuntu', pull='udebs') diff --git a/pull-pkg b/pull-pkg new file mode 100755 index 0000000..8ed38b8 --- /dev/null +++ b/pull-pkg @@ -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 [version|release] +# +# Copyright (C) 2008, Iain Lane , +# 2010-2011, Stefano Rivera +# 2017-2018, Dan Streetman +# +# ################################################################## +# +# 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() diff --git a/pull-uca-ddebs b/pull-uca-ddebs new file mode 100755 index 0000000..bd55ac5 --- /dev/null +++ b/pull-uca-ddebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-uca-ddebs -- pull ddeb package files for ubuntu cloud archive +# Basic usage: pull-uca-ddebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='uca', pull='ddebs') diff --git a/pull-uca-debs b/pull-uca-debs new file mode 100755 index 0000000..096cf8f --- /dev/null +++ b/pull-uca-debs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-uca-debs -- pull deb package files for ubuntu cloud archive +# Basic usage: pull-uca-debs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='uca', pull='debs') diff --git a/pull-uca-source b/pull-uca-source index 0bd97d2..6aa6676 100755 --- a/pull-uca-source +++ b/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 [version] +# pull-uca-source -- pull source package files for ubuntu cloud archive +# Basic usage: pull-uca-source [version|release] # -# Copyright (C) 2008, Iain Lane , -# 2010-2011, Stefano Rivera -# 2016, Corey Bryant -# 2016, Dan Streetman -# -# ################################################################## -# -# 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 [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') diff --git a/pull-uca-udebs b/pull-uca-udebs new file mode 100755 index 0000000..95b0626 --- /dev/null +++ b/pull-uca-udebs @@ -0,0 +1,11 @@ +#!/usr/bin/python3 +# +# pull-uca-udebs -- pull udeb package files for ubuntu cloud archive +# Basic usage: pull-uca-udebs [version|release] +# +# See pull-pkg + +from ubuntutools.pullpkg import PullPkg + +if __name__ == '__main__': + PullPkg.main(distro='uca', pull='udebs') diff --git a/setup.py b/setup.py index ce8c966..35fdddc 100755 --- a/setup.py +++ b/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',