Bug#695797: patch

Jean-Baptiste Lallement jean-baptiste.lallement at canonical.com
Wed Dec 19 14:01:14 UTC 2012


Tags: patch

In Ubuntu we applied the enclosed patch autopkgtest (2.2.3ubuntu2). It 
uses python-debian to do control file parsing.

-- 
Jean-Baptiste
IRC: jibel
-------------- next part --------------
diff -Nru autopkgtest-2.2.3ubuntu1/debian/changelog autopkgtest-2.2.3ubuntu2/debian/changelog
--- autopkgtest-2.2.3ubuntu1/debian/changelog	2012-11-28 16:23:52.000000000 +0100
+++ autopkgtest-2.2.3ubuntu2/debian/changelog	2012-12-19 11:28:24.000000000 +0100
@@ -1,3 +1,9 @@
+autopkgtest (2.2.3ubuntu2) UNRELEASED; urgency=low
+
+  * Use debian.deb822 to parse control files. (LP: #1073856)
+
+ -- Jean-Baptiste Lallement <jean-baptiste.lallement at canonical.com>  Wed, 12 Dec 2012 22:48:51 +0100
+
 autopkgtest (2.2.3ubuntu1) raring; urgency=low
 
   * Fix adt-run's user option fails with permission denied. (LP: 1084116) (Closes: #686292)
diff -Nru autopkgtest-2.2.3ubuntu1/debian/control autopkgtest-2.2.3ubuntu2/debian/control
--- autopkgtest-2.2.3ubuntu1/debian/control	2012-11-28 16:24:07.000000000 +0100
+++ autopkgtest-2.2.3ubuntu2/debian/control	2012-12-19 11:28:24.000000000 +0100
@@ -11,7 +11,7 @@
 
 Package: autopkgtest
 Architecture: all
-Depends: python (>= 2.6), debhelper
+Depends: python (>= 2.6), debhelper, python-debian
 Conflicts: autodebtest (<< 0.5.3)
 Replaces: autodebtest (<< 0.5.3)
 Recommends: apt-utils, pbuilder
diff -Nru autopkgtest-2.2.3ubuntu1/runner/adt-run autopkgtest-2.2.3ubuntu2/runner/adt-run
--- autopkgtest-2.2.3ubuntu1/runner/adt-run	2012-11-28 16:17:36.000000000 +0100
+++ autopkgtest-2.2.3ubuntu2/runner/adt-run	2012-12-19 11:59:48.000000000 +0100
@@ -36,6 +36,7 @@
 import fnmatch
 import shutil
 import copy
+from debian import deb822
 
 from optparse import OptionParser
 signal.signal(signal.SIGINT, signal.SIG_DFL) # undo stupid Python SIGINT thing
@@ -1215,45 +1216,21 @@
 		return []
 
 	lno = 0
-	def badctrl(m): testbed.bomb('tests/control line %d: %s' % (lno, m))
 	stz = { }	# stz[field_name][index] = (lno, value)
 			# special field names:
 			# stz[' lno'] = number
 			# stz[' tests'] = list of Test objects
 			# empty dictionary means we're between stanzas
-	def in_stanza(stz):
-		return stz.has_key(' lno')
-	def end_stanza(stz):
-		if not in_stanza(stz): return
-		stz[' errs'] = 0
-		stanzas.append(stz.copy())
-		stz.clear()
-		hcurrent = None
-
-	initre = regexp.compile('([A-Z][-0-9a-zA-Z]*)\s*\:\s*(.*)$')
-	while 1:
-		l = control.readline()
-		if not l: break
+	for paragraph in deb822.Deb822.iter_paragraphs(control):
 		lno += 1
-		if not l.endswith('\n'): badctrl('unterminated line')
-		if regexp.compile('\s*\#').match(l): continue
-		if not regexp.compile('\S').match(l): end_stanza(stz); continue
-		initmat = initre.match(l)
-		if initmat:
-			(fname, l) = initmat.groups()
-			fname = string.capwords(fname)
-			if not in_stanza(stz):
-				stz = { ' lno': lno, ' tests': [] }
-			if not stz.has_key(fname): stz[fname] = [ ]
-			hcurrent = stz[fname]
-		elif regexp.compile('\s').match(l):
-			if not hcurrent: badctrl('unexpected continuation')
-		else:
-			badctrl('syntax error')
-		hcurrent.append((lno, l))
-	end_stanza(stz)
+		stz = { ' lno': lno, ' tests': [] }
+		for field, value in paragraph.iteritems():
+			v = "".join(value.split('\n')).replace('  ',' ')
+			stz[field] = [(lno, v)]
+			lno += 1 + value.count('\n')  # Count multilines fields
+		stanzas.append(stz.copy())
 
-        return stanzas
+	return stanzas
 
 def read_control(act, tree, control_override):
 


More information about the autopkgtest-devel mailing list