mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
* pull-lp-source: Now check if package exists in the release.
This commit is contained in:
parent
d3efcc879f
commit
bd51d19e4c
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -6,7 +6,7 @@ ubuntu-dev-tools (0.37ubuntu1) intrepid; urgency=low
|
|||||||
* hugdaylist: Improved argument and error handling.
|
* hugdaylist: Improved argument and error handling.
|
||||||
* pull-lp-source:
|
* pull-lp-source:
|
||||||
- Use optparse for option handling.
|
- Use optparse for option handling.
|
||||||
- Check that 'distro' exists on Launchpad.
|
- Check that the 'release' and 'package' actually exist on Launchpad.
|
||||||
- Use subprocess for dget calls.
|
- Use subprocess for dget calls.
|
||||||
|
|
||||||
[ Siegfried-Angel Gevatter Pujals ]
|
[ Siegfried-Angel Gevatter Pujals ]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# pull-lp-source -- pull a source package from Launchpad
|
# pull-lp-source -- pull a source package from Launchpad
|
||||||
# Basic usage: pull-lp-source <source package> [<distro>]
|
# Basic usage: pull-lp-source <source package> [<release>]
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Iain Lane <iain@orangesquash.org.uk>
|
# Copyright (C) 2008 Iain Lane <iain@orangesquash.org.uk>
|
||||||
#
|
#
|
||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
@ -36,16 +37,14 @@ class BackportFromLP:
|
|||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
|
||||||
def __init__(self, package, target_distro):
|
def __init__(self, package, target_release):
|
||||||
self.package = package
|
self.package = package
|
||||||
self.target_distro = target_distro
|
self.target_release = target_release
|
||||||
self.__prepare_sources()
|
self.__prepare_sources()
|
||||||
|
|
||||||
def __prepare_sources(self):
|
def __prepare_sources(self):
|
||||||
# Scrape the source package from Launchpad :)
|
# Scrape the source package from Launchpad :)
|
||||||
import re
|
contents = os.popen('wget -q https://launchpad.net/ubuntu/%(target_release)s/+source/%(package)s -O-' % self).read()
|
||||||
|
|
||||||
contents = os.popen('wget -q https://launchpad.net/ubuntu/%(target_distro)s/+source/%(package)s -O-' % self).read()
|
|
||||||
links = re.findall('a href=\"(.*\.dsc)\"', contents)
|
links = re.findall('a href=\"(.*\.dsc)\"', contents)
|
||||||
|
|
||||||
if len(links) == 1 and \
|
if len(links) == 1 and \
|
||||||
@ -56,7 +55,7 @@ class BackportFromLP:
|
|||||||
'Ensure that the package specified is a valid source ' +\
|
'Ensure that the package specified is a valid source ' +\
|
||||||
'package name and that Launchpad is not down.'
|
'package name and that Launchpad is not down.'
|
||||||
|
|
||||||
default_distro = 'intrepid'
|
default_release = 'intrepid'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
usage = "Usage: %prog <package> [distribution]"
|
usage = "Usage: %prog <package> [distribution]"
|
||||||
@ -71,36 +70,34 @@ if __name__ == '__main__':
|
|||||||
package = args[0]
|
package = args[0]
|
||||||
|
|
||||||
if len(args) == 2: # Custom distribution specified.
|
if len(args) == 2: # Custom distribution specified.
|
||||||
distro = args[1]
|
release = args[1]
|
||||||
else:
|
else:
|
||||||
distro = os.getenv('DIST') or default_distro
|
release = os.getenv('DIST') or default_release
|
||||||
|
|
||||||
# Correct-ish args, can proceed.
|
# Correct-ish args, can proceed.
|
||||||
# Check distro by checking if Launchpad page exists
|
# Check release by checking if Launchpad page exists
|
||||||
try:
|
try:
|
||||||
urllib2.urlopen("https://launchpad.net/ubuntu/%s" % distro)
|
urllib2.urlopen("https://launchpad.net/ubuntu/%s" % release)
|
||||||
except urllib2.HTTPError:
|
except urllib2.HTTPError:
|
||||||
print >> sys.stderr, "The distribution '%s' does not appear to exist on " \
|
print >> sys.stderr, "The '%s' release does not appear to exist on " \
|
||||||
"Launchpad." % distro
|
"Launchpad." % release
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Check package exists.
|
# Check package exists.
|
||||||
""" TODO: Find a way to check that the package exists here.
|
sourcePage = urllib2.urlopen("https://launchpad.net/ubuntu/%s/+source/%s" % \
|
||||||
madison = subprocess.Popen(['rmadison', '-u', 'ubuntu', '-a', 'source', \
|
(release, package)).read()
|
||||||
'-s', distro, package], stdout = subprocess.PIPE)
|
m = re.search('"/ubuntu/%s/\+source/%s/(\d[^"]+)"' % (release, \
|
||||||
out = madison.communicate()[0]
|
package.replace('+', '\+')), sourcePage)
|
||||||
print madison.returncode
|
if not m:
|
||||||
assert (madison.returncode == 0)
|
print >> sys.stderr, "The '%s' package does not appear to exist in " \
|
||||||
if madison == 0:
|
"the '%s' release." % (package, release)
|
||||||
print "The '%s' package doesn't appear to exist in %s." % (package, distro)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
"""
|
|
||||||
|
|
||||||
# All good - start downloading...
|
# All good - start downloading...
|
||||||
try:
|
try:
|
||||||
print 'Attempting to get %s from distro %s...' % \
|
print 'Attempting to get %s from release %s...' % \
|
||||||
(package, distro.capitalize())
|
(package, release.capitalize())
|
||||||
BackportFromLP(package, distro)
|
BackportFromLP(package, release)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
print 'Error when downloading package %s from distro %s: %s' % \
|
print 'Error when downloading package %s from release %s: %s.' % \
|
||||||
(package, distro, e)
|
(package, release, e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user