From 5a1b8a03ff11acaecd85c061d65353b47cdca55f Mon Sep 17 00:00:00 2001 From: ignask Date: Wed, 29 Mar 2023 17:43:09 +0000 Subject: [PATCH] fix multiline fields in changes files --- pkg/private/deb/make_deb.py | 12 +++++++----- tests/deb/pkg_deb_test.py | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py index 9e2e5c5e..56a7297f 100644 --- a/pkg/private/deb/make_deb.py +++ b/pkg/private/deb/make_deb.py @@ -139,7 +139,7 @@ def MakeDebianControlField(name: str, value: str, is_multiline:bool=False) -> st '\\n is not allowed in simple control fields (%s)' % value) lines = value.split('\n') - result = name + ': ' +lines[0].strip() + '\n' + result = (name + ': ' +lines[0].strip()).strip() + '\n' for line in lines[1:]: if not line.startswith(' '): result += ' ' @@ -147,7 +147,6 @@ def MakeDebianControlField(name: str, value: str, is_multiline:bool=False) -> st result += '\n' return result - def CreateDebControl(extrafiles=None, **kwargs): """Create the control.tar.gz file.""" # create the control file @@ -298,13 +297,16 @@ def CreateChanges(output, is_multiline=True), MakeDebianControlField( 'Files', '\n ' + ' '.join( - [checksums['md5'], debsize, section, priority, deb_basename])), + [checksums['md5'], debsize, section, priority, deb_basename]), + is_multiline=True), MakeDebianControlField( 'Checksums-Sha1', - '\n ' + ' '.join([checksums['sha1'], debsize, deb_basename])), + '\n ' + ' '.join([checksums['sha1'], debsize, deb_basename]), + is_multiline=True), MakeDebianControlField( 'Checksums-Sha256', - '\n ' + ' '.join([checksums['sha256'], debsize, deb_basename])) + '\n ' + ' '.join([checksums['sha256'], debsize, deb_basename]), + is_multiline=True) ]) with open(output, 'wb') as changes_fh: changes_fh.write(changesdata.encode('utf-8')) diff --git a/tests/deb/pkg_deb_test.py b/tests/deb/pkg_deb_test.py index 33344133..f8e81bc4 100644 --- a/tests/deb/pkg_deb_test.py +++ b/tests/deb/pkg_deb_test.py @@ -249,6 +249,32 @@ def test_changes(self): content[d_start + len(d_expect)].isupper(), 'Description has unexpected characters at end (%s)' % content) + self.maxDiff = None + expect = '''Format: 1\.8 +Date: Thu Jan 1 \d{2}:00:00 1970 +Source: fizzbuzz +Binary: fizzbuzz +Architecture: all +Version: 4\.5\.6 +Distribution: trusty +Urgency: low +Maintainer: soméone@somewhere.com +Changed-By: soméone@somewhere.com +Description: + fizzbuzz - toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é +Changes: + fizzbuzz \(4\.5\.6\) trusty; urgency=low + Changes are tracked in revision control\. +Files: + [a-f0-9]{32} \d{4} contrib/devel optional fizzbuzz_4\.5\.6_all\.deb +Checksums-Sha1: + [a-f0-9]{40} \d{4} fizzbuzz_4\.5\.6_all\.deb +Checksums-Sha256: + [a-f0-9]{64} \d{4} fizzbuzz_4\.5\.6_all\.deb +''' + + self.assertRegex(content, expect) + if __name__ == '__main__': unittest.main()