mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 15:41:09 +00:00
Check the sync blacklist
This commit is contained in:
parent
ce2f96bc0d
commit
e04d4df889
67
syncpackage
67
syncpackage
@ -20,15 +20,17 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import debian.deb822
|
||||
import debian.debian_support
|
||||
import codecs
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
import debian.deb822
|
||||
import debian.debian_support
|
||||
from devscripts.logger import Logger
|
||||
|
||||
from lazr.restfulclient.errors import HTTPError
|
||||
|
||||
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
||||
@ -380,6 +382,27 @@ def copy(src_pkg, release, simulate=False, force=False):
|
||||
Logger.normal('Request succeeded; you should get an e-mail once it is '
|
||||
'processed.')
|
||||
|
||||
def is_blacklisted(query):
|
||||
url = 'http://people.canonical.com/~ubuntu-archive/sync-blacklist.txt'
|
||||
with codecs.EncodedFile(urllib.urlopen(url), 'UTF-8') as f:
|
||||
applicable_comments = []
|
||||
for line in f:
|
||||
if not line.strip():
|
||||
applicable_comments = []
|
||||
continue
|
||||
m = re.match(r'^\s*([a-z0-9.+-]+)?\s*(?:#\s*(.+)?)?$', line)
|
||||
source, comment = m.groups()
|
||||
if source and query == source:
|
||||
if comment:
|
||||
applicable_comments.append(comment)
|
||||
if applicable_comments:
|
||||
return u'; '.join(applicable_comments)
|
||||
else:
|
||||
return True
|
||||
elif comment:
|
||||
applicable_comments.append(comment)
|
||||
return False
|
||||
|
||||
def main():
|
||||
usage = "%prog [options] <.dsc URL/path or package name>"
|
||||
epilog = "See %s(1) for more info." % os.path.basename(sys.argv[0])
|
||||
@ -489,30 +512,32 @@ def main():
|
||||
if args[0].endswith('.dsc'):
|
||||
parser.error('.dsc files can only be synced using --no-lp.')
|
||||
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value('LPINSTANCE')
|
||||
if options.lpinstance is None:
|
||||
options.lpinstance = config.get_value('LPINSTANCE')
|
||||
try:
|
||||
Launchpad.login(service=options.lpinstance, api_version='devel')
|
||||
except IOError:
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
Launchpad.login(service=options.lpinstance, api_version='devel')
|
||||
except IOError:
|
||||
sys.exit(1)
|
||||
if options.release is None:
|
||||
ubuntu = Launchpad.distributions["ubuntu"]
|
||||
options.release = ubuntu.current_series.name
|
||||
|
||||
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
||||
options.component, options.release, None)
|
||||
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
||||
options.component, options.release,
|
||||
options.debian_mirror)
|
||||
|
||||
blacklisted = is_blacklisted(src_pkg.source)
|
||||
if blacklisted:
|
||||
Logger.error("Source package is blacklisted")
|
||||
if isinstance(blacklisted, basestring):
|
||||
Logger.error(u"Reason: %s", blacklisted)
|
||||
sys.exit(1)
|
||||
|
||||
if options.lp:
|
||||
copy(src_pkg, options.release, options.simulate, options.force)
|
||||
else:
|
||||
Launchpad.login_anonymously()
|
||||
if options.release is None:
|
||||
ubuntu = Launchpad.distributions["ubuntu"]
|
||||
options.release = ubuntu.current_series.name
|
||||
|
||||
os.environ['DEB_VENDOR'] = 'Ubuntu'
|
||||
|
||||
src_pkg = fetch_source_pkg(args[0], options.dist, options.debversion,
|
||||
options.component, options.release,
|
||||
options.debian_mirror)
|
||||
|
||||
sync_dsc(src_pkg, options.dist, options.release, options.uploader_name,
|
||||
options.uploader_email, options.bugs, options.ubuntu_mirror,
|
||||
options.keyid, options.simulate, options.force)
|
||||
|
Loading…
x
Reference in New Issue
Block a user