syncpackage: Print propper error message if dsc file is malformed.

This commit is contained in:
Benjamin Drung 2010-08-02 15:37:48 +02:00
parent 660e6256c7
commit 5c14871416
2 changed files with 22 additions and 20 deletions

3
debian/changelog vendored
View File

@ -18,6 +18,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low
version for debian versions that contain more than one dash. version for debian versions that contain more than one dash.
- Prepend script name to every output - Prepend script name to every output
- Output every executed command in verbose mode - Output every executed command in verbose mode
- Print propper error message if dsc file is malformed.
* update-maintainer: Add a --quiet option. * update-maintainer: Add a --quiet option.
[ Michael Bienia ] [ Michael Bienia ]
@ -28,7 +29,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low
* requestsync: Fix bug where the variable 'hasLP' is not always set * requestsync: Fix bug where the variable 'hasLP' is not always set
(lp: #607874). (lp: #607874).
-- Benjamin Drung <bdrung@ubuntu.com> Fri, 30 Jul 2010 03:51:02 +0200 -- Benjamin Drung <bdrung@ubuntu.com> Mon, 02 Aug 2010 15:35:49 +0200
ubuntu-dev-tools (0.100) maverick; urgency=low ubuntu-dev-tools (0.100) maverick; urgency=low

View File

@ -19,6 +19,7 @@
# #
# ################################################################## # ##################################################################
import debian.deb822
import debian.debian_support import debian.debian_support
import hashlib import hashlib
import optparse import optparse
@ -130,27 +131,23 @@ def remove_signature(dscname, script_name=None, verbose=False):
f.writelines(unsigned_file) f.writelines(unsigned_file)
f.close() f.close()
def dsc_getfiles(dsc): def dsc_getfiles(dscurl):
'''Return list of files in a .dsc file (excluding the .dsc file itself).''' '''Return list of files in a .dsc file (excluding the .dsc file itself).'''
basepath = os.path.dirname(dsc) basepath = os.path.dirname(dscurl)
f = urllib.urlopen(dsc) dsc = debian.deb822.Dsc(urllib.urlopen(dscurl))
if 'Files' not in dsc:
print >> sys.stderr, "%s: Error: No Files field found in the dcs file. Please check %s!" % \
(script_name, os.path.basename(dscurl))
sys.exit(1)
files = [] files = []
for f in dcs['Files']:
# skip until 'Files:'
for l in f:
if l.strip() == 'Files:':
break
for l in f:
if not l.startswith(' '):
break
(checksum, size, fname) = l.split() (checksum, size, fname) = l.split()
url = os.path.join(basepath, fname) url = os.path.join(basepath, f['name'])
if not fname.endswith('.dsc'): if not f['name'].endswith('.dsc'):
files.append(File(url, checksum, size)) files.append(File(url, f['md5sum'], f['size']))
f.close()
return files return files
def add_fixed_bugs(changes, bugs, script_name=None, verbose=False): def add_fixed_bugs(changes, bugs, script_name=None, verbose=False):
@ -183,8 +180,12 @@ def sync_dsc(script_name, dscurl, debian_dist, release, name, email, bugs, keyid
dscfile = dscurl dscfile = dscurl
else: else:
urllib.urlretrieve(dscurl, dscname) urllib.urlretrieve(dscurl, dscname)
dscfile = open(dscname).readlines() dscfile = debian.deb822.Dsc(file(dscname))
new_ver = Version(filter(lambda l: l.startswith("Version:"), dscfile)[0][8:].strip()) if "Version" not in dscfile:
print >> sys.stderr, "%s: Error: No Version field found in the dcs file. Please check %s!" % \
(script_name, dscname)
sys.exit(1)
new_ver = Version(dscfile["Version"])
try: try:
ubuntu_source = getUbuntuSrcPkg(srcpkg, release) ubuntu_source = getUbuntuSrcPkg(srcpkg, release)