Skip to content

Commit

Permalink
fix multiline fields in changes files
Browse files Browse the repository at this point in the history
  • Loading branch information
ignask committed Mar 30, 2023
1 parent 7d7a076 commit 5a1b8a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/private/deb/make_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,14 @@ 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 += ' '
result += line
result += '\n'
return result


def CreateDebControl(extrafiles=None, **kwargs):
"""Create the control.tar.gz file."""
# create the control file
Expand Down Expand Up @@ -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'))
Expand Down
26 changes: 26 additions & 0 deletions tests/deb/pkg_deb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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é[email protected]
Changed-By: somé[email protected]
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()

0 comments on commit 5a1b8a0

Please sign in to comment.