3 # update-appdata.py - Update the <releases/> section of resources/freedesktop/org.wireshark.Wireshark.metainfo.xml.
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
9 # SPDX-License-Identifier: GPL-2.0-or-later
10 '''Update the <release> tag in resources/freedesktop/org.wireshark.Wireshark.metainfo.xml
12 According to https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html
13 the <releases/> tag in resources/freedesktop/org.wireshark.Wireshark.metainfo.xml should contain release
14 information sorted newest to oldest.
16 As part of our release process, when we create release tag x.y.z, we tag
17 the next commit x.y.z+1rc0, e.g.
19 v3.0.0 2019-02-28 release tag
20 v3.0.1rc0 2019-02-28 next commit after v3.0.0
21 v3.0.1 2019-04-08 release tag
22 v3.0.2rc0 2019-04-08 next commit after v3.0.1
24 Find a list of release versions based on our most recent rc0 tag and
25 update the <releases/> section of resources/freedesktop/org.wireshark.Wireshark.metainfo.xml accordingly.
26 Assume that the tag for the most recent release doesn't exist and use
30 from datetime
import date
38 this_dir
= os
.path
.dirname(__file__
)
39 appdata_xml
= os
.path
.join(this_dir
, '..', 'resources', 'freedesktop', 'org.wireshark.Wireshark.metainfo.xml')
42 cur_rc0
= subprocess
.run(
43 ['git', 'describe', '--match', 'v*rc0'],
46 stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
).stdout
48 print('Unable to fetch most recent rc0.')
52 ver_m
= re
.match('v(\d+\.\d+)\.(\d+)rc0.*', cur_rc0
)
53 maj_min
= ver_m
.group(1)
54 next_micro
= ver_m
.group(2)
56 print('Unable to fetch major.minor version.')
59 # https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-releases
60 release_tag_fmt
= '''\
61 <release version="{0}.{1}" date="{2}">
62 <url>https://www.wireshark.org/docs/relnotes/wireshark-{0}.{1}.html</url>
65 cur_date
= date
.fromtimestamp(time
.time()).isoformat()
67 f
' <!-- Automatically generated by tools/{os.path.basename(__file__)} -->\n',
68 release_tag_fmt
.format(maj_min
, next_micro
, cur_date
)
70 print(f
'Added {maj_min}.{next_micro}, {cur_date}')
72 for micro
in range(int(next_micro
) - 1, -1, -1):
74 tag_date
= subprocess
.run(
75 ['git', 'log', '-1', '--format=%cd', '--date=format:%F', 'v{}.{}'.format(maj_min
, micro
)],
78 stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
).stdout
.strip()
79 release_tag_l
.append(release_tag_fmt
.format(maj_min
, micro
, tag_date
))
80 print(f
'Added {maj_min}.{micro}, {tag_date}')
82 print('Unable to fetch release tag')
86 with io
.open(appdata_xml
, 'r', encoding
='UTF-8') as ax_fd
:
89 if '</releases>' in line
:
94 if '<releases>' in line
:
96 ax_lines
.extend(release_tag_l
)
98 with io
.open(appdata_xml
, 'w', encoding
='UTF-8') as ax_fd
:
99 ax_fd
.write(''.join(ax_lines
))
101 if __name__
== '__main__':